diff options
author | joe <joe@jerkface.net> | 2013-07-05 02:18:01 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-07-05 02:18:01 -0400 |
commit | af30d520e948542d112ede4cdeb1faf954b88045 (patch) | |
tree | 6da3fc9e543b56ea6c4399127051f64614f0618f | |
parent | d11e3db1db427cf8a2987e4ec5bb97288b808e2a (diff) |
XMPP module now calls setResource "" on empty bind requests.
-rw-r--r-- | Presence/XMPP.hs | 40 | ||||
-rw-r--r-- | Presence/main.hs | 1 |
2 files changed, 23 insertions, 18 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs index d35e5617..c4e4d7f6 100644 --- a/Presence/XMPP.hs +++ b/Presence/XMPP.hs | |||
@@ -242,24 +242,28 @@ tagName _ = "" | |||
242 | 242 | ||
243 | handleIQSetBind session cmdChan stanza_id = do | 243 | handleIQSetBind session cmdChan stanza_id = do |
244 | mchild <- nextElement | 244 | mchild <- nextElement |
245 | case mchild of | 245 | rsc <- case mchild of |
246 | Just child -> do | 246 | Just child -> do |
247 | let unhandledBind = liftIO $ putStrLn $ "unhandled-bind: "++show child | 247 | let unhandledBind = do |
248 | case tagName child of | 248 | liftIO $ putStrLn $ "unhandled-bind: "++show child |
249 | "{urn:ietf:params:xml:ns:xmpp-bind}resource" | 249 | return "" |
250 | -> do | 250 | case tagName child of |
251 | rsc <- lift content | 251 | "{urn:ietf:params:xml:ns:xmpp-bind}resource" |
252 | liftIO $ do | 252 | -> do |
253 | putStrLn $ "iq-set-bind-resource " ++ show rsc | 253 | rsc <- lift content |
254 | setResource session (L.fromChunks [S.encodeUtf8 rsc]) | 254 | return $ L.fromChunks [S.encodeUtf8 rsc] |
255 | jid <- getJID session | 255 | _ -> unhandledBind |
256 | atomically $ writeTChan cmdChan (Send $ iq_bind_reply stanza_id (toStrict $ L.decodeUtf8 $ L.show jid) ) | 256 | Nothing -> do |
257 | forCachedPresence session $ \presence -> do | 257 | liftIO $ putStrLn $ "empty bind request!" |
258 | xs <- xmlifyPresenceForClient presence | 258 | return "" |
259 | atomically . writeTChan cmdChan . Send $ xs | 259 | liftIO $ do |
260 | _ -> unhandledBind | 260 | L.putStrLn $ "iq-set-bind-resource " <++> rsc |
261 | Nothing -> do | 261 | setResource session rsc |
262 | liftIO $ putStrLn $ "empty bind request!" | 262 | jid <- getJID session |
263 | atomically $ writeTChan cmdChan (Send $ iq_bind_reply stanza_id (toStrict $ L.decodeUtf8 $ L.show jid) ) | ||
264 | forCachedPresence session $ \presence -> do | ||
265 | xs <- xmlifyPresenceForClient presence | ||
266 | atomically . writeTChan cmdChan . Send $ xs | ||
263 | 267 | ||
264 | 268 | ||
265 | iq_session_reply host stanza_id = | 269 | iq_session_reply host stanza_id = |
diff --git a/Presence/main.hs b/Presence/main.hs index 6721db86..e8c07788 100644 --- a/Presence/main.hs +++ b/Presence/main.hs | |||
@@ -113,6 +113,7 @@ instance JabberClientSession ClientSession where | |||
113 | return $ ClientSession (hostname state) uid_ref res_ref state | 113 | return $ ClientSession (hostname state) uid_ref res_ref state |
114 | 114 | ||
115 | setResource s resource = do | 115 | setResource s resource = do |
116 | -- TODO: handle resource = empty string | ||
116 | writeIORef (unix_resource s) (Just resource) | 117 | writeIORef (unix_resource s) (Just resource) |
117 | L.putStrLn $ "CLIENT SESSION: resource " <++> resource | 118 | L.putStrLn $ "CLIENT SESSION: resource " <++> resource |
118 | 119 | ||