Pass additional_data to groupchats
This commit is contained in:
parent
0c8d88d372
commit
4c45c186c4
3 changed files with 25 additions and 12 deletions
|
@ -1506,8 +1506,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.stanza = self.msg_obj.stanza
|
self.stanza = self.msg_obj.stanza
|
||||||
if not hasattr(self, 'additional_data'):
|
self.additional_data = self.msg_obj.additional_data
|
||||||
self.additional_data = self.msg_obj.additional_data
|
|
||||||
self.id_ = self.msg_obj.stanza.getID()
|
self.id_ = self.msg_obj.stanza.getID()
|
||||||
self.fjid = self.msg_obj.fjid
|
self.fjid = self.msg_obj.fjid
|
||||||
self.msgtxt = self.msg_obj.msgtxt
|
self.msgtxt = self.msg_obj.msgtxt
|
||||||
|
|
|
@ -1072,6 +1072,8 @@ class ConversationTextview(GObject.GObject):
|
||||||
"""
|
"""
|
||||||
Print 'chat' type messages
|
Print 'chat' type messages
|
||||||
"""
|
"""
|
||||||
|
if additional_data is None:
|
||||||
|
additional_data = {}
|
||||||
buffer_ = self.tv.get_buffer()
|
buffer_ = self.tv.get_buffer()
|
||||||
buffer_.begin_user_action()
|
buffer_.begin_user_action()
|
||||||
insert_mark = None
|
insert_mark = None
|
||||||
|
|
|
@ -1097,23 +1097,29 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.is_anonymous = False
|
self.is_anonymous = False
|
||||||
if not obj.nick:
|
if not obj.nick:
|
||||||
# message from server
|
# message from server
|
||||||
self.print_conversation(obj.msgtxt, tim=obj.timestamp,
|
self.print_conversation(
|
||||||
xhtml=obj.xhtml_msgtxt, displaymarking=obj.displaymarking)
|
obj.msgtxt, tim=obj.timestamp,
|
||||||
|
xhtml=obj.xhtml_msgtxt, displaymarking=obj.displaymarking,
|
||||||
|
additional_data=obj.additional_data)
|
||||||
else:
|
else:
|
||||||
# message from someone
|
# message from someone
|
||||||
if obj.has_timestamp:
|
if obj.has_timestamp:
|
||||||
# don't print xhtml if it's an old message.
|
# don't print xhtml if it's an old message.
|
||||||
# Like that xhtml messages are grayed too.
|
# Like that xhtml messages are grayed too.
|
||||||
self.print_old_conversation(obj.msgtxt, contact=obj.nick,
|
self.print_old_conversation(
|
||||||
|
obj.msgtxt, contact=obj.nick,
|
||||||
tim=obj.timestamp, xhtml=None, encrypted=obj.encrypted,
|
tim=obj.timestamp, xhtml=None, encrypted=obj.encrypted,
|
||||||
displaymarking=obj.displaymarking, msg_stanza_id=obj.id_)
|
displaymarking=obj.displaymarking, msg_stanza_id=obj.id_,
|
||||||
|
additional_data=obj.additional_data)
|
||||||
else:
|
else:
|
||||||
if obj.nick == self.nick:
|
if obj.nick == self.nick:
|
||||||
self.last_sent_txt = obj.msgtxt
|
self.last_sent_txt = obj.msgtxt
|
||||||
self.print_conversation(obj.msgtxt, contact=obj.nick,
|
self.print_conversation(
|
||||||
|
obj.msgtxt, contact=obj.nick,
|
||||||
tim=obj.timestamp, xhtml=obj.xhtml_msgtxt,
|
tim=obj.timestamp, xhtml=obj.xhtml_msgtxt,
|
||||||
displaymarking=obj.displaymarking, encrypted=obj.encrypted,
|
displaymarking=obj.displaymarking, encrypted=obj.encrypted,
|
||||||
correct_id=obj.correct_id, msg_stanza_id=obj.id_)
|
correct_id=obj.correct_id, msg_stanza_id=obj.id_,
|
||||||
|
additional_data=obj.additional_data)
|
||||||
obj.needs_highlight = self.needs_visual_notification(obj.msgtxt)
|
obj.needs_highlight = self.needs_visual_notification(obj.msgtxt)
|
||||||
|
|
||||||
def on_private_message(self, nick, sent, msg, tim, xhtml, session, msg_log_id=None,
|
def on_private_message(self, nick, sent, msg, tim, xhtml, session, msg_log_id=None,
|
||||||
|
@ -1168,7 +1174,10 @@ class GroupchatControl(ChatControlBase):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def print_old_conversation(self, text, contact='', tim=None, xhtml = None,
|
def print_old_conversation(self, text, contact='', tim=None, xhtml = None,
|
||||||
displaymarking=None, msg_stanza_id=None, encrypted=None):
|
displaymarking=None, msg_stanza_id=None, encrypted=None, additional_data=None):
|
||||||
|
if additional_data is None:
|
||||||
|
additional_data = {}
|
||||||
|
|
||||||
if contact:
|
if contact:
|
||||||
if contact == self.nick: # it's us
|
if contact == self.nick: # it's us
|
||||||
kind = 'outgoing'
|
kind = 'outgoing'
|
||||||
|
@ -1185,11 +1194,11 @@ class GroupchatControl(ChatControlBase):
|
||||||
small_attr, small_attr + ['restored_message'],
|
small_attr, small_attr + ['restored_message'],
|
||||||
small_attr + ['restored_message'], count_as_new=False, xhtml=xhtml,
|
small_attr + ['restored_message'], count_as_new=False, xhtml=xhtml,
|
||||||
displaymarking=displaymarking, msg_stanza_id=msg_stanza_id,
|
displaymarking=displaymarking, msg_stanza_id=msg_stanza_id,
|
||||||
encrypted=encrypted)
|
encrypted=encrypted, additional_data=additional_data)
|
||||||
|
|
||||||
def print_conversation(self, text, contact='', tim=None, xhtml=None,
|
def print_conversation(self, text, contact='', tim=None, xhtml=None,
|
||||||
graphics=True, displaymarking=None, correct_id=None, msg_stanza_id=None,
|
graphics=True, displaymarking=None, correct_id=None, msg_stanza_id=None,
|
||||||
encrypted=None):
|
encrypted=None, additional_data=None):
|
||||||
"""
|
"""
|
||||||
Print a line in the conversation
|
Print a line in the conversation
|
||||||
|
|
||||||
|
@ -1197,6 +1206,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
(contact = 'info' in such a case).
|
(contact = 'info' in such a case).
|
||||||
If contact is not set: it's a message from the server or help.
|
If contact is not set: it's a message from the server or help.
|
||||||
"""
|
"""
|
||||||
|
if additional_data is None:
|
||||||
|
additional_data = {}
|
||||||
other_tags_for_name = []
|
other_tags_for_name = []
|
||||||
other_tags_for_text = []
|
other_tags_for_text = []
|
||||||
if contact:
|
if contact:
|
||||||
|
@ -1251,7 +1262,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
ChatControlBase.print_conversation_line(self, text, kind, contact, tim,
|
ChatControlBase.print_conversation_line(self, text, kind, contact, tim,
|
||||||
other_tags_for_name, [], other_tags_for_text, xhtml=xhtml,
|
other_tags_for_name, [], other_tags_for_text, xhtml=xhtml,
|
||||||
graphics=graphics, displaymarking=displaymarking,
|
graphics=graphics, displaymarking=displaymarking,
|
||||||
correct_id=correct_id, msg_stanza_id=msg_stanza_id, encrypted=encrypted)
|
correct_id=correct_id, msg_stanza_id=msg_stanza_id, encrypted=encrypted,
|
||||||
|
additional_data=additional_data)
|
||||||
|
|
||||||
def get_nb_unread(self):
|
def get_nb_unread(self):
|
||||||
type_events = ['printed_marked_gc_msg']
|
type_events = ['printed_marked_gc_msg']
|
||||||
|
|
Loading…
Add table
Reference in a new issue