diff options
author | joe <joe@jerkface.net> | 2014-03-16 19:59:11 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-03-16 19:59:11 -0400 |
commit | b6adb5217bc60f5757cc115d8b5754920fe2a4d8 (patch) | |
tree | 36e2d324f9dc1241fdbf4563de6accd9038600b3 | |
parent | 6f6f85f11980e782917cb84c7a66c24f41f19ac3 (diff) |
oops
-rw-r--r-- | Presence/ClientState.hs | 32 |
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 @@ | |||
1 | module ClientState where | ||
2 | |||
3 | import Control.Concurrent.STM | ||
4 | import Data.Text ( Text ) | ||
5 | import Data.Int ( Int8 ) | ||
6 | import Data.Bits ( (.&.) ) | ||
7 | |||
8 | import UTmp ( ProcessID ) | ||
9 | import XMPPServer ( Stanza ) | ||
10 | |||
11 | data ClientState = ClientState | ||
12 | { clientResource :: Text | ||
13 | , clientUser :: Text | ||
14 | , clientPid :: Maybe ProcessID | ||
15 | , clientStatus :: TVar (Maybe Stanza) | ||
16 | , clientFlags :: TVar Int8 | ||
17 | } | ||
18 | |||
19 | cf_available :: Int8 | ||
20 | cf_available = 0x1 | ||
21 | cf_interested :: Int8 | ||
22 | cf_interested = 0x2 | ||
23 | |||
24 | -- | True if the client has sent an initial presence | ||
25 | clientIsAvailable c = do | ||
26 | flgs <- readTVar (clientFlags c) | ||
27 | return $ flgs .&. cf_available /= 0 | ||
28 | |||
29 | -- | True if the client has requested a roster | ||
30 | clientIsInterested c = do | ||
31 | flgs <- readTVar (clientFlags c) | ||
32 | return $ flgs .&. cf_interested /= 0 | ||