last_message_time is now indexed by full_jid. for [1697]

This commit is contained in:
Yann Leboulanger 2006-03-14 17:13:34 +00:00
parent dab9943bc2
commit 51d57ba717
5 changed files with 17 additions and 11 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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]

View File

@ -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()