update correctly self_contact Contact instance and roster row when we use an anonymous account (our jid changes in this case). Fixes #5370
This commit is contained in:
parent
e7a6dffe7b
commit
8f2120371b
4 changed files with 39 additions and 0 deletions
|
@ -777,7 +777,10 @@ class Connection(ConnectionHandlers):
|
|||
self.server_resource = con.Resource
|
||||
if gajim.config.get_per('accounts', self.name, 'anonymous_auth'):
|
||||
# Get jid given by server
|
||||
old_jid = gajim.get_jid_from_account(self.name)
|
||||
gajim.config.set_per('accounts', self.name, 'name', con.User)
|
||||
new_jid = gajim.get_jid_from_account(self.name)
|
||||
self.dispatch('NEW_JID', (old_jid, new_jid))
|
||||
if auth:
|
||||
self.last_io = gajim.idlequeue.current_time()
|
||||
self.connected = 2
|
||||
|
|
|
@ -219,6 +219,17 @@ class Contacts:
|
|||
del self._gc_contacts[old_name]
|
||||
del self._metacontacts_tags[old_name]
|
||||
|
||||
def change_contact_jid(self, old_jid, new_jid, account):
|
||||
if account not in self._contacts:
|
||||
return
|
||||
if old_jid not in self._contacts[account]:
|
||||
return
|
||||
self._contacts[account][new_jid] = []
|
||||
for _contact in self._contacts[account][old_jid]:
|
||||
_contact.jid = new_jid
|
||||
self._contacts[account][new_jid].append(_contact)
|
||||
del self._contacts[account][old_jid]
|
||||
|
||||
def add_account(self, account):
|
||||
self._contacts[account] = {}
|
||||
self._gc_contacts[account] = {}
|
||||
|
|
|
@ -263,6 +263,14 @@ class Interface:
|
|||
if self.remote_ctrl:
|
||||
self.remote_ctrl.raise_signal('AccountPresence', (show, account))
|
||||
|
||||
def handle_event_new_jid(self, account, data):
|
||||
#('NEW_JID', account, (old_jid, new_jid))
|
||||
'''
|
||||
This event is raised when our JID changed (most probably because we use
|
||||
anonymous account. We update contact and roster entry in this case.
|
||||
'''
|
||||
self.roster.rename_self_contact(data[0], data[1], account)
|
||||
|
||||
def edit_own_details(self, account):
|
||||
jid = gajim.get_jid_from_account(account)
|
||||
if 'profile' not in self.instances[account]:
|
||||
|
@ -1515,6 +1523,7 @@ class Interface:
|
|||
|
||||
def handle_event_signed_in(self, account, empty):
|
||||
'''SIGNED_IN event is emitted when we sign in, so handle it'''
|
||||
# ('SIGNED_IN', account, ())
|
||||
# block signed in notifications for 30 seconds
|
||||
gajim.block_signed_in_notifications[account] = True
|
||||
self.roster.set_actions_menu_needs_rebuild()
|
||||
|
@ -2001,6 +2010,7 @@ class Interface:
|
|||
'INFORMATION': [self.handle_event_information],
|
||||
'ERROR_ANSWER': [self.handle_event_error_answer],
|
||||
'STATUS': [self.handle_event_status],
|
||||
'NEW_JID': [self.handle_event_new_jid],
|
||||
'NOTIFY': [self.handle_event_notify],
|
||||
'MSGERROR': [self.handle_event_msgerror],
|
||||
'MSGSENT': [self.handle_event_msgsent],
|
||||
|
|
|
@ -784,6 +784,21 @@ class RosterWindow:
|
|||
|
||||
return True
|
||||
|
||||
def rename_self_contact(self, old_jid, new_jid, account):
|
||||
'''Rename the self_contact jid
|
||||
|
||||
Keyword arguments:
|
||||
old_jid -- our old jid
|
||||
new_jid -- our new jid
|
||||
account -- the corresponding account.
|
||||
'''
|
||||
gajim.contacts.change_contact_jid(old_jid, new_jid, account)
|
||||
self_iter = self._get_self_contact_iter(account, model=self.model)
|
||||
if not self_iter:
|
||||
return
|
||||
self.model[self_iter][C_JID] = new_jid
|
||||
self.draw_contact(new_jid, account)
|
||||
|
||||
def add_groupchat(self, jid, account, status=''):
|
||||
'''Add groupchat to roster and draw it.
|
||||
Return the added contact instance.
|
||||
|
|
Loading…
Add table
Reference in a new issue