From c412a6a55f61293c772f32737d2d70c3aa4cf715 Mon Sep 17 00:00:00 2001 From: Jefry Lagrange Date: Mon, 19 Mar 2012 15:52:33 -0400 Subject: [PATCH] decline jingleFT correctly --- src/common/jingle_session.py | 9 ++++++++- src/common/protocol/bytestream.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index 14c9080fd..3ddf45eac 100644 --- a/src/common/jingle_session.py +++ b/src/common/jingle_session.py @@ -148,6 +148,14 @@ class JingleSession(object): reason = xmpp.Node('reason') reason.addChild('decline') self._session_terminate(reason) + + def cancel_session(self): + """ + Called when user declines session in UI (when we aren't the initiator) + """ + reason = xmpp.Node('reason') + reason.addChild('cancel') + self._session_terminate(reason) def approve_content(self, media, name=None): content = self.get_content(media, name) @@ -730,7 +738,6 @@ class JingleSession(object): self.__session_info(p) def _session_terminate(self, reason=None): - assert self.state != JingleStates.ended stanza, jingle = self.__make_jingle('session-terminate', reason=reason) self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent') if self.connection.connection and self.connection.connected >= 2: diff --git a/src/common/protocol/bytestream.py b/src/common/protocol/bytestream.py index dd7486ae2..6af6d1637 100644 --- a/src/common/protocol/bytestream.py +++ b/src/common/protocol/bytestream.py @@ -195,6 +195,10 @@ class ConnectionBytestream: # user response to ConfirmationDialog may come after we've disconneted if not self.connection or self.connected < 2: return + if file_props['session-type'] == 'jingle': + jingle = self._sessions[file_props['session-sid']] + jingle.cancel_session() + return iq = xmpp.Iq(to=unicode(file_props['sender']), typ='error') iq.setAttr('id', file_props['request-id']) if code == '400' and typ in ('stream', 'profile'):