From c34982dba9ae16be1669c2cb1b33792aab316286 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Tue, 1 Jan 2013 23:50:22 +0100 Subject: [PATCH] Projects/Pontarius/Apply various minor fixes Started using double quotes instead of single quotes on XMLDecl, to conform to the quotations of the other XML. To conform with the Haskell style guidelines, `TLS' is now spelled `Tls', and `XML' is now spelled `Xml'. Updated library name in README file. --- README | 4 ++-- pontarius-xmpp.cabal | 6 +++--- source/Data/Conduit/{TLS.hs => Tls.hs} | 2 +- source/Network/Xmpp.hs | 10 +++++----- source/Network/Xmpp/Basic.hs | 4 ++-- source/Network/Xmpp/Concurrent/Channels.hs | 2 +- source/Network/Xmpp/Connection.hs | 4 ++-- source/Network/Xmpp/Pickle.hs | 2 +- source/Network/Xmpp/Session.hs | 12 ++++++------ source/Network/Xmpp/Stream.hs | 12 ++++++------ source/Network/Xmpp/{TLS.hs => Tls.hs} | 14 +++++++------- source/Network/Xmpp/Types.hs | 20 ++++++++++---------- source/Network/Xmpp/Xep/ServiceDiscovery.hs | 8 ++++---- source/Text/{XML => Xml}/Stream/Elements.hs | 2 +- 14 files changed, 51 insertions(+), 51 deletions(-) rename source/Data/Conduit/{TLS.hs => Tls.hs} (98%) rename source/Network/Xmpp/{TLS.hs => Tls.hs} (90%) rename source/Text/{XML => Xml}/Stream/Elements.hs (97%) diff --git a/README b/README index b4a7bee..b502625 100644 --- a/README +++ b/README @@ -1,2 +1,2 @@ -Pontarius is an active work in progress to build a Haskell XMPP library that -implements the client capabilities of RFC 6120 ("XMPP Core"). \ No newline at end of file +Pontarius XMPP is an active work in progress to build a Haskell XMPP library +that implements the client capabilities of RFC 6120 ("XMPP Core"). diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index 7007be0..aa760aa 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -56,7 +56,7 @@ Library Exposed-modules: Network.Xmpp , Network.Xmpp.IM , Network.Xmpp.Basic - Other-modules: Data.Conduit.TLS + Other-modules: Data.Conduit.Tls , Network.Xmpp.Bind , Network.Xmpp.Concurrent , Network.Xmpp.Concurrent.Types @@ -87,10 +87,10 @@ Library , Network.Xmpp.Sasl.Types , Network.Xmpp.Session , Network.Xmpp.Stream - , Network.Xmpp.TLS + , Network.Xmpp.Tls , Network.Xmpp.Types , Network.Xmpp.Xep.ServiceDiscovery - , Text.XML.Stream.Elements + , Text.Xml.Stream.Elements GHC-Options: -Wall Source-Repository head diff --git a/source/Data/Conduit/TLS.hs b/source/Data/Conduit/Tls.hs similarity index 98% rename from source/Data/Conduit/TLS.hs rename to source/Data/Conduit/Tls.hs index 68fa23b..17e4d19 100644 --- a/source/Data/Conduit/TLS.hs +++ b/source/Data/Conduit/Tls.hs @@ -1,6 +1,6 @@ {-# Language NoMonomorphismRestriction #-} {-# OPTIONS_HADDOCK hide #-} -module Data.Conduit.TLS +module Data.Conduit.Tls ( tlsinit -- , conduitStdout , module TLS diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index c276b8b..f7a686b 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -25,11 +25,11 @@ module Network.Xmpp ( -- * Session management Session + , simpleConnect + , connectTcp , newSession , withConnection - , connectTcp - , simpleConnect - , startTLS + , startTls , simpleAuth , auth , scramSha1 @@ -148,7 +148,7 @@ module Network.Xmpp , StreamFailure(..) , StreamErrorInfo(..) , StreamErrorCondition(..) - , TLSFailure(..) + , TlsFailure(..) ) where @@ -166,5 +166,5 @@ import Network.Xmpp.Presence import Network.Xmpp.Sasl import Network.Xmpp.Session import Network.Xmpp.Stream -import Network.Xmpp.TLS +import Network.Xmpp.Tls import Network.Xmpp.Types diff --git a/source/Network/Xmpp/Basic.hs b/source/Network/Xmpp/Basic.hs index 4f31f0a..5ee4058 100644 --- a/source/Network/Xmpp/Basic.hs +++ b/source/Network/Xmpp/Basic.hs @@ -3,7 +3,7 @@ module Network.Xmpp.Basic , ConnectionState(..) , connectTcp , simpleConnect - , startTLS + , startTls , simpleAuth , auth , scramSha1 @@ -19,5 +19,5 @@ import Network.Xmpp.Connection import Network.Xmpp.Sasl import Network.Xmpp.Session import Network.Xmpp.Stream -import Network.Xmpp.TLS +import Network.Xmpp.Tls import Network.Xmpp.Types diff --git a/source/Network/Xmpp/Concurrent/Channels.hs b/source/Network/Xmpp/Concurrent/Channels.hs index 31c294a..9516afb 100644 --- a/source/Network/Xmpp/Concurrent/Channels.hs +++ b/source/Network/Xmpp/Concurrent/Channels.hs @@ -32,7 +32,7 @@ import Network.Xmpp.Concurrent.Types import Network.Xmpp.Marshal import Network.Xmpp.Pickle import Network.Xmpp.Types -import Text.XML.Stream.Elements +import Text.Xml.Stream.Elements toChans :: TChan Stanza -> TVar IQHandlers diff --git a/source/Network/Xmpp/Connection.hs b/source/Network/Xmpp/Connection.hs index 942ba8a..1d682fa 100644 --- a/source/Network/Xmpp/Connection.hs +++ b/source/Network/Xmpp/Connection.hs @@ -33,7 +33,7 @@ import Network.Xmpp.Pickle import System.IO -import Text.XML.Stream.Elements +import Text.Xml.Stream.Elements import Text.XML.Stream.Parse as XP import Text.XML.Unresolved(InvalidEventStream(..)) @@ -62,7 +62,7 @@ pushStanza s = withConnection' . pushElement $ pickleElem xpStanza s pushXmlDecl :: StateT Connection_ IO Bool pushXmlDecl = do con <- gets cHand - liftIO $ (cSend con) "" + liftIO $ (cSend con) "" pushOpenElement :: Element -> StateT Connection_ IO Bool pushOpenElement e = do diff --git a/source/Network/Xmpp/Pickle.hs b/source/Network/Xmpp/Pickle.hs index e00e190..e16cb2e 100644 --- a/source/Network/Xmpp/Pickle.hs +++ b/source/Network/Xmpp/Pickle.hs @@ -27,7 +27,7 @@ import Data.XML.Pickle import Network.Xmpp.Types -import Text.XML.Stream.Elements +import Text.Xml.Stream.Elements mbToBool :: Maybe t -> Bool mbToBool (Just _) = True diff --git a/source/Network/Xmpp/Session.hs b/source/Network/Xmpp/Session.hs index 59b4b72..0902407 100644 --- a/source/Network/Xmpp/Session.hs +++ b/source/Network/Xmpp/Session.hs @@ -19,7 +19,7 @@ import Network.Xmpp.Sasl import Network.Xmpp.Sasl.Mechanisms import Network.Xmpp.Sasl.Types import Network.Xmpp.Stream -import Network.Xmpp.TLS +import Network.Xmpp.Tls import Network.Xmpp.Types -- | The quick and easy way to set up a connection to an XMPP server @@ -53,7 +53,7 @@ simpleConnect host port hostname username password resource = do con <- case con' of Left e -> Ex.throwIO e Right r -> return r - startTLS exampleParams con + startTls exampleParams con saslResponse <- simpleAuth username password resource con case saslResponse of Right jid -> newSession con @@ -88,8 +88,8 @@ connectTcp address port hostname = do -- TODO: Catch remaining xmppStartStream errors. toError _ = StreamErrorInfo StreamBadFormat Nothing Nothing -sessionXML :: Element -sessionXML = pickleElem +sessionXml :: Element +sessionXml = pickleElem (xpElemBlank "{urn:ietf:params:xml:ns:xmpp-session}session") () @@ -99,14 +99,14 @@ sessionIQ = IQRequestS $ IQRequest { iqRequestID = "sess" , iqRequestTo = Nothing , iqRequestLangTag = Nothing , iqRequestType = Set - , iqRequestPayload = sessionXML + , iqRequestPayload = sessionXml } -- Sends the session IQ set element and waits for an answer. Throws an error if -- if an IQ error stanza is returned from the server. startSession :: Connection -> IO () startSession con = do - answer <- pushIQ' "session" Nothing Set Nothing sessionXML con + answer <- pushIQ' "session" Nothing Set Nothing sessionXml con case answer of Left e -> error $ show e Right _ -> return () diff --git a/source/Network/Xmpp/Stream.hs b/source/Network/Xmpp/Stream.hs index 87bba00..5e197ca 100644 --- a/source/Network/Xmpp/Stream.hs +++ b/source/Network/Xmpp/Stream.hs @@ -25,18 +25,18 @@ import Network.Xmpp.Errors import Network.Xmpp.Pickle import Network.Xmpp.Types -import Text.XML.Stream.Elements +import Text.Xml.Stream.Elements import Text.XML.Stream.Parse as XP -- import Text.XML.Stream.Elements --- Unpickles and returns a stream element. Throws a StreamXMLError on failure. +-- Unpickles and returns a stream element. Throws a StreamXmlError on failure. streamUnpickleElem :: PU [Node] a -> Element -> StreamSink a streamUnpickleElem p x = do case unpickleElem p x of - Left l -> throwError $ StreamOtherFailure -- TODO: Log: StreamXMLError (show l) + Left l -> throwError $ StreamOtherFailure -- TODO: Log: StreamXmlError (show l) Right r -> return r -- This is the conduit sink that handles the stream XML events. We extend it @@ -166,14 +166,14 @@ xpStreamFeatures = xpWrap (Just "stream") ) (xpTriple - (xpOption pickleTLSFeature) + (xpOption pickleTlsFeature) (xpOption pickleSaslFeature) (xpAll xpElemVerbatim) ) ) where - pickleTLSFeature :: PU [Node] Bool - pickleTLSFeature = xpElemNodes "{urn:ietf:params:xml:ns:xmpp-tls}starttls" + pickleTlsFeature :: PU [Node] Bool + pickleTlsFeature = xpElemNodes "{urn:ietf:params:xml:ns:xmpp-tls}starttls" (xpElemExists "required") pickleSaslFeature :: PU [Node] [Text] pickleSaslFeature = xpElemNodes diff --git a/source/Network/Xmpp/TLS.hs b/source/Network/Xmpp/Tls.hs similarity index 90% rename from source/Network/Xmpp/TLS.hs rename to source/Network/Xmpp/Tls.hs index ac68f3e..f3db8d5 100644 --- a/source/Network/Xmpp/TLS.hs +++ b/source/Network/Xmpp/Tls.hs @@ -2,7 +2,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} -module Network.Xmpp.TLS where +module Network.Xmpp.Tls where import qualified Control.Exception.Lifted as Ex import Control.Monad @@ -13,7 +13,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL import Data.Conduit import qualified Data.Conduit.Binary as CB -import Data.Conduit.TLS as TLS +import Data.Conduit.Tls as TLS import Data.Typeable import Data.XML.Types @@ -74,18 +74,18 @@ exampleParams = TLS.defaultParamsClient -- Pushes ", waits for "", performs the TLS handshake, and -- restarts the stream. -startTLS :: TLS.TLSParams -> Connection -> IO (Either TLSFailure ()) -startTLS params con = Ex.handle (return . Left . TLSError) +startTls :: TLS.TLSParams -> Connection -> IO (Either TlsFailure ()) +startTls params con = Ex.handle (return . Left . TlsError) . flip withConnection con . runErrorT $ do features <- lift $ gets sFeatures state <- gets sConnectionState case state of ConnectionPlain -> return () - ConnectionClosed -> throwError TLSNoConnection - ConnectionSecured -> throwError TLSConnectionSecured + ConnectionClosed -> throwError TlsNoConnection + ConnectionSecured -> throwError TlsConnectionSecured con <- lift $ gets cHand - when (stls features == Nothing) $ throwError TLSNoServerSupport + when (stls features == Nothing) $ throwError TlsNoServerSupport lift $ pushElement starttlsE answer <- lift $ pullElement case answer of diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index 6af878c..9d33266 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -40,7 +40,7 @@ module Network.Xmpp.Types , ConnectionState(..) , StreamErrorInfo(..) , langTag - , TLSFailure(..) + , TlsFailure(..) , module Network.Xmpp.Jid ) where @@ -625,7 +625,7 @@ instance Read StreamErrorCondition where data StreamErrorInfo = StreamErrorInfo { errorCondition :: !StreamErrorCondition , errorText :: !(Maybe (Maybe LangTag, Text)) - , errorXML :: !(Maybe Element) + , errorXml :: !(Maybe Element) } deriving (Show, Eq) -- | Signals an XMPP stream error or another unpredicted stream-related @@ -814,13 +814,13 @@ mkConnection con = Connection `fmap` (atomically $ newTMVar con) -- | Failure conditions that may arise during TLS negotiation. -data TLSFailure = TLSError TLS.TLSError - | TLSNoServerSupport - | TLSNoConnection - | TLSConnectionSecured -- ^ Connection already secured - | TLSStreamError StreamFailure - | TLSFailureError -- General instance used for the Error instance (TODO) +data TlsFailure = TlsError TLS.TLSError + | TlsNoServerSupport + | TlsNoConnection + | TlsConnectionSecured -- ^ Connection already secured + | TlsStreamError StreamFailure + | TlsFailureError -- General instance used for the Error instance (TODO) deriving (Show, Eq, Typeable) -instance Error TLSFailure where - noMsg = TLSFailureError +instance Error TlsFailure where + noMsg = TlsFailureError diff --git a/source/Network/Xmpp/Xep/ServiceDiscovery.hs b/source/Network/Xmpp/Xep/ServiceDiscovery.hs index f4ee1e1..5eaf192 100644 --- a/source/Network/Xmpp/Xep/ServiceDiscovery.hs +++ b/source/Network/Xmpp/Xep/ServiceDiscovery.hs @@ -35,7 +35,7 @@ import Network.Xmpp.Types data DiscoError = DiscoNoQueryElement | DiscoIQError IQError | DiscoTimeout - | DiscoXMLError Element UnpickleError + | DiscoXmlError Element UnpickleError deriving (Show) @@ -97,7 +97,7 @@ queryInfo to node context = do IQResponseResult r -> case iqResultPayload r of Nothing -> Left DiscoNoQueryElement Just p -> case unpickleElem xpQueryInfo p of - Left e -> Left $ DiscoXMLError p e + Left e -> Left $ DiscoXmlError p e Right r -> Right r where queryBody = pickleElem xpQueryInfo (QIR node [] []) @@ -114,7 +114,7 @@ xmppQueryInfo to node con = do Right r -> case iqResultPayload r of Nothing -> Left DiscoNoQueryElement Just p -> case unpickleElem xpQueryInfo p of - Left e -> Left $ DiscoXMLError p e + Left e -> Left $ DiscoXmlError p e Right r -> Right r where queryBody = pickleElem xpQueryInfo (QIR node [] []) @@ -161,7 +161,7 @@ queryItems to node session = do IQResponseResult r -> case iqResultPayload r of Nothing -> Left DiscoNoQueryElement Just p -> case unpickleElem xpQueryItems p of - Left e -> Left $ DiscoXMLError p e + Left e -> Left $ DiscoXmlError p e Right r -> Right r where queryBody = pickleElem xpQueryItems (node, []) diff --git a/source/Text/XML/Stream/Elements.hs b/source/Text/Xml/Stream/Elements.hs similarity index 97% rename from source/Text/XML/Stream/Elements.hs rename to source/Text/Xml/Stream/Elements.hs index e0156e5..a357607 100644 --- a/source/Text/XML/Stream/Elements.hs +++ b/source/Text/Xml/Stream/Elements.hs @@ -1,7 +1,7 @@ {-# OPTIONS_HADDOCK hide #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} -module Text.XML.Stream.Elements where +module Text.Xml.Stream.Elements where import Control.Applicative ((<$>)) import Control.Exception