refactor to allow changing our nick after nick conflict but first #967 needs to be fixed so I can test

This commit is contained in:
Nikos Kouremenos 2005-09-26 22:29:52 +00:00
parent 04d82ec3fc
commit 1fff71ad87
4 changed files with 22 additions and 5 deletions

View File

@ -380,8 +380,10 @@ class Connection:
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.')))
# the jid_from in this case is FAKE JID: room_jid/nick
room_jid = gajim.get_room_from_fjid(jid_from)
self.dispatch('ASK_NEW_NICK', (room_jid, _('Unable to join room'),
_('Your desired nickname is in use or registered by another occupant. Please use another:')))
else: # print in the window the error
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
errmsg, errcode))

View File

@ -96,9 +96,12 @@ def get_room_and_nick_from_fjid(jid):
# gaim@conference.jabber.no/nick/nick-continued
# return ('gaim@conference.jabber.no', 'nick/nick-continued')
l = jid.split('/', 1)
if len(l) == 1: #No nick
if len(l) == 1: # No nick
l.append('')
return l
def get_room_from_fjid(jid):
return get_room_and_nick_from_fjid(jid)[0]
def get_contact_instances_from_jid(account, jid):
''' we may have two or more resources on that jid '''

View File

@ -169,6 +169,11 @@ class Interface:
def handle_event_information(self, unused, data):
#('INFORMATION', account, (title_text, section_text))
dialogs.InformationDialog(data[0], data[1])
def handle_event_ask_new_nick(self, unused, data):
#('ASK_NEW_NICK', account, (room_jid, title_text, prompt_text))
pass
# FIXME: find a way to call show_change_nick_input_dialog in GC.py
def handle_event_http_auth(self, account, data):
#('HTTP_AUTH', account, (method, url, iq_obj))
@ -1043,6 +1048,7 @@ class Interface:
'HTTP_AUTH': self.handle_event_http_auth,
'VCARD_PUBLISHED': self.handle_event_vcard_published,
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
'ASK_NEW_NICK': self.handle_event_ask_new_nick,
}
def exec_event(self, account):

View File

@ -454,8 +454,14 @@ class GroupchatWindow(chat.Chat):
def on_change_nick_menuitem_activate(self, widget):
room_jid = self.get_active_jid()
nick = self.nicks[room_jid]
instance = dialogs.InputDialog(_('Changing Nickname'),
_('Please specify the new nickname you want to use:'), nick)
title = _('Changing Nickname')
prompt = _('Please specify the new nickname you want to use:')
self.show_change_nick_input_dialog(title, prompt, nick, room_jid)
def show_change_nick_input_dialog(self, title, prompt, proposed_nick,
room_jid):
'''asks user for new nick and on ok it sets it on room'''
instance = dialogs.InputDialog(title, prompt, proposed_nick)
response = instance.get_response()
if response == gtk.RESPONSE_OK:
nick = instance.input_entry.get_text().decode('utf-8')