changeset c5ca2af584d3 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=c5ca2af584d3 description: ability to save xhtml messages. Fixes #5736
diffstat:
src/chat_control.py | 12 +++++++----- src/common/config.py | 1 + src/common/connection.py | 15 +++++++++------ src/history_window.py | 11 ++++++++--- src/session.py | 6 +++++- 5 files changed, 30 insertions(+), 15 deletions(-)
diffs (136 lines):
diff -r d75458337ba8 -r c5ca2af584d3 src/chat_control.py --- a/src/chat_control.py Sun May 29 20:45:18 2011 +0200 +++ b/src/chat_control.py Mon May 30 19:47:05 2011 +0200 @@ -2921,11 +2921,13 @@ small_attr = ['small'] else: small_attr = [] - ChatControlBase.print_conversation_line(self, row[2], kind, name, tim, - small_attr, - small_attr + ['restored_message'], - small_attr + ['restored_message'], - False, old_kind=local_old_kind) + xhtml = None + if row[2].startswith('<body '): + xhtml = row[2] + ChatControlBase.print_conversation_line(self, row[2], kind, name, + 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'): local_old_kind = None else: diff -r d75458337ba8 -r c5ca2af584d3 src/common/config.py --- a/src/common/config.py Sun May 29 20:45:18 2011 +0200 +++ b/src/common/config.py Mon May 30 19:47:05 2011 +0200 @@ -234,6 +234,7 @@ '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.')], '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_disconnected_bg_color': [opt_str, '#ab6161', _('Background color of contacts when they just signed out.')], 'restored_messages_color': [opt_color, '#555753'], diff -r d75458337ba8 -r c5ca2af584d3 src/common/connection.py --- a/src/common/connection.py Sun May 29 20:45:18 2011 +0200 +++ b/src/common/connection.py Mon May 30 19:47:05 2011 +0200 @@ -432,10 +432,10 @@
if callback: 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, - subject, type_): + subject, type_, xhtml=None): if not forward_from and session and session.is_loggable(): ji = gajim.get_jid_without_resource(jid) if gajim.config.should_log(self.name, ji): @@ -451,6 +451,9 @@ else: kind = 'single_msg_sent' 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) except exceptions.PysqliteOperationalError, e: self.dispatch('DB_ERROR', (_('Disk Write Error'), @@ -1751,7 +1754,7 @@ callback_args=[], now=False):
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) jid = helpers.parse_jid(jid) gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self, @@ -1760,7 +1763,7 @@ callback(msg_id, *callback_args)
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, chatstate=chatstate, msg_id=msg_id, composing_xep=composing_xep, @@ -1773,7 +1776,7 @@ return
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) jid = helpers.parse_jid(obj.jid) gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self, @@ -1784,7 +1787,7 @@ if not obj.is_loggable: return 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_, subject=obj.subject, chatstate=obj.chatstate, msg_id=obj.msg_id, diff -r d75458337ba8 -r c5ca2af584d3 src/history_window.py --- a/src/history_window.py Sun May 29 20:45:18 2011 +0200 +++ b/src/history_window.py Mon May 30 19:47:05 2011 +0200 @@ -478,12 +478,17 @@
if subject: message = _('Subject: %s\n') % subject + message - message += '\n' + xhtml = None + if message.startswith('<body '): + xhtml = message + if tag_msg: self.history_textview.print_real_text(message, [tag_msg], - name=contact_name) + name=contact_name, xhtml=xhtml) 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): text = self.query_entry.get_text() diff -r d75458337ba8 -r c5ca2af584d3 src/session.py --- a/src/session.py Sun May 29 20:45:18 2011 +0200 +++ b/src/session.py Mon May 30 19:47:05 2011 +0200 @@ -85,8 +85,12 @@
if self.is_loggable() and obj.msgtxt: 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, - obj.msgtxt, tim=obj.timestamp, subject=obj.subject) + msg_to_log, tim=obj.timestamp, subject=obj.subject) except exceptions.PysqliteOperationalError, e: self.conn.dispatch('ERROR', (_('Disk WriteError'), str(e))) except exceptions.DatabaseMalformed: