summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Presence/ClientState.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/Presence/ClientState.hs b/Presence/ClientState.hs
new file mode 100644
index 00000000..44d81b4f
--- /dev/null
+++ b/Presence/ClientState.hs
@@ -0,0 +1,32 @@
1module ClientState where
2
3import Control.Concurrent.STM
4import Data.Text ( Text )
5import Data.Int ( Int8 )
6import Data.Bits ( (.&.) )
7
8import UTmp ( ProcessID )
9import XMPPServer ( Stanza )
10
11data ClientState = ClientState
12 { clientResource :: Text
13 , clientUser :: Text
14 , clientPid :: Maybe ProcessID
15 , clientStatus :: TVar (Maybe Stanza)
16 , clientFlags :: TVar Int8
17 }
18
19cf_available :: Int8
20cf_available = 0x1
21cf_interested :: Int8
22cf_interested = 0x2
23
24-- | True if the client has sent an initial presence
25clientIsAvailable c = do
26 flgs <- readTVar (clientFlags c)
27 return $ flgs .&. cf_available /= 0
28
29-- | True if the client has requested a roster
30clientIsInterested c = do
31 flgs <- readTVar (clientFlags c)
32 return $ flgs .&. cf_interested /= 0