decline jingleFT correctly

This commit is contained in:
Jefry Lagrange 2012-03-19 15:52:33 -04:00
parent c9fa13e458
commit c412a6a55f
2 changed files with 12 additions and 1 deletions

View File

@ -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:

View File

@ -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'):