summaryrefslogtreecommitdiff
path: root/Presence/XMPPServer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/XMPPServer.hs')
-rw-r--r--Presence/XMPPServer.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index 044ed9e4..4a859bc9 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -40,6 +40,33 @@ import Network.Socket
40import Data.String 40import Data.String
41import Control.Monad.Trans.Maybe 41import Control.Monad.Trans.Maybe
42import Control.Monad.IO.Class 42import Control.Monad.IO.Class
43import Control.DeepSeq
44import Control.Concurrent.STM
45
46-- | Jabber ID (JID) datatype
47data JID = JID { name :: Maybe ByteString
48 , server :: ByteString
49 , resource :: Maybe ByteString
50 }
51 deriving (Ord,Eq)
52
53instance Show JID where
54 show (JID n s r ) = L.unpack $ fmap (<++>"@") n <?++> s <++?> fmap ("/"<++>) r
55
56instance NFData JID where
57 rnf v@(JID n s r) = n `seq` s `seq` r `seq` ()
58
59jid user host rsrc = JID (Just user) host (Just rsrc)
60
61data JabberShow = Offline
62 | Away
63 | Available
64 deriving (Show,Enum,Ord,Eq,Read)
65
66data Presence = Presence JID JabberShow
67
68instance NFData Presence where
69 rnf (Presence jid stat) = rnf jid `seq` stat `seq` ()
43 70
44 71
45class XMPPSession session where 72class XMPPSession session where
@@ -48,6 +75,7 @@ class XMPPSession session where
48 setResource :: session -> ByteString -> IO () 75 setResource :: session -> ByteString -> IO ()
49 getJID :: session -> IO ByteString 76 getJID :: session -> IO ByteString
50 closeSession :: session -> IO () 77 closeSession :: session -> IO ()
78 subscribeToPresence :: session -> Maybe JID -> IO (TChan Presence)
51 79
52 80
53greet host = L.unlines 81greet host = L.unlines