You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
875 B
34 lines
875 B
{-# LANGUAGE OverloadedStrings #-} |
|
|
|
module Network.XMPP.Bind where |
|
|
|
import Data.Text as Text |
|
|
|
import Data.XML.Pickle |
|
import Data.XML.Types |
|
|
|
import Network.XMPP.Types |
|
import Network.XMPP.Pickle |
|
import Network.XMPP.Concurrent |
|
|
|
bindP :: PU [Node] b -> PU [Node] b |
|
bindP c = xpElemNodes "{urn:ietf:params:xml:ns:xmpp-bind}bind" c |
|
|
|
bindBody :: Maybe Text -> Element |
|
bindBody rsrc = (pickleElem |
|
(bindP . xpOption $ xpElemNodes "resource" (xpContent xpId)) |
|
rsrc |
|
) |
|
|
|
jidP :: PU [Node] JID |
|
jidP = bindP $ xpElemNodes "jid" (xpContent xpPrim) |
|
|
|
xmppThreadedBind :: Maybe Text -> XMPPThread Text |
|
xmppThreadedBind rsrc = do |
|
answer <- sendIQ' Nothing Set Nothing (bindBody rsrc) |
|
let (Right IQResult{iqResultPayload = Just b}) = answer -- TODO: Error handling |
|
let (JID _n _d (Just r)) = unpickleElem jidP b |
|
return r |
|
|
|
|
|
|
|
|