use NEC to handle error messages
This commit is contained in:
parent
3e2bfd67a3
commit
da524c94fd
|
@ -896,12 +896,15 @@ class ConnectionHandlersBase:
|
||||||
# keep track of sessions this connection has with other JIDs
|
# keep track of sessions this connection has with other JIDs
|
||||||
self.sessions = {}
|
self.sessions = {}
|
||||||
|
|
||||||
def _ErrorCB(self, con, iq_obj):
|
gajim.ged.register_event_handler('error-received', ged.CORE,
|
||||||
log.debug('ErrorCB')
|
self._nec_error_received)
|
||||||
id_ = unicode(iq_obj.getID())
|
|
||||||
if id_ in self.last_ids:
|
def _nec_error_received(self, obj):
|
||||||
|
if obj.conn.name != self.name:
|
||||||
|
return
|
||||||
|
if obj.id_ in self.last_ids:
|
||||||
gajim.nec.push_incoming_event(LastResultReceivedEvent(None,
|
gajim.nec.push_incoming_event(LastResultReceivedEvent(None,
|
||||||
conn=self, iq_obj=iq_obj))
|
conn=self, iq_obj=obj.iq_obj))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _LastResultCB(self, con, iq_obj):
|
def _LastResultCB(self, con, iq_obj):
|
||||||
|
@ -1103,6 +1106,8 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
gajim.nec.register_incoming_event(RosternotesReceivedEvent)
|
gajim.nec.register_incoming_event(RosternotesReceivedEvent)
|
||||||
gajim.ged.register_event_handler('roster-received', ged.CORE,
|
gajim.ged.register_event_handler('roster-received', ged.CORE,
|
||||||
self._nec_roster_received)
|
self._nec_roster_received)
|
||||||
|
gajim.ged.register_event_handler('error-received', ged.CORE,
|
||||||
|
self._nec_error_received)
|
||||||
|
|
||||||
def build_http_auth_answer(self, iq_obj, answer):
|
def build_http_auth_answer(self, iq_obj, answer):
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
|
@ -1133,21 +1138,20 @@ ConnectionJingle, ConnectionIBBytestream):
|
||||||
|
|
||||||
def _ErrorCB(self, con, iq_obj):
|
def _ErrorCB(self, con, iq_obj):
|
||||||
log.debug('ErrorCB')
|
log.debug('ErrorCB')
|
||||||
if ConnectionHandlersBase._ErrorCB(self, con, iq_obj):
|
gajim.nec.push_incoming_event(ErrorReceivedEvent(None, conn=self,
|
||||||
|
iq_obj=iq_obj))
|
||||||
|
|
||||||
|
def _nec_error_received(self, obj):
|
||||||
|
if obj.conn.name != self.name:
|
||||||
return
|
return
|
||||||
id_ = unicode(iq_obj.getID())
|
if obj.id_ in self.version_ids:
|
||||||
if id_ in self.version_ids:
|
|
||||||
gajim.nec.push_incoming_event(VersionResultReceivedEvent(None,
|
gajim.nec.push_incoming_event(VersionResultReceivedEvent(None,
|
||||||
conn=self, iq_obj=iq_obj))
|
conn=self, iq_obj=obj.iq_obj))
|
||||||
return
|
return True
|
||||||
if id_ in self.entity_time_ids:
|
if obj.id_ in self.entity_time_ids:
|
||||||
gajim.nec.push_incoming_event(LastResultReceivedEvent(None,
|
gajim.nec.push_incoming_event(TimeResultReceivedEvent(None,
|
||||||
conn=self, iq_obj=iq_obj))
|
conn=self, iq_obj=obj.iq_obj))
|
||||||
return
|
return True
|
||||||
jid_from = helpers.get_full_jid_from_iq(iq_obj)
|
|
||||||
errmsg = iq_obj.getErrorMsg()
|
|
||||||
errcode = iq_obj.getErrorCode()
|
|
||||||
self.dispatch('ERROR_ANSWER', (id_, jid_from, errmsg, errcode))
|
|
||||||
|
|
||||||
def _nec_private_storate_bookmarks_received(self, obj):
|
def _nec_private_storate_bookmarks_received(self, obj):
|
||||||
if obj.conn.name != self.name:
|
if obj.conn.name != self.name:
|
||||||
|
|
|
@ -547,3 +547,14 @@ class SearchResultReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
f[i.getName()] = i.getData()
|
f[i.getName()] = i.getData()
|
||||||
self.data.append(f)
|
self.data.append(f)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class ErrorReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
|
name = 'error-received'
|
||||||
|
base_network_events = []
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
self.get_id()
|
||||||
|
self.get_jid_resource()
|
||||||
|
self.errmsg = self.iq_obj.getErrorMsg()
|
||||||
|
self.errcode = self.iq_obj.getErrorCode()
|
||||||
|
return True
|
|
@ -167,41 +167,38 @@ class Interface:
|
||||||
'id': obj.iq_id}, sec_msg, on_response_yes=(on_yes, obj),
|
'id': obj.iq_id}, sec_msg, on_response_yes=(on_yes, obj),
|
||||||
on_response_no=(response, obj, 'no'))
|
on_response_no=(response, obj, 'no'))
|
||||||
|
|
||||||
def handle_event_error_answer(self, account, array):
|
def handle_event_error_answer(self, obj):
|
||||||
#('ERROR_ANSWER', account, (id, jid_from, errmsg, errcode))
|
#('ERROR_ANSWER', account, (id_, fjid, errmsg, errcode))
|
||||||
id_, jid_from, errmsg, errcode = array
|
if unicode(obj.errcode) in ('400', '403', '406') and obj.id_:
|
||||||
if unicode(errcode) in ('400', '403', '406') and id_:
|
|
||||||
# show the error dialog
|
# show the error dialog
|
||||||
ft = self.instances['file_transfers']
|
ft = self.instances['file_transfers']
|
||||||
sid = id_
|
sid = obj.id_
|
||||||
if len(id_) > 3 and id_[2] == '_':
|
if len(obj.id_) > 3 and obj.id_[2] == '_':
|
||||||
sid = id_[3:]
|
sid = obj.id_[3:]
|
||||||
if sid in ft.files_props['s']:
|
if sid in ft.files_props['s']:
|
||||||
file_props = ft.files_props['s'][sid]
|
file_props = ft.files_props['s'][sid]
|
||||||
if unicode(errcode) == '400':
|
if unicode(obj.errcode) == '400':
|
||||||
file_props['error'] = -3
|
file_props['error'] = -3
|
||||||
else:
|
else:
|
||||||
file_props['error'] = -4
|
file_props['error'] = -4
|
||||||
self.handle_event_file_request_error(account,
|
self.handle_event_file_request_error(obj.conn.name, (obj.fjid,
|
||||||
(jid_from, file_props, errmsg))
|
file_props, obj.errmsg))
|
||||||
conn = gajim.connections[account]
|
obj.conn.disconnect_transfer(file_props)
|
||||||
conn.disconnect_transfer(file_props)
|
|
||||||
return
|
return
|
||||||
elif unicode(errcode) == '404':
|
elif unicode(obj.errcode) == '404':
|
||||||
conn = gajim.connections[account]
|
sid = obj.id_
|
||||||
sid = id_
|
if len(obj.id_) > 3 and obj.id_[2] == '_':
|
||||||
if len(id_) > 3 and id_[2] == '_':
|
sid = obj.id_[3:]
|
||||||
sid = id_[3:]
|
if sid in obj.conn.files_props:
|
||||||
if sid in conn.files_props:
|
file_props = obj.conn.files_props[sid]
|
||||||
file_props = conn.files_props[sid]
|
self.handle_event_file_send_error(obj.conn.name, (obj.fjid,
|
||||||
self.handle_event_file_send_error(account,
|
file_props))
|
||||||
(jid_from, file_props))
|
obj.conn.disconnect_transfer(file_props)
|
||||||
conn.disconnect_transfer(file_props)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
ctrl = self.msg_win_mgr.get_control(jid_from, account)
|
ctrl = self.msg_win_mgr.get_control(obj.fjid, obj.conn.name)
|
||||||
if ctrl and ctrl.type_id == message_control.TYPE_GC:
|
if ctrl and ctrl.type_id == message_control.TYPE_GC:
|
||||||
ctrl.print_conversation('Error %s: %s' % (array[2], array[1]))
|
ctrl.print_conversation('Error %s: %s' % (obj.errcode, obj.errmsg))
|
||||||
|
|
||||||
def handle_event_con_type(self, account, con_type):
|
def handle_event_con_type(self, account, con_type):
|
||||||
# ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'plain'
|
# ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'plain'
|
||||||
|
@ -2069,7 +2066,6 @@ class Interface:
|
||||||
'ERROR': [self.handle_event_error],
|
'ERROR': [self.handle_event_error],
|
||||||
'DB_ERROR': [self.handle_event_db_error],
|
'DB_ERROR': [self.handle_event_db_error],
|
||||||
'INFORMATION': [self.handle_event_information],
|
'INFORMATION': [self.handle_event_information],
|
||||||
'ERROR_ANSWER': [self.handle_event_error_answer],
|
|
||||||
'STATUS': [self.handle_event_status],
|
'STATUS': [self.handle_event_status],
|
||||||
'NEW_JID': [self.handle_event_new_jid],
|
'NEW_JID': [self.handle_event_new_jid],
|
||||||
'NOTIFY': [self.handle_event_notify],
|
'NOTIFY': [self.handle_event_notify],
|
||||||
|
@ -2142,6 +2138,7 @@ class Interface:
|
||||||
'ARCHIVING_CHANGED': [self.handle_event_archiving_changed],
|
'ARCHIVING_CHANGED': [self.handle_event_archiving_changed],
|
||||||
'ARCHIVING_ERROR': [self.handle_event_archiving_error],
|
'ARCHIVING_ERROR': [self.handle_event_archiving_error],
|
||||||
'bookmarks-received': [self.handle_event_bookmarks],
|
'bookmarks-received': [self.handle_event_bookmarks],
|
||||||
|
'error-received': [self.handle_event_error_answer],
|
||||||
'gmail-notify': [self.handle_event_gmail_notify],
|
'gmail-notify': [self.handle_event_gmail_notify],
|
||||||
'http-auth-received': [self.handle_event_http_auth],
|
'http-auth-received': [self.handle_event_http_auth],
|
||||||
'last-result-received': [self.handle_event_last_status_time],
|
'last-result-received': [self.handle_event_last_status_time],
|
||||||
|
|
Loading…
Reference in New Issue