changeset 97675d403519 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=97675d403519
description: don't mark received message as read until it's really read by
user. Fixes #7094
diffstat:
src/chat_control.py | 47 ++++++++++++++++++++++++-----------------------
src/roster_window.py | 21 +++++++++++++++++++--
2 files changed, 43 insertions(+), 25 deletions(-)
diffs (146 lines):
diff -r 4a8be3052e4c -r 97675d403519 src/chat_control.py
--- a/src/chat_control.py Tue Mar 06 11:51:11 2012 +0100
+++ b/src/chat_control.py Thu Mar 08 20:03:17 2012 +0100
@@ -920,10 +920,9 @@
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 @@
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 @@
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_)
-
- event = gajim.events.create_event(type_, (self,),
+ self.account, self.contact, type_)
+
+ 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 @@
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 @@
# 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 @@
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:
diff -r 4a8be3052e4c -r 97675d403519 src/roster_window.py
--- a/src/roster_window.py Tue Mar 06 11:51:11 2012 +0100
+++ b/src/roster_window.py Thu Mar 08 20:03:17 2012 +0100
@@ -1889,6 +1889,18 @@
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 @@
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,
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits