summaryrefslogtreecommitdiff
path: root/Presence/main.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-06-17 18:03:50 -0400
committerjoe <joe@jerkface.net>2013-06-17 18:03:50 -0400
commit7e8af335398be37523ff19244225b84d48e027ff (patch)
treea934d4e9230432480a392c0ef56d1b47bdb94118 /Presence/main.hs
parent6f87525d0b6c6ce3ae397b84bc237de92c805b33 (diff)
cleaner debug output
Diffstat (limited to 'Presence/main.hs')
-rw-r--r--Presence/main.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/Presence/main.hs b/Presence/main.hs
index dd6bfb2e..36796b6e 100644
--- a/Presence/main.hs
+++ b/Presence/main.hs
@@ -30,7 +30,7 @@ import Control.Exception
30import LocalPeerCred 30import LocalPeerCred
31import System.Posix.User 31import System.Posix.User
32import qualified Data.Set as Set 32import qualified Data.Set as Set
33import Data.Set (Set) 33import Data.Set as Set (Set,(\\))
34 34
35import ByteStringOperators 35import ByteStringOperators
36import qualified Data.ByteString.Lazy.Char8 as L 36import qualified Data.ByteString.Lazy.Char8 as L
@@ -48,15 +48,21 @@ toJabberId host (user,tty,_) =
48 48
49track_login :: IORef (Set L.ByteString) -> t -> IO () 49track_login :: IORef (Set L.ByteString) -> t -> IO ()
50track_login tracked e = do 50track_login tracked e = do
51 -- print e
52 putStrLn "---"
53#ifndef NOUTMP 51#ifndef NOUTMP
54 us <- users 52 us <- users
55#else 53#else
56 let us = [] 54 let us = []
57#endif 55#endif
58 let ids = mapMaybe (toJabberId "localhost") us 56 let ids = Set.fromList $ mapMaybe (toJabberId "localhost") us
59 forM_ ids L.putStrLn 57 -- forM_ ids L.putStrLn
58 state <- readIORef tracked
59 let arrivals = ids \\ state
60 departures = state \\ ids
61 forM_ (Set.toList departures) $ \id -> do
62 putStrLn $ id <++> " logged out."
63 forM_ (Set.toList arrivals) $ \id -> do
64 putStrLn $ id <++> " logged in."
65 writeIORef tracked ids
60 66
61data UnixSession = UnixSession { 67data UnixSession = UnixSession {
62 unix_uid :: (IORef (Maybe UserID)), 68 unix_uid :: (IORef (Maybe UserID)),
@@ -101,19 +107,18 @@ start = do
101 tracked <- newIORef Set.empty 107 tracked <- newIORef Set.empty
102 let dologin e = track_login tracked e 108 let dologin e = track_login tracked e
103 dologin :: t -> IO () 109 dologin :: t -> IO ()
110 dologin ()
104#ifndef NOUTMP 111#ifndef NOUTMP
105 installHandler sigUSR1 (Catch (dologin (userError "signaled"))) Nothing 112 installHandler sigUSR1 (Catch (dologin (userError "signaled"))) Nothing
106#endif 113#endif
107 -- installHandler sigTERM (CatchOnce (dologin (userError "term signaled"))) Nothing 114 -- installHandler sigTERM (CatchOnce (dologin (userError "term signaled"))) Nothing
108 inotify <- initINotify 115 inotify <- initINotify
109 print inotify
110#ifndef NOUTMP 116#ifndef NOUTMP
111 wd <- addWatch 117 wd <- addWatch
112 inotify 118 inotify
113 [CloseWrite] -- [Open,Close,Access,Modify,Move] 119 [CloseWrite] -- [Open,Close,Access,Modify,Move]
114 utmp_file 120 utmp_file
115 dologin 121 dologin
116 print wd
117#endif 122#endif
118 mtty <- monitorTTY on_chvt 123 mtty <- monitorTTY on_chvt
119 sock <- listenForXmppClients UnixSessions 5222 HNil 124 sock <- listenForXmppClients UnixSessions 5222 HNil