summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-16 14:22:55 -0400
committerjoe <joe@jerkface.net>2014-03-16 14:22:55 -0400
commit5f0d519e73baf763c8caeab10d90fa9a55dc71b8 (patch)
tree497501152100ae90b8f0c8835713bb4a24f8eff9
parentfe3087cc86552fdccac5b90d49d998611a493a45 (diff)
write to terminal
-rw-r--r--Presence/ConsoleWriter.hs17
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
246writeAllPty :: ConsoleWriter -> Stanza -> IO Bool 252writeAllPty :: ConsoleWriter -> Stanza -> IO Bool
247writeAllPty cw msg = do 253writeAllPty 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
250resource :: UtmpRecord -> Text 261resource :: UtmpRecord -> Text
251resource u = 262resource u =