From 08d9439b39d6a3728f1c4095f61ddeb1a6aa9e96 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 13:35:57 +0200 Subject: [PATCH 1/5] Message.hs: Replace "theadID" with "threadID" Fixes #23. --- source/Network/Xmpp/IM/Message.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Network/Xmpp/IM/Message.hs b/source/Network/Xmpp/IM/Message.hs index b141eea..f29e163 100644 --- a/source/Network/Xmpp/IM/Message.hs +++ b/source/Network/Xmpp/IM/Message.hs @@ -16,7 +16,7 @@ data MessageBody = MessageBody { bodyLang :: Maybe LangTag , bodyContent :: Text } -data MessageThread = MessageThread { theadID :: Text +data MessageThread = MessageThread { threadID :: Text , threadParent :: Maybe Text } From 2ca1ca20bb34778df9470e964fc66ebfca0af4e8 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 14:01:34 +0200 Subject: [PATCH 2/5] Remove IsString instance of `Jid' IsString instances are never supposed to fail, but parsing Strings to JIDs might. We might do this later with Template Haskell instead, or something. --- source/Network/Xmpp/Marshal.hs | 2 +- source/Network/Xmpp/Types.hs | 3 --- tests/Tests.hs | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/Network/Xmpp/Marshal.hs b/source/Network/Xmpp/Marshal.hs index ff893da..da7dbd0 100644 --- a/source/Network/Xmpp/Marshal.hs +++ b/source/Network/Xmpp/Marshal.hs @@ -277,4 +277,4 @@ xpJid :: PU Text Jid xpJid = PU { unpickleTree = \input -> case jidFromText input of Nothing -> UnpickleError $ ErrorMessage "Could not parse JID." Just jid -> Result jid Nothing - , pickleTree = \input -> pack $ jidToText input } + , pickleTree = \input -> jidToText input } diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index dea21e7..45999cd 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -936,9 +936,6 @@ parseJid s = case jidFromText $ Text.pack s of Just jid -> jid Nothing -> error $ "Jid value (" ++ s ++ ") did not validate" -instance IsString Jid where - fromString = fromJust . jidFromText . Text.pack - -- | Converts a Text to a JID. jidFromText :: Text -> Maybe Jid jidFromText t = do diff --git a/tests/Tests.hs b/tests/Tests.hs index ba7dadb..41f334a 100644 --- a/tests/Tests.hs +++ b/tests/Tests.hs @@ -28,13 +28,13 @@ import System.Environment import System.Log.Logger testUser1 :: Jid -testUser1 = "echo1@species64739.dyndns.org/bot" +testUser1 = parseJid "echo1@species64739.dyndns.org/bot" testUser2 :: Jid -testUser2 = "echo2@species64739.dyndns.org/bot" +testUser2 = parseJid "echo2@species64739.dyndns.org/bot" supervisor :: Jid -supervisor = "uart14@species64739.dyndns.org" +supervisor = parseJid "uart14@species64739.dyndns.org" config = def{sessionStreamConfiguration = def{connectionDetails = UseHost "localhost" (PortNumber 5222)}} From 03ec46cd2f23c5855db231a6bcb5e645fd5bc2d0 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 14:22:47 +0200 Subject: [PATCH 3/5] README.md: Clarifications, mention ICU dependency, and conform to API --- README.md | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 90516b5..30bfd2c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ Welcome to Pontarius XMPP! ========================== -Pontarius XMPP is an active work in progress to build a Haskell XMPP library -that implements the client capabilities of [RFC 6120](http://tools.ietf.org/html/rfc6120). +Pontarius XMPP is an active work in progress to build a Haskell XMPP client +library that implements the capabilities of [RFC 6120 +("XMPP CORE")](http://tools.ietf.org/html/rfc6120), [RFC 6121 ("XMPP +IM")](http://tools.ietf.org/html/rfc6121), and [RFC 6122 ("XMPP +ADDR")](http://tools.ietf.org/html/rfc6122). Pontarius XMPP is part of [the +Pontarius project](http://www.pontarius.org/), an effort to produce free and +open source, uncentralized, and privacy-aware software solutions. Getting started --------------- @@ -14,6 +19,10 @@ page](http://hackage.haskell.org/package/pontarius-xmpp/). _Note:_ Pontarius XMPP is still in its Alpha phase. Pontarius XMPP is not yet feature-complete, it may contain bugs, and its API may change between versions. +_Note:_ You will need the ICU Unicode library and it's header files in order to +be able to build Pontarius XMPP. On Debian, you will need to install the +*libicu-dev* package. In Fedora, the package is called *libicu-devel*. + The first thing to do is to import the modules that we are going to use. We are also using the OverloadedStrings LANGUAGE pragma in order to be able to type Text values like strings. @@ -36,15 +45,16 @@ When this is done, a Session object can be acquired by calling result <- session "example.com" + (Just (\_ -> ( [scramSha1 "username" Nothing "password"]) + , Nothing)) def - (Just ([scramSha1 "username" Nothing "password"], Nothing)) -The three parameters above are the XMPP server realm, the session configuration -settings (set to the default settings), and a SASL handler (for authentication). -session will perform the necessary DNS queries to find the address -of the realm, connect, establish the XMPP stream, attempt to secure the stream -with TLS, authenticate, establish a concurrent interface for interacting with -the stream, and return the Session object. +The three parameters above are the XMPP server realm, a SASL handler (for +authentication), and the session configuration settings (set to the default +settings). session will perform the necessary DNS queries to find +the address of the realm, connect, establish the XMPP stream, attempt to secure +the stream with TLS, authenticate, establish a concurrent interface for +interacting with the stream, and return the Session object. The return type of session is IO (Either XmppFailure Session). As XmppFailure is an @@ -58,7 +68,11 @@ doing it could be doing something like this: Next, let us set our status to Online. - sendPresence (Presence Nothing Nothing Nothing Nothing Nothing []) sess + sendPresence def sess + +Here, def refers to the default Presence value, which +is the same as Presence Nothing Nothing Nothing Nothing Available +[]. Now, let's say that we want to receive all message stanzas, and echo the stanzas back to the recipient. This can be done like so: From d7de7ee17d47ff13efe5cafd4e1b8b18a2f83e58 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 14:31:30 +0200 Subject: [PATCH 4/5] pontarius-xmpp.cabal: Add bugtracker URL and change descriptions --- pontarius-xmpp.cabal | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index 397520a..3e9aa3c 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -10,11 +10,11 @@ Author: Jon Kristensen, Mahdi Abdinejadi, Philipp Balzarek Maintainer: info@jonkri.com Stability: alpha Homepage: https://github.com/pontarius/pontarius-xmpp/ -Bug-Reports: mailto:info@jonkri.com +Bug-Reports: https://github.com/pontarius/pontarius-xmpp/issues/ Package-URL: http://www.jonkri.com/releases/pontarius-xmpp-0.2.0.1.tar.gz -Synopsis: An incomplete implementation of RFC 6120 (XMPP: Core) -Description: Pontarius XMPP is a work in progress implementation of - RFC 6120 (XMPP: Core). +Synopsis: An incomplete XMPP client implementation +Description: Pontarius XMPP is a work in progress implementation of RFC 6120 + ("XMPP CORE"), RFC 6121 ("XMPP IM"), and RFC 6122 ("XMPP ADDR"). Category: Network Tested-With: GHC ==7.0.4, GHC ==7.4.1 From 61d1e6ed7a65cca731cd111a796a6e815e7f89a8 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 14:34:01 +0200 Subject: [PATCH 5/5] examples/echoclient/Main.hs: Adapt to new API --- examples/echoclient/Main.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/echoclient/Main.hs b/examples/echoclient/Main.hs index 2e3ab90..35b17ef 100644 --- a/examples/echoclient/Main.hs +++ b/examples/echoclient/Main.hs @@ -20,12 +20,13 @@ main = do updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG result <- session "example.com" + (Just (\_ -> ( [scramSha1 "username" Nothing "password"]) + , Nothing)) def - (Just ([scramSha1 "username" Nothing "password"], Nothing)) sess <- case result of Right s -> return s Left e -> error $ "XmppFailure: " ++ (show e) - sendPresence (Presence Nothing Nothing Nothing Nothing Nothing []) sess + sendPresence def sess forever $ do msg <- getMessage sess case answerMessage msg (messagePayload msg) of