diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index 14c9080fd6789347c7adbc29816ec12d6fbcbdb6..3ddf45eac175039f35935ad7d47f8fab407ccde5 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 dd7486ae26b55c34c37a77bb6494eafa273d047f..6af6d16372932867552c15f17b23996252d71ad6 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'):