Browse Source

add Text.XML.Stream.Elements.parseElement

minor fix-ups
master
Philipp Balzarek 13 years ago
parent
commit
e96b5e557a
  1. 2
      source/Network/Xmpp/Marshal.hs
  2. 6
      source/Network/Xmpp/Xep/InbandRegistration.hs
  3. 2
      source/Text/XML/Stream/Elements.hs

2
source/Network/Xmpp/Marshal.hs

@ -48,7 +48,7 @@ xpMessage = xpWrap @@ -48,7 +48,7 @@ xpMessage = xpWrap
(xpAttrImplied "id" xpPrim)
(xpAttrImplied "from" xpPrim)
(xpAttrImplied "to" xpPrim)
(xpAttrImplied xmlLang xpPrim)
xpLangTag
-- TODO: NS?
)
(xpAll xpElemVerbatim)

6
source/Network/Xmpp/Xep/InbandRegistration.hs

@ -68,7 +68,7 @@ supported = runErrorT $ fromFeatures <+> fromDisco @@ -68,7 +68,7 @@ supported = runErrorT $ fromFeatures <+> fromDisco
Right qir -> return $ "jabber:iq:register" `elem` qiFeatures qir
f <+> g = do
r <- f
if r then return r else g
if r then return True else g
query :: IQRequestType -> Query -> XmppConMonad (Either IbrError Query)
@ -94,6 +94,8 @@ instance Error RegisterError @@ -94,6 +94,8 @@ instance Error RegisterError
mapError f = mapErrorT (liftM $ left f)
-- | Retrieve the necessary fields and fill them in to register an account with
-- the server
registerWith :: [(Field, Text.Text)] -> XmppConMonad (Either RegisterError Query)
registerWith givenFields = runErrorT $ do
fs <- mapError IbrError $ ErrorT requestFields
@ -108,6 +110,8 @@ registerWith givenFields = runErrorT $ do @@ -108,6 +110,8 @@ registerWith givenFields = runErrorT $ do
result <- mapError IbrError . ErrorT . query Set $ emptyQuery {fields}
return result
-- | Terminate your account on the server. You have to be logged in for this to
-- work. You connection will most likely be terminated after unregistering.
unregister :: XmppConMonad (Either IbrError Query)
unregister = query Set $ emptyQuery {remove = True}

2
source/Text/XML/Stream/Elements.hs

@ -39,6 +39,8 @@ data InvalidXmppXml = InvalidXmppXml String deriving (Show, Typeable) @@ -39,6 +39,8 @@ data InvalidXmppXml = InvalidXmppXml String deriving (Show, Typeable)
instance Exception InvalidXmppXml
parseElement txt = documentRoot $ TXU.parseText_ TXU.def txt
elements :: R.MonadThrow m => C.Conduit Event m Element
elements = do
x <- C.await

Loading…
Cancel
Save