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
This commit is contained in:
Jean-Marie Traissard 2008-03-20 20:26:58 +00:00
parent 9e15e4bcab
commit ff32d0ccb3
2 changed files with 37 additions and 38 deletions

View File

@ -663,6 +663,12 @@ class ChatControlBase(MessageControl):
if not count_as_new: if not count_as_new:
return return
if kind == 'incoming': if kind == 'incoming':
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() gajim.last_message_time[self.account][full_jid] = time.time()
if kind in ('incoming', 'incoming_queue'): if kind in ('incoming', 'incoming_queue'):

View File

@ -4245,31 +4245,25 @@ class RosterWindow:
if message is None: if message is None:
# user pressed Cancel to change status message dialog # user pressed Cancel to change status message dialog
return 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
# 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(): for ctrl in win.controls():
fjid = ctrl.get_full_jid() fjid = ctrl.get_full_jid()
if gajim.last_message_time[ctrl.account].has_key(fjid): if gajim.last_message_time[ctrl.account].has_key(fjid):
if time.time() - gajim.last_message_time[ctrl.account][fjid]\ if time.time() - gajim.last_message_time[ctrl.account][fjid] < 2:
< 2:
recent = True recent = True
break break
if recent:
break
if unread or recent: if unread or recent:
dialog = dialogs.ConfirmationDialog(_('You have unread messages'), dialog = dialogs.ConfirmationDialog(_('You have unread messages'),
_('Messages will only be available for reading them later if you' _('Messages will only be available for reading them later if you'
@ -4282,8 +4276,7 @@ class RosterWindow:
if gajim.connections[acct].connected: if gajim.connections[acct].connected:
self.quit_on_next_offline += 1 self.quit_on_next_offline += 1
self.send_status(acct, 'offline', message) self.send_status(acct, 'offline', message)
else:
self.quit_on_next_offline = 0
if not self.quit_on_next_offline: if not self.quit_on_next_offline:
self.quit_gtkgui_interface() self.quit_gtkgui_interface()