ERROR messages are a message like all others with ONE data (that can be a tuple)
This commit is contained in:
parent
f69c456b4d
commit
a1858c9517
|
@ -134,14 +134,11 @@ class Connection:
|
||||||
gajim.config.set('usegpg', False)
|
gajim.config.set('usegpg', False)
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
def dispatch(self, event, pritext, sectext=''):
|
def dispatch(self, event, data):
|
||||||
if not event in self.handlers:
|
if not event in self.handlers:
|
||||||
return
|
return
|
||||||
for handler in self.handlers[event]:
|
for handler in self.handlers[event]:
|
||||||
if len(sectext):
|
handler(self.name, data)
|
||||||
handler(self.name, pritext, sectext)
|
|
||||||
else:
|
|
||||||
handler(self.name, pritext)
|
|
||||||
|
|
||||||
# this is in features.py but it is blocking
|
# this is in features.py but it is blocking
|
||||||
def _discover(self, ns, jid, node = None):
|
def _discover(self, ns, jid, node = None):
|
||||||
|
@ -288,7 +285,7 @@ class Connection:
|
||||||
errmsg = prs.getError()
|
errmsg = prs.getError()
|
||||||
errcode = prs.getErrorCode()
|
errcode = prs.getErrorCode()
|
||||||
if errcode == '409': #conflict : Nick Conflict
|
if errcode == '409': #conflict : Nick Conflict
|
||||||
self.dispatch('ERROR', errmsg)
|
self.dispatch('ERROR', (errmsg, ''))
|
||||||
elif errcode == '502': # Internal Timeout:
|
elif errcode == '502': # Internal Timeout:
|
||||||
self.dispatch('NOTIFY', (prs.getFrom().getStripped().encode('utf8'),
|
self.dispatch('NOTIFY', (prs.getFrom().getStripped().encode('utf8'),
|
||||||
'error', errmsg, prs.getFrom().getResource().encode('utf8'), prio, keyID,
|
'error', errmsg, prs.getFrom().getResource().encode('utf8'), prio, keyID,
|
||||||
|
@ -318,8 +315,8 @@ class Connection:
|
||||||
self.connection = None
|
self.connection = None
|
||||||
if not self.on_purpose:
|
if not self.on_purpose:
|
||||||
self.dispatch('ERROR',
|
self.dispatch('ERROR',
|
||||||
_('Connection with account "%s" has been lost') % self.name,
|
(_('Connection with account "%s" has been lost') % self.name,
|
||||||
_('To continue sending and receiving messages, you will need to reconnect.'))
|
_('To continue sending and receiving messages, you will need to reconnect.')))
|
||||||
self.on_purpose = False
|
self.on_purpose = False
|
||||||
# END disconenctedCB
|
# END disconenctedCB
|
||||||
|
|
||||||
|
@ -580,7 +577,8 @@ class Connection:
|
||||||
gajim.log.debug("Couldn't connect to %s" % self.name)
|
gajim.log.debug("Couldn't connect to %s" % self.name)
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', _('Could not connect to "%s"') % self.name)
|
self.dispatch('ERROR', (_('Could not connect to "%s"') % self.name,
|
||||||
|
''))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
con.RegisterHandler('message', self._messageCB)
|
con.RegisterHandler('message', self._messageCB)
|
||||||
|
@ -615,7 +613,8 @@ class Connection:
|
||||||
except IOError: #probably a timeout
|
except IOError: #probably a timeout
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', _('Could not connect to "%s"') % self.name)
|
self.dispatch('ERROR', (_('Could not connect to "%s"') % self.name,
|
||||||
|
''))
|
||||||
return None
|
return None
|
||||||
if auth:
|
if auth:
|
||||||
con.initRoster()
|
con.initRoster()
|
||||||
|
@ -625,8 +624,8 @@ class Connection:
|
||||||
gajim.log.debug("Couldn't authenticate to %s" % self.name)
|
gajim.log.debug("Couldn't authenticate to %s" % self.name)
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', _('Authentication failed with "%s"' % name), \
|
self.dispatch('ERROR', (_('Authentication failed with "%s"' % name),
|
||||||
_('Please check your login and password for correctness.'))
|
_('Please check your login and password for correctness.')))
|
||||||
return None
|
return None
|
||||||
# END connect
|
# END connect
|
||||||
|
|
||||||
|
@ -846,8 +845,8 @@ class Connection:
|
||||||
con_type = c.connect((config['hostname'], port), proxy = proxy)
|
con_type = c.connect((config['hostname'], port), proxy = proxy)
|
||||||
if not con_type:
|
if not con_type:
|
||||||
gajim.log.debug("Couldn't connect to %s" % name)
|
gajim.log.debug("Couldn't connect to %s" % name)
|
||||||
self.dispatch('ERROR', _('Could not connect to "%s"') % name,
|
self.dispatch('ERROR', (_('Could not connect to "%s"') % name,
|
||||||
_('Check your connection or try again later'))
|
_('Check your connection or try again later')))
|
||||||
return False
|
return False
|
||||||
gajim.log.debug('Connected to server')
|
gajim.log.debug('Connected to server')
|
||||||
# FIXME! This blocks!
|
# FIXME! This blocks!
|
||||||
|
@ -855,7 +854,7 @@ class Connection:
|
||||||
req['username'] = config['name']
|
req['username'] = config['name']
|
||||||
req['password'] = config['password']
|
req['password'] = config['password']
|
||||||
if not common.xmpp.features.register(c, config['hostname'], req):
|
if not common.xmpp.features.register(c, config['hostname'], req):
|
||||||
self.dispatch('ERROR', _('Error: ') + c.lastErr)
|
self.dispatch('ERROR', (_('Error:'), c.lastErr))
|
||||||
return False
|
return False
|
||||||
self.name = name
|
self.name = name
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
|
|
10
src/gajim.py
10
src/gajim.py
|
@ -189,11 +189,13 @@ class Interface:
|
||||||
self.roster.mklists(data, account)
|
self.roster.mklists(data, account)
|
||||||
self.roster.draw_roster()
|
self.roster.draw_roster()
|
||||||
|
|
||||||
def handle_event_warning(self, unused, msg, sectext=''):
|
def handle_event_warning(self, unused, data):
|
||||||
dialogs.Warning_dialog(msg, sectext).get_response()
|
#('WARNING', account, (title_text, section_text))
|
||||||
|
dialogs.Warning_dialog(data[0], data[1]).get_response()
|
||||||
|
|
||||||
def handle_event_error(self, unused, msg, sectext=''):
|
def handle_event_error(self, unused, data):
|
||||||
dialogs.Error_dialog(msg, sectext).get_response()
|
#('ERROR', account, (title_text, section_text))
|
||||||
|
dialogs.Error_dialog(data[0], data[1]).get_response()
|
||||||
|
|
||||||
def handle_event_error_answer(self, account, array):
|
def handle_event_error_answer(self, account, array):
|
||||||
#('ERROR_ANSWER', account, (jid_from. errmsg, errcode))
|
#('ERROR_ANSWER', account, (jid_from. errmsg, errcode))
|
||||||
|
|
Loading…
Reference in New Issue