[Jingle] refactor a bit and ignore non-critical errors. Fixes #5794
This commit is contained in:
parent
4d88aef9db
commit
c6dc1b8b20
1 changed files with 12 additions and 14 deletions
|
@ -318,14 +318,14 @@ class JingleSession(object):
|
||||||
def __on_error(self, stanza, jingle, error, action):
|
def __on_error(self, stanza, jingle, error, action):
|
||||||
# FIXME
|
# FIXME
|
||||||
text = error.getTagData('text')
|
text = error.getTagData('text')
|
||||||
jingle_error = None
|
error_name = None
|
||||||
xmpp_error = None
|
|
||||||
for child in error.getChildren():
|
for child in error.getChildren():
|
||||||
if child.getNamespace() == xmpp.NS_JINGLE_ERRORS:
|
if child.getNamespace() == xmpp.NS_JINGLE_ERRORS:
|
||||||
jingle_error = child.getName()
|
error_name = child.getName()
|
||||||
|
break
|
||||||
elif child.getNamespace() == xmpp.NS_STANZAS:
|
elif child.getNamespace() == xmpp.NS_STANZAS:
|
||||||
xmpp_error = child.getName()
|
error_name = child.getName()
|
||||||
self.__dispatch_error(xmpp_error, jingle_error, text)
|
self.__dispatch_error(error_name, text, error.getAttribute('type'))
|
||||||
# FIXME: Not sure when we would want to do that...
|
# FIXME: Not sure when we would want to do that...
|
||||||
|
|
||||||
def __on_transport_replace(self, stanza, jingle, error, action):
|
def __on_transport_replace(self, stanza, jingle, error, action):
|
||||||
|
@ -478,7 +478,7 @@ class JingleSession(object):
|
||||||
self.connection.delete_jingle_session(self.sid)
|
self.connection.delete_jingle_session(self.sid)
|
||||||
reason, text = self.__reason_from_stanza(jingle)
|
reason, text = self.__reason_from_stanza(jingle)
|
||||||
if reason not in ('success', 'cancel', 'decline'):
|
if reason not in ('success', 'cancel', 'decline'):
|
||||||
self.__dispatch_error(reason, reason, text)
|
self.__dispatch_error(reason, text)
|
||||||
if text:
|
if text:
|
||||||
text = '%s (%s)' % (reason, text)
|
text = '%s (%s)' % (reason, text)
|
||||||
else:
|
else:
|
||||||
|
@ -530,14 +530,12 @@ class JingleSession(object):
|
||||||
|
|
||||||
return (contents, contents_rejected, failure_reason)
|
return (contents, contents_rejected, failure_reason)
|
||||||
|
|
||||||
def __dispatch_error(self, error, jingle_error=None, text=None):
|
def __dispatch_error(self, error=None, text=None, type_=None):
|
||||||
if jingle_error:
|
|
||||||
error = jingle_error
|
|
||||||
if text:
|
if text:
|
||||||
text = '%s (%s)' % (error, text)
|
text = '%s (%s)' % (error, text)
|
||||||
else:
|
if type_ != 'modify':
|
||||||
text = error
|
self.connection.dispatch('JINGLE_ERROR',
|
||||||
self.connection.dispatch('JINGLE_ERROR', (self.peerjid, self.sid, text))
|
(self.peerjid, self.sid, text or error))
|
||||||
|
|
||||||
def __reason_from_stanza(self, stanza):
|
def __reason_from_stanza(self, stanza):
|
||||||
# TODO: Move to GUI?
|
# TODO: Move to GUI?
|
||||||
|
@ -579,7 +577,7 @@ class JingleSession(object):
|
||||||
if text:
|
if text:
|
||||||
err.setTagData('text', text)
|
err.setTagData('text', text)
|
||||||
self.connection.connection.send(err_stanza)
|
self.connection.connection.send(err_stanza)
|
||||||
self.__dispatch_error(error, jingle_error, text)
|
self.__dispatch_error(jingle_error or error, text, type_)
|
||||||
|
|
||||||
def __append_content(self, jingle, content):
|
def __append_content(self, jingle, content):
|
||||||
"""
|
"""
|
||||||
|
@ -630,7 +628,7 @@ class JingleSession(object):
|
||||||
# TODO: Move to GUI?
|
# TODO: Move to GUI?
|
||||||
reason, text = self.__reason_from_stanza(jingle)
|
reason, text = self.__reason_from_stanza(jingle)
|
||||||
if reason not in ('success', 'cancel', 'decline'):
|
if reason not in ('success', 'cancel', 'decline'):
|
||||||
self.__dispatch_error(reason, reason, text)
|
self.__dispatch_error(reason, text)
|
||||||
if text:
|
if text:
|
||||||
text = '%s (%s)' % (reason, text)
|
text = '%s (%s)' % (reason, text)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue