|
|
|
@ -6,6 +6,7 @@ module Network.Xmpp.Concurrent.Types where |
|
|
|
import Control.Concurrent |
|
|
|
import Control.Concurrent |
|
|
|
import Control.Concurrent.STM |
|
|
|
import Control.Concurrent.STM |
|
|
|
import qualified Control.Exception.Lifted as Ex |
|
|
|
import qualified Control.Exception.Lifted as Ex |
|
|
|
|
|
|
|
import Control.Monad.Error |
|
|
|
import qualified Data.ByteString as BS |
|
|
|
import qualified Data.ByteString as BS |
|
|
|
import Data.Default |
|
|
|
import Data.Default |
|
|
|
import qualified Data.Map as Map |
|
|
|
import qualified Data.Map as Map |
|
|
|
@ -15,14 +16,20 @@ import Data.Typeable |
|
|
|
import Data.XML.Types (Element) |
|
|
|
import Data.XML.Types (Element) |
|
|
|
import Network |
|
|
|
import Network |
|
|
|
import Network.Xmpp.IM.Roster.Types |
|
|
|
import Network.Xmpp.IM.Roster.Types |
|
|
|
import Network.Xmpp.Types |
|
|
|
|
|
|
|
import Network.Xmpp.Sasl.Types |
|
|
|
import Network.Xmpp.Sasl.Types |
|
|
|
|
|
|
|
import Network.Xmpp.Types |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data Plugin = Plugin { inHandler :: StanzaHandler |
|
|
|
data Plugin' = Plugin' { inHandler :: Stanza -> IO [Stanza] |
|
|
|
, outHandler :: (Stanza -> IO Bool) -> Stanza -> IO Bool |
|
|
|
, outHandler :: Stanza -> IO Bool |
|
|
|
|
|
|
|
-- | In order to allow plugins to tie the knot (Plugin |
|
|
|
|
|
|
|
-- / Session) we pass the plugin the completed Session |
|
|
|
|
|
|
|
-- once it exists |
|
|
|
|
|
|
|
, onSessionUp :: Session -> IO () |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Plugin = (Stanza -> IO Bool) -> ErrorT XmppFailure IO Plugin' |
|
|
|
|
|
|
|
|
|
|
|
-- | Configuration for the @Session@ object. |
|
|
|
-- | Configuration for the @Session@ object. |
|
|
|
data SessionConfiguration = SessionConfiguration |
|
|
|
data SessionConfiguration = SessionConfiguration |
|
|
|
{ -- | Configuration for the @Stream@ object. |
|
|
|
{ -- | Configuration for the @Stream@ object. |
|
|
|
@ -80,6 +87,7 @@ data Session = Session |
|
|
|
, stopThreads :: IO () |
|
|
|
, stopThreads :: IO () |
|
|
|
, rosterRef :: TVar Roster |
|
|
|
, rosterRef :: TVar Roster |
|
|
|
, conf :: SessionConfiguration |
|
|
|
, conf :: SessionConfiguration |
|
|
|
|
|
|
|
, sendStanza' :: Stanza -> IO Bool |
|
|
|
, sRealm :: HostName |
|
|
|
, sRealm :: HostName |
|
|
|
, sSaslCredentials :: Maybe (ConnectionState -> [SaslHandler] , Maybe Text) |
|
|
|
, sSaslCredentials :: Maybe (ConnectionState -> [SaslHandler] , Maybe Text) |
|
|
|
, reconnectWait :: TVar Int |
|
|
|
, reconnectWait :: TVar Int |
|
|
|
|