Browse Source

additional cleanups and documentation fixes

master
Philipp Balzarek 12 years ago
parent
commit
79c368c6eb
  1. 16
      source/Network/Xmpp.hs
  2. 16
      source/Network/Xmpp/Concurrent/Types.hs

16
source/Network/Xmpp.hs

@ -54,12 +54,14 @@ module Network.Xmpp
, StreamConfiguration(..) , StreamConfiguration(..)
, SessionConfiguration(..) , SessionConfiguration(..)
, ConnectionDetails(..) , ConnectionDetails(..)
, ConnectionState(..)
, closeConnection , closeConnection
, endSession , endSession
, waitForStream , waitForStream
-- ** Authentication handlers -- ** Authentication handlers
-- | The use of 'scramSha1' is /recommended/, but 'digestMd5' might be -- | The use of 'scramSha1' is /recommended/, but 'digestMd5' might be
-- useful for interaction with older implementations. -- useful for interaction with older implementations.
, SaslHandler
, AuthData , AuthData
, Username , Username
, Password , Password
@ -211,11 +213,19 @@ module Network.Xmpp
-- | Network.Xmpp doesn't re-export the accessors to avoid name -- | Network.Xmpp doesn't re-export the accessors to avoid name
-- clashes. To use them import Network.Xmpp.Lens -- clashes. To use them import Network.Xmpp.Lens
, module Network.Xmpp.Lens , module Network.Xmpp.Lens
-- * Miscellaneous -- * Plugins
-- Plugins modify incoming and outgoing stanzas. They can, for example, handle
-- encryption, compression or other protocol extensions.
, Annotated(..)
, Annotation(..)
, Plugin
, Plugin'(..)
-- * LangTag
, LangTag , LangTag
, langTagFromText , langTagFromText
, langTagToText , langTagToText
, parseLangTag , parseLangTag
-- * Miscellaneous
, XmppFailure(..) , XmppFailure(..)
, StreamErrorInfo(..) , StreamErrorInfo(..)
, StreamErrorCondition(..) , StreamErrorCondition(..)
@ -223,10 +233,6 @@ module Network.Xmpp
, AuthSaslFailure , AuthSaslFailure
, AuthIllegalCredentials , AuthIllegalCredentials
, AuthOtherFailure ) , AuthOtherFailure )
, SaslHandler
, Plugin
, Plugin'
, ConnectionState(..)
, connectTls , connectTls
, def , def
) where ) where

16
source/Network/Xmpp/Concurrent/Types.hs

@ -38,6 +38,10 @@ type Resource = Text
-- It is recommended to leave the resource up to the server -- It is recommended to leave the resource up to the server
type AuthData = Maybe (ConnectionState -> [SaslHandler] , Maybe Resource) type AuthData = Maybe (ConnectionState -> [SaslHandler] , Maybe Resource)
-- | Annotations are auxiliary data attached to received stanzas by 'Plugin's to
-- convey information regarding their operation. For example, a plugin for
-- encryption might attach information about whether a received stanza was
-- encrypted and which algorithm was used.
data Annotation = forall f.(Typeable f, Show f) => Annotation{fromAnnotation :: f} data Annotation = forall f.(Typeable f, Show f) => Annotation{fromAnnotation :: f}
instance Show Annotation where instance Show Annotation where
@ -49,17 +53,19 @@ type Annotated a = (a, [Annotation])
getAnnotation :: Typeable b => Annotated a -> Maybe b getAnnotation :: Typeable b => Annotated a -> Maybe b
getAnnotation = foldr (\(Annotation a) b -> maybe b Just $ cast a) Nothing . snd getAnnotation = foldr (\(Annotation a) b -> maybe b Just $ cast a) Nothing . snd
data Plugin' = Plugin' { inHandler :: Stanza data Plugin' = Plugin'
{ -- | Resulting stanzas and additional Annotations
inHandler :: Stanza
-> [Annotation] -> [Annotation]
-> IO [(Stanza, [Annotation])] -> IO [(Stanza, [Annotation])]
, outHandler :: Stanza -> IO (Either XmppFailure ()) , outHandler :: Stanza -> IO (Either XmppFailure ())
-- | In order to allow plugins to tie the knot (Plugin -- | In order to allow plugins to tie the knot (Plugin / Session) we pass
-- / Session) we pass the plugin the completed Session -- the plugin the completed Session once it exists
-- once it exists
, onSessionUp :: Session -> IO () , onSessionUp :: Session -> IO ()
} }
type Plugin = (Stanza -> IO (Either XmppFailure ())) type Plugin = (Stanza -> IO (Either XmppFailure ())) -- ^ pass stanza to next
-- plugin
-> ErrorT XmppFailure IO Plugin' -> ErrorT XmppFailure IO Plugin'
-- | Configuration for the @Session@ object. -- | Configuration for the @Session@ object.

Loading…
Cancel
Save