summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-06 02:22:47 -0500
committerjoe <joe@jerkface.net>2014-03-06 02:22:47 -0500
commit52efeff2233c896b87effcec8641e695c7120607 (patch)
tree63a3e4f296b9dd8c96575c315a968e565b4f86c1 /Presence
parenta41ffe16f5f3237a0b16c49f743ba423b19e46d6 (diff)
offline notifications
Diffstat (limited to 'Presence')
-rw-r--r--Presence/XMPPServer.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index af392f27..4dda1f70 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -22,6 +22,8 @@ module XMPPServer
22 , sendModifiedStanzaToClient 22 , sendModifiedStanzaToClient
23 , presenceProbe 23 , presenceProbe
24 , presenceSolicitation 24 , presenceSolicitation
25 , makePresenceStanza
26 , JabberShow(..)
25 ) where 27 ) where
26 28
27import Debug.Trace 29import Debug.Trace
@@ -746,6 +748,32 @@ grokStanza "jabber:client" stanzaTag =
746mkname :: Text -> Text -> XML.Name 748mkname :: Text -> Text -> XML.Name
747mkname namespace name = (Name name (Just namespace) Nothing) 749mkname namespace name = (Name name (Just namespace) Nothing)
748 750
751makePresenceStanza namespace mjid pstat = do
752 stanzaFromList PresenceStatus { presenceShow = pstat
753 , presencePriority = Nothing
754 , presenceStatus = []
755 }
756 $ [ EventBeginElement (mkname namespace "presence")
757 (setFrom $ typ pstat) ]
758 ++ (shw pstat >>= jabberShow) ++
759 [ EventEndElement (mkname namespace "presence")]
760 where
761 setFrom = maybe id
762 (\jid -> (attr "from" jid :) )
763 mjid
764 typ Offline = [attr "type" "unavailable"]
765 typ _ = []
766 shw ExtendedAway = ["xa"]
767 shw Chatty = ["chat"]
768 shw Away = ["away"]
769 shw DoNotDisturb = ["dnd"]
770 shw _ = []
771 jabberShow stat =
772 [ EventBeginElement "{jabber:client}show" []
773 , EventContent (ContentText stat)
774 , EventEndElement "{jabber:client}show" ]
775
776
749makePong :: Text -> Maybe Text -> Text -> Text -> [XML.Event] 777makePong :: Text -> Maybe Text -> Text -> Text -> [XML.Event]
750makePong namespace mid to from = 778makePong namespace mid to from =
751 -- Note: similar to session reply 779 -- Note: similar to session reply