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
(xpAttrImplied "id" xpPrim) (xpAttrImplied "id" xpPrim)
(xpAttrImplied "from" xpPrim) (xpAttrImplied "from" xpPrim)
(xpAttrImplied "to" xpPrim) (xpAttrImplied "to" xpPrim)
(xpAttrImplied xmlLang xpPrim) xpLangTag
-- TODO: NS? -- TODO: NS?
) )
(xpAll xpElemVerbatim) (xpAll xpElemVerbatim)

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

@ -68,7 +68,7 @@ supported = runErrorT $ fromFeatures <+> fromDisco
Right qir -> return $ "jabber:iq:register" `elem` qiFeatures qir Right qir -> return $ "jabber:iq:register" `elem` qiFeatures qir
f <+> g = do f <+> g = do
r <- f r <- f
if r then return r else g if r then return True else g
query :: IQRequestType -> Query -> XmppConMonad (Either IbrError Query) query :: IQRequestType -> Query -> XmppConMonad (Either IbrError Query)
@ -94,6 +94,8 @@ instance Error RegisterError
mapError f = mapErrorT (liftM $ left f) 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 :: [(Field, Text.Text)] -> XmppConMonad (Either RegisterError Query)
registerWith givenFields = runErrorT $ do registerWith givenFields = runErrorT $ do
fs <- mapError IbrError $ ErrorT requestFields fs <- mapError IbrError $ ErrorT requestFields
@ -108,6 +110,8 @@ registerWith givenFields = runErrorT $ do
result <- mapError IbrError . ErrorT . query Set $ emptyQuery {fields} result <- mapError IbrError . ErrorT . query Set $ emptyQuery {fields}
return result 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 :: XmppConMonad (Either IbrError Query)
unregister = query Set $ emptyQuery {remove = True} unregister = query Set $ emptyQuery {remove = True}

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

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

Loading…
Cancel
Save