summaryrefslogtreecommitdiff
path: root/Presence/ConsoleWriter.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-05 13:21:50 -0400
committerjoe <joe@jerkface.net>2014-04-05 13:21:50 -0400
commit237aa5bfb1b15735658f6623386746d1593add9b (patch)
treebaf2a1c12667fa15a69f8b932bfb2ecdf6ca2420 /Presence/ConsoleWriter.hs
parent20620e2f3a2f757cd4d5f4116cb553c5ee9a5b6c (diff)
Fixed stair-stepping.
Diffstat (limited to 'Presence/ConsoleWriter.hs')
-rw-r--r--Presence/ConsoleWriter.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/Presence/ConsoleWriter.hs b/Presence/ConsoleWriter.hs
index 5ed4f1df..b5040ba7 100644
--- a/Presence/ConsoleWriter.hs
+++ b/Presence/ConsoleWriter.hs
@@ -230,6 +230,7 @@ readEnvFile var file = fmap parse $ readFile file
230writeActiveTTY :: ConsoleWriter -> Stanza -> IO Bool 230writeActiveTTY :: ConsoleWriter -> Stanza -> IO Bool
231writeActiveTTY cw msg = do 231writeActiveTTY cw msg = do
232 putStrLn $ "writeActiveTTY" 232 putStrLn $ "writeActiveTTY"
233 -- TODO: Do not deliver if the detination user does not own the active tty!
233 (tty, mbu) <- atomically $ do 234 (tty, mbu) <- atomically $ do
234 num <- readTVar $ csActiveTTY cw 235 num <- readTVar $ csActiveTTY cw
235 utmp <- readTVar $ csUtmp cw 236 utmp <- readTVar $ csUtmp cw
@@ -281,7 +282,7 @@ deliverTerminalMessage cw tty utmp msg = do
281 t <- messageText msg 282 t <- messageText msg
282 return $ Text.unpack 283 return $ Text.unpack
283 $ case stanzaFrom msg of 284 $ case stanzaFrom msg of
284 Just from -> from <> " says...\r\n" <> crlf t <> "\r\n" 285 Just from -> "\r\n" <> from <> " says...\r\n" <> crlf t <> "\r\n"
285 Nothing -> crlf t <> "\r\n" 286 Nothing -> crlf t <> "\r\n"
286 writeFile (Text.unpack tty) text 287 writeFile (Text.unpack tty) text
287 return True -- return True if a message was delivered 288 return True -- return True if a message was delivered
@@ -289,6 +290,7 @@ deliverTerminalMessage cw tty utmp msg = do
289-- | Deliver the given message to all a user's PTYs. 290-- | Deliver the given message to all a user's PTYs.
290writeAllPty :: ConsoleWriter -> Stanza -> IO Bool 291writeAllPty :: ConsoleWriter -> Stanza -> IO Bool
291writeAllPty cw msg = do 292writeAllPty cw msg = do
293 -- TODO: filter only ptys owned by the destination user.
292 us <- atomically $ readTVar (csUtmp cw) 294 us <- atomically $ readTVar (csUtmp cw)
293 let ptys = Map.filterWithKey ispty us 295 let ptys = Map.filterWithKey ispty us
294 ispty k _ = "pts/" `Text.isPrefixOf` k 296 ispty k _ = "pts/" `Text.isPrefixOf` k