From 51d57ba717aeac91c62d623d4ef46c210c3344b8 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 14 Mar 2006 17:13:34 +0000 Subject: [PATCH] last_message_time is now indexed by full_jid. for [1697] --- src/chat_control.py | 6 ++++-- src/gajim.py | 3 ++- src/message_control.py | 2 +- src/message_window.py | 7 ++++--- src/roster_window.py | 10 ++++++---- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 2d099346f..f2d1cbe37 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -391,7 +391,8 @@ class ChatControlBase(MessageControl): if not count_as_new: return if kind == 'incoming_queue': - gajim.last_message_time[self.account][jid] = time.time() + gajim.last_message_time[self.account][self.get_full_jid()] = \ + time.time() urgent = True if (not self.parent_win.get_active_jid() or \ jid != self.parent_win.get_active_jid() or \ @@ -1254,7 +1255,8 @@ class ChatControl(ChatControlBase): def allow_shutdown(self): jid = self.contact.jid - if time.time() - gajim.last_message_time[self.account][jid] < 2: + if time.time() - gajim.last_message_time[self.account]\ + [self.get_full_jid()] < 2: # 2 seconds dialog = dialogs.ConfirmationDialog( #%s is being replaced in the code with JID diff --git a/src/gajim.py b/src/gajim.py index 14be1c656..47b00cf77 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1502,8 +1502,9 @@ class Interface: else: contact = gajim.contacts.get_first_contact_from_jid(account, jid) self.roster.new_chat(contact, account) - gajim.last_message_time[account][jid] = 0 # long time ago w = gajim.interface.msg_win_mgr.get_window(jid, account) + ctrl = w.get_control + gajim.last_message_time[account][jid] = 0 # long time ago elif typ == message_control.TYPE_PM: if gajim.interface.msg_win_mgr.has_window(jid, account): w = gajim.interface.msg_win_mgr.get_window(jid, account) diff --git a/src/message_control.py b/src/message_control.py index 94f8ad968..a0fe71653 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -52,7 +52,7 @@ class MessageControl: self.print_time_timeout_id = None self.resource = resource - gajim.last_message_time[self.account][contact.jid] = 0 + gajim.last_message_time[self.account][self.get_full_jid()] = 0 self.xml = gtk.glade.XML(GTKGUI_GLADE, widget_name, APP) self.widget = self.xml.get_widget(widget_name) diff --git a/src/message_window.py b/src/message_window.py index 306ecdca1..d325e123d 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -248,7 +248,8 @@ class MessageWindow: ctrl_page = self.notebook.page_num(ctrl.widget) self.notebook.set_current_page(ctrl_page) - def remove_tab(self, ctrl,reason=None): # reason is only for gc (offline status message) + def remove_tab(self, ctrl, reason = None): + '''reason is only for gc (offline status message)''' # Shutdown the MessageControl if not ctrl.allow_shutdown(): return @@ -261,12 +262,12 @@ class MessageWindow: if gajim.interface.systray_enabled: gajim.interface.systray.remove_jid(ctrl.contact.jid, ctrl.account, ctrl.type_id) - del gajim.last_message_time[ctrl.account][ctrl.contact.jid] + del gajim.last_message_time[ctrl.account][ctrl.get_full_jid()] self.disconnect_tab_dnd(ctrl.widget) self.notebook.remove_page(self.notebook.page_num(ctrl.widget)) - fjid = control.get_full_jid() + fjid = ctrl.get_full_jid() del self._controls[ctrl.account][fjid] if len(self._controls[ctrl.account]) == 0: del self._controls[ctrl.account] diff --git a/src/roster_window.py b/src/roster_window.py index 12479a7e1..e1fc71bbb 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2188,9 +2188,9 @@ _('If "%s" accepts this request you will know his or her status.') % jid) break for ctrl in win.controls(): - jid = ctrl.contact.jid - if gajim.last_message_time[acct].has_key(jid): - if time.time() - gajim.last_message_time[acct][jid] < 2: + fjid = ctrl.get_full_jid() + if gajim.last_message_time[acct].has_key(fjid): + if time.time() - gajim.last_message_time[acct][fjid] < 2: recent = True break if unread: @@ -2249,8 +2249,10 @@ _('If "%s" accepts this request you will know his or her status.') % jid) win = gajim.interface.msg_win_mgr.get_window(fjid, account) if not win: self.new_chat(contact, account, resource = resource) - gajim.last_message_time[account][contact.jid] = 0 # long time ago win = gajim.interface.msg_win_mgr.get_window(fjid, account) + ctrl = win.get_control(fjid, account) + # last message is long time ago + gajim.last_message_time[account][ctrl.get_full_jid()] = 0 win.set_active_tab(fjid, account) win.window.present()