From 2c34dd6d458d2a09731925fa2e7346ac0b545e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 11 Jun 2017 01:58:27 +0200 Subject: [PATCH] Show encryption icon in chat --- .../channel-secure-croped-symbolic.symbolic.png | Bin 0 -> 246 bytes src/chat_control.py | 11 +++-------- src/chat_control_base.py | 6 ++++-- src/common/connection_handlers_events.py | 1 + src/conversation_textview.py | 8 +++++++- src/groupchat_control.py | 15 +++++++++------ 6 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png diff --git a/icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png b/icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png new file mode 100644 index 0000000000000000000000000000000000000000..976c7f8dd5a3e789881c385df48e301de97b1a52 GIT binary patch literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~o!3HGD9`RZNDVAa<&kznEsNqQI0P-1&gWR1M z)}51i36e~A^mSxl*x1kgCy^D%=PdAuEM{QfI|9OtQ?>b|fr8bZE{-7@!AJY=@-`^& zv~))w&|7o#e8UD||Epmx8W-7<9!;Mz>2=|fhNd7ctLFjPy$lCZdkzXPomUBN_`c6} zifHnhb+a`a>XeJm?bPbfRK1p=7FZ&4xGkt__XPQ`YrmzoF=XfNoooNC^kQ{KV(Yyh kZu^gI*Ix6XoZ$f9#ODh=?;DR literal 0 HcmV?d00001 diff --git a/src/chat_control.py b/src/chat_control.py index db7cca9a4..58e31a67f 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -990,7 +990,7 @@ class ChatControl(ChatControlBase): def get_our_nick(self): return gajim.nicks[self.account] - def print_conversation(self, text, frm='', tim=None, encrypted=False, + def print_conversation(self, text, frm='', tim=None, encrypted=None, subject=None, xhtml=None, simple=False, xep0184_id=None, displaymarking=None, msg_log_id=None, correct_id=None, msg_stanza_id=None, additional_data=None): @@ -1023,12 +1023,6 @@ class ChatControl(ChatControlBase): kind = 'info' name = '' else: - if self.session and self.session.enable_encryption: - # ESessions - if not encrypted: - msg = _('The following message was NOT encrypted') - ChatControlBase.print_conversation_line(self, msg, 'status', - '', tim) if not frm: kind = 'incoming' name = contact.get_shown_name() @@ -1048,7 +1042,8 @@ class ChatControl(ChatControlBase): subject=subject, old_kind=self.old_msg_kind, xhtml=xhtml, simple=simple, xep0184_id=xep0184_id, displaymarking=displaymarking, msg_log_id=msg_log_id, msg_stanza_id=msg_stanza_id, - correct_id=correct_id, additional_data=additional_data) + correct_id=correct_id, additional_data=additional_data, + encrypted=encrypted) if text.startswith('/me ') or text.startswith('/me\n'): self.old_msg_kind = None else: diff --git a/src/chat_control_base.py b/src/chat_control_base.py index ea3324c7c..9dd5acdf2 100644 --- a/src/chat_control_base.py +++ b/src/chat_control_base.py @@ -894,7 +894,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[], count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False, xep0184_id=None, graphics=True, displaymarking=None, msg_log_id=None, - msg_stanza_id=None, correct_id=None, additional_data=None): + msg_stanza_id=None, correct_id=None, additional_data=None, + encrypted=None): """ Print 'chat' type messages correct_id = (message_id, correct_id) @@ -919,7 +920,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): other_tags_for_name, other_tags_for_time, other_tags_for_text, subject, old_kind, xhtml, simple=simple, graphics=graphics, displaymarking=displaymarking, msg_stanza_id=msg_stanza_id, - correct_id=correct_id, additional_data=additional_data) + correct_id=correct_id, additional_data=additional_data, + encrypted=encrypted) if xep0184_id is not None: textview.add_xep0184_mark(xep0184_id) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 312d810ba..d88508203 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -1497,6 +1497,7 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent): self.nickname = self.msg_obj.resource self.timestamp = self.msg_obj.timestamp self.xhtml_msgtxt = self.stanza.getXHTML() + self.encrypted = self.msg_obj.encrypted self.correct_id = None # XEP-0308 if gajim.config.get('ignore_incoming_xhtml'): diff --git a/src/conversation_textview.py b/src/conversation_textview.py index b0146b6bf..db481044d 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -170,6 +170,8 @@ class ConversationTextview(GObject.GObject): MESSAGE_CORRECTED_PIXBUF = gtkgui_helpers.get_icon_pixmap( 'document-edit-symbolic') + MESSAGE_ENCRYPTED_PIXBUF = gtkgui_helpers.get_icon_pixmap( + 'channel-secure-croped-symbolic') # smooth scroll constants MAX_SCROLL_TIME = 0.4 # seconds @@ -1100,7 +1102,8 @@ class ConversationTextview(GObject.GObject): def print_conversation_line(self, text, jid, 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, simple=False, graphics=True, - displaymarking=None, msg_stanza_id=None, correct_id=None, additional_data=None): + displaymarking=None, msg_stanza_id=None, correct_id=None, additional_data=None, + encrypted=None): """ Print 'chat' type messages """ @@ -1168,6 +1171,9 @@ class ConversationTextview(GObject.GObject): self.print_time(text, kind, tim, simple, direction_mark, other_tags_for_time, iter_) + if encrypted: + buffer_.insert_pixbuf(iter_, self.MESSAGE_ENCRYPTED_PIXBUF) + # If there's a displaymarking, print it here. if displaymarking: self.print_displaymarking(displaymarking, iter_=iter_) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 71cd8aa79..834e709f0 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1090,14 +1090,14 @@ class GroupchatControl(ChatControlBase): # don't print xhtml if it's an old message. # Like that xhtml messages are grayed too. self.print_old_conversation(obj.msgtxt, contact=obj.nick, - tim=obj.timestamp, xhtml=None, + tim=obj.timestamp, xhtml=None, encrypted=obj.encrypted, displaymarking=obj.displaymarking, msg_stanza_id=obj.id_) else: if obj.nick == self.nick: self.last_sent_txt = obj.msgtxt self.print_conversation(obj.msgtxt, contact=obj.nick, tim=obj.timestamp, xhtml=obj.xhtml_msgtxt, - displaymarking=obj.displaymarking, + displaymarking=obj.displaymarking, encrypted=obj.encrypted, correct_id=obj.correct_id, msg_stanza_id=obj.id_) obj.needs_highlight = self.needs_visual_notification(obj.msgtxt) @@ -1153,7 +1153,7 @@ class GroupchatControl(ChatControlBase): return None def print_old_conversation(self, text, contact='', tim=None, xhtml = None, - displaymarking=None, msg_stanza_id=None): + displaymarking=None, msg_stanza_id=None, encrypted=None): if contact: if contact == self.nick: # it's us kind = 'outgoing' @@ -1165,13 +1165,16 @@ class GroupchatControl(ChatControlBase): small_attr = ['small'] else: small_attr = [] + ChatControlBase.print_conversation_line(self, text, kind, contact, tim, small_attr, small_attr + ['restored_message'], 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) 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): """ Print a line in the conversation @@ -1233,7 +1236,7 @@ class GroupchatControl(ChatControlBase): ChatControlBase.print_conversation_line(self, text, kind, contact, tim, other_tags_for_name, [], other_tags_for_text, xhtml=xhtml, graphics=graphics, displaymarking=displaymarking, - correct_id=correct_id, msg_stanza_id=msg_stanza_id) + correct_id=correct_id, msg_stanza_id=msg_stanza_id, encrypted=encrypted) def get_nb_unread(self): type_events = ['printed_marked_gc_msg']