You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

14 years ago
{-# LANGUAGE NoMonomorphismRestriction, OverloadedStrings #-}
module Network.XMPP
( module Network.XMPP.Bind
, module Network.XMPP.Concurrent
, module Network.XMPP.Monad
, module Network.XMPP.SASL
, module Network.XMPP.Session
, module Network.XMPP.Stream
, module Network.XMPP.TLS
, module Network.XMPP.Types
, connectXMPP
, sessionConnect
) where
14 years ago
import Data.Text as Text
14 years ago
import Network
import Network.XMPP.Bind
import Network.XMPP.Concurrent
import Network.XMPP.Monad
import Network.XMPP.SASL
import Network.XMPP.Session
import Network.XMPP.Stream
import Network.XMPP.TLS
import Network.XMPP.Types
14 years ago
import System.IO
14 years ago
--fromHandle :: Handle -> Text -> Text -> Maybe Text -> Text -> IO ((), XMPPState)
fromHandle :: Handle -> Text -> Text -> Maybe Text -> Text -> XMPPThread a
-> IO ((), XMPPState)
14 years ago
fromHandle handle hostname username rsrc password a =
xmppFromHandle handle hostname username rsrc $ do
14 years ago
xmppStartStream
-- this will check whether the server supports tls
-- on it's own
xmppStartTLS exampleParams
xmppSASL password
14 years ago
xmppBind rsrc
14 years ago
xmppSession
14 years ago
_ <- runThreaded a
return ()
14 years ago
connectXMPP :: HostName -> Text -> Text -> Maybe Text
-> Text -> XMPPThread a -> IO ((), XMPPState)
14 years ago
connectXMPP host hostname username rsrc passwd a = do
14 years ago
con <- connectTo host (PortNumber 5222)
hSetBuffering con NoBuffering
14 years ago
fromHandle con hostname username rsrc passwd a
sessionConnect :: HostName -> Text -> Text
-> Maybe Text -> XMPPThread a -> IO (a, XMPPState)
14 years ago
sessionConnect host hostname username rsrc a = do
con <- connectTo host (PortNumber 5222)
hSetBuffering con NoBuffering
14 years ago
xmppFromHandle con hostname username rsrc $
xmppStartStream >> runThreaded a