From 2aab7710e18e1664b433d84778617b881c2a8782 Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Sat, 1 Jun 2013 17:42:54 +0200
Subject: [PATCH] move SessionConfiguration to Network.Xmpp.Concurrent.Types
---
source/Network/Xmpp/Concurrent/Types.hs | 29 ++++++++++++++++++++++++-
source/Network/Xmpp/Types.hs | 26 ----------------------
2 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/source/Network/Xmpp/Concurrent/Types.hs b/source/Network/Xmpp/Concurrent/Types.hs
index c2b97b8..9491b93 100644
--- a/source/Network/Xmpp/Concurrent/Types.hs
+++ b/source/Network/Xmpp/Concurrent/Types.hs
@@ -7,14 +7,41 @@ import Control.Concurrent
import Control.Concurrent.STM
import qualified Control.Exception.Lifted as Ex
import qualified Data.ByteString as BS
+import Data.Default
import qualified Data.Map as Map
import Data.Text (Text)
+import qualified Data.Text as Text
import Data.Typeable
import Data.XML.Types (Element)
-
import Network.Xmpp.IM.Roster.Types
import Network.Xmpp.Types
+
+-- | Configuration for the @Session@ object.
+data SessionConfiguration = SessionConfiguration
+ { -- | Configuration for the @Stream@ object.
+ sessionStreamConfiguration :: StreamConfiguration
+ -- | Handler to be run when the session ends (for whatever reason).
+ , onConnectionClosed :: XmppFailure -> IO ()
+ -- | Function to generate the stream of stanza identifiers.
+ , sessionStanzaIDs :: IO (IO StanzaID)
+ , extraStanzaHandlers :: [StanzaHandler]
+ , enableRoster :: Bool
+ }
+
+instance Default SessionConfiguration where
+ def = SessionConfiguration { sessionStreamConfiguration = def
+ , onConnectionClosed = \_ -> return ()
+ , sessionStanzaIDs = do
+ idRef <- newTVarIO 1
+ return . atomically $ do
+ curId <- readTVar idRef
+ writeTVar idRef (curId + 1 :: Integer)
+ return . StanzaID . Text.pack . show $ curId
+ , extraStanzaHandlers = []
+ , enableRoster = True
+ }
+
-- | Handlers to be run when the Xmpp session ends and when the Xmpp connection is
-- closed.
data EventHandlers = EventHandlers
diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs
index d93bb70..4817d0e 100644
--- a/source/Network/Xmpp/Types.hs
+++ b/source/Network/Xmpp/Types.hs
@@ -49,7 +49,6 @@ module Network.Xmpp.Types
, jidFromTexts
, StreamEnd(..)
, InvalidXmppXml(..)
- , SessionConfiguration(..)
, TlsBehaviour(..)
)
where
@@ -1088,31 +1087,6 @@ type StanzaHandler = TChan Stanza -- ^ outgoing stanza
-> Stanza -- ^ stanza to handle
-> IO Bool -- ^ True when processing should continue
--- | Configuration for the @Session@ object.
-data SessionConfiguration = SessionConfiguration
- { -- | Configuration for the @Stream@ object.
- sessionStreamConfiguration :: StreamConfiguration
- -- | Handler to be run when the session ends (for whatever reason).
- , sessionClosedHandler :: XmppFailure -> IO ()
- -- | Function to generate the stream of stanza identifiers.
- , sessionStanzaIDs :: IO (IO StanzaID)
- , extraStanzaHandlers :: [StanzaHandler]
- , enableRoster :: Bool
- }
-
-instance Default SessionConfiguration where
- def = SessionConfiguration { sessionStreamConfiguration = def
- , sessionClosedHandler = \_ -> return ()
- , sessionStanzaIDs = do
- idRef <- newTVarIO 1
- return . atomically $ do
- curId <- readTVar idRef
- writeTVar idRef (curId + 1 :: Integer)
- return . StanzaID . Text.pack . show $ curId
- , extraStanzaHandlers = []
- , enableRoster = True
- }
-
-- | How the client should behave in regards to TLS.
data TlsBehaviour = RequireTls -- ^ Require the use of TLS; disconnect if it's
-- not offered.