Browse Source

add StreamConfiguration parameter to session and rename hardcodedTcpDetails to TcpDetails

master
Philipp Balzarek 13 years ago
parent
commit
f4a88fbbb8
  1. 1
      source/Network/Xmpp.hs
  2. 7
      source/Network/Xmpp/Concurrent.hs
  3. 12
      source/Network/Xmpp/Stream.hs
  4. 4
      source/Network/Xmpp/Types.hs

1
source/Network/Xmpp.hs

@ -27,6 +27,7 @@ module Network.Xmpp
( -- * Session management ( -- * Session management
Session Session
, session , session
, StreamConfiguration(..)
-- TODO: Close session, etc. -- TODO: Close session, etc.
-- ** Authentication handlers -- ** Authentication handlers
-- | The use of 'scramSha1' is /recommended/, but 'digestMd5' might be -- | The use of 'scramSha1' is /recommended/, but 'digestMd5' might be

7
source/Network/Xmpp/Concurrent.hs

@ -132,7 +132,8 @@ writeWorker stCh writeR = forever $ do
-- value, @session@ will attempt to secure the connection with TLS. If the fifth -- value, @session@ will attempt to secure the connection with TLS. If the fifth
-- parameters is a 'Just' value, @session@ will attempt to authenticate and -- parameters is a 'Just' value, @session@ will attempt to authenticate and
-- acquire an XMPP resource. -- acquire an XMPP resource.
session :: Text -- ^ The realm host name session :: Text -- ^ The hostname / realm
-> StreamConfiguration -- ^ configuration details
-> Maybe TLS.TLSParams -- ^ TLS settings, if securing the -> Maybe TLS.TLSParams -- ^ TLS settings, if securing the
-- connection to the server is -- connection to the server is
-- desired -- desired
@ -140,8 +141,8 @@ session :: Text -- ^ The realm host name
-- JID resource (or Nothing to let -- JID resource (or Nothing to let
-- the server decide) -- the server decide)
-> IO (Either XmppFailure (Session, Maybe AuthFailure)) -> IO (Either XmppFailure (Session, Maybe AuthFailure))
session realm mbTls mbSasl = runErrorT $ do session host config mbTls mbSasl = runErrorT $ do
con <- ErrorT $ openStream realm def con <- ErrorT $ openStream host config
case mbTls of case mbTls of
Nothing -> return () Nothing -> return ()
Just tls -> ErrorT $ startTls tls con Just tls -> ErrorT $ startTls tls con

12
source/Network/Xmpp/Stream.hs

@ -253,12 +253,14 @@ streamS expectedTo = do
-- | Connects to the XMPP server and opens the XMPP stream against the given -- | Connects to the XMPP server and opens the XMPP stream against the given
-- realm. -- realm.
openStream :: Text -> StreamConfiguration -> IO (Either XmppFailure (TMVar Stream)) openStream :: Text
openStream realm config = runErrorT $ do -> StreamConfiguration
(address, port) <- case hardcodedTcpDetails config of -> IO (Either XmppFailure (TMVar Stream))
Nothing -> dnsLookup realm (resolvConf config) openStream host config = runErrorT $ do
(address, port) <- case tcpDetails config of
Nothing -> dnsLookup host (resolvConf config)
Just (address, port) -> return (address, port) Just (address, port) -> return (address, port)
stream' <- connectTcp (Text.unpack address) port realm config stream' <- connectTcp (Text.unpack address) port host config
result <- liftIO $ withStream startStream stream' result <- liftIO $ withStream startStream stream'
return stream' return stream'

4
source/Network/Xmpp/Types.hs

@ -1024,7 +1024,7 @@ data StreamConfiguration =
-- | By specifying these details, Pontarius XMPP will -- | By specifying these details, Pontarius XMPP will
-- connect to the provided address and port, and will -- connect to the provided address and port, and will
-- not perform a DNS look-up -- not perform a DNS look-up
, hardcodedTcpDetails :: Maybe (Text, PortID) , tcpDetails :: Maybe (Text, PortID)
-- | DNS resolver configuration -- | DNS resolver configuration
, resolvConf :: ResolvConf , resolvConf :: ResolvConf
} }
@ -1033,6 +1033,6 @@ data StreamConfiguration =
instance Default StreamConfiguration where instance Default StreamConfiguration where
def = StreamConfiguration { preferredLang = Nothing def = StreamConfiguration { preferredLang = Nothing
, toJid = Nothing , toJid = Nothing
, hardcodedTcpDetails = Nothing , tcpDetails = Nothing
, resolvConf = defaultResolvConf , resolvConf = defaultResolvConf
} }

Loading…
Cancel
Save