From ff32d0ccb371b0951e047c5cc8c727f82bed4f91 Mon Sep 17 00:00:00 2001 From: Jean-Marie Traissard Date: Thu, 20 Mar 2008 20:26:58 +0000 Subject: [PATCH] roster.on_quit_request() cleanups : -Check if there are pending events and send offline even if we don't ask a status message (was a indentation mistake I think) - Really make unread and recent working according to 'notify_on_all_muc_messages' value - be faster, hopefully --- src/chat_control.py | 8 +++++- src/roster_window.py | 67 ++++++++++++++++++++------------------------ 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 483bfab48..942b480e3 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -663,7 +663,13 @@ class ChatControlBase(MessageControl): if not count_as_new: return if kind == 'incoming': - gajim.last_message_time[self.account][full_jid] = time.time() + if not self.type_id == message_control.TYPE_GC or \ + gajim.config.get('notify_on_all_muc_messages') or \ + 'marked' in other_tags_for_text: + # it's a normal message, or a muc message with want to be + # notified about if quitting just after + # other_tags_for_text == ['marked'] --> highlighted gc message + gajim.last_message_time[self.account][full_jid] = time.time() if kind in ('incoming', 'incoming_queue'): gc_message = False diff --git a/src/roster_window.py b/src/roster_window.py index 786d4ec8f..54cfdfa2d 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -4245,45 +4245,38 @@ class RosterWindow: if message is None: # user pressed Cancel to change status message dialog return - # check if we have unread or recent mesages - unread = False - recent = False - if gajim.events.get_nb_events() > 0: - unread = True - for win in gajim.interface.msg_win_mgr.windows(): - unrd = 0 - for ctrl in win.controls(): - if ctrl.type_id == message_control.TYPE_GC: - if gajim.config.get('notify_on_all_muc_messages'): - unrd += ctrl.get_nb_unread() - else: - if ctrl.attention_flag: - unrd += 1 - if unrd: - unread = True - break - for ctrl in win.controls(): - fjid = ctrl.get_full_jid() - if gajim.last_message_time[ctrl.account].has_key(fjid): - if time.time() - gajim.last_message_time[ctrl.account][fjid]\ - < 2: - recent = True - break - if unread or recent: - dialog = dialogs.ConfirmationDialog(_('You have unread messages'), - _('Messages will only be available for reading them later if you' - ' have history enabled and contact is in your roster.')) - if dialog.get_response() != gtk.RESPONSE_OK: - return + # check if we have unread messages + unread = gajim.events.get_nb_events() + if not gajim.config.get('notify_on_all_muc_messages'): + unread_not_to_notify = gajim.events.get_nb_events(['printed_gc_msg']) + unread -= unread_not_to_notify + + # check if we have recent messages + recent = False + for win in gajim.interface.msg_win_mgr.windows(): + for ctrl in win.controls(): + fjid = ctrl.get_full_jid() + if gajim.last_message_time[ctrl.account].has_key(fjid): + if time.time() - gajim.last_message_time[ctrl.account][fjid] < 2: + recent = True + break + if recent: + break + + if unread or recent: + dialog = dialogs.ConfirmationDialog(_('You have unread messages'), + _('Messages will only be available for reading them later if you' + ' have history enabled and contact is in your roster.')) + if dialog.get_response() != gtk.RESPONSE_OK: + return + + self.quit_on_next_offline = 0 + for acct in accounts: + if gajim.connections[acct].connected: + self.quit_on_next_offline += 1 + self.send_status(acct, 'offline', message) - self.quit_on_next_offline = 0 - for acct in accounts: - if gajim.connections[acct].connected: - self.quit_on_next_offline += 1 - self.send_status(acct, 'offline', message) - else: - self.quit_on_next_offline = 0 if not self.quit_on_next_offline: self.quit_gtkgui_interface()