diff options
author | joe <joe@jerkface.net> | 2014-02-16 03:22:42 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-02-16 03:22:42 -0500 |
commit | a09686173da568122559a8debf4190b5f5e98d5e (patch) | |
tree | 45d3ce9342ae1d37e953ada3339c61efa1255176 /Presence | |
parent | 00eb50e9876d9afcfdf6bd52ac937ffaedc1f27b (diff) |
more presence parsing
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/XMPPServer.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 10928892..004f7472 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -286,18 +286,25 @@ parsePresenceStatus ns = do | |||
286 | , presencePriority = prio | 286 | , presencePriority = prio |
287 | , presenceStatus = status | 287 | , presenceStatus = status |
288 | } | 288 | } |
289 | grokPresence stanzaTag = do | 289 | grokPresence ns stanzaTag = do |
290 | let typ = lookupAttrib "type" (tagAttrs stanzaTag) | 290 | let typ = lookupAttrib "type" (tagAttrs stanzaTag) |
291 | case typ of | 291 | case typ of |
292 | Nothing -> parsePresenceStatus "jabber:client" | 292 | Nothing -> parsePresenceStatus ns |
293 | Just "unavailable" -> fmap (fmap (\p -> p {presenceShow=Offline})) | 293 | Just "unavailable" -> fmap (fmap (\p -> p {presenceShow=Offline})) |
294 | $ parsePresenceStatus "jabber:client" | 294 | $ parsePresenceStatus ns |
295 | Just "error" -> return . Just $ PresenceInformError | ||
296 | Just "unsubscribed" -> return . Just $ PresenceInformSubscription False | ||
297 | Just "subscribed" -> return . Just $ PresenceInformSubscription True | ||
298 | Just "probe" -> return . Just $ PresenceRequestStatus | ||
299 | Just "unsubscribe" -> return . Just $ PresenceRequestSubscription False | ||
300 | Just "subscribe" -> return . Just $ PresenceRequestSubscription True | ||
295 | _ -> return Nothing -- todo | 301 | _ -> return Nothing -- todo |
296 | 302 | ||
297 | grokStanza "jabber:server" stanzaTag = | 303 | grokStanza "jabber:server" stanzaTag = |
298 | case () of | 304 | case () of |
299 | _ | stanzaTag `isServerIQOf` "get" -> grokStanzaIQGet stanzaTag | 305 | _ | stanzaTag `isServerIQOf` "get" -> grokStanzaIQGet stanzaTag |
300 | _ | stanzaTag `isServerIQOf` "result" -> grokStanzaIQResult stanzaTag | 306 | _ | stanzaTag `isServerIQOf` "result" -> grokStanzaIQResult stanzaTag |
307 | _ | tagName stanzaTag == "{jabber:server}presence" -> grokPresence "jabber:server" stanzaTag | ||
301 | _ -> return $ Just Unrecognized | 308 | _ -> return $ Just Unrecognized |
302 | 309 | ||
303 | grokStanza "jabber:client" stanzaTag = | 310 | grokStanza "jabber:client" stanzaTag = |
@@ -305,7 +312,7 @@ grokStanza "jabber:client" stanzaTag = | |||
305 | _ | stanzaTag `isClientIQOf` "get" -> grokStanzaIQGet stanzaTag | 312 | _ | stanzaTag `isClientIQOf` "get" -> grokStanzaIQGet stanzaTag |
306 | _ | stanzaTag `isClientIQOf` "set" -> grokStanzaIQSet stanzaTag | 313 | _ | stanzaTag `isClientIQOf` "set" -> grokStanzaIQSet stanzaTag |
307 | _ | stanzaTag `isClientIQOf` "result" -> grokStanzaIQResult stanzaTag | 314 | _ | stanzaTag `isClientIQOf` "result" -> grokStanzaIQResult stanzaTag |
308 | _ | tagName stanzaTag == "{jabber:client}presence" -> grokPresence stanzaTag | 315 | _ | tagName stanzaTag == "{jabber:client}presence" -> grokPresence "jabber:client" stanzaTag |
309 | _ -> return $ Just Unrecognized | 316 | _ -> return $ Just Unrecognized |
310 | 317 | ||
311 | xmppInbound :: Server ConnectionKey | 318 | xmppInbound :: Server ConnectionKey |