plugins XE0166, XEP-0234, XEP-0260, XEP-0261: renamed session key managing other peer's jid to "peer_jid" instead of "to_jid"
This commit is contained in:
parent
1a5f1bd144
commit
31c9e0d06e
4 changed files with 19 additions and 19 deletions
|
|
@ -115,7 +115,7 @@ class XEP_0166(object):
|
|||
def _buildJingleElt(self, client, session, action):
|
||||
iq_elt = client.IQ('set')
|
||||
iq_elt['from'] = client.jid.full()
|
||||
iq_elt['to'] = session['to_jid'].full()
|
||||
iq_elt['to'] = session['peer_jid'].full()
|
||||
jingle_elt = iq_elt.addElement("jingle", NS_JINGLE)
|
||||
jingle_elt["sid"] = session['id']
|
||||
jingle_elt['action'] = action
|
||||
|
|
@ -259,10 +259,10 @@ class XEP_0166(object):
|
|||
return iq_elt, context_elt
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def initiate(self, to_jid, contents, profile=C.PROF_KEY_NONE):
|
||||
def initiate(self, peer_jid, contents, profile=C.PROF_KEY_NONE):
|
||||
"""Send a session initiation request
|
||||
|
||||
@param to_jid(jid.JID): jid to establith session with
|
||||
@param peer_jid(jid.JID): jid to establith session with
|
||||
@param contents(list[dict]): list of contents to use:
|
||||
The dict must have the following keys:
|
||||
- app_ns(unicode): namespace of the application
|
||||
|
|
@ -285,7 +285,7 @@ class XEP_0166(object):
|
|||
'state': STATE_PENDING,
|
||||
'initiator': initiator,
|
||||
'role': XEP_0166.ROLE_INITIATOR,
|
||||
'to_jid': to_jid,
|
||||
'peer_jid': peer_jid,
|
||||
'started': time.time(),
|
||||
'contents': {}
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ class XEP_0166(object):
|
|||
def jingleRequestConfirmationDefault(self, action, session, content_name, desc_elt, profile):
|
||||
"""This method request confirmation for a jingle session"""
|
||||
log.debug(u"Using generic jingle confirmation method")
|
||||
return xml_tools.deferConfirm(self.host, _(CONFIRM_TXT).format(entity=session['to_jid'].full()), _('Confirm Jingle session'), profile=profile)
|
||||
return xml_tools.deferConfirm(self.host, _(CONFIRM_TXT).format(entity=session['peer_jid'].full()), _('Confirm Jingle session'), profile=profile)
|
||||
|
||||
## jingle events ##
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ class XEP_0166(object):
|
|||
self.sendError('bad-request', None, request, profile)
|
||||
return
|
||||
|
||||
to_jid = jid.JID(request['from'])
|
||||
peer_jid = jid.JID(request['from'])
|
||||
|
||||
# we get or create the session
|
||||
try:
|
||||
|
|
@ -413,13 +413,13 @@ class XEP_0166(object):
|
|||
except KeyError:
|
||||
session = client.jingle_sessions[sid] = {'id': sid,
|
||||
'state': STATE_PENDING,
|
||||
'initiator': to_jid,
|
||||
'initiator': peer_jid,
|
||||
'role': XEP_0166.ROLE_RESPONDER,
|
||||
'to_jid': to_jid,
|
||||
'peer_jid': peer_jid,
|
||||
'started': time.time(),
|
||||
}
|
||||
else:
|
||||
if session['to_jid'] != to_jid:
|
||||
if session['peer_jid'] != peer_jid:
|
||||
log.warning(u"sid conflict ({}), the jid doesn't match. Can be a collision, a hack attempt, or a bad sid generation".format(sid))
|
||||
self.sendError('service-unavailable', sid, request, profile)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ class XEP_0234(object):
|
|||
def getHandler(self, profile):
|
||||
return XEP_0234_handler()
|
||||
|
||||
def _fileJingleSend(self, to_jid, filepath, name="", file_desc="", profile=C.PROF_KEY_NONE):
|
||||
return self.fileJingleSend(jid.JID(to_jid), filepath, name or None, file_desc or None, profile)
|
||||
def _fileJingleSend(self, peer_jid, filepath, name="", file_desc="", profile=C.PROF_KEY_NONE):
|
||||
return self.fileJingleSend(jid.JID(peer_jid), filepath, name or None, file_desc or None, profile)
|
||||
|
||||
def fileJingleSend(self, to_jid, filepath, name=None, file_desc=None, profile=C.PROF_KEY_NONE):
|
||||
self._j.initiate(to_jid,
|
||||
def fileJingleSend(self, peer_jid, filepath, name=None, file_desc=None, profile=C.PROF_KEY_NONE):
|
||||
self._j.initiate(peer_jid,
|
||||
[{'app_ns': NS_JINGLE_FT,
|
||||
'senders': self._j.ROLE_INITIATOR,
|
||||
'app_kwargs': {'filepath': filepath,
|
||||
|
|
@ -93,7 +93,7 @@ class XEP_0234(object):
|
|||
application_data = content_data['application_data']
|
||||
file_data = application_data['file_data']
|
||||
d = xml_tools.deferDialog(self.host,
|
||||
_(CONFIRM).format(entity=session['to_jid'].full(), **file_data),
|
||||
_(CONFIRM).format(entity=session['peer_jid'].full(), **file_data),
|
||||
_(CONFIRM_TITLE),
|
||||
type_=C.XMLUI_DIALOG_FILE,
|
||||
options={C.XMLUI_DATA_FILETYPE: C.XMLUI_DATA_FILETYPE_DIR},
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class XEP_0260(object):
|
|||
content_data = session['contents'][content_name]
|
||||
transport_data = content_data['transport_data']
|
||||
sid = transport_data['sid'] = unicode(uuid.uuid4())
|
||||
session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(client.jid, session['to_jid'], sid)
|
||||
session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(client.jid, session['peer_jid'], sid)
|
||||
candidates = transport_data['candidates'] = yield self._s5b.getCandidates(profile)
|
||||
mode = 'tcp' # XXX: we only manage tcp for now
|
||||
transport_elt = self._buildCandidates(session, candidates, sid, session_hash, client, mode)
|
||||
|
|
@ -239,7 +239,7 @@ class XEP_0260(object):
|
|||
# and we give our candidates
|
||||
assert 'peer_candidates' not in transport_data
|
||||
sid = transport_data['sid'] = transport_elt['sid']
|
||||
session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(session['to_jid'], client.jid, sid)
|
||||
session_hash = transport_data['session_hash'] = self._s5b.getSessionHash(session['peer_jid'], client.jid, sid)
|
||||
peer_candidates = transport_data['peer_candidates'] = self._parseCandidates(transport_elt)
|
||||
file_obj = content_data['file_obj']
|
||||
stream_d = self._s5b.registerHash(session_hash, file_obj, profile)
|
||||
|
|
|
|||
|
|
@ -74,16 +74,16 @@ class XEP_0261(object):
|
|||
elif action == self._j.A_SESSION_INITIATE:
|
||||
transport_data['sid'] = transport_elt['sid']
|
||||
elif action in (self._j.A_START, self._j.A_PREPARE_RESPONDER):
|
||||
to_jid = session['to_jid']
|
||||
peer_jid = session['peer_jid']
|
||||
sid = transport_data['sid']
|
||||
file_obj = content_data['file_obj']
|
||||
args = [session, content_name, profile]
|
||||
if action == self._j.A_START:
|
||||
block_size = transport_data['block_size']
|
||||
d = self._ibb.startStream(file_obj, to_jid, sid, block_size, profile)
|
||||
d = self._ibb.startStream(file_obj, peer_jid, sid, block_size, profile)
|
||||
d.addErrback(self._streamEb, *args)
|
||||
else:
|
||||
d = self._ibb.createSession(file_obj, to_jid, sid, profile)
|
||||
d = self._ibb.createSession(file_obj, peer_jid, sid, profile)
|
||||
d.addCallbacks(self._streamCb, self._streamEb, args, None, args)
|
||||
else:
|
||||
log.warning(u"FIXME: unmanaged action {}".format(action))
|
||||
|
|
|
|||
Loading…
Reference in a new issue