Show trust level for incoming encrypted messages
This commit is contained in:
parent
5af7fbd428
commit
ae4c98cbb2
|
@ -199,6 +199,12 @@ class MUCUser(IntEnum):
|
||||||
AFFILIATION = 3
|
AFFILIATION = 3
|
||||||
AFFILIATION_TEXT = 4
|
AFFILIATION_TEXT = 4
|
||||||
|
|
||||||
|
@unique
|
||||||
|
class Trust(IntEnum):
|
||||||
|
UNTRUSTED = 0
|
||||||
|
UNDECIDED = 1
|
||||||
|
BLIND = 2
|
||||||
|
VERIFIED = 3
|
||||||
|
|
||||||
EME_MESSAGES = {
|
EME_MESSAGES = {
|
||||||
'urn:xmpp:otr:0':
|
'urn:xmpp:otr:0':
|
||||||
|
|
|
@ -44,7 +44,7 @@ from gajim.common import i18n
|
||||||
from gajim.common.i18n import _
|
from gajim.common.i18n import _
|
||||||
from gajim.common.helpers import AdditionalDataDict
|
from gajim.common.helpers import AdditionalDataDict
|
||||||
from gajim.common.fuzzyclock import FuzzyClock
|
from gajim.common.fuzzyclock import FuzzyClock
|
||||||
from gajim.common.const import StyleAttr
|
from gajim.common.const import StyleAttr, Trust
|
||||||
|
|
||||||
from gajim.gtk import util
|
from gajim.gtk import util
|
||||||
from gajim.gtk.util import load_icon
|
from gajim.gtk.util import load_icon
|
||||||
|
@ -60,6 +60,22 @@ SHOWN = 2
|
||||||
|
|
||||||
log = logging.getLogger('gajim.conversation_textview')
|
log = logging.getLogger('gajim.conversation_textview')
|
||||||
|
|
||||||
|
TRUST_SYMBOL_DATA = {
|
||||||
|
Trust.UNTRUSTED: ('dialog-error-symbolic',
|
||||||
|
_('Untrusted'),
|
||||||
|
'error-color'),
|
||||||
|
Trust.UNDECIDED: ('security-low-symbolic',
|
||||||
|
_('Trust Not Decided'),
|
||||||
|
'warning-color'),
|
||||||
|
Trust.BLIND: ('security-medium-symbolic',
|
||||||
|
_('Unverified'),
|
||||||
|
'success-color'),
|
||||||
|
Trust.VERIFIED: ('security-high-symbolic',
|
||||||
|
_('Verified'),
|
||||||
|
'encrypted-color')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def is_selection_modified(mark):
|
def is_selection_modified(mark):
|
||||||
name = mark.get_name()
|
name = mark.get_name()
|
||||||
return name in ('selection_bound', 'insert')
|
return name in ('selection_bound', 'insert')
|
||||||
|
@ -1133,13 +1149,17 @@ class ConversationTextview(GObject.GObject):
|
||||||
color = 'unencrypted-color'
|
color = 'unencrypted-color'
|
||||||
tooltip = _('Not encrypted')
|
tooltip = _('Not encrypted')
|
||||||
else:
|
else:
|
||||||
icon = 'channel-secure-symbolic'
|
name, fingerprint, trust = details
|
||||||
color = 'encrypted-color'
|
tooltip = _('Encrypted (%s)') % (name)
|
||||||
name, fingerprint = details
|
if trust is None:
|
||||||
if fingerprint is None:
|
# The encryption plugin did not pass trust information
|
||||||
tooltip = name
|
icon = 'channel-secure-symbolic'
|
||||||
|
color = 'encrypted-color'
|
||||||
else:
|
else:
|
||||||
tooltip = '%s %s' % (name, fingerprint)
|
icon, trust_tooltip, color = TRUST_SYMBOL_DATA[trust]
|
||||||
|
tooltip = tooltip + '\n' + trust_tooltip
|
||||||
|
if fingerprint is not None:
|
||||||
|
tooltip = tooltip + ' (' + fingerprint + ')'
|
||||||
|
|
||||||
temp_mark = self._buffer.create_mark(None, iter_, True)
|
temp_mark = self._buffer.create_mark(None, iter_, True)
|
||||||
self._buffer.insert(iter_, ' ')
|
self._buffer.insert(iter_, ' ')
|
||||||
|
@ -1164,7 +1184,8 @@ class ConversationTextview(GObject.GObject):
|
||||||
return
|
return
|
||||||
|
|
||||||
fingerprint = additional_data.get_value('encrypted', 'fingerprint')
|
fingerprint = additional_data.get_value('encrypted', 'fingerprint')
|
||||||
return name, fingerprint
|
trust = additional_data.get_value('encrypted', 'trust')
|
||||||
|
return name, fingerprint, trust
|
||||||
|
|
||||||
def print_time(self, text, kind, tim, simple, direction_mark, other_tags_for_time, iter_):
|
def print_time(self, text, kind, tim, simple, direction_mark, other_tags_for_time, iter_):
|
||||||
local_tim = time.localtime(tim)
|
local_tim = time.localtime(tim)
|
||||||
|
|
Loading…
Reference in New Issue