ability to save xhtml messages. Fixes #5736
This commit is contained in:
parent
f22c453d4e
commit
ff0c0dc1c5
|
@ -2921,11 +2921,13 @@ class ChatControl(ChatControlBase):
|
||||||
small_attr = ['small']
|
small_attr = ['small']
|
||||||
else:
|
else:
|
||||||
small_attr = []
|
small_attr = []
|
||||||
ChatControlBase.print_conversation_line(self, row[2], kind, name, tim,
|
xhtml = None
|
||||||
small_attr,
|
if row[2].startswith('<body '):
|
||||||
small_attr + ['restored_message'],
|
xhtml = row[2]
|
||||||
small_attr + ['restored_message'],
|
ChatControlBase.print_conversation_line(self, row[2], kind, name,
|
||||||
False, old_kind=local_old_kind)
|
tim, small_attr, small_attr + ['restored_message'],
|
||||||
|
small_attr + ['restored_message'], False,
|
||||||
|
old_kind=local_old_kind, xhtml=xhtml)
|
||||||
if row[2].startswith('/me ') or row[2].startswith('/me\n'):
|
if row[2].startswith('/me ') or row[2].startswith('/me\n'):
|
||||||
local_old_kind = None
|
local_old_kind = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -234,6 +234,7 @@ class Config:
|
||||||
'print_status_in_chats': [opt_bool, True, _('If False, Gajim will no longer print status line in chats when a contact changes his or her status and/or his or her status message.')],
|
'print_status_in_chats': [opt_bool, True, _('If False, Gajim will no longer print status line in chats when a contact changes his or her status and/or his or her status message.')],
|
||||||
'print_status_in_muc': [opt_str, 'in_and_out', _('can be "none", "all" or "in_and_out". If "none", Gajim will no longer print status line in groupchats when a member changes his or her status and/or his or her status message. If "all" Gajim will print all status messages. If "in_and_out", Gajim will only print FOO enters/leaves group chat.')],
|
'print_status_in_muc': [opt_str, 'in_and_out', _('can be "none", "all" or "in_and_out". If "none", Gajim will no longer print status line in groupchats when a member changes his or her status and/or his or her status message. If "all" Gajim will print all status messages. If "in_and_out", Gajim will only print FOO enters/leaves group chat.')],
|
||||||
'log_contact_status_changes': [opt_bool, False],
|
'log_contact_status_changes': [opt_bool, False],
|
||||||
|
'log_xhtml_messages': [opt_bool, False, _('Log XHTML messages instead of plain text messages.')],
|
||||||
'just_connected_bg_color': [opt_str, '#adc3c6', _('Background color of contacts when they just signed in.')],
|
'just_connected_bg_color': [opt_str, '#adc3c6', _('Background color of contacts when they just signed in.')],
|
||||||
'just_disconnected_bg_color': [opt_str, '#ab6161', _('Background color of contacts when they just signed out.')],
|
'just_disconnected_bg_color': [opt_str, '#ab6161', _('Background color of contacts when they just signed out.')],
|
||||||
'restored_messages_color': [opt_color, '#555753'],
|
'restored_messages_color': [opt_color, '#555753'],
|
||||||
|
|
|
@ -432,10 +432,10 @@ class CommonConnection:
|
||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(jid, msg, keyID, forward_from, session, original_message,
|
callback(jid, msg, keyID, forward_from, session, original_message,
|
||||||
subject, type_, msg_iq)
|
subject, type_, msg_iq, xhtml)
|
||||||
|
|
||||||
def log_message(self, jid, msg, forward_from, session, original_message,
|
def log_message(self, jid, msg, forward_from, session, original_message,
|
||||||
subject, type_):
|
subject, type_, xhtml=None):
|
||||||
if not forward_from and session and session.is_loggable():
|
if not forward_from and session and session.is_loggable():
|
||||||
ji = gajim.get_jid_without_resource(jid)
|
ji = gajim.get_jid_without_resource(jid)
|
||||||
if gajim.config.should_log(self.name, ji):
|
if gajim.config.should_log(self.name, ji):
|
||||||
|
@ -451,6 +451,9 @@ class CommonConnection:
|
||||||
else:
|
else:
|
||||||
kind = 'single_msg_sent'
|
kind = 'single_msg_sent'
|
||||||
try:
|
try:
|
||||||
|
if xhtml and gajim.config.get('log_xhtml_messages'):
|
||||||
|
log_msg = '<body xmlns="%s">%s</body>' % (
|
||||||
|
common.xmpp.NS_XHTML, xhtml)
|
||||||
gajim.logger.write(kind, jid, log_msg)
|
gajim.logger.write(kind, jid, log_msg)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError, e:
|
||||||
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
||||||
|
@ -1751,7 +1754,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
callback_args=[], now=False):
|
callback_args=[], now=False):
|
||||||
|
|
||||||
def cb(jid, msg, keyID, forward_from, session, original_message,
|
def cb(jid, msg, keyID, forward_from, session, original_message,
|
||||||
subject, type_, msg_iq):
|
subject, type_, msg_iq, xhtml):
|
||||||
msg_id = self.connection.send(msg_iq, now=now)
|
msg_id = self.connection.send(msg_iq, now=now)
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
|
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
|
||||||
|
@ -1760,7 +1763,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
callback(msg_id, *callback_args)
|
callback(msg_id, *callback_args)
|
||||||
|
|
||||||
self.log_message(jid, msg, forward_from, session, original_message,
|
self.log_message(jid, msg, forward_from, session, original_message,
|
||||||
subject, type_)
|
subject, type_, xhtml)
|
||||||
|
|
||||||
self._prepare_message(jid, msg, keyID, type_=type_, subject=subject,
|
self._prepare_message(jid, msg, keyID, type_=type_, subject=subject,
|
||||||
chatstate=chatstate, msg_id=msg_id, composing_xep=composing_xep,
|
chatstate=chatstate, msg_id=msg_id, composing_xep=composing_xep,
|
||||||
|
@ -1773,7 +1776,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
return
|
return
|
||||||
|
|
||||||
def cb(jid, msg, keyID, forward_from, session, original_message,
|
def cb(jid, msg, keyID, forward_from, session, original_message,
|
||||||
subject, type_, msg_iq):
|
subject, type_, msg_iq, xhtml):
|
||||||
msg_id = self.connection.send(msg_iq, now=obj.now)
|
msg_id = self.connection.send(msg_iq, now=obj.now)
|
||||||
jid = helpers.parse_jid(obj.jid)
|
jid = helpers.parse_jid(obj.jid)
|
||||||
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
|
gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self,
|
||||||
|
@ -1784,7 +1787,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
if not obj.is_loggable:
|
if not obj.is_loggable:
|
||||||
return
|
return
|
||||||
self.log_message(jid, msg, forward_from, session, original_message,
|
self.log_message(jid, msg, forward_from, session, original_message,
|
||||||
subject, type_)
|
subject, type_, xhtml)
|
||||||
|
|
||||||
self._prepare_message(obj.jid, obj.message, obj.keyID, type_=obj.type_,
|
self._prepare_message(obj.jid, obj.message, obj.keyID, type_=obj.type_,
|
||||||
subject=obj.subject, chatstate=obj.chatstate, msg_id=obj.msg_id,
|
subject=obj.subject, chatstate=obj.chatstate, msg_id=obj.msg_id,
|
||||||
|
|
|
@ -478,12 +478,17 @@ class HistoryWindow:
|
||||||
|
|
||||||
if subject:
|
if subject:
|
||||||
message = _('Subject: %s\n') % subject + message
|
message = _('Subject: %s\n') % subject + message
|
||||||
message += '\n'
|
xhtml = None
|
||||||
|
if message.startswith('<body '):
|
||||||
|
xhtml = message
|
||||||
|
|
||||||
if tag_msg:
|
if tag_msg:
|
||||||
self.history_textview.print_real_text(message, [tag_msg],
|
self.history_textview.print_real_text(message, [tag_msg],
|
||||||
name=contact_name)
|
name=contact_name, xhtml=xhtml)
|
||||||
else:
|
else:
|
||||||
self.history_textview.print_real_text(message, name=contact_name)
|
self.history_textview.print_real_text(message, name=contact_name,
|
||||||
|
xhtml=xhtml)
|
||||||
|
self.history_textview.print_real_text('\n')
|
||||||
|
|
||||||
def on_query_entry_activate(self, widget):
|
def on_query_entry_activate(self, widget):
|
||||||
text = self.query_entry.get_text()
|
text = self.query_entry.get_text()
|
||||||
|
|
|
@ -85,8 +85,12 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
|
|
||||||
if self.is_loggable() and obj.msgtxt:
|
if self.is_loggable() and obj.msgtxt:
|
||||||
try:
|
try:
|
||||||
|
if obj.xhtml and gajim.config.get('log_xhtml_messages'):
|
||||||
|
msg_to_log = obj.xhtml
|
||||||
|
else:
|
||||||
|
msg_to_log = obj.msgtxt
|
||||||
msg_id = gajim.logger.write(log_type, obj.fjid,
|
msg_id = gajim.logger.write(log_type, obj.fjid,
|
||||||
obj.msgtxt, tim=obj.timestamp, subject=obj.subject)
|
msg_to_log, tim=obj.timestamp, subject=obj.subject)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError, e:
|
||||||
self.conn.dispatch('ERROR', (_('Disk WriteError'), str(e)))
|
self.conn.dispatch('ERROR', (_('Disk WriteError'), str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
|
|
Loading…
Reference in New Issue