coding standards
This commit is contained in:
parent
69544d5f5c
commit
8bbca8a0a7
|
@ -78,11 +78,11 @@ class ConnectionJingle(object):
|
||||||
"""
|
"""
|
||||||
# get data
|
# get data
|
||||||
jid = helpers.get_full_jid_from_iq(stanza)
|
jid = helpers.get_full_jid_from_iq(stanza)
|
||||||
id = stanza.getID()
|
id_ = stanza.getID()
|
||||||
|
|
||||||
if (jid, id) in self.__iq_responses.keys():
|
if (jid, id_) in self.__iq_responses.keys():
|
||||||
self.__iq_responses[(jid, id)].on_stanza(stanza)
|
self.__iq_responses[(jid, id_)].on_stanza(stanza)
|
||||||
del self.__iq_responses[(jid, id)]
|
del self.__iq_responses[(jid, id_)]
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
jingle = stanza.getTag('jingle')
|
jingle = stanza.getTag('jingle')
|
||||||
|
@ -93,7 +93,7 @@ class ConnectionJingle(object):
|
||||||
else:
|
else:
|
||||||
sid = None
|
sid = None
|
||||||
for sesn in self._sessions.values():
|
for sesn in self._sessions.values():
|
||||||
if id in sesn.iq_ids:
|
if id_ in sesn.iq_ids:
|
||||||
sesn.on_stanza(stanza)
|
sesn.on_stanza(stanza)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -101,14 +101,15 @@ class ConnectionJingle(object):
|
||||||
if sid not in self._sessions:
|
if sid not in self._sessions:
|
||||||
#TODO: tie-breaking and other things...
|
#TODO: tie-breaking and other things...
|
||||||
newjingle = JingleSession(con=self, weinitiate=False, jid=jid,
|
newjingle = JingleSession(con=self, weinitiate=False, jid=jid,
|
||||||
iq_id=id, sid=sid)
|
iq_id=id_, sid=sid)
|
||||||
self._sessions[sid] = newjingle
|
self._sessions[sid] = newjingle
|
||||||
|
|
||||||
# we already have such session in dispatcher...
|
# we already have such session in dispatcher...
|
||||||
self._sessions[sid].collect_iq_id(id)
|
self._sessions[sid].collect_iq_id(id_)
|
||||||
self._sessions[sid].on_stanza(stanza)
|
self._sessions[sid].on_stanza(stanza)
|
||||||
# Delete invalid/unneeded sessions
|
# Delete invalid/unneeded sessions
|
||||||
if sid in self._sessions and self._sessions[sid].state == JingleStates.ended:
|
if sid in self._sessions and \
|
||||||
|
self._sessions[sid].state == JingleStates.ended:
|
||||||
self.delete_jingle_session(sid)
|
self.delete_jingle_session(sid)
|
||||||
|
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
@ -142,7 +143,7 @@ class ConnectionJingle(object):
|
||||||
def start_file_transfer(self, jid, file_props):
|
def start_file_transfer(self, jid, file_props):
|
||||||
logger.info("start file transfer with file: %s" % file_props)
|
logger.info("start file transfer with file: %s" % file_props)
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(self.name,
|
contact = gajim.contacts.get_contact_with_highest_priority(self.name,
|
||||||
gajim.get_jid_without_resource(jid))
|
gajim.get_jid_without_resource(jid))
|
||||||
if contact is None:
|
if contact is None:
|
||||||
return
|
return
|
||||||
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
|
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
|
||||||
|
@ -150,25 +151,26 @@ class ConnectionJingle(object):
|
||||||
self._sessions[jingle.sid] = jingle
|
self._sessions[jingle.sid] = jingle
|
||||||
file_props['sid'] = jingle.sid
|
file_props['sid'] = jingle.sid
|
||||||
c = JingleFileTransfer(jingle, file_props=file_props,
|
c = JingleFileTransfer(jingle, file_props=file_props,
|
||||||
use_security=use_security)
|
use_security=use_security)
|
||||||
jingle.add_content('file' + helpers.get_random_string_16(), c)
|
jingle.add_content('file' + helpers.get_random_string_16(), c)
|
||||||
jingle.start_session()
|
jingle.start_session()
|
||||||
return c.transport.sid
|
return c.transport.sid
|
||||||
|
|
||||||
|
|
||||||
def iter_jingle_sessions(self, jid, sid=None, media=None):
|
def iter_jingle_sessions(self, jid, sid=None, media=None):
|
||||||
if sid:
|
if sid:
|
||||||
return (session for session in self._sessions.values() if session.sid == sid)
|
return (session for session in self._sessions.values() if \
|
||||||
sessions = (session for session in self._sessions.values() if session.peerjid == jid)
|
session.sid == sid)
|
||||||
|
sessions = (session for session in self._sessions.values() if \
|
||||||
|
session.peerjid == jid)
|
||||||
if media:
|
if media:
|
||||||
if media not in ('audio', 'video', 'file'):
|
if media not in ('audio', 'video', 'file'):
|
||||||
return tuple()
|
return tuple()
|
||||||
else:
|
else:
|
||||||
return (session for session in sessions if session.get_content(media))
|
return (session for session in sessions if \
|
||||||
|
session.get_content(media))
|
||||||
else:
|
else:
|
||||||
return sessions
|
return sessions
|
||||||
|
|
||||||
|
|
||||||
def get_jingle_session(self, jid, sid=None, media=None):
|
def get_jingle_session(self, jid, sid=None, media=None):
|
||||||
if sid:
|
if sid:
|
||||||
if sid in self._sessions:
|
if sid in self._sessions:
|
||||||
|
|
Loading…
Reference in New Issue