summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-07 17:09:32 +0200
committermathieui <mathieui@mathieui.net>2012-05-07 17:09:32 +0200
commit784e608f66e0b97d9f08c0b0072478865a560e70 (patch)
treee65acb4e8d7911563c4fbd7b427fa5ece2adf3d6 /src
parent0d21c1b74b7218a4f7a58cb0c42b89926c7b3583 (diff)
downloadpoezio-784e608f66e0b97d9f08c0b0072478865a560e70.tar.gz
poezio-784e608f66e0b97d9f08c0b0072478865a560e70.tar.bz2
poezio-784e608f66e0b97d9f08c0b0072478865a560e70.tar.xz
poezio-784e608f66e0b97d9f08c0b0072478865a560e70.zip
Fix the duplicate messages when talking to an offline gmail contact
Diffstat (limited to 'src')
-rw-r--r--src/core.py39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/core.py b/src/core.py
index 65bf6a35..6bea69aa 100644
--- a/src/core.py
+++ b/src/core.py
@@ -66,6 +66,27 @@ ERROR_AND_STATUS_CODES = {
'503': _('The maximum number of users has been reached'),
}
+# http://xmpp.org/extensions/xep-0086.html
+DEPRECATED_ERRORS = {
+ '302': _('Redirect'),
+ '400': _('Bad request'),
+ '401': _('Not authorized'),
+ '402': _('Payment required'),
+ '403': _('Forbidden'),
+ '404': _('Not found'),
+ '405': _('Not allowed'),
+ '406': _('Not acceptable'),
+ '407': _('Registration required'),
+ '408': _('Request timeout'),
+ '409': _('Conflict'),
+ '500': _('Internal server error'),
+ '501': _('Feature not implemented'),
+ '502': _('Remote server error'),
+ '503': _('Service unavailable'),
+ '504': _('Remote server timeout'),
+ '510': _('Disconnected'),
+}
+
possible_show = {'available':None,
'chat':'chat',
'away':'away',
@@ -843,9 +864,9 @@ class Core(object):
"""
jid = message['from']
body = xhtml.get_body_from_message_stanza(message)
+ if message['type'] == 'error':
+ return self.information(self.get_error_message_from_error_stanza(message, deprecated=True), 'Error')
if not body:
- if message['type'] == 'error':
- self.information(self.get_error_message_from_error_stanza(message), 'Error')
return
conversation = self.get_tab_of_conversation_with_jid(jid, create=True)
self.events.trigger('conversation_msg', message, conversation)
@@ -1198,7 +1219,7 @@ class Core(object):
self.current_tab().on_half_scroll_down()
self.refresh_window()
- def get_error_message_from_error_stanza(self, stanza):
+ def get_error_message_from_error_stanza(self, stanza, deprecated=False):
"""
Takes a stanza of the form <message type='error'><error/></message>
and return a well formed string containing the error informations
@@ -1209,10 +1230,16 @@ class Core(object):
code = stanza['error']['code']
body = stanza['error']['text']
if not body:
- if code in ERROR_AND_STATUS_CODES:
- body = ERROR_AND_STATUS_CODES[code]
+ if deprecated:
+ if code in DEPRECATED_ERRORS:
+ body = DEPRECATED_ERRORS[code]
+ else:
+ body = condition or _('Unknown error')
else:
- body = condition or _('Unknown error')
+ if code in ERROR_AND_STATUS_CODES:
+ body = ERROR_AND_STATUS_CODES[code]
+ else:
+ body = condition or _('Unknown error')
if code:
message = _('%(from)s: %(code)s - %(msg)s: %(body)s') % {'from':sender, 'msg':msg, 'body':body, 'code':code}
else: