~singpolyma/jingle-xmpp

4a5f48c61812a6d81848af8cc91b7d0efdf3977a — Christopher Vollick 26 days ago 86b6938
Build JingleSID Higher Up

We have a newtype to wrap JingleSID, but we were only using it at the
bottom of the calltree, and propogating it all around as Text before
then. That's silly.

Now we build it at the top and use it everywhere.
1 files changed, 12 insertions(+), 12 deletions(-)

M Jingle.hs
M Jingle.hs => Jingle.hs +12 -12
@@ 29,8 29,8 @@ import qualified Jingle.Socks5Server as Socks5Server
import Util
import Jingle.StoreChunks

sessionAccept :: Text -> Text -> XMPP.JID -> XML.Element -> XML.Element
sessionAccept sid contentName responder transport =
sessionAccept :: JingleSID -> Text -> XMPP.JID -> XML.Element -> XML.Element
sessionAccept (JingleSID sid) contentName responder transport =
	XML.Element (s"{urn:xmpp:jingle:1}jingle") [
		(s"sid", [XML.ContentText sid]),
		(s"action", [s"session-accept"]),


@@ 64,8 64,8 @@ ibbTransport tsid =
		(s"sid", [XML.ContentText tsid])
	] []

ibbTransportAccept :: Text -> Text -> Text -> XMPP.JID -> XML.Element
ibbTransportAccept sid tsid contentName initiator =
ibbTransportAccept :: JingleSID -> Text -> Text -> XMPP.JID -> XML.Element
ibbTransportAccept (JingleSID sid) tsid contentName initiator =
	XML.Element (s"{urn:xmpp:jingle:1}jingle") [
		(s"sid", [XML.ContentText sid]),
		(s"action", [s"transport-accept"]),


@@ 85,8 85,8 @@ s5bCandidateError =
	(s"{urn:xmpp:jingle:transports:s5b:1}candidate-error")
	[] []

s5bCandidateErrorTI :: Text -> Text -> Text -> XMPP.JID -> XML.Element
s5bCandidateErrorTI sid tsid contentName initiator =
s5bCandidateErrorTI :: JingleSID -> Text -> Text -> XMPP.JID -> XML.Element
s5bCandidateErrorTI (JingleSID sid) tsid contentName initiator =
	XML.Element (s"{urn:xmpp:jingle:1}jingle") [
		(s"sid", [XML.ContentText sid]),
		(s"action", [s"transport-info"]),


@@ 118,7 118,7 @@ sessionInitiate ::
	-> (JingleTSID -> UIO ())
	-> (JingleTSID -> Int -> UIO ())
	-> XMPP.IQ
	-> Text
	-> JingleSID
	-> [XML.Element]
	-> Text
	-> Maybe Int


@@ 212,16 212,16 @@ jingleHandler' ::
	-> (JingleTSID -> Int -> UIO ())
	-> XMPP.IQ
	-> [XML.Element]
	-> Text
	-> JingleSID
	-> XMPP.XMPP ()
jingleHandler' hostPort newSession newTransport setSize iq@XMPP.IQ {
	XMPP.iqFrom = Just from
} children sid
	| jingleAction (s"session-initiate") iq,
	  (desc:_) <- fileTransferDescription `overChildrenOf` content = do
		liftIO $ UIO.run $ newSession (JingleSID sid) iq
		liftIO $ UIO.run $ newSession sid iq
		sessionInitiate hostPort
			(newTransport (JingleSID sid))
			(newTransport sid)
			setSize
			iq sid content contentName (fileSizeFromDescription desc)
	| jingleAction (s"transport-info") iq,


@@ 236,7 236,7 @@ jingleHandler' hostPort newSession newTransport setSize iq@XMPP.IQ {
	            (s"{urn:xmpp:jingle:transports:ibb:1}transport")
	            `overChildrenOf` content = do
		liftIO $ UIO.run $
			newTransport (JingleSID sid) (JingleTSID tsid)
			newTransport sid (JingleTSID tsid)
		XMPP.putStanza $ iqReply Nothing iq

		XMPP.putStanza $ iqNewRequest iq XMPP.IQSet


@@ 259,7 259,7 @@ jingleHandler ::
	-> XML.Element
	-> XMPP.XMPP ()
jingleHandler hostPort newSession newTransport setSize iq jingle
	| Just sid <- XML.attributeText (s"sid") jingle =
	| Just sid <- JingleSID <$> XML.attributeText (s"sid") jingle = do
		jingleHandler' hostPort newSession newTransport setSize
			iq (XML.elementChildren jingle) sid
	| otherwise = XMPP.putStanza $ iqError notImplemented iq