fix handling file transfer cancel properly

This commit is contained in:
Jefry Lagrange 2012-03-22 00:56:11 -04:00
parent c5ebac3f77
commit 48524a60c0
3 changed files with 9 additions and 4 deletions

View File

@ -149,6 +149,8 @@ class ConnectionJingle(object):
return
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
jingle = JingleSession(self, weinitiate=True, jid=jid)
# this is a file transfer
jingle.session_type_FT = True
self._sessions[jingle.sid] = jingle
file_props['sid'] = jingle.sid
if contact.supports(xmpp.NS_JINGLE_BYTESTREAM):

View File

@ -102,6 +102,8 @@ class JingleSession(object):
# file. Could be 'md5', 'sha-1', etc...
self.hash_algo = None
self.file_hash = None
# Tells whether this session is a file transfer or not
self.session_type_FT = False
# callbacks to call on proper contents
# use .prepend() to add new callbacks, especially when you're going
# to send error instead of ack
@ -585,9 +587,11 @@ class JingleSession(object):
else:
# TODO
text = reason
gajim.nec.push_incoming_event(JingleTransferCancelledEvent(None,
conn=self.connection, jingle_session=self, media=None,
reason=text))
if reason == 'cancel' and self.session_type_FT:
gajim.nec.push_incoming_event(JingleTransferCancelledEvent(None,
conn=self.connection, jingle_session=self, media=None,
reason=text))
def __broadcast_all(self, stanza, jingle, error, action):
"""

View File

@ -1166,7 +1166,6 @@ class Interface:
ft.show_stopped(obj.jid, file_props, 'Peer cancelled ' +
'the transfer')
obj.conn.delete_jingle_session(obj.sid)
def handle_event_jingle_incoming(self, obj):
# ('JINGLE_INCOMING', account, peer jid, sid, tuple-of-contents==(type,