~singpolyma/network-protocol-xmpp

6ac34f1c3cad5ed4db48987165aac04cea3c0142 — John Millikin 9 years ago 1ab0aa0
Misc stylistic cleanups
M Network/Protocol/XMPP.hs => Network/Protocol/XMPP.hs +8 -8
@@ 1,4 1,4 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,7 13,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.


module Network.Protocol.XMPP
	( 
	-- * JIDs


@@ 65,9 64,10 @@ module Network.Protocol.XMPP
	, getSession
	, runXMPP
	) where
import Network.Protocol.XMPP.Client
import Network.Protocol.XMPP.Component
import Network.Protocol.XMPP.Connections
import Network.Protocol.XMPP.JID
import Network.Protocol.XMPP.Monad
import Network.Protocol.XMPP.Stanza

import           Network.Protocol.XMPP.Client
import           Network.Protocol.XMPP.Component
import           Network.Protocol.XMPP.Connections
import           Network.Protocol.XMPP.JID
import           Network.Protocol.XMPP.Monad
import           Network.Protocol.XMPP.Stanza

M Network/Protocol/XMPP/Client.hs => Network/Protocol/XMPP/Client.hs +11 -9
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,17 15,17 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Client
	( runClient
	, bindJID
	) where
import Control.Monad ((>=>))
import Control.Monad.Error (throwError)
import Control.Monad.Trans (liftIO)
import Data.ByteString (ByteString)

import           Control.Monad ((>=>))
import           Control.Monad.Error (throwError)
import           Control.Monad.Trans (liftIO)
import           Data.ByteString (ByteString)
import qualified Data.Text.Lazy as T
import Network (connectTo)
import           Network (connectTo)
import qualified System.IO as IO

import qualified Network.Protocol.XMPP.Client.Authentication as A


@@ 33,8 35,8 @@ import qualified Network.Protocol.XMPP.Handle as H
import qualified Network.Protocol.XMPP.JID as J
import qualified Network.Protocol.XMPP.Monad as M
import qualified Network.Protocol.XMPP.XML as X
import Network.Protocol.XMPP.ErrorT
import Network.Protocol.XMPP.Stanza
import           Network.Protocol.XMPP.ErrorT
import           Network.Protocol.XMPP.Stanza

runClient :: C.Server
          -> J.JID -- ^ Client JID

M Network/Protocol/XMPP/Client/Authentication.hs => Network/Protocol/XMPP/Client/Authentication.hs +9 -7
@@ 1,4 1,7 @@
-- Copyright (C) 2009-2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable #-}

-- Copyright (C) 2009-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,26 16,25 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Network.Protocol.XMPP.Client.Authentication
	( Result (..)
	, authenticate
	) where

import qualified Control.Exception as Exc
import Control.Monad (when, (>=>))
import Control.Monad.IO.Class (MonadIO, liftIO)
import           Control.Monad (when, (>=>))
import           Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Control.Monad.Error as E
import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Data.Text.Lazy as TL
import Data.Typeable (Typeable)
import           Data.Typeable (Typeable)
import qualified Network.Protocol.SASL.GNU as SASL

import qualified Network.Protocol.XMPP.Monad as M
import qualified Network.Protocol.XMPP.XML as X
import Network.Protocol.XMPP.JID (JID, formatJID, jidResource)
import           Network.Protocol.XMPP.JID (JID, formatJID, jidResource)

data Result = Success | Failure
	deriving (Show, Eq)

M Network/Protocol/XMPP/Client/Features.hs => Network/Protocol/XMPP/Client/Features.hs +5 -3
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,13 15,13 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Client.Features
	( Feature (..)
	, parseFeatures
	, parseFeature
	) where
import Control.Arrow ((&&&))

import           Control.Arrow ((&&&))
import qualified Data.ByteString.Char8 as B
import qualified Data.Text.Lazy as TL
import qualified Network.Protocol.XMPP.XML as X

M Network/Protocol/XMPP/Component.hs => Network/Protocol/XMPP/Component.hs +11 -9
@@ 1,5 1,7 @@
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010 Stephan Maka <stephan@spaceboyz.net>
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 14,28 16,28 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Component
	( runComponent
	) where
import Control.Monad (when)
import Control.Monad.Error (throwError)
import Data.Bits (shiftR, (.&.))
import Data.Char (intToDigit)

import           Control.Monad (when)
import           Control.Monad.Error (throwError)
import           Data.Bits (shiftR, (.&.))
import           Data.Char (intToDigit)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Encoding as TE
import Network (connectTo)
import Network.Protocol.SASL.GNU (sha1)
import           Network (connectTo)
import           Network.Protocol.SASL.GNU (sha1)
import qualified System.IO as IO

import qualified Network.Protocol.XMPP.Connections as C
import qualified Network.Protocol.XMPP.Handle as H
import qualified Network.Protocol.XMPP.Monad as M
import qualified Network.Protocol.XMPP.XML as X
import Network.Protocol.XMPP.JID (JID)
import           Network.Protocol.XMPP.JID (JID)

runComponent :: C.Server
             -> T.Text -- ^ Server secret

M Network/Protocol/XMPP/Connections.hs => Network/Protocol/XMPP/Connections.hs +7 -5
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,20 15,20 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Connections
	( Server (..)
	, xmlHeader
	, startOfStream
	, qnameStream
	) where
import Network (HostName, PortID)

import           Network (HostName, PortID)
import qualified Data.ByteString.Lazy as B
import qualified Data.Text.Lazy as T
import Data.Text.Lazy.Encoding (encodeUtf8)
import           Data.Text.Lazy.Encoding (encodeUtf8)

import qualified Network.Protocol.XMPP.XML as X
import Network.Protocol.XMPP.JID (JID, formatJID)
import           Network.Protocol.XMPP.JID (JID, formatJID)

data Server = Server
	{ serverJID      :: JID

M Network/Protocol/XMPP/ErrorT.hs => Network/Protocol/XMPP/ErrorT.hs +7 -6
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE TypeFamilies #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,16 15,15 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE TypeFamilies #-}
module Network.Protocol.XMPP.ErrorT
	( ErrorT (..)
	, mapErrorT
	) where

import Control.Monad (liftM)
import Control.Monad.Fix (MonadFix, mfix)
import Control.Monad.Trans (MonadIO, liftIO)
import Control.Monad.Trans.Class (MonadTrans, lift)
import           Control.Monad (liftM)
import           Control.Monad.Fix (MonadFix, mfix)
import           Control.Monad.Trans (MonadIO, liftIO)
import           Control.Monad.Trans.Class (MonadTrans, lift)
import qualified Control.Monad.Error as E
import qualified Control.Monad.Reader as R


M Network/Protocol/XMPP/Handle.hs => Network/Protocol/XMPP/Handle.hs +6 -5
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,7 15,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Handle
	( Handle (..)
	, startTLS


@@ 21,14 22,14 @@ module Network.Protocol.XMPP.Handle
	, hGetBytes
	) where

import Control.Monad (when)
import           Control.Monad (when)
import qualified Control.Monad.Error as E
import Control.Monad.Trans (liftIO)
import           Control.Monad.Trans (liftIO)
import qualified Data.ByteString.Lazy as B
import qualified Data.Text.Lazy as T
import qualified System.IO as IO
import qualified Network.Protocol.TLS.GNU as TLS
import Network.Protocol.XMPP.ErrorT
import           Network.Protocol.XMPP.ErrorT

data Handle =
	  PlainHandle IO.Handle

M Network/Protocol/XMPP/JID.hs => Network/Protocol/XMPP/JID.hs +6 -4
@@ 1,4 1,7 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,8 16,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Network.Protocol.XMPP.JID
	( JID (..)
	, Node (..)


@@ 25,10 26,11 @@ module Network.Protocol.XMPP.JID
	, parseJID_
	, formatJID
	) where

import qualified Data.Text.Lazy as TL
import           Data.Text.Lazy (Text)
import qualified Data.Text.IDN.StringPrep as SP
import Data.String (IsString, fromString)
import           Data.String (IsString, fromString)

newtype Node = Node { strNode :: Text }
newtype Domain = Domain { strDomain :: Text }

M Network/Protocol/XMPP/Monad.hs => Network/Protocol/XMPP/Monad.hs +11 -9
@@ 1,4 1,7 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,8 16,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Monad
	( XMPP (..)
	, Error (..)


@@ 34,18 35,19 @@ module Network.Protocol.XMPP.Monad
	, putElement
	, putStanza
	) where

import qualified Control.Applicative as A
import qualified Control.Concurrent.MVar as M
import Control.Monad (ap)
import Control.Monad.Fix (MonadFix, mfix)
import Control.Monad.Trans (MonadIO, liftIO)
import           Control.Monad (ap)
import           Control.Monad.Fix (MonadFix, mfix)
import           Control.Monad.Trans (MonadIO, liftIO)
import qualified Control.Monad.Error as E
import qualified Control.Monad.Reader as R
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Text.Lazy (Text)
import Data.Text.Lazy.Encoding (encodeUtf8)
import           Data.Text.Lazy (Text)
import           Data.Text.Lazy.Encoding (encodeUtf8)

import Network.Protocol.XMPP.ErrorT
import           Network.Protocol.XMPP.ErrorT
import qualified Network.Protocol.XMPP.Handle as H
import qualified Network.Protocol.XMPP.Stanza as S
import qualified Network.Protocol.XMPP.XML as X

M Network/Protocol/XMPP/Stanza.hs => Network/Protocol/XMPP/Stanza.hs +5 -4
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,7 15,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.Stanza
	( Stanza (..)
	


@@ 32,10 33,10 @@ module Network.Protocol.XMPP.Stanza
	, elementToStanza
	) where

import Control.Monad (when)
import           Control.Monad (when)
import qualified Data.Text.Lazy as T
import qualified Network.Protocol.XMPP.XML as X
import Network.Protocol.XMPP.JID (JID, parseJID, formatJID)
import           Network.Protocol.XMPP.JID (JID, parseJID, formatJID)

class Stanza a where
	stanzaTo        :: a -> Maybe JID

M Network/Protocol/XMPP/XML.hs => Network/Protocol/XMPP/XML.hs +7 -5
@@ 1,4 1,6 @@
-- Copyright (C) 2010 John Millikin <jmillikin@gmail.com>
{-# LANGUAGE OverloadedStrings #-}

-- Copyright (C) 2010-2011 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by


@@ 13,7 15,6 @@
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

{-# LANGUAGE OverloadedStrings #-}
module Network.Protocol.XMPP.XML
	( Element(..)
	, Node(..)


@@ 48,12 49,13 @@ module Network.Protocol.XMPP.XML
	, eventsToElement
	
	) where
import Control.Monad (when)

import           Control.Monad (when)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.Text.Lazy as TL
import Data.XML.Types as X
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import           Data.XML.Types as X
import           Data.IORef (IORef, newIORef, readIORef, writeIORef)
import qualified Text.XML.LibXML.SAX as SAX

getattr :: Name -> Element -> Maybe TL.Text