diff options
Diffstat (limited to 'Presence/ClientState.hs')
-rw-r--r-- | Presence/ClientState.hs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/Presence/ClientState.hs b/Presence/ClientState.hs deleted file mode 100644 index 08cc54ed..00000000 --- a/Presence/ClientState.hs +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
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 | -- | The unix tty or the jabber resource for this client. | ||
13 | { clientResource :: Text | ||
14 | -- | Unix user that is running this client. | ||
15 | , clientUser :: Text | ||
16 | -- | The specific roster/identity of the user that this client presenting. | ||
17 | , clientProfile :: Text | ||
18 | -- | The unix process id of the client if we know it. | ||
19 | , clientPid :: Maybe ProcessID | ||
20 | -- | The presence (away/available) stanza this client is indicating. | ||
21 | , clientStatus :: TVar (Maybe Stanza) | ||
22 | -- | XMPP client flags (read access via 'clientIsAvailable' and 'clientIsInterested') | ||
23 | , clientFlags :: TVar Int8 | ||
24 | } | ||
25 | |||
26 | cf_available :: Int8 | ||
27 | cf_available = 0x1 | ||
28 | cf_interested :: Int8 | ||
29 | cf_interested = 0x2 | ||
30 | |||
31 | -- | True if the client has sent an initial presence | ||
32 | clientIsAvailable :: ClientState -> STM Bool | ||
33 | clientIsAvailable c = do | ||
34 | flgs <- readTVar (clientFlags c) | ||
35 | return $ flgs .&. cf_available /= 0 | ||
36 | |||
37 | -- | True if the client has requested a roster | ||
38 | clientIsInterested :: ClientState -> STM Bool | ||
39 | clientIsInterested c = do | ||
40 | flgs <- readTVar (clientFlags c) | ||
41 | return $ flgs .&. cf_interested /= 0 | ||