...
 
Commits (2)
......@@ -1369,6 +1369,7 @@ class ChatControl(ChatControlBase):
self.add_message(event.message, kind, tim=event.time,
encrypted=event.encrypted, subject=event.subject,
xhtml=event.xhtml, displaymarking=event.displaymarking,
message_id=event.msg_id,
correct_id=event.correct_id, additional_data=event.additional_data)
if isinstance(event.msg_log_id, int):
message_ids.append(event.msg_log_id)
......
......@@ -326,6 +326,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self.received_history_pos = 0
self.orig_msg = None
# For XEP-0333
self.last_msg_id = None
self.set_emoticon_popover()
# Attach speller
......@@ -996,6 +999,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if restored:
return
if message_id:
self.last_msg_id = message_id
if kind == 'incoming':
if not self.type_id == message_control.TYPE_GC or \
app.config.notify_for_muc(jid) or \
......@@ -1039,6 +1045,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
event_type.type_, self.contact.jid)
event = event_type(text, subject, self, msg_log_id,
msg_id=message_id,
show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
app.events.add_event(self.account, full_jid, event)
......@@ -1195,6 +1202,11 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
types=type_):
# There were events to remove
self.redraw_after_event_removed(jid)
# XEP-0333 Send <displayed> tag.
con.get_module('ChatMarkers').send_displayed_marker(
self.get_full_jid(), self.last_msg_id,
self.type_id == message_control.TYPE_GC)
self.last_msg_id = None
# send chatstate inactive to the one we're leaving
# and active to the one we visit
if self.msg_textview.has_text():
......@@ -1237,8 +1249,14 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
# we are at the end
if not app.events.remove_events(
self.account, jid, types=types_list):
con = app.connections[self.account]
# There were events to remove
self.redraw_after_event_removed(jid)
# XEP-0333 Send <displayed> tag.
con.get_module('ChatMarkers').send_displayed_marker(
self.get_full_jid(), self.last_msg_id,
self.type_id == message_control.TYPE_GC)
self.last_msg_id = None
def _on_scrollbar_button_release(self, scrollbar, event):
if event.get_button()[1] != 1:
......@@ -1303,6 +1321,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
We just removed a 'printed_*' event, redraw contact in roster or
gc_roster and titles in roster and msg_win
"""
if not self.parent_win: # minimized groupchat
return
self.parent_win.redraw_tab(self)
self.parent_win.show_title()
# TODO : get the contact and check get_show_in_roster()
......
......@@ -152,6 +152,7 @@ gajim_common_features = [
nbxmpp.NS_BYTESTREAM,
nbxmpp.NS_FILE,
nbxmpp.NS_MUC,
nbxmpp.NS_CHATMARKERS,
nbxmpp.NS_COMMANDS,
nbxmpp.NS_DISCO_INFO,
nbxmpp.NS_LAST,
......
......@@ -308,6 +308,9 @@ class CommonConnection:
obj.session.last_send = time.time()
msg_iq.setThread(obj.session.thread_id)
if obj.message:
msg_iq.setTag('markable', namespace=nbxmpp.NS_CHATMARKERS)
self._push_stanza_message_outgoing(obj, msg_iq)
def _push_stanza_message_outgoing(self, obj, msg_iq):
......
......@@ -63,8 +63,8 @@ class ChatEvent(Event):
type_ = 'chat'
def __init__(self, message, subject, kind, time_, encrypted, resource,
msg_log_id, correct_id=None, xhtml=None, session=None, form_node=None,
displaymarking=None, sent_forwarded=False, show_in_roster=False,
show_in_systray=True, additional_data=None):
displaymarking=None, sent_forwarded=False, msg_id=None,
show_in_roster=False, show_in_systray=True, additional_data=None):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.message = message
......@@ -80,6 +80,7 @@ class ChatEvent(Event):
self.form_node = form_node
self.displaymarking = displaymarking
self.sent_forwarded = sent_forwarded
self.msg_id = msg_id
if additional_data is None:
from gajim.common.helpers import AdditionalDataDict
additional_data = AdditionalDataDict()
......@@ -94,13 +95,14 @@ class PmEvent(ChatEvent):
class PrintedChatEvent(Event):
type_ = 'printed_chat'
def __init__(self, message, subject, control, msg_log_id, time_=None,
show_in_roster=False, show_in_systray=True):
msg_id=None, show_in_roster=False, show_in_systray=True):
Event.__init__(self, time_, show_in_roster=show_in_roster,
show_in_systray=show_in_systray)
self.message = message
self.subject = subject
self.control = control
self.msg_log_id = msg_log_id
self.msg_id = msg_id
class PrintedGcMsgEvent(PrintedChatEvent):
type_ = 'printed_gc_msg'
......
......@@ -40,6 +40,7 @@ MODULES = [
'bookmarks',
'caps',
'carbons',
'chat_markers',
'chatstates',
'delimiter',
'discovery',
......
......@@ -150,6 +150,11 @@ class Message(BaseModule):
additional_data.set_value(
'gajim', 'user_timestamp', properties.user_timestamp)
marker_id = None
marker = stanza.getTag('displayed', namespace=nbxmpp.NS_CHATMARKERS)
if marker:
marker_id = marker.getAttr('id')
event_attr = {
'conn': self._con,
'stanza': stanza,
......@@ -173,7 +178,8 @@ class Message(BaseModule):
'timestamp': properties.timestamp,
'delayed': properties.user_timestamp is not None,
'muc_pm': properties.is_muc_pm,
'gc_control': gc_control
'gc_control': gc_control,
'marker_id': marker_id
}
app.nec.push_incoming_event(NetworkEvent('update-client-info',
......
......@@ -1213,14 +1213,14 @@ class GroupchatControl(ChatControlBase):
obj.needs_highlight = self.needs_visual_notification(obj.msgtxt)
def on_private_message(self, nick, sent, msg, tim, xhtml, session, msg_log_id=None,
encrypted=False, displaymarking=None):
encrypted=False, displaymarking=None, msg_id=None):
# Do we have a queue?
fjid = self.room_jid + '/' + nick
no_queue = len(app.events.get_events(self.account, fjid)) == 0
event = events.PmEvent(msg, '', 'incoming', tim, encrypted, '',
msg_log_id, xhtml=xhtml, session=session, form_node=None,
displaymarking=displaymarking, sent_forwarded=sent)
displaymarking=displaymarking, sent_forwarded=sent, msg_id=msg_id)
app.events.add_event(self.account, fjid, event)
autopopup = app.config.get('autopopup')
......@@ -1482,7 +1482,8 @@ class GroupchatControl(ChatControlBase):
# otherwise pass it off to the control to be queued
self.on_private_message(nick, obj.sent, obj.msgtxt, obj.timestamp,
obj.xhtml, self.session, msg_log_id=obj.msg_log_id,
encrypted=obj.encrypted, displaymarking=obj.displaymarking)
encrypted=obj.encrypted, displaymarking=obj.displaymarking,
msg_id=obj.message_id)
def _nec_ping(self, obj):
if self.contact.jid != obj.contact.room_jid:
......
......@@ -2650,6 +2650,44 @@ class RosterWindow:
self.application.set_account_actions_state(obj.conn.name, True)
self.draw_account(obj.conn.name)
def _nec_message_received(self, obj):
if not obj.marker_id:
return
if obj.mtype == 'error':
return
if obj.mtype == 'groupchat':
types = ['printed_gc_msg', 'printed_marked_gc_msg']
control = app.interface.msg_win_mgr.get_control(obj.jid,
obj.account)
if not control:
if obj.jid in app.interface.minimized_controls[obj.account]:
control = app.interface.minimized_controls[obj.account][obj.jid]
if not control:
return
if obj.resource != control.nick:
return
event_jid = obj.jid
else:
if not obj.forwarded or not obj.sent:
return
types = ['chat', 'pm', 'printed_chat', 'printed_pm']
control = app.interface.msg_win_mgr.get_control(obj.fjid,
obj.account)
if not control:
control = app.interface.msg_win_mgr.get_gc_control(obj.jid,
obj.account)
event_jid = obj.fjid
# Compare with control.last_msg_id.
events = app.events.get_events(obj.account, event_jid, types)
if not events:
return
if events[-1].msg_id != obj.marker_id:
return
if not app.events.remove_events(obj.account, event_jid, types=types):
# There were events to remove
if control:
control.redraw_after_event_removed(obj.fjid)
def _nec_decrypted_message_received(self, obj):
if not obj.msgtxt:
return True
......@@ -5681,6 +5719,8 @@ class RosterWindow:
self._nec_signed_in)
app.ged.register_event_handler('decrypted-message-received', ged.GUI2,
self._nec_decrypted_message_received)
app.ged.register_event_handler('message-received', ged.GUI2,
self._nec_message_received)
app.ged.register_event_handler('blocking', ged.GUI1,
self._nec_blocking)
app.ged.register_event_handler('style-changed', ged.GUI1,
......
......@@ -257,6 +257,7 @@ class ChatControlSession:
session=self, form_node=obj.form_node,
displaymarking=obj.displaymarking,
sent_forwarded=obj.forwarded and obj.sent,
msg_id=obj.message_id,
show_in_roster=obj.show_in_roster,
show_in_systray=obj.show_in_systray,
additional_data=obj.additional_data)
......