From 3656666553aabb3e338ed9ca35630b3f1c769899 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 14 Dec 2021 20:06:40 -0500 Subject: [PATCH] Update to work with network 3.0 --- lib/Network/Protocol/XMPP/Client.hs | 3 +-- lib/Network/Protocol/XMPP/Component.hs | 3 +-- lib/Network/Protocol/XMPP/Connections.hs | 12 ++++++++++-- network-protocol-xmpp.cabal | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Network/Protocol/XMPP/Client.hs b/lib/Network/Protocol/XMPP/Client.hs index e5f66a7..b7b28a8 100644 --- a/lib/Network/Protocol/XMPP/Client.hs +++ b/lib/Network/Protocol/XMPP/Client.hs @@ -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 diff --git a/lib/Network/Protocol/XMPP/Component.hs b/lib/Network/Protocol/XMPP/Component.hs index 4b7d71e..abe969f 100644 --- a/lib/Network/Protocol/XMPP/Component.hs +++ b/lib/Network/Protocol/XMPP/Component.hs @@ -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 diff --git a/lib/Network/Protocol/XMPP/Connections.hs b/lib/Network/Protocol/XMPP/Connections.hs index c380266..9ee9ded 100644 --- a/lib/Network/Protocol/XMPP/Connections.hs +++ b/lib/Network/Protocol/XMPP/Connections.hs @@ -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 diff --git a/network-protocol-xmpp.cabal b/network-protocol-xmpp.cabal index 0bb6b97..35266ba 100644 --- a/network-protocol-xmpp.cabal +++ b/network-protocol-xmpp.cabal @@ -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 -- 2.45.2