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.

42 lines
1.1 KiB

{-# LANGUAGE OverloadedStrings #-}
14 years ago
module Network.XMPP.Bind where
import Control.Monad.Trans.State
import Data.Text as Text
import Network.XMPP.Monad
import Network.XMPP.Types
import Network.XMPP.Pickle
14 years ago
import Network.XMPP.Marshal
import Text.XML.Expat.Pickle
14 years ago
bindReqIQ :: Maybe Text -> Stanza
bindReqIQ resource= SIQ $ IQ Nothing Nothing "bind" Set
(pickleElem
(bindP . xpOption
$ xpElemNodes "resource" (xpContent xpText))
resource
)
14 years ago
jidP :: PU [Node Text Text] JID
jidP = bindP $ xpElemNodes "jid" (xpContent xpPrim)
14 years ago
14 years ago
xmppBind :: XMPPMonad ()
14 years ago
xmppBind = do
res <- gets sResource
push $ bindReqIQ res
answer <- pull
let SIQ (IQ Nothing Nothing _ Result b) = answer
let (JID n d (Just r)) = unpickleElem jidP b
14 years ago
modify (\s -> s{sResource = Just r})
14 years ago
bindP :: PU [Node Text.Text Text.Text] b -> PU [Node Text.Text Text.Text] b
bindP c = ignoreAttrs $ xpElemNs "bind" "urn:ietf:params:xml:ns:xmpp-bind"
xpUnit
c
14 years ago