Browse Source

rename XmppConnectionState to ConnectionState

master
Philipp Balzarek 13 years ago
parent
commit
a057326c13
  1. 2
      source/Network/Xmpp/Basic.hs
  2. 2
      source/Network/Xmpp/Concurrent/Threads.hs
  3. 4
      source/Network/Xmpp/Connection.hs
  4. 2
      source/Network/Xmpp/Sasl.hs
  5. 4
      source/Network/Xmpp/Stream.hs
  6. 8
      source/Network/Xmpp/TLS.hs
  7. 12
      source/Network/Xmpp/Types.hs

2
source/Network/Xmpp/Basic.hs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
module Network.Xmpp.Basic
( Connection(..)
, XmppConnectionState(..)
, ConnectionState(..)
, connectTcp
, simpleConnect
, startTLS

2
source/Network/Xmpp/Concurrent/Threads.hs

@ -34,7 +34,7 @@ readWorker onStanza onConnectionClosed stateRef = @@ -34,7 +34,7 @@ readWorker onStanza onConnectionClosed stateRef =
s <- atomically $ do
con@(Connection con_) <- readTMVar stateRef
state <- sConnectionState <$> readTMVar con_
when (state == XmppConnectionClosed)
when (state == ConnectionClosed)
retry
return con
allowInterrupt

4
source/Network/Xmpp/Connection.hs

@ -127,7 +127,7 @@ xmppNoConnection = Connection_ @@ -127,7 +127,7 @@ xmppNoConnection = Connection_
}
, cEventSource = DCI.ResumableSource zeroSource (return ())
, sFeatures = SF Nothing [] []
, sConnectionState = XmppConnectionClosed
, sConnectionState = ConnectionClosed
, sHostname = Nothing
, sJid = Nothing
, sStreamLang = Nothing
@ -167,7 +167,7 @@ connectTcpRaw host port hostname = do @@ -167,7 +167,7 @@ connectTcpRaw host port hostname = do
{ cHand = hand
, cEventSource = eSource
, sFeatures = (SF Nothing [] [])
, sConnectionState = XmppConnectionPlain
, sConnectionState = ConnectionPlain
, sHostname = (Just hostname)
, sJid = Nothing
, sPreferredLang = Nothing -- TODO: Allow user to set

2
source/Network/Xmpp/Sasl.hs

@ -54,7 +54,7 @@ xmppSasl handlers = withConnection $ do @@ -54,7 +54,7 @@ xmppSasl handlers = withConnection $ do
(_name, handler):_ -> runErrorT $ do
cs <- gets sConnectionState
case cs of
XmppConnectionClosed -> throwError AuthConnectionError
ConnectionClosed -> throwError AuthConnectionError
_ -> do
r <- handler
_ <- ErrorT $ left AuthStreamError <$> restartStream

4
source/Network/Xmpp/Stream.hs

@ -67,9 +67,9 @@ startStream = runErrorT $ do @@ -67,9 +67,9 @@ startStream = runErrorT $ do
state <- get
-- Set the `to' attribute depending on the state of the connection.
let from = case sConnectionState state of
XmppConnectionPlain -> if sJidWhenPlain state
ConnectionPlain -> if sJidWhenPlain state
then sJid state else Nothing
XmppConnectionSecured -> sJid state
ConnectionSecured -> sJid state
case sHostname state of
Nothing -> throwError StreamConnectionError
Just hostname -> lift $ do

8
source/Network/Xmpp/TLS.hs

@ -93,9 +93,9 @@ startTLS params con = Ex.handle (return . Left . TLSError) @@ -93,9 +93,9 @@ startTLS params con = Ex.handle (return . Left . TLSError)
features <- lift $ gets sFeatures
state <- gets sConnectionState
case state of
XmppConnectionPlain -> return ()
XmppConnectionClosed -> throwError TLSNoConnection
XmppConnectionSecured -> throwError TLSConnectionSecured
ConnectionPlain -> return ()
ConnectionClosed -> throwError TLSNoConnection
ConnectionSecured -> throwError TLSConnectionSecured
con <- lift $ gets cHand
when (stls features == Nothing) $ throwError TLSNoServerSupport
lift $ pushElement starttlsE
@ -115,5 +115,5 @@ startTLS params con = Ex.handle (return . Left . TLSError) @@ -115,5 +115,5 @@ startTLS params con = Ex.handle (return . Left . TLSError)
}
lift $ modify ( \x -> x {cHand = newHand})
either (lift . Ex.throwIO) return =<< lift restartStream
modify (\s -> s{sConnectionState = XmppConnectionSecured})
modify (\s -> s{sConnectionState = ConnectionSecured})
return ()

12
source/Network/Xmpp/Types.hs

@ -37,7 +37,7 @@ module Network.Xmpp.Types @@ -37,7 +37,7 @@ module Network.Xmpp.Types
, withConnection
, withConnection'
, mkConnection
, XmppConnectionState(..)
, ConnectionState(..)
, XmppStreamError(..)
, langTag
, module Network.Xmpp.Jid
@ -740,10 +740,10 @@ data ServerFeatures = SF @@ -740,10 +740,10 @@ data ServerFeatures = SF
, other :: ![Element]
} deriving Show
data XmppConnectionState
= XmppConnectionClosed -- ^ No connection at this point.
| XmppConnectionPlain -- ^ Connection established, but not secured.
| XmppConnectionSecured -- ^ Connection established and secured via TLS.
data ConnectionState
= ConnectionClosed -- ^ No connection at this point.
| ConnectionPlain -- ^ Connection established, but not secured.
| ConnectionSecured -- ^ Connection established and secured via TLS.
deriving (Show, Eq, Typeable)
data HandleLike = Hand { cSend :: BS.ByteString -> IO Bool
@ -756,7 +756,7 @@ data HandleLike = Hand { cSend :: BS.ByteString -> IO Bool @@ -756,7 +756,7 @@ data HandleLike = Hand { cSend :: BS.ByteString -> IO Bool
}
data Connection_ = Connection_
{ sConnectionState :: !XmppConnectionState -- ^ State of
{ sConnectionState :: !ConnectionState -- ^ State of
-- connection
, cHand :: HandleLike
, cEventSource :: ResumableSource IO Event

Loading…
Cancel
Save