~singpolyma/network-protocol-xmpp

3656666553aabb3e338ed9ca35630b3f1c769899 — Stephen Paul Weber 11 months ago 3f30f38
Update to work with network 3.0
M lib/Network/Protocol/XMPP/Client.hs => lib/Network/Protocol/XMPP/Client.hs +1 -2
@@ 23,7 23,6 @@ import           Control.Monad.Error (throwError)
import           Control.Monad.Trans (liftIO)
import           Data.ByteString (ByteString)
import           Data.Text (Text)
import           Network (connectTo)
import qualified System.IO as IO

import qualified Network.Protocol.XMPP.Client.Authentication as A


@@ 46,7 45,7 @@ runClient :: C.Server
runClient server jid username password xmpp = do
	-- Open a TCP connection
	let C.Server sjid host port = server
	rawHandle <- connectTo host port
	rawHandle <- C.connectTo host port
	IO.hSetBuffering rawHandle IO.NoBuffering
	let handle = H.PlainHandle rawHandle


M lib/Network/Protocol/XMPP/Component.hs => lib/Network/Protocol/XMPP/Component.hs +1 -2
@@ 28,7 28,6 @@ import           Data.ByteString (ByteString)
import qualified Data.Text
import           Data.Text (Text)
import           Data.Text.Encoding (encodeUtf8)
import           Network (connectTo)
import           Network.Protocol.SASL.GNU (sha1)
import qualified System.IO as IO



@@ 45,7 44,7 @@ runComponent :: C.Server
             -> IO (Either M.Error a)
runComponent server password xmpp = do
	let C.Server jid host port = server
	rawHandle <- connectTo host port
	rawHandle <- C.connectTo host port
	IO.hSetBuffering rawHandle IO.NoBuffering
	let handle = H.PlainHandle rawHandle
	M.startXMPP handle (s"jabber:component:accept") $ do

M lib/Network/Protocol/XMPP/Connections.hs => lib/Network/Protocol/XMPP/Connections.hs +10 -2
@@ 18,22 18,30 @@ module Network.Protocol.XMPP.Connections
	, xmlHeader
	, startOfStream
	, qnameStream
	, connectTo
	) where

import           Network (HostName, PortID)
import           Network.Socket (HostName, PortNumber, socketToHandle)
import           Network.Simple.TCP (connectSock)
import           Data.ByteString (ByteString)
import qualified Data.Text
import           Data.Text (Text)
import           Data.Text.Encoding (encodeUtf8)
import qualified System.IO as IO

import qualified Network.Protocol.XMPP.XML as X
import           Network.Protocol.XMPP.JID (JID, formatJID)
import           Network.Protocol.XMPP.String (s)

connectTo :: HostName -> PortNumber -> IO IO.Handle
connectTo host port =
	(`socketToHandle` IO.ReadWriteMode) =<<
	(fst <$> connectSock host (show port))

data Server = Server
	{ serverJID      :: JID
	, serverHostname :: HostName
	, serverPort     :: PortID
	, serverPort     :: PortNumber
	}

-- Since only the opening tag should be written, normal XML

M network-protocol-xmpp.cabal => network-protocol-xmpp.cabal +2 -1
@@ 36,7 36,8 @@ library
    , gsasl >= 0.3 && < 0.4
    , libxml-sax >= 0.7 && < 0.8
    , monads-tf >= 0.1 && < 0.2
    , network >= 2.2 && < 3.0.0.0
    , network >= 3.0 && < 4.0
    , network-simple >= 0.4 && < 0.5
    , text >= 0.10
    , transformers >= 0.2
    , xml-types >= 0.3 && < 0.4