|
|
|
@ -104,10 +104,11 @@ startStream = runErrorT $ do |
|
|
|
stream <- liftIO $ mkStream state |
|
|
|
stream <- liftIO $ mkStream state |
|
|
|
-- Set the `from' (which is also the expected to) attribute depending on the |
|
|
|
-- Set the `from' (which is also the expected to) attribute depending on the |
|
|
|
-- state of the stream. |
|
|
|
-- state of the stream. |
|
|
|
let expectedTo = case streamState state of |
|
|
|
let expectedTo = case (streamState state, toJid $ streamConfiguration state) of |
|
|
|
Plain -> if includeJidWhenPlain state |
|
|
|
(Plain, (Just (jid, True))) -> Just jid |
|
|
|
then toJid state else Nothing |
|
|
|
(Secured, (Just (jid, _))) -> Just jid |
|
|
|
Secured -> toJid state |
|
|
|
(Plain, Nothing) -> Nothing |
|
|
|
|
|
|
|
(Secured, Nothing) -> Nothing |
|
|
|
case streamHostname state of |
|
|
|
case streamHostname state of |
|
|
|
Nothing -> throwError XmppOtherFailure -- TODO: When does this happen? |
|
|
|
Nothing -> throwError XmppOtherFailure -- TODO: When does this happen? |
|
|
|
Just hostname -> lift $ do |
|
|
|
Just hostname -> lift $ do |
|
|
|
@ -117,7 +118,7 @@ startStream = runErrorT $ do |
|
|
|
, expectedTo |
|
|
|
, expectedTo |
|
|
|
, Just (Jid Nothing hostname Nothing) |
|
|
|
, Just (Jid Nothing hostname Nothing) |
|
|
|
, Nothing |
|
|
|
, Nothing |
|
|
|
, preferredLang state |
|
|
|
, preferredLang $ streamConfiguration state |
|
|
|
) |
|
|
|
) |
|
|
|
response <- ErrorT $ runEventsSink $ runErrorT $ streamS expectedTo |
|
|
|
response <- ErrorT $ runEventsSink $ runErrorT $ streamS expectedTo |
|
|
|
case response of |
|
|
|
case response of |
|
|
|
@ -243,9 +244,9 @@ 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 |
|
|
|
-- host name, port, and realm. |
|
|
|
-- host name, port, and realm. |
|
|
|
openStream :: HostName -> PortID -> Text -> IO (Either XmppFailure (TMVar Stream)) |
|
|
|
openStream :: HostName -> PortID -> Text -> StreamConfiguration -> IO (Either XmppFailure (TMVar Stream)) |
|
|
|
openStream address port hostname = do |
|
|
|
openStream address port hostname config = do |
|
|
|
stream <- connectTcp address port hostname |
|
|
|
stream <- connectTcp address port hostname config |
|
|
|
case stream of |
|
|
|
case stream of |
|
|
|
Right stream' -> do |
|
|
|
Right stream' -> do |
|
|
|
result <- withStream startStream stream' |
|
|
|
result <- withStream startStream stream' |
|
|
|
@ -389,16 +390,14 @@ xmppNoStream = Stream { |
|
|
|
, streamId = Nothing |
|
|
|
, streamId = Nothing |
|
|
|
, streamLang = Nothing |
|
|
|
, streamLang = Nothing |
|
|
|
, streamJid = Nothing |
|
|
|
, streamJid = Nothing |
|
|
|
, preferredLang = Nothing |
|
|
|
, streamConfiguration = StreamConfiguration Nothing Nothing |
|
|
|
, toJid = Nothing |
|
|
|
|
|
|
|
, includeJidWhenPlain = False |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
where |
|
|
|
where |
|
|
|
zeroSource :: Source IO output |
|
|
|
zeroSource :: Source IO output |
|
|
|
zeroSource = liftIO . ExL.throwIO $ XmppOtherFailure |
|
|
|
zeroSource = liftIO . ExL.throwIO $ XmppOtherFailure |
|
|
|
|
|
|
|
|
|
|
|
connectTcp :: HostName -> PortID -> Text -> IO (Either XmppFailure (TMVar Stream)) |
|
|
|
connectTcp :: HostName -> PortID -> Text -> StreamConfiguration -> IO (Either XmppFailure (TMVar Stream)) |
|
|
|
connectTcp host port hostname = do |
|
|
|
connectTcp host port hostname config = do |
|
|
|
let PortNumber portNumber = port |
|
|
|
let PortNumber portNumber = port |
|
|
|
debugM "Pontarius.Xmpp" $ "Connecting to " ++ host ++ " on port " ++ |
|
|
|
debugM "Pontarius.Xmpp" $ "Connecting to " ++ host ++ " on port " ++ |
|
|
|
(show portNumber) ++ " through the realm " ++ (T.unpack hostname) ++ "." |
|
|
|
(show portNumber) ++ " through the realm " ++ (T.unpack hostname) ++ "." |
|
|
|
@ -434,9 +433,7 @@ connectTcp host port hostname = do |
|
|
|
, streamId = Nothing |
|
|
|
, streamId = Nothing |
|
|
|
, streamLang = Nothing |
|
|
|
, streamLang = Nothing |
|
|
|
, streamJid = Nothing |
|
|
|
, streamJid = Nothing |
|
|
|
, preferredLang = Nothing -- TODO: Allow user to set |
|
|
|
, streamConfiguration = config |
|
|
|
, toJid = Nothing -- TODO: Allow user to set |
|
|
|
|
|
|
|
, includeJidWhenPlain = False -- TODO: Allow user to set |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
stream' <- mkStream stream |
|
|
|
stream' <- mkStream stream |
|
|
|
return $ Right stream' |
|
|
|
return $ Right stream' |
|
|
|
|