~singpolyma/network-protocol-xmpp

f5a270b357a76bbbdab6f5bdf4e6c69aad371240 — John Millikin 15 years ago 8f95c73
Change JIDs to be unformatted when shown -- turns out using show for formatting was a dumb idea, because it would typecheck even if the value was no longer a JID.
M Network/Protocol/XMPP/Client.hs => Network/Protocol/XMPP/Client.hs +2 -2
@@ 33,7 33,7 @@ import qualified Text.XML.HXT.Arrow as A
import Text.XML.HXT.DOM.TypeDefs (XmlTree)
import qualified Text.XML.HXT.DOM.XmlNode as XN

import Network.Protocol.XMPP.JID (JID, jidParse)
import Network.Protocol.XMPP.JID (JID, jidParse, jidFormat)
import Network.Protocol.XMPP.SASL (Mechanism, bestMechanism)
import qualified Network.Protocol.XMPP.Stream as S
import Network.Protocol.XMPP.Util (mkElement, mkQName)


@@ 63,7 63,7 @@ clientAuthenticate (ConnectedClient serverJID stream) jid username password = do
		Just m -> m
	
	-- TODO: use detected mechanism
	let saslText = concat [(show jid), "\x00", username, "\x00", password]
	let saslText = concat [(jidFormat jid), "\x00", username, "\x00", password]
	let b64Text = encode saslText
	
	S.putTree stream $ mkElement ("", "auth")

M Network/Protocol/XMPP/JID.hs => Network/Protocol/XMPP/JID.hs +1 -4
@@ 33,10 33,7 @@ module Network.Protocol.XMPP.JID (
	) where

data JID = JID (Maybe JIDNode) JIDDomain (Maybe JIDResource)
	deriving (Eq)

instance Show JID where
	show = jidFormat
	deriving (Eq, Show)

newtype JIDNode = JIDNode String
	deriving (Eq, Show)

M Network/Protocol/XMPP/Stream.hs => Network/Protocol/XMPP/Stream.hs +2 -2
@@ 48,7 48,7 @@ import qualified Network.GnuTLS as GnuTLS
import Foreign (allocaBytes)
import Foreign.C (peekCAStringLen)

import Network.Protocol.XMPP.JID (JID)
import Network.Protocol.XMPP.JID (JID, jidFormat)
import Network.Protocol.XMPP.SASL (Mechanism, findMechanism)
import qualified Network.Protocol.XMPP.Util as Util



@@ 116,7 116,7 @@ beginStream' jid h = do
	let xmlHeader =
		"<?xml version='1.0'?>\n" ++
		"<stream:stream xmlns='jabber:client'" ++
		" to='" ++ (DOM.attrEscapeXml . show) jid ++ "'" ++
		" to='" ++ (DOM.attrEscapeXml . jidFormat) jid ++ "'" ++
		" version='1.0'" ++
		" xmlns:stream='http://etherx.jabber.org/streams'>"