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
"""
@ -934,9 +933,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if self.was_at_the_end or kind == 'outgoing':
end = True
textview.print_conversation_line(text, jid, kind, name, tim,
other_tags_for_name, other_tags_for_time, other_tags_for_text,
subject, old_kind, xhtml, simple=simple, graphics=graphics,
displaymarking=displaymarking)
other_tags_for_name, other_tags_for_time, other_tags_for_text,
subject, old_kind, xhtml, simple=simple, graphics=graphics,
displaymarking=displaymarking)
if xep0184_id is not None:
textview.show_xep0184_warning(xep0184_id)
@ -979,18 +978,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
type_ = 'printed_' + self.type_id
event = 'message_received'
show_in_roster = notify.get_show_in_roster(event,
self.account, self.contact, self.session)
self.account, self.contact, self.session)
show_in_systray = notify.get_show_in_systray(event,
self.account, self.contact, type_)
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)
# We need to redraw contact if we show in roster
if show_in_roster:
gajim.interface.roster.draw_contact(self.contact.jid,
self.account)
self.account)
if not self.parent_win:
return
@ -2398,8 +2397,8 @@ class ChatControl(ChatControlBase):
return gajim.nicks[self.account]
def print_conversation(self, text, frm='', tim=None, encrypted=False,
subject=None, xhtml=None, simple=False, xep0184_id=None,
displaymarking=None):
subject=None, xhtml=None, simple=False, xep0184_id=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()
@ -2461,8 +2461,9 @@ class ChatControl(ChatControlBase):
if xhtml:
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)
subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml,
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,9 +2644,14 @@ 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:
gajim.logger.set_read_messages([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)
obj.session.control = gajim.interface.new_chat(contact,