Commit ff8a1f28 authored by Philipp Hörist's avatar Philipp Hörist

Refactor XHTML event code

- Move xhtml data into additional_data
- Remove xhtml event attribute
- Allows now to store both message and xhtml data in the database
- Always store xhtml data
parent 83bff1b8
Pipeline #4442 passed with stages
in 4 minutes and 58 seconds
......@@ -34,7 +34,7 @@ from gi.repository import Gio
from gi.repository import Pango
from gi.repository import GLib
from gi.repository import Gdk
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
from nbxmpp.protocol import NS_XHTML_IM, NS_FILE, NS_MUC
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5
......@@ -824,7 +824,6 @@ class ChatControl(ChatControlBase):
typ,
tim=obj.properties.timestamp,
subject=obj.properties.subject,
xhtml=obj.xhtml,
displaymarking=obj.displaymarking,
msg_log_id=obj.msg_log_id,
message_id=obj.properties.id,
......@@ -861,11 +860,13 @@ class ChatControl(ChatControlBase):
gtkgui_helpers.remove_css_class(
self.msg_textview, 'gajim-msg-correcting')
self.add_message(obj.message, self.contact.jid, tim=obj.timestamp,
xhtml=obj.xhtml,
displaymarking=displaymarking, message_id=message_id,
correct_id=obj.correct_id,
additional_data=obj.additional_data)
self.add_message(obj.message,
self.contact.jid,
tim=obj.timestamp,
displaymarking=displaymarking,
message_id=message_id,
correct_id=obj.correct_id,
additional_data=obj.additional_data)
def send_message(self, message, xhtml=None,
process_commands=True, attention=False):
......@@ -894,10 +895,17 @@ class ChatControl(ChatControlBase):
def get_our_nick(self):
return app.nicks[self.account]
def add_message(self, text, frm='', tim=None,
subject=None, xhtml=None,
displaymarking=None, msg_log_id=None, correct_id=None,
message_id=None, additional_data=None, error=None):
def add_message(self,
text,
frm='',
tim=None,
subject=None,
displaymarking=None,
msg_log_id=None,
correct_id=None,
message_id=None,
additional_data=None,
error=None):
"""
Print a line in the conversation
......@@ -930,7 +938,7 @@ class ChatControl(ChatControlBase):
name = self.get_our_nick()
ChatControlBase.add_message(self, text, kind, name, tim,
subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml,
subject=subject, old_kind=self.old_msg_kind,
displaymarking=displaymarking,
msg_log_id=msg_log_id, message_id=message_id,
correct_id=correct_id, additional_data=additional_data,
......@@ -1246,9 +1254,6 @@ class ChatControl(ChatControlBase):
tim = float(row.time)
xhtml = None
if msg.startswith('<body '):
xhtml = msg
if row.subject:
msg = _('Subject: %(subject)s\n%(message)s') % \
{'subject': row.subject, 'message': msg}
......@@ -1259,7 +1264,6 @@ class ChatControl(ChatControlBase):
tim,
restored=True,
old_kind=local_old_kind,
xhtml=xhtml,
additional_data=additional_data,
message_id=row.message_id,
marker=row.marker,
......@@ -1289,11 +1293,14 @@ class ChatControl(ChatControlBase):
kind = 'print_queue'
if event.sent_forwarded:
kind = 'out'
self.add_message(event.message, kind, tim=event.time,
subject=event.subject,
xhtml=event.xhtml, displaymarking=event.displaymarking,
correct_id=event.correct_id, message_id=event.message_id,
additional_data=event.additional_data)
self.add_message(event.message,
kind,
tim=event.time,
subject=event.subject,
displaymarking=event.displaymarking,
correct_id=event.correct_id,
message_id=event.message_id,
additional_data=event.additional_data)
if isinstance(event.msg_log_id, int):
message_ids.append(event.msg_log_id)
......
......@@ -907,12 +907,22 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
chatstate = con.get_module('Chatstate').get_active_chatstate(
self.contact)
app.nec.push_outgoing_event(MessageOutgoingEvent(None,
account=self.account, jid=self.contact.jid, message=message,
type_=type_, chatstate=chatstate,
resource=resource, user_nick=self.user_nick, xhtml=xhtml,
label=label, control=self, attention=attention, correct_id=correct_id,
automatic_message=False, encryption=self.encryption))
event = MessageOutgoingEvent(None,
account=self.account,
jid=self.contact.jid,
message=message,
type_=type_,
chatstate=chatstate,
resource=resource,
user_nick=self.user_nick,
label=label,
control=self,
attention=attention,
correct_id=correct_id,
automatic_message=False,
encryption=self.encryption)
event.additional_data.set_value('gajim', 'xhtml', xhtml)
app.nec.push_outgoing_event(event)
# Record the history of sent messages
self.save_message(message, 'sent')
......@@ -988,7 +998,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
def add_message(self, text, kind, name, tim,
other_tags_for_name=None, other_tags_for_time=None,
other_tags_for_text=None, restored=False, subject=None,
old_kind=None, xhtml=None,
old_kind=None,
displaymarking=None, msg_log_id=None,
message_id=None, correct_id=None, additional_data=None,
marker=None, error=None):
......@@ -1014,7 +1024,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
textview.print_conversation_line(text, kind, name, tim,
other_tags_for_name, other_tags_for_time, other_tags_for_text,
subject, old_kind, xhtml,
subject, old_kind,
displaymarking=displaymarking, message_id=message_id,
correct_id=correct_id, additional_data=additional_data,
marker=marker, error=error)
......
......@@ -165,6 +165,7 @@ gajim_common_features = [
nbxmpp.NS_CONFERENCE,
nbxmpp.NS_CORRECT,
nbxmpp.NS_EME,
nbxmpp.NS_XHTML_IM,
nbxmpp.NS_HASHES_2,
nbxmpp.NS_HASHES_MD5,
nbxmpp.NS_HASHES_SHA1,
......
......@@ -29,11 +29,11 @@ through ClientCaps objects which are hold by contact instances.
import logging
from nbxmpp import (NS_XHTML_IM, NS_ESESSION, NS_CHATSTATES,
from nbxmpp import (NS_ESESSION, NS_CHATSTATES,
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO,
NS_JINGLE_FILE_TRANSFER_5)
# Features where we cannot safely assume that the other side supports them
FEATURE_BLACKLIST = [NS_CHATSTATES, NS_XHTML_IM, NS_ESESSION,
FEATURE_BLACKLIST = [NS_CHATSTATES, NS_ESESSION,
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO,
NS_JINGLE_FILE_TRANSFER_5]
......
......@@ -109,7 +109,7 @@ class Config:
'sort_by_show_in_roster': [opt_bool, True, '', True],
'sort_by_show_in_muc': [opt_bool, False, '', True],
'use_speller': [opt_bool, False, ],
'ignore_incoming_xhtml': [opt_bool, False, ],
'show_xhtml': [opt_bool, True, ],
'speller_language': [opt_str, '', _('Language used for spell checking.')],
'print_time': [opt_str, 'always', _('\'always\' - print time for every message.\n\'sometimes\' - print time every print_ichat_every_foo_minutes minute.\n\'never\' - never print time.')],
'emoticons_theme': [opt_str, 'noto-emoticons', '', True],
......@@ -224,7 +224,6 @@ class Config:
'print_join_left_default': [opt_bool, False, _('Default Setting: Show a status message for every join or leave in a group chat.')],
'print_status_muc_default': [opt_bool, False, _('Default Setting: Show a status message for all status changes (away, dnd, etc.) of users in a group chat.')],
'log_contact_status_changes': [opt_bool, False],
'log_xhtml_messages': [opt_bool, False, _('Store XHTML messages in chat history instead of plain text messages.')],
'roster_window_skip_taskbar': [opt_bool, False, _('Don\'t show contact list window in the system taskbar.')],
'use_urgency_hint': [opt_bool, True, _('If enabled, Gajim makes the window flash (the default behaviour in most Window Managers) when holding pending events.')],
'notification_timeout': [opt_int, 5],
......
......@@ -210,16 +210,22 @@ class CommonConnection:
else:
fjid = obj.get_full_jid()
xhtml = obj.additional_data.get_value('gajim', 'xhtml', None)
if obj.type_ == 'chat':
msg_iq = nbxmpp.Message(body=obj.message, typ=obj.type_,
xhtml=obj.xhtml)
msg_iq = nbxmpp.Message(body=obj.message,
typ=obj.type_,
xhtml=xhtml)
else:
if obj.subject:
msg_iq = nbxmpp.Message(body=obj.message, typ='normal',
subject=obj.subject, xhtml=obj.xhtml)
msg_iq = nbxmpp.Message(body=obj.message,
typ='normal',
subject=obj.subject,
xhtml=xhtml)
else:
msg_iq = nbxmpp.Message(body=obj.message, typ='normal',
xhtml=obj.xhtml)
msg_iq = nbxmpp.Message(body=obj.message,
typ='normal',
xhtml=xhtml)
if obj.correct_id:
msg_iq.setTag('replace', attrs={'id': obj.correct_id},
......@@ -324,13 +330,13 @@ class CommonConnection:
if not app.config.should_log(self.name, jid):
return
if obj.xhtml and app.config.get('log_xhtml_messages'):
obj.message = '<body xmlns="%s">%s</body>' % (nbxmpp.NS_XHTML,
obj.xhtml)
if obj.message is None:
return
app.logger.insert_into_logs(self.name, jid, obj.timestamp, obj.kind,
app.logger.insert_into_logs(self.name,
jid,
obj.timestamp,
obj.kind,
message=obj.message,
subject=obj.subject,
additional_data=obj.additional_data,
......@@ -1619,8 +1625,11 @@ class Connection(CommonConnection, ConnectionHandlers):
if not app.account_is_connected(self.name):
return
msg_iq = nbxmpp.Message(obj.jid, obj.message, typ='groupchat',
xhtml=obj.xhtml)
xhtml = obj.additional_data.get_value('gajim', 'xhtml', None)
msg_iq = nbxmpp.Message(obj.jid,
obj.message,
typ='groupchat',
xhtml=xhtml)
obj.stanza_id = self.connection.getAnID()
msg_iq.setID(obj.stanza_id)
......
......@@ -578,7 +578,6 @@ class MessageOutgoingEvent(nec.NetworkOutgoingEvent):
self.stanza_id = None
self.resource = None
self.user_nick = None
self.xhtml = None
self.label = None
self.session = None
self.delayed = None
......@@ -620,7 +619,6 @@ class GcMessageOutgoingEvent(nec.NetworkOutgoingEvent):
self.additional_data = AdditionalDataDict()
self.message = ''
self.chatstate = None
self.xhtml = None
self.stanza_id = None
self.label = None
self.callback = None
......
......@@ -62,7 +62,7 @@ class Event:
class ChatEvent(Event):
type_ = 'chat'
def __init__(self, message, subject, kind, time_, resource,
msg_log_id, correct_id=None, message_id=None, xhtml=None, session=None,
msg_log_id, correct_id=None, message_id=None, session=None,
displaymarking=None, sent_forwarded=False, show_in_roster=False,
show_in_systray=True, additional_data=None):
Event.__init__(self, time_, show_in_roster=show_in_roster,
......@@ -75,7 +75,6 @@ class ChatEvent(Event):
self.msg_log_id = msg_log_id
self.message_id = message_id
self.correct_id = correct_id
self.xhtml = xhtml
self.session = session
self.displaymarking = displaymarking
self.sent_forwarded = sent_forwarded
......
......@@ -1091,8 +1091,6 @@ def update_optional_features(account=None):
features.append(nbxmpp.NS_BOOKMARKS_2 + '+notify')
elif app.connections[account_].get_module('Bookmarks').using_bookmark_1:
features.append(nbxmpp.NS_BOOKMARKS + '+notify')
if not app.config.get('ignore_incoming_xhtml'):
features.append(nbxmpp.NS_XHTML_IM)
if app.is_installed('FARSTREAM'):
features.append(nbxmpp.NS_JINGLE_RTP)
features.append(nbxmpp.NS_JINGLE_RTP_AUDIO)
......
......@@ -160,7 +160,7 @@ class Message(BaseModule):
'gajim', 'user_timestamp', properties.user_timestamp)
parse_oob(properties, additional_data)
xhtml = parse_xhtml(properties)
parse_xhtml(properties, additional_data)
app.nec.push_incoming_event(NetworkEvent('update-client-info',
account=self._account,
......@@ -188,7 +188,6 @@ class Message(BaseModule):
'session': session,
'delayed': properties.user_timestamp is not None,
'gc_control': gc_control,
'xhtml': xhtml,
'popup': False,
'msg_log_id': None,
'displaymarking': parse_securitylabel(stanza),
......@@ -202,7 +201,6 @@ class Message(BaseModule):
event_attr.update({
'room_jid': jid,
'nickname': resource,
'xhtml_msgtxt': xhtml,
'nick': resource or '',
})
event = NetworkEvent('gc-message-received', **event_attr)
......
......@@ -16,7 +16,7 @@
import logging
from gajim.common import app
from gajim.common.i18n import get_rfc5646_lang
log = logging.getLogger('gajim.c.m.misc')
......@@ -43,7 +43,9 @@ def parse_correction(properties):
# XEP-0071: XHTML-IM
def parse_xhtml(properties):
if app.config.get('ignore_incoming_xhtml'):
return None
return properties.xhtml
def parse_xhtml(properties, additional_data):
if not properties.has_xhtml:
return
body = properties.xhtml.get_body(get_rfc5646_lang())
additional_data.set_value('gajim', 'xhtml', body)
......@@ -82,6 +82,7 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
additional_data = AdditionalDataDict()
parse_oob(properties, additional_data)
parse_xhtml(properties, additional_data)
if properties.is_encrypted:
additional_data['encrypted'] = properties.encrypted.additional_data
......@@ -103,7 +104,6 @@ class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
'msgtxt': msgtxt,
'session': session,
'gc_control': None,
'xhtml': parse_xhtml(properties),
'popup': False,
'msg_log_id': None,
'displaymarking': None,
......
......@@ -913,7 +913,7 @@ class ConversationTextview(GObject.GObject):
def print_conversation_line(self, text, kind, name, tim,
other_tags_for_name=None, other_tags_for_time=None, other_tags_for_text=None,
subject=None, old_kind=None, xhtml=None, graphics=True,
subject=None, old_kind=None, graphics=True,
displaymarking=None, message_id=None, correct_id=None, additional_data=None,
marker=None, error=None):
"""
......@@ -1028,7 +1028,7 @@ class ConversationTextview(GObject.GObject):
self.print_subject(subject, iter_=iter_)
iter_ = self.print_real_text(text, text_tags, name, xhtml, graphics=graphics,
iter_ = self.print_real_text(text, text_tags, name, graphics=graphics,
mark=insert_mark, additional_data=additional_data)
message_icons = MessageIcons()
......@@ -1256,7 +1256,7 @@ class ConversationTextview(GObject.GObject):
buffer_.insert(end_iter, subject)
self.print_empty_line(end_iter)
def print_real_text(self, text, text_tags=None, name=None, xhtml=None,
def print_real_text(self, text, text_tags=None, name=None,
graphics=True, mark=None, additional_data=None):
"""
Add normal and special text. call this to add text
......@@ -1270,7 +1270,9 @@ class ConversationTextview(GObject.GObject):
iter_ = buffer_.get_end_iter()
else:
iter_ = buffer_.get_iter_at_mark(mark)
if xhtml:
xhtml = additional_data.get_value('gajim', 'xhtml', False)
if xhtml and app.config.get('show_xhtml'):
try:
if name and (text.startswith('/me ') or text.startswith('/me\n')):
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
......
......@@ -673,11 +673,10 @@
</child>
<child>
<object class="GtkCheckButton" id="xhtml_checkbutton">
<property name="label" translatable="yes">_Ignore formatting of incoming messages</property>
<property name="label" translatable="yes">_Show XHTML formatting</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Some messages may include rich content (xhtml formatting, colors etc). If checked, Gajim will just display the plain message text.</property>
<property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
......
......@@ -832,7 +832,6 @@ class GroupchatControl(ChatControlBase):
# message from server
self.add_message(obj.msgtxt,
tim=obj.properties.timestamp,
xhtml=obj.xhtml_msgtxt,
displaymarking=obj.displaymarking,
additional_data=obj.additional_data)
else:
......@@ -841,16 +840,14 @@ class GroupchatControl(ChatControlBase):
self.add_message(obj.msgtxt,
contact=obj.nick,
tim=obj.properties.timestamp,
xhtml=obj.xhtml_msgtxt,
displaymarking=obj.displaymarking,
correct_id=obj.correct_id,
message_id=obj.properties.id,
additional_data=obj.additional_data)
obj.needs_highlight = self.needs_visual_notification(obj.msgtxt)
def on_private_message(self, nick, sent, msg, tim, xhtml, session,
msg_log_id=None,
displaymarking=None):
def on_private_message(self, nick, sent, msg, tim, session, additional_data,
msg_log_id=None, displaymarking=None):
# Do we have a queue?
fjid = self.room_jid + '/' + nick
......@@ -860,10 +857,10 @@ class GroupchatControl(ChatControlBase):
tim,
'',
msg_log_id,
xhtml=xhtml,
session=session,
displaymarking=displaymarking,
sent_forwarded=sent)
sent_forwarded=sent,
additional_data=additional_data)
app.events.add_event(self.account, fjid, event)
autopopup = app.config.get('autopopup')
......@@ -882,7 +879,7 @@ class GroupchatControl(ChatControlBase):
if contact:
app.interface.roster.draw_contact(self.room_jid, self.account)
def add_message(self, text, contact='', tim=None, xhtml=None,
def add_message(self, text, contact='', tim=None,
displaymarking=None, correct_id=None, message_id=None,
additional_data=None):
"""
......@@ -923,12 +920,18 @@ class GroupchatControl(ChatControlBase):
self.check_focus_out_line()
ChatControlBase.add_message(
self, text, kind, contact, tim,
other_tags_for_name, [], other_tags_for_text, xhtml=xhtml,
displaymarking=displaymarking,
correct_id=correct_id, message_id=message_id,
additional_data=additional_data)
ChatControlBase.add_message(self,
text,
kind,
contact,
tim,
other_tags_for_name,
[],
other_tags_for_text,
displaymarking=displaymarking,
correct_id=correct_id,
message_id=message_id,
additional_data=additional_data)
def get_nb_unread(self):
type_events = ['printed_marked_gc_msg']
......@@ -1099,7 +1102,6 @@ class GroupchatControl(ChatControlBase):
obj.msgtxt,
frm,
tim=obj.properties.timestamp,
xhtml=obj.xhtml,
displaymarking=obj.displaymarking,
message_id=obj.properties.id,
correct_id=obj.correct_id)
......@@ -1109,8 +1111,8 @@ class GroupchatControl(ChatControlBase):
obj.properties.is_sent_carbon,
obj.msgtxt,
obj.properties.timestamp,
obj.xhtml,
self.session,
obj.additional_data,
msg_log_id=obj.msg_log_id,
displaymarking=obj.displaymarking)
......@@ -1574,10 +1576,17 @@ class GroupchatControl(ChatControlBase):
self.contact)
# Send the message
app.nec.push_outgoing_event(GcMessageOutgoingEvent(
None, account=self.account, jid=self.room_jid, message=message,
xhtml=xhtml, label=label, chatstate=chatstate,
correct_id=correct_id, automatic_message=False))
event = GcMessageOutgoingEvent(None,
account=self.account,
jid=self.room_jid,
message=message,
label=label,
chatstate=chatstate,
correct_id=correct_id,
automatic_message=False)
event.additional_data.set_value('gajim', 'xhtml', xhtml)
app.nec.push_outgoing_event(event)
self.msg_textview.get_buffer().set_text('')
self.msg_textview.grab_focus()
......
......@@ -616,21 +616,17 @@ class HistoryWindow(Gtk.ApplicationWindow):
buf.insert(end_iter, format_)
if subject:
message = _('Subject: %s\n') % subject + message
xhtml = None
if message.startswith('<body '):
xhtml = message
if tag_msg:
self.history_textview.print_real_text(
message, [tag_msg],
message,
[tag_msg],
name=contact_name,
xhtml=xhtml,
additional_data=additional_data)
else:
self.history_textview.print_real_text(
message,
name=contact_name,
xhtml=xhtml,
additional_data=additional_data)
self.history_textview.print_real_text('\n', text_tags=['eol'])
......
......@@ -949,6 +949,13 @@ class HtmlTextView(Gtk.TextView):
parser = xml.sax.make_parser()
parser.setContentHandler(HtmlHandler(textview, conv_textview, eob))
parser.parse(StringIO(html))
self._delete_last_char(buffer_, eob)
@staticmethod
def _delete_last_char(buffer_, iter_):
start_iter = iter_.copy()
start_iter.backward_char()
buffer_.delete(start_iter, iter_)
@staticmethod
def _on_copy_clipboard(textview):
......
......@@ -147,7 +147,7 @@ class Preferences(Gtk.ApplicationWindow):
self._ui.positive_184_ack_checkbutton.set_active(st)
# Ignore XHTML
st = app.config.get('ignore_incoming_xhtml')
st = app.config.get('show_xhtml')
self._ui.xhtml_checkbutton.set_active(st)
# Print status messages in single chats
......@@ -674,8 +674,7 @@ class Preferences(Gtk.ApplicationWindow):
self.on_checkbutton_toggled(widget, 'positive_184_ack')
def on_xhtml_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ignore_incoming_xhtml')
helpers.update_optional_features()
self.on_checkbutton_toggled(widget, 'show_xhtml')
def on_print_status_in_chats_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'print_status_in_chats')
......
......@@ -22,6 +22,8 @@ from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Pango
from nbxmpp.modules.misc import build_xhtml_body
from gajim.common import app
from gajim.common.i18n import _
from gajim.common.const import StyleAttr
......@@ -361,7 +363,7 @@ class MessageTextView(Gtk.TextView):
text += self.end_tags[tag_name]
if modified:
return '<p>' + self.make_clickable_urls(text) + '</p>'
return build_xhtml_body('<p>%s</p>' % self.make_clickable_urls(text))
return None
def replace_emojis(self):
......
......@@ -369,7 +369,7 @@ class GajimRemote(Server):
# event has not been handled at GUI level
return
self.raise_signal('GCMessage', (obj.conn.name, [obj.fjid, obj.msgtxt,
obj.properties.timestamp, obj.delayed, obj.xhtml_msgtxt,
obj.properties.timestamp, obj.delayed,
obj.displaymarking, obj.needs_highlight]))
def _nec_decrypted_message_received(self, obj):
......@@ -379,7 +379,7 @@ class GajimRemote(Server):
self.raise_signal('NewMessage', (
obj.conn.name, [obj.fjid, obj.msgtxt, obj.properties.timestamp,
event_type, obj.properties.subject,
obj.msg_log_id, obj.properties.nickname, obj.xhtml]))
obj.msg_log_id, obj.properties.nickname]))
def on_our_status(self, obj):
self.raise_signal('AccountPresence', (obj.show, obj.conn.name))
......
......@@ -107,11 +107,6 @@ class ChatControlSession:
log_type = KindConstant.CHAT_MSG_SENT
if self.is_loggable() and obj.msgtxt:
if obj.xhtml and app.config.get('log_xhtml_messages'):
msg_to_log = obj.xhtml
else:
msg_to_log = obj.msgtxt
jid = obj.fjid
if not obj.properties.is_muc_pm:
jid = obj.jid
......@@ -121,7 +116,7 @@ class ChatControlSession:
jid,
obj.properties.timestamp,
log_type,
message=msg_to_log,
message=obj.msgtxt,
subject=obj.properties.subject,
additional_data=obj.additional_data,
stanza_id=obj.unique_id,
......@@ -237,7 +232,6 @@ class ChatControlSession:
obj.msg_log_id,
correct_id=obj.correct_id,
message_id=obj.properties.id,
xhtml=obj.xhtml,
session=self,
displaymarking=obj.displaymarking,
sent_forwarded=obj.properties.is_sent_carbon,
......@@ -248,7 +242,7 @@ class ChatControlSession:
app.events.add_event(self.conn.name, fjid, event)
def roster_message(self, jid, msg, tim, msg_type='',
subject=None, resource='', msg_log_id=None, user_nick='', xhtml=None,
subject=None, resource='', msg_log_id=None, user_nick='',
displaymarking=None, additional_data=None):
"""
Display the message or show notification in the roster
......@@ -311,9 +305,12 @@ class ChatControlSession:
if msg_type == 'error':
typ = 'error'
self.control.add_message(msg, typ, tim=tim,
subject=subject, xhtml=xhtml, displaymarking=displaymarking,
additional_data=additional_data)
self.control.add_message(msg,
typ,
tim=tim,
subject=subject,
displaymarking=displaymarking,
additional_data=additional_data)
if msg_log_id:
app.logger.set_read_messages([msg_log_id])
......@@ -328,7 +325,7 @@ class ChatControlSession:
show_in_systray = get_show_in_systray(event_type, contact.jid)
event = event_t(msg, subject, msg_type, tim, resource,
msg_log_id, xhtml=xhtml, session=self,
msg_log_id, session=self,
displaymarking=displaymarking, sent_forwarded=False,
show_in_roster=show_in_roster, show_in_systray=show_in_systray,
additional_data=additional_data)
......
......@@ -4,7 +4,7 @@ Tests for capabilities and the capabilities cache
import unittest
from unittest.mock import MagicMock, Mock
from nbxmpp import NS_MUC, NS_PING, NS_XHTML_IM
from nbxmpp import NS_MUC, NS_PING, NS_XHTML_IM, NS_JINGLE_FILE_TRANSFER_5
from nbxmpp.structs import DiscoIdentity
from nbxmpp.structs import DiscoInfo
from gajim.common import caps_cache as caps
......@@ -24,7 +24,7 @@ class CommonCapsTest(unittest.TestCase):
name='Gajim')
self.identities = [self.identity]
self.features = [NS_MUC, NS_XHTML_IM]
self.features = [NS_MUC, NS_XHTML_IM, NS_JINGLE_FILE_TRANSFER_5]
# Simulate a filled db
db_caps_cache = {
......@@ -116,7 +116,7 @@ class TestClientCaps(CommonCapsTest):
self.assertTrue(caps.client_supports(self.client_caps, NS_PING),
msg="Assume supported, if we don't have caps")
self.assertFalse(caps.client_supports(self.client_caps, NS_XHTML_IM),
self.assertFalse(caps.client_supports(self.client_caps, NS_JINGLE_FILE_TRANSFER_5),
msg="Must not assume blacklisted feature is supported on default")
self.cc.initialize_from_db()
......
Markdown is supported
0% or