last_message_time is now saved in gajim.py so we begin to count time when we receive the message and not when we print it (fix #162)
This commit is contained in:
parent
348c7314f7
commit
669b7bde6b
|
@ -57,7 +57,6 @@ class Chat:
|
||||||
self.tagOut = {} # holds tag for our nick
|
self.tagOut = {} # holds tag for our nick
|
||||||
self.tagStatus = {} # holds status messages
|
self.tagStatus = {} # holds status messages
|
||||||
self.nb_unread = {}
|
self.nb_unread = {}
|
||||||
self.last_message_time = {}
|
|
||||||
self.last_time_printout = {}
|
self.last_time_printout = {}
|
||||||
self.print_time_timeout_id = {}
|
self.print_time_timeout_id = {}
|
||||||
self.names = {} # what is printed in the tab (eg. user.name)
|
self.names = {} # what is printed in the tab (eg. user.name)
|
||||||
|
@ -293,7 +292,7 @@ class Chat:
|
||||||
|
|
||||||
del self.plugin.windows[self.account][kind][jid]
|
del self.plugin.windows[self.account][kind][jid]
|
||||||
del self.nb_unread[jid]
|
del self.nb_unread[jid]
|
||||||
del self.last_message_time[jid]
|
del gajim.last_message_time[self.account][jid]
|
||||||
del self.last_time_printout[jid]
|
del self.last_time_printout[jid]
|
||||||
del self.xmls[jid]
|
del self.xmls[jid]
|
||||||
del self.tagIn[jid]
|
del self.tagIn[jid]
|
||||||
|
@ -308,7 +307,7 @@ class Chat:
|
||||||
|
|
||||||
self.set_compact_view(self.always_compact_view)
|
self.set_compact_view(self.always_compact_view)
|
||||||
self.nb_unread[jid] = 0
|
self.nb_unread[jid] = 0
|
||||||
self.last_message_time[jid] = 0
|
gajim.last_message_time[self.account][jid] = 0
|
||||||
self.last_time_printout[jid] = float(0.0)
|
self.last_time_printout[jid] = float(0.0)
|
||||||
|
|
||||||
if gajim.config.get('use_speller') and 'gtkspell' in globals():
|
if gajim.config.get('use_speller') and 'gtkspell' in globals():
|
||||||
|
@ -901,7 +900,7 @@ class Chat:
|
||||||
return
|
return
|
||||||
|
|
||||||
if kind == 'incoming':
|
if kind == 'incoming':
|
||||||
self.last_message_time[jid] = time.time()
|
gajim.last_message_time[self.account][jid] = time.time()
|
||||||
|
|
||||||
if (jid != self.get_active_jid() or \
|
if (jid != self.get_active_jid() or \
|
||||||
not self.window.is_active() or \
|
not self.window.is_active() or \
|
||||||
|
|
|
@ -41,4 +41,6 @@ if LANG:
|
||||||
else:
|
else:
|
||||||
LANG = 'en'
|
LANG = 'en'
|
||||||
|
|
||||||
|
last_message_time = {} # list of time of the latest incomming message
|
||||||
|
# {acct1: {jid1: time1, jid2: time2}, }
|
||||||
encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}
|
encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}
|
||||||
|
|
|
@ -1164,6 +1164,8 @@ _('To change the account name, it must be disconnected.')).get_response()
|
||||||
self.plugin.sleeper_state[name] = \
|
self.plugin.sleeper_state[name] = \
|
||||||
self.plugin.sleeper_state[self.account]
|
self.plugin.sleeper_state[self.account]
|
||||||
gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account]
|
gajim.encrypted_chats[name] = gajim.encrypted_chats[self.account]
|
||||||
|
gajim.last_message_time[name] = \
|
||||||
|
gajim.last_message_time[self.account]
|
||||||
#upgrade account variable in opened windows
|
#upgrade account variable in opened windows
|
||||||
for kind in ['infos', 'chats', 'gc', 'gc_config']:
|
for kind in ['infos', 'chats', 'gc', 'gc_config']:
|
||||||
for j in self.plugin.windows[name][kind]:
|
for j in self.plugin.windows[name][kind]:
|
||||||
|
@ -1180,6 +1182,7 @@ _('To change the account name, it must be disconnected.')).get_response()
|
||||||
del self.plugin.roster.contacts[self.account]
|
del self.plugin.roster.contacts[self.account]
|
||||||
del self.plugin.sleeper_state[self.account]
|
del self.plugin.sleeper_state[self.account]
|
||||||
del gajim.encrypted_chats[self.account]
|
del gajim.encrypted_chats[self.account]
|
||||||
|
del gajim.last_time_message[self.account]
|
||||||
gajim.connections[self.account].name = name
|
gajim.connections[self.account].name = name
|
||||||
gajim.connections[name] = gajim.connections[self.account]
|
gajim.connections[name] = gajim.connections[self.account]
|
||||||
del gajim.connections[self.account]
|
del gajim.connections[self.account]
|
||||||
|
@ -1230,6 +1233,7 @@ _('To change the account name, it must be disconnected.')).get_response()
|
||||||
self.plugin.allow_notifications[name] = False
|
self.plugin.allow_notifications[name] = False
|
||||||
self.plugin.sleeper_state[name] = 0
|
self.plugin.sleeper_state[name] = 0
|
||||||
gajim.encrypted_chats[name] = []
|
gajim.encrypted_chats[name] = []
|
||||||
|
gajim.last_message_time[name] = {}
|
||||||
#refresh accounts window
|
#refresh accounts window
|
||||||
if self.plugin.windows.has_key('accounts'):
|
if self.plugin.windows.has_key('accounts'):
|
||||||
self.plugin.windows['accounts'].init_accounts()
|
self.plugin.windows['accounts'].init_accounts()
|
||||||
|
|
|
@ -509,6 +509,7 @@ class Interface:
|
||||||
self.roster.to_be_removed[name] = []
|
self.roster.to_be_removed[name] = []
|
||||||
self.sleeper_state[name] = 0
|
self.sleeper_state[name] = 0
|
||||||
gajim.encrypted_chats[name] = []
|
gajim.encrypted_chats[name] = []
|
||||||
|
gajim.last_message_time[name] = {}
|
||||||
if self.windows.has_key('accounts'):
|
if self.windows.has_key('accounts'):
|
||||||
self.windows['accounts'].init_accounts()
|
self.windows['accounts'].init_accounts()
|
||||||
self.roster.draw_roster()
|
self.roster.draw_roster()
|
||||||
|
@ -846,6 +847,7 @@ class Interface:
|
||||||
#2:autoaway and use sleeper
|
#2:autoaway and use sleeper
|
||||||
#3:autoxa and use sleeper
|
#3:autoxa and use sleeper
|
||||||
gajim.encrypted_chats[a] = []
|
gajim.encrypted_chats[a] = []
|
||||||
|
gajim.last_message_time[a] = {}
|
||||||
|
|
||||||
self.roster = roster_window.RosterWindow(self)
|
self.roster = roster_window.RosterWindow(self)
|
||||||
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
|
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
|
||||||
|
|
|
@ -106,7 +106,7 @@ class GroupchatWindow(chat.Chat):
|
||||||
def on_groupchat_window_delete_event(self, widget, event):
|
def on_groupchat_window_delete_event(self, widget, event):
|
||||||
"""close window"""
|
"""close window"""
|
||||||
for room_jid in self.xmls:
|
for room_jid in self.xmls:
|
||||||
if time.time() - self.last_message_time[room_jid] < 2:
|
if time.time() - gajim.last_message_time[self.account][room_jid] < 2:
|
||||||
dialog = dialogs.ConfirmationDialog(
|
dialog = dialogs.ConfirmationDialog(
|
||||||
_('You just received a new message in room "%s"') %room_jid.split('@')[0],
|
_('You just received a new message in room "%s"') %room_jid.split('@')[0],
|
||||||
_('If you close this window, this message will be lost.')
|
_('If you close this window, this message will be lost.')
|
||||||
|
@ -795,7 +795,7 @@ class GroupchatWindow(chat.Chat):
|
||||||
menu.reposition()
|
menu.reposition()
|
||||||
|
|
||||||
def remove_tab(self, room_jid):
|
def remove_tab(self, room_jid):
|
||||||
if time.time() - self.last_message_time[room_jid] < 2:
|
if time.time() - gajim.last_message_time[self.account][room_jid] < 2:
|
||||||
dialog = dialogs.ConfirmationDialog(
|
dialog = dialogs.ConfirmationDialog(
|
||||||
_('You just received a new message in room "%s"'),
|
_('You just received a new message in room "%s"'),
|
||||||
_('If you close this tab, the message will be lost.') % \
|
_('If you close this tab, the message will be lost.') % \
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
|
||||||
unread = True
|
unread = True
|
||||||
break
|
break
|
||||||
for jid in win.users:
|
for jid in win.users:
|
||||||
if time.time() - win.last_message_time[jid] < 2:
|
if time.time() - gajim.last_message_time[account][jid] < 2:
|
||||||
recent = True
|
recent = True
|
||||||
break
|
break
|
||||||
if unread:
|
if unread:
|
||||||
|
|
|
@ -179,7 +179,8 @@ class TabbedChatWindow(chat.Chat):
|
||||||
def on_tabbed_chat_window_delete_event(self, widget, event):
|
def on_tabbed_chat_window_delete_event(self, widget, event):
|
||||||
"""close window"""
|
"""close window"""
|
||||||
for jid in self.users:
|
for jid in self.users:
|
||||||
if time.time() - self.last_message_time[jid] < 2: # 2 seconds
|
if time.time() - gajim.last_message_time[self.account][jid] < 2:
|
||||||
|
# 2 seconds
|
||||||
dialog = dialogs.ConfirmationDialog(
|
dialog = dialogs.ConfirmationDialog(
|
||||||
_('You just received a new message from "%s"' % jid),
|
_('You just received a new message from "%s"' % jid),
|
||||||
_('If you close the window, this message will be lost.'))
|
_('If you close the window, this message will be lost.'))
|
||||||
|
@ -220,7 +221,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
message_buffer.set_text('', -1)
|
message_buffer.set_text('', -1)
|
||||||
|
|
||||||
def remove_tab(self, jid):
|
def remove_tab(self, jid):
|
||||||
if time.time() - self.last_message_time[jid] < 2:
|
if time.time() - gajim.last_message_time[self.account][jid] < 2:
|
||||||
dialog = dialogs.ConfirmationDialog(
|
dialog = dialogs.ConfirmationDialog(
|
||||||
_('You just received a new message from "%s"' % jid),
|
_('You just received a new message from "%s"' % jid),
|
||||||
_('If you close this tab, the message will be lost.'))
|
_('If you close this tab, the message will be lost.'))
|
||||||
|
|
Loading…
Reference in New Issue