handle ERROR and INFORMATION events through NEC
This commit is contained in:
parent
ae6ffa2a18
commit
2582720366
|
@ -256,9 +256,10 @@ class CommonConnection:
|
|||
try:
|
||||
jid = self.check_jid(jid)
|
||||
except helpers.InvalidFormat:
|
||||
self.dispatch('ERROR', (_('Invalid Jabber ID'),
|
||||
_('It is not possible to send a message to %s, this JID is not '
|
||||
'valid.') % jid))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Invalid Jabber ID'), sec_txt=_(
|
||||
'It is not possible to send a message to %s, this JID is not '
|
||||
'valid.') % jid))
|
||||
return
|
||||
|
||||
if msg and not xhtml and gajim.config.get(
|
||||
|
@ -912,9 +913,10 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.disconnect(on_purpose=True)
|
||||
return
|
||||
if not data[1]: # wrong answer
|
||||
self.dispatch('ERROR', (_('Invalid answer'),
|
||||
_('Transport %(name)s answered wrongly to register '
|
||||
'request: %(error)s') % {'name': data[0],
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self, level='error', pri_txt=_('Invalid answer'),
|
||||
sec_txt=_('Transport %(name)s answered wrongly to '
|
||||
'register request: %(error)s') % {'name': data[0],
|
||||
'error': data[3]}))
|
||||
return
|
||||
is_form = data[2]
|
||||
|
@ -1195,7 +1197,9 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
key = common.xmpp.NS_XMPP_STREAMS + ' ' + self.streamError
|
||||
if key in common.xmpp.ERRORS:
|
||||
sectxt2 = _('Server replied: %s') % common.xmpp.ERRORS[key][2]
|
||||
self.dispatch('ERROR', (pritxt, '%s\n%s' % (sectxt2, sectxt)))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self, level='error', pri_txt=pritxt,
|
||||
sec_txt='%s\n%s' % (sectxt2, sectxt)))
|
||||
return
|
||||
# show popup
|
||||
gajim.nec.push_incoming_event(ConnectionLostEvent(None,
|
||||
|
@ -1363,9 +1367,10 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.disconnect(on_purpose = True)
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
|
||||
show='offline'))
|
||||
self.dispatch('ERROR', (_('Authentication failed with "%s"') % \
|
||||
self._hostname,
|
||||
_('Please check your login and password for correctness.')))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Authentication failed with "%s"') % \
|
||||
self._hostname, sec_txt=_('Please check your login and password'
|
||||
'for correctness.')))
|
||||
if self.on_connect_auth:
|
||||
self.on_connect_auth(None)
|
||||
self.on_connect_auth = None
|
||||
|
@ -1438,10 +1443,11 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
gajim.nec.push_incoming_event(PrivacyListRemovedEvent(None,
|
||||
conn=self, list_name=privacy_list))
|
||||
else:
|
||||
self.dispatch('ERROR', (_('Error while removing privacy list'),
|
||||
_('Privacy list %s has not been removed. It is maybe active in '
|
||||
'one of your connected resources. Deactivate it and try '
|
||||
'again.') % privacy_list))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Error while removing privacy '
|
||||
'list'), sec_txt=_('Privacy list %s has not been removed. '
|
||||
'It is maybe active in one of your connected resources. '
|
||||
'Deactivate it and tryagain.') % privacy_list))
|
||||
common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list,
|
||||
_on_del_privacy_list_result)
|
||||
|
||||
|
@ -1516,8 +1522,10 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
if not self.privacy_rules_supported:
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
|
||||
show=gajim.SHOW_LIST[self.connected]))
|
||||
self.dispatch('ERROR', (_('Invisibility not supported'),
|
||||
_('Account %s doesn\'t support invisibility.') % self.name))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Invisibility not supported',
|
||||
sec_txt=_('Account %s doesn\'t support invisibility.') % \
|
||||
self.name)))
|
||||
return
|
||||
# If we are already connected, and privacy rules are supported, send
|
||||
# offline presence first as it's required by XEP-0126
|
||||
|
@ -2522,9 +2530,11 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
if result.getID() == id_:
|
||||
on_remove_success(True)
|
||||
return
|
||||
self.dispatch('ERROR', (_('Unregister failed'),
|
||||
_('Unregistration with server %(server)s failed: '
|
||||
'%(error)s') % {'server': hostname,
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self, level='error',
|
||||
pri_txt=_('Unregister failed'),
|
||||
sec_txt=_('Unregistration with server %(server)s '
|
||||
'failed: %(error)s') % {'server': hostname,
|
||||
'error': result.getErrorMsg()}))
|
||||
on_remove_success(False)
|
||||
con.RegisterHandler('iq', _on_answer, 'result', system=True)
|
||||
|
|
|
@ -125,8 +125,9 @@ class ConnectionDisco:
|
|||
|
||||
def _agent_registered_cb(self, con, resp, agent):
|
||||
if resp.getType() == 'result':
|
||||
self.dispatch('INFORMATION', (_('Registration succeeded'),
|
||||
_('Registration with agent %s succeeded') % agent))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='info', pri_txt=_('Registration succeeded'), sec_txt=_(
|
||||
'Registration with agent %s succeeded') % agent))
|
||||
self.request_subscription(agent, auto_auth=True)
|
||||
self.agent_registrations[agent]['roster_push'] = True
|
||||
if self.agent_registrations[agent]['sub_received']:
|
||||
|
@ -134,9 +135,10 @@ class ConnectionDisco:
|
|||
p = self.add_sha(p)
|
||||
self.connection.send(p)
|
||||
if resp.getType() == 'error':
|
||||
self.dispatch('ERROR', (_('Registration failed'), _('Registration '
|
||||
'with agent %(agent)s failed with error %(error)s: '
|
||||
'%(error_msg)s') % {'agent': agent, 'error': resp.getError(),
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Registration failed'), sec_txt=_(
|
||||
'Registration with agent %(agent)s failed with error %(error)s:'
|
||||
' %(error_msg)s') % {'agent': agent, 'error': resp.getError(),
|
||||
'error_msg': resp.getErrorMsg()}))
|
||||
|
||||
def register_agent(self, agent, info, is_form=False):
|
||||
|
@ -328,7 +330,8 @@ class ConnectionVcard:
|
|||
fil.write(str(card))
|
||||
fil.close()
|
||||
except IOError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e)))
|
||||
|
||||
def get_cached_vcard(self, fjid, is_fake_jid=False):
|
||||
"""
|
||||
|
@ -564,9 +567,10 @@ class ConnectionVcard:
|
|||
self.disconnect(on_purpose=True)
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
|
||||
show='offline'))
|
||||
self.dispatch('ERROR', (_('Invisibility not supported'),
|
||||
_('Account %s doesn\'t support invisibility.') % \
|
||||
self.name))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self, level='error', pri_txt=_('Invisibility not '
|
||||
'supported'), sec_txt=_('Account %s doesn\'t support '
|
||||
'invisibility.') % self.name))
|
||||
return
|
||||
# Ask metacontacts before roster
|
||||
self.get_metacontacts()
|
||||
|
|
|
@ -997,8 +997,9 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
try:
|
||||
self.get_jid_resource()
|
||||
except helpers.InvalidFormat:
|
||||
self.conn.dispatch('ERROR', (_('Invalid Jabber ID'),
|
||||
_('A message from a non-valid JID arrived, it has been '
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self.conn,
|
||||
level='error', pri_txt=_('Invalid Jabber ID'),
|
||||
sec_txt=_('A message from a non-valid JID arrived, it has been '
|
||||
'ignored.')))
|
||||
return
|
||||
|
||||
|
@ -1027,9 +1028,11 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
try:
|
||||
self.get_jid_resource()
|
||||
except helpers.InvalidFormat:
|
||||
self.conn.dispatch('ERROR', (_('Invalid Jabber ID'),
|
||||
_('A message from a non-valid JID arrived, it has been '
|
||||
'ignored.')))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.conn, level='error',
|
||||
pri_txt=_('Invalid Jabber ID'),
|
||||
sec_txt=_('A message from a non-valid JID arrived, it '
|
||||
'has been ignored.')))
|
||||
return
|
||||
self.forwarded = True
|
||||
elif sent_tag:
|
||||
|
@ -1041,9 +1044,11 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
try:
|
||||
self.get_jid_resource()
|
||||
except helpers.InvalidFormat:
|
||||
self.conn.dispatch('ERROR', (_('Invalid Jabber ID'),
|
||||
_('A message from a non-valid JID arrived, it has been '
|
||||
'ignored.')))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.conn, level='error',
|
||||
pri_txt=_('Invalid Jabber ID'),
|
||||
sec_txt=_('A message from a non-valid JID arrived, it '
|
||||
'has been ignored.')))
|
||||
return
|
||||
self.forwarded = True
|
||||
self.sent = True
|
||||
|
@ -2268,3 +2273,10 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent):
|
|||
class ClientCertPassphraseEvent(nec.NetworkIncomingEvent):
|
||||
name = 'client-cert-passphrase'
|
||||
base_network_events = []
|
||||
|
||||
class InformationEvent(nec.NetworkIncomingEvent):
|
||||
name = 'information'
|
||||
base_network_events = []
|
||||
|
||||
def init(self):
|
||||
self.popup = True
|
||||
|
|
|
@ -103,11 +103,12 @@ class JingleRTPContent(JingleContent):
|
|||
bin = gst.parse_bin_from_description(pipeline, True)
|
||||
return bin
|
||||
except GError, error_str:
|
||||
self.session.connection.dispatch('ERROR',
|
||||
(_("%s configuration error") % text.capitalize(),
|
||||
_("Couldn't setup %s. Check your configuration.\n\n"
|
||||
"Pipeline was:\n%s\n\n"
|
||||
"Error was:\n%s") % (text, pipeline, error_str)))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.session.connection, level='error',
|
||||
pri_txt=_('%s configuration error') % text.capitalize(),
|
||||
sec_txt=_("Couldn't setup %s. Check your configuration.\n\n"
|
||||
"Pipeline was:\n%s\n\nError was:\n%s") % (text, pipeline,
|
||||
error_str)))
|
||||
raise JingleContentSetupException
|
||||
|
||||
def add_remote_candidates(self, candidates):
|
||||
|
@ -201,10 +202,11 @@ class JingleRTPContent(JingleContent):
|
|||
# or raise an error, Jingle way
|
||||
# or maybe one-sided stream?
|
||||
if not self.stream_failed_once:
|
||||
self.session.connection.dispatch('ERROR',
|
||||
(_("GStreamer error"),
|
||||
_("Error: %s\nDebug: %s" % (message.structure['gerror'],
|
||||
message.structure['debug']))))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.session.connection, level='error',
|
||||
pri_txt=_('GStreamer error'), sec_txt=_('Error: %s\nDebug: '
|
||||
'%s' % (message.structure['gerror'],
|
||||
message.structure['debug']))))
|
||||
|
||||
sink_pad = self.p2psession.get_property('sink-pad')
|
||||
|
||||
|
|
|
@ -374,8 +374,9 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
|||
port = gajim.config.get('file_transfers_port')
|
||||
self._add_streamhosts_to_query(query, sender, port, my_ips)
|
||||
except socket.gaierror:
|
||||
self.dispatch('ERROR', (_('Wrong host'),
|
||||
_('Invalid local address? :-O')))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Wrong host'),
|
||||
sec_txt=_('Invalid local address? :-O')))
|
||||
|
||||
def _add_addiditional_streamhosts_to_query(self, query, file_props):
|
||||
sender = file_props['sender']
|
||||
|
|
|
@ -189,8 +189,9 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
|
|||
alt_name=alt_name))
|
||||
|
||||
def _on_error(self, message):
|
||||
self.dispatch('ERROR', (_('Avahi error'),
|
||||
_('%s\nLink-local messaging might not work properly.') % message))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||
level='error', pri_txt=_('Avahi error'), sec_txt=_('%s\nLink-local '
|
||||
'messaging might not work properly.') % message))
|
||||
|
||||
def connect(self, show='online', msg=''):
|
||||
self.get_config_values_or_default()
|
||||
|
|
|
@ -2575,10 +2575,11 @@ class AccountsWindow:
|
|||
return
|
||||
if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \
|
||||
gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf:
|
||||
gajim.connections[gajim.ZEROCONF_ACC_NAME].dispatch('ERROR',
|
||||
(_('Account Local already exists.'),
|
||||
_('Please rename or remove it before enabling link-local messaging'
|
||||
'.')))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=gajim.connections[gajim.ZEROCONF_ACC_NAME],
|
||||
level='error', pri_txt=_('Account Local already exists.'),
|
||||
sec_txt=_('Please rename or remove it before enabling '
|
||||
'link-local messaging.')))
|
||||
return
|
||||
|
||||
if gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'active') \
|
||||
|
|
|
@ -105,10 +105,6 @@ class Interface:
|
|||
### Methods handling events from connection
|
||||
################################################################################
|
||||
|
||||
def handle_event_error(self, unused, data):
|
||||
#('ERROR', account, (title_text, section_text))
|
||||
dialogs.ErrorDialog(data[0], data[1])
|
||||
|
||||
def handle_event_db_error(self, unused, data):
|
||||
#('DB_ERROR', account, (title_text, section_text))
|
||||
if self.db_error_dialog:
|
||||
|
@ -118,9 +114,18 @@ class Interface:
|
|||
self.db_error_dialog = None
|
||||
self.db_error_dialog.connect('destroy', destroyed)
|
||||
|
||||
def handle_event_information(self, unused, data):
|
||||
#('INFORMATION', account, (title_text, section_text))
|
||||
dialogs.InformationDialog(data[0], data[1])
|
||||
def handle_event_information(self, obj):
|
||||
if obj.popup:
|
||||
if obj.level == 'error':
|
||||
cls = dialogs.ErrorDialog
|
||||
elif obj.level == 'warn':
|
||||
cls = dialogs.WarningDialog
|
||||
elif obj.level == 'info':
|
||||
cls = dialogs.InformationDialog
|
||||
else:
|
||||
return
|
||||
|
||||
cls(obj.pri_txt, obj.sec_txt)
|
||||
|
||||
def handle_ask_new_nick(self, account, room_jid):
|
||||
title = _('Unable to join group chat')
|
||||
|
@ -1372,9 +1377,7 @@ class Interface:
|
|||
|
||||
def create_core_handlers_list(self):
|
||||
self.handlers = {
|
||||
'ERROR': [self.handle_event_error],
|
||||
'DB_ERROR': [self.handle_event_db_error],
|
||||
'INFORMATION': [self.handle_event_information],
|
||||
'FILE_SEND_ERROR': [self.handle_event_file_send_error],
|
||||
'atom-entry-received': [self.handle_atom_entry],
|
||||
'bad-gpg-passphrase': [self.handle_event_bad_gpg_passphrase],
|
||||
|
@ -1392,6 +1395,7 @@ class Interface:
|
|||
'gpg-password-required': [self.handle_event_gpg_password_required],
|
||||
'gpg-trust-key': [self.handle_event_gpg_trust_key],
|
||||
'http-auth-received': [self.handle_event_http_auth],
|
||||
'information': [self.handle_event_information],
|
||||
'insecure-password': [self.handle_event_insecure_password],
|
||||
'insecure-ssl-connection': \
|
||||
[self.handle_event_insecure_ssl_connection],
|
||||
|
|
|
@ -96,14 +96,18 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
obj.msg_id = gajim.logger.write(log_type, obj.fjid,
|
||||
msg_to_log, tim=obj.timestamp, subject=obj.subject)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.conn.dispatch('ERROR', (_('Disk WriteError'), str(e)))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.conn, level='error', pri_txt=_('Disk WriteError'),
|
||||
sec_txt=str(e)))
|
||||
except exceptions.DatabaseMalformed:
|
||||
pritext = _('Database Error')
|
||||
sectext = _('The database file (%s) cannot be read. Try to '
|
||||
'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) '
|
||||
'or remove it (all history will be lost).') % \
|
||||
common.logger.LOG_DB_PATH
|
||||
self.conn.dispatch('ERROR', (pritext, sectext))
|
||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||
conn=self.conn, level='error', pri_txt=pritxt,
|
||||
sec_txt=sectxt))
|
||||
|
||||
treat_as = gajim.config.get('treat_incoming_messages')
|
||||
if treat_as:
|
||||
|
|
Loading…
Reference in New Issue