From e96b5e557a8b631308785ed4f7d4e409f3c226da Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Sat, 13 Oct 2012 14:45:46 +0200
Subject: [PATCH] add Text.XML.Stream.Elements.parseElement minor fix-ups
---
source/Network/Xmpp/Marshal.hs | 2 +-
source/Network/Xmpp/Xep/InbandRegistration.hs | 6 +++++-
source/Text/XML/Stream/Elements.hs | 2 ++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/source/Network/Xmpp/Marshal.hs b/source/Network/Xmpp/Marshal.hs
index d7e0ae8..4de88c4 100644
--- a/source/Network/Xmpp/Marshal.hs
+++ b/source/Network/Xmpp/Marshal.hs
@@ -48,7 +48,7 @@ xpMessage = xpWrap
(xpAttrImplied "id" xpPrim)
(xpAttrImplied "from" xpPrim)
(xpAttrImplied "to" xpPrim)
- (xpAttrImplied xmlLang xpPrim)
+ xpLangTag
-- TODO: NS?
)
(xpAll xpElemVerbatim)
diff --git a/source/Network/Xmpp/Xep/InbandRegistration.hs b/source/Network/Xmpp/Xep/InbandRegistration.hs
index 633b024..fc2f0f2 100644
--- a/source/Network/Xmpp/Xep/InbandRegistration.hs
+++ b/source/Network/Xmpp/Xep/InbandRegistration.hs
@@ -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
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
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}
diff --git a/source/Text/XML/Stream/Elements.hs b/source/Text/XML/Stream/Elements.hs
index a10e7a6..e0156e5 100644
--- a/source/Text/XML/Stream/Elements.hs
+++ b/source/Text/XML/Stream/Elements.hs
@@ -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