catch all error codes for MUC JEP and issue translatable strings so non english user does not see english.

This commit is contained in:
Nikos Kouremenos 2005-09-03 17:18:07 +00:00
parent 75a9d0ae2c
commit 650bbdca39
2 changed files with 26 additions and 5 deletions

View File

@ -355,16 +355,37 @@ class Connection:
elif ptype == 'error': elif ptype == 'error':
errmsg = prs.getError() errmsg = prs.getError()
errcode = prs.getErrorCode() errcode = prs.getErrorCode()
if errcode == '409': #conflict: Nick Conflict if errcode == '502': # Internal Timeout:
self.dispatch('ERROR', (_('Unable to join room'),
_('Server response:') + '\n' + errmsg))
elif errcode == '502': # Internal Timeout:
self.dispatch('NOTIFY', (prs.getFrom().getStripped(), self.dispatch('NOTIFY', (prs.getFrom().getStripped(),
'error', errmsg, prs.getFrom().getResource(), 'error', errmsg, prs.getFrom().getResource(),
prio, keyID, prs.getRole(), prs.getAffiliation(), prs.getJid(), prio, keyID, prs.getRole(), prs.getAffiliation(), prs.getJid(),
prs.getReason(), prs.getActor(), prs.getStatusCode(), prs.getReason(), prs.getActor(), prs.getStatusCode(),
prs.getNewNick())) prs.getNewNick()))
elif errcode == '401': # password required to join
self.dispatch('ERROR', (_('Unable to join room'),
_('A password is required to join this room.')))
elif errcode == '403': # we are banned
self.dispatch('ERROR', (_('Unable to join room'),
_('You are banned from this room.')))
elif errcode == '404': # room does not exist
self.dispatch('ERROR', (_('Unable to join room'),
_('Such room does not exist.')))
elif errcode == '405':
self.dispatch('ERROR', (_('Unable to join room'),
_('Room creation is restricted,')))
elif errcode == '406':
self.dispatch('ERROR', (_('Unable to join room'),
_('Your registered nickname must be used.')))
elif errcode == '407':
self.dispatch('ERROR', (_('Unable to join room'),
_('You are not in the members list.')))
elif errcode == '409': # nick conflict
self.dispatch('ERROR', (_('Unable to join room'),
_('Your desired nickname is in use or registered by another user.')))
else: else:
#FIXME: wtf is ERROR_ANSWER? maybe I should handle there?
#some comments in the code ARE VITAL ppl :( :( :(
#other ppl read your code. do not make their life miserable
self.dispatch('ERROR_ANSWER', ('', prs.getFrom().getStripped(), self.dispatch('ERROR_ANSWER', ('', prs.getFrom().getStripped(),
errmsg, errcode)) errmsg, errcode))
if not ptype or ptype == 'unavailable': if not ptype or ptype == 'unavailable':

View File

@ -188,7 +188,7 @@ class Interface:
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode)) #('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
if jid_from in self.windows[account]['gc']: if jid_from in self.windows[account]['gc']:
self.windows[account]['gc'][jid_from].print_conversation( self.windows[account]['gc'][jid_from].print_conversation(
'Error %s: %s' % (array[2], array[1]), jid_from) _('Error %s: %s') % (array[2], array[1]), jid_from)
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', 'tcp' # ('CON_TYPE', account, con_type) which can be 'ssl', 'tls', 'tcp'