don't mark received message as read until it's really read by user. Fixes #7094

This commit is contained in:
Yann Leboulanger 2012-03-08 20:03:17 +01:00
parent 72be2c49e0
commit 1d980fa2ef
2 changed files with 42 additions and 24 deletions

View File

@ -920,10 +920,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self.received_history_pos = pos
def print_conversation_line(self, text, kind, name, tim,
other_tags_for_name=[], other_tags_for_time=[],
other_tags_for_text=[], count_as_new=True, subject=None,
old_kind=None, xhtml=None, simple=False, xep0184_id=None,
graphics=True, displaymarking=None):
other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[],
count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False,
xep0184_id=None, graphics=True, displaymarking=None, msg_id=None):
"""
Print 'chat' type messages
"""
@ -983,7 +982,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
show_in_systray = notify.get_show_in_systray(event,
self.account, self.contact, type_)
event = gajim.events.create_event(type_, (self,),
event = gajim.events.create_event(type_, (self, msg_id),
show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
gajim.events.add_event(self.account, full_jid, event)
@ -2399,7 +2398,7 @@ class ChatControl(ChatControlBase):
def print_conversation(self, text, frm='', tim=None, encrypted=False,
subject=None, xhtml=None, simple=False, xep0184_id=None,
displaymarking=None):
displaymarking=None, msg_id=None):
"""
Print a line in the conversation
@ -2430,21 +2429,22 @@ class ChatControl(ChatControlBase):
# ESessions
if not encrypted:
msg = _('The following message was NOT encrypted')
ChatControlBase.print_conversation_line(self, msg, 'status', '',
tim)
ChatControlBase.print_conversation_line(self, msg, 'status',
'', tim)
else:
# GPG encryption
if encrypted and not self.gpg_is_active:
msg = _('The following message was encrypted')
ChatControlBase.print_conversation_line(self, msg, 'status', '',
tim)
# turn on OpenPGP if this was in fact a XEP-0027 encrypted message
ChatControlBase.print_conversation_line(self, msg, 'status',
'', tim)
# turn on OpenPGP if this was in fact a XEP-0027 encrypted
# message
if encrypted == 'xep27':
self._toggle_gpg()
elif not encrypted and self.gpg_is_active:
msg = _('The following message was NOT encrypted')
ChatControlBase.print_conversation_line(self, msg, 'status', '',
tim)
ChatControlBase.print_conversation_line(self, msg, 'status',
'', tim)
if not frm:
kind = 'incoming'
name = contact.get_shown_name()
@ -2462,7 +2462,8 @@ class ChatControl(ChatControlBase):
xhtml = '<body xmlns="%s">%s</body>' % (NS_XHTML, xhtml)
ChatControlBase.print_conversation_line(self, text, kind, name, tim,
subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml,
simple=simple, xep0184_id=xep0184_id, displaymarking=displaymarking)
simple=simple, xep0184_id=xep0184_id, displaymarking=displaymarking,
msg_id=msg_id)
if text.startswith('/me ') or text.startswith('/me\n'):
self.old_msg_kind = None
else:

View File

@ -1889,6 +1889,18 @@ class RosterWindow:
Only performed if removal was requested before but the contact still had
pending events
"""
msg_ids = []
for ev in event_list:
if ev.type_ != 'printed_chat':
continue
if len(ev.parameters) > 1 and ev.parameters[1]:
# There is a msg_id
msg_ids.append(ev.parameters[1])
if msg_ids:
gajim.logger.set_read_messages(msg_ids)
contact_list = ((event.jid.split('/')[0], event.account) for event in \
event_list)
@ -2632,8 +2644,13 @@ class RosterWindow:
obj.session.control.print_conversation(obj.msgtxt, typ,
tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
xhtml=obj.xhtml, displaymarking=obj.displaymarking)
xhtml=obj.xhtml, displaymarking=obj.displaymarking,
msg_id=obj.msg_id)
if obj.msg_id:
pw = obj.session.control.parent_win
end = obj.session.control.was_at_the_end
if not pw or (pw.get_active_control() and obj.session.control \
== pw.get_active_control() and pw.is_active() and end):
gajim.logger.set_read_messages([obj.msg_id])
elif obj.popup:
contact = gajim.contacts.get_contact(obj.conn.name, obj.jid)