correctly change the resource of a control. Fixes #5261

This commit is contained in:
Yann Leboulanger 2009-09-15 17:41:47 +02:00
parent 949dbe6e38
commit 651e801334
3 changed files with 24 additions and 2 deletions

View File

@ -1433,6 +1433,19 @@ class ChatControl(ChatControlBase):
else: else:
self._tune_image.hide() self._tune_image.hide()
def change_resource(self, resource):
old_full_jid = self.get_full_jid()
self.resource = resource
new_full_jid = self.get_full_jid()
# update gajim.last_message_time
if old_full_jid in gajim.last_message_time[self.account]:
gajim.last_message_time[self.account][new_full_jid] = \
gajim.last_message_time[self.account][old_full_jid]
# update events
gajim.events.change_jid(self.account, old_full_jid, new_full_jid)
# update MessageWindow._controls
self.parent_win.change_jid(self.account, old_full_jid, new_full_jid)
def on_avatar_eventbox_enter_notify_event(self, widget, event): def on_avatar_eventbox_enter_notify_event(self, widget, event):
''' '''
we enter the eventbox area so we under conditions add a timeout we enter the eventbox area so we under conditions add a timeout

View File

@ -158,6 +158,15 @@ class MessageWindow(object):
if self.account == old_name: if self.account == old_name:
self.account = new_name self.account = new_name
def change_jid(self, account, old_jid, new_jid):
''' call then when the full jid of a contral change'''
if account not in self._controls:
return
if old_jid not in self._controls[account]:
return
self._controls[account][new_jid] = self._controls[account][old_jid]
del self._controls[account][old_jid]
def get_num_controls(self): def get_num_controls(self):
return sum(len(d) for d in self._controls.values()) return sum(len(d) for d in self._controls.values())

View File

@ -88,8 +88,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
subject = msg.getSubject() subject = msg.getSubject()
if self.jid != full_jid_with_resource: if self.jid != full_jid_with_resource:
self.resource = gajim.get_nick_from_fjid(full_jid_with_resource) self.resource = gajim.get_nick_from_fjid(full_jid_with_resource)
if self.control: if self.control and self.control.resource:
self.control.resource = self.resource self.control.change_resource(self.resource)
if not msg_type or msg_type not in ('chat', 'groupchat', 'error'): if not msg_type or msg_type not in ('chat', 'groupchat', 'error'):
msg_type = 'normal' msg_type = 'normal'