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:
parent
04d82ec3fc
commit
1fff71ad87
|
@ -380,8 +380,10 @@ class Connection:
|
||||||
self.dispatch('ERROR', (_('Unable to join room'),
|
self.dispatch('ERROR', (_('Unable to join room'),
|
||||||
_('You are not in the members list.')))
|
_('You are not in the members list.')))
|
||||||
elif errcode == '409': # nick conflict
|
elif errcode == '409': # nick conflict
|
||||||
self.dispatch('ERROR', (_('Unable to join room'),
|
# the jid_from in this case is FAKE JID: room_jid/nick
|
||||||
_('Your desired nickname is in use or registered by another user.')))
|
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
|
else: # print in the window the error
|
||||||
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
self.dispatch('ERROR_ANSWER', ('', jid_stripped,
|
||||||
errmsg, errcode))
|
errmsg, errcode))
|
||||||
|
|
|
@ -96,9 +96,12 @@ def get_room_and_nick_from_fjid(jid):
|
||||||
# gaim@conference.jabber.no/nick/nick-continued
|
# gaim@conference.jabber.no/nick/nick-continued
|
||||||
# return ('gaim@conference.jabber.no', 'nick/nick-continued')
|
# return ('gaim@conference.jabber.no', 'nick/nick-continued')
|
||||||
l = jid.split('/', 1)
|
l = jid.split('/', 1)
|
||||||
if len(l) == 1: #No nick
|
if len(l) == 1: # No nick
|
||||||
l.append('')
|
l.append('')
|
||||||
return l
|
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):
|
def get_contact_instances_from_jid(account, jid):
|
||||||
''' we may have two or more resources on that jid '''
|
''' we may have two or more resources on that jid '''
|
||||||
|
|
|
@ -169,6 +169,11 @@ class Interface:
|
||||||
def handle_event_information(self, unused, data):
|
def handle_event_information(self, unused, data):
|
||||||
#('INFORMATION', account, (title_text, section_text))
|
#('INFORMATION', account, (title_text, section_text))
|
||||||
dialogs.InformationDialog(data[0], data[1])
|
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):
|
def handle_event_http_auth(self, account, data):
|
||||||
#('HTTP_AUTH', account, (method, url, iq_obj))
|
#('HTTP_AUTH', account, (method, url, iq_obj))
|
||||||
|
@ -1043,6 +1048,7 @@ class Interface:
|
||||||
'HTTP_AUTH': self.handle_event_http_auth,
|
'HTTP_AUTH': self.handle_event_http_auth,
|
||||||
'VCARD_PUBLISHED': self.handle_event_vcard_published,
|
'VCARD_PUBLISHED': self.handle_event_vcard_published,
|
||||||
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
|
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
|
||||||
|
'ASK_NEW_NICK': self.handle_event_ask_new_nick,
|
||||||
}
|
}
|
||||||
|
|
||||||
def exec_event(self, account):
|
def exec_event(self, account):
|
||||||
|
|
|
@ -454,8 +454,14 @@ class GroupchatWindow(chat.Chat):
|
||||||
def on_change_nick_menuitem_activate(self, widget):
|
def on_change_nick_menuitem_activate(self, widget):
|
||||||
room_jid = self.get_active_jid()
|
room_jid = self.get_active_jid()
|
||||||
nick = self.nicks[room_jid]
|
nick = self.nicks[room_jid]
|
||||||
instance = dialogs.InputDialog(_('Changing Nickname'),
|
title = _('Changing Nickname')
|
||||||
_('Please specify the new nickname you want to use:'), nick)
|
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()
|
response = instance.get_response()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
nick = instance.input_entry.get_text().decode('utf-8')
|
nick = instance.input_entry.get_text().decode('utf-8')
|
||||||
|
|
Loading…
Reference in New Issue