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.

35 lines
875 B

{-# LANGUAGE OverloadedStrings #-}
14 years ago
module Network.XMPP.Bind where
import Data.Text as Text
14 years ago
import Data.XML.Pickle
import Data.XML.Types
14 years ago
import Network.XMPP.Types
import Network.XMPP.Pickle
14 years ago
import Network.XMPP.Concurrent
14 years ago
bindP :: PU [Node] b -> PU [Node] b
bindP c = xpElemNodes "{urn:ietf:params:xml:ns:xmpp-bind}bind" c
14 years ago
bindBody :: Maybe Text -> Element
bindBody rsrc = (pickleElem
(bindP . xpOption $ xpElemNodes "resource" (xpContent xpId))
rsrc
)
14 years ago
jidP :: PU [Node] JID
jidP = bindP $ xpElemNodes "jid" (xpContent xpPrim)
14 years ago
14 years ago
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
14 years ago
let (JID _n _d (Just r)) = unpickleElem jidP b
return r