Show encryption icon in chat

This commit is contained in:
Philipp Hörist 2017-06-11 01:58:27 +02:00
parent c8115e4164
commit 2c34dd6d45
6 changed files with 24 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

View File

@ -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:

View File

@ -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)

View File

@ -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'):

View File

@ -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_)

View File

@ -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']