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.
|
|
|
|
{-# LANGUAGE NoMonomorphismRestriction, OverloadedStrings #-}
|
|
|
|
|
module Network.XMPPConduit where
|
|
|
|
|
|
|
|
|
|
import Control.Monad
|
|
|
|
|
import Control.Monad.Trans
|
|
|
|
|
import Control.Monad.Trans.State
|
|
|
|
|
|
|
|
|
|
import qualified Data.ByteString as BS
|
|
|
|
|
import Data.Text as Text
|
|
|
|
|
|
|
|
|
|
import Network
|
|
|
|
|
import Network.XMPP.Monad
|
|
|
|
|
import Network.XMPP.TLS
|
|
|
|
|
import Network.XMPP.Stream
|
|
|
|
|
import Network.XMPP.SASL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import System.IO
|
|
|
|
|
|
|
|
|
|
fromHandle :: Handle -> Text -> Text -> Text -> IO ((), XMPPState)
|
|
|
|
|
fromHandle handle hostname username password =
|
|
|
|
|
xmppFromHandle handle hostname username "" $ do
|
|
|
|
|
xmppStartStream
|
|
|
|
|
-- this will check whether the server supports tls
|
|
|
|
|
-- on it's own
|
|
|
|
|
xmppStartTLS exampleParams
|
|
|
|
|
xmppSASL password
|
|
|
|
|
gets haveTLS >>= liftIO . print
|
|
|
|
|
forever $ pull >>= liftIO . print
|
|
|
|
|
return ()
|
|
|
|
|
|
|
|
|
|
main = do
|
|
|
|
|
con <- connectTo "localhost" (PortNumber 5222)
|
|
|
|
|
hSetBuffering con NoBuffering
|
|
|
|
|
(fs,st) <- fromHandle con "species64739.dyndns.org" "bot" "pwd"
|
|
|
|
|
print $ haveTLS st
|
|
|
|
|
putStrLn ""
|
|
|
|
|
hGetContents con >>= putStrLn
|
|
|
|
|
|