diff options
Diffstat (limited to 'Presence/ConsoleWriter.hs')
-rw-r--r-- | Presence/ConsoleWriter.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Presence/ConsoleWriter.hs b/Presence/ConsoleWriter.hs index d75dfec0..aca4bf98 100644 --- a/Presence/ConsoleWriter.hs +++ b/Presence/ConsoleWriter.hs | |||
@@ -240,12 +240,23 @@ deliverTerminalMessage cw tty utmp msg = do | |||
240 | mode <- fmap fileMode (getFileStatus $ Text.unpack tty) | 240 | mode <- fmap fileMode (getFileStatus $ Text.unpack tty) |
241 | let mesgy = mode .&. 0o020 /= 0 -- verify mode g+w | 241 | let mesgy = mode .&. 0o020 /= 0 -- verify mode g+w |
242 | if not mesgy then return False else do | 242 | if not mesgy then return False else do |
243 | -- TODO: deliver to active console | 243 | text <- do |
244 | return False -- return True if a message was delivered | 244 | t <- messageText msg |
245 | return $ Text.unpack | ||
246 | $ case stanzaFrom msg of | ||
247 | Just from -> from <> " says...\n" <> t | ||
248 | Nothing -> t | ||
249 | writeFile (Text.unpack tty) text | ||
250 | return True -- return True if a message was delivered | ||
245 | 251 | ||
246 | writeAllPty :: ConsoleWriter -> Stanza -> IO Bool | 252 | writeAllPty :: ConsoleWriter -> Stanza -> IO Bool |
247 | writeAllPty cw msg = do | 253 | writeAllPty cw msg = do |
248 | return False -- return True if a message was delivered | 254 | us <- atomically $ readTVar (csUtmp cw) |
255 | let ptys = Map.filterWithKey ispty us | ||
256 | ispty k _ = "pts/" `Text.isPrefixOf` k | ||
257 | bs <- forM (Map.toList ptys) $ \(tty,utmp) -> do | ||
258 | deliverTerminalMessage cw tty utmp msg | ||
259 | return $ or bs | ||
249 | 260 | ||
250 | resource :: UtmpRecord -> Text | 261 | resource :: UtmpRecord -> Text |
251 | resource u = | 262 | resource u = |