changeset bcca3dc4f68d in /home/hg/repos/gajim-plugins
author: lovetox <[email protected]>
branches:
details:gajim-plugins?cmd=changeset;node=bcca3dc4f68d
description: Warn user when new Fingerprints are in DB and
refreshAuthLockSymbol()
diffstat:
omemo/__init__.py | 5 +++-
omemo/omemo/liteidentitykeystore.py | 11 ++++++++
omemo/ui.py | 46 ++++++++++++++++++++++++++++--------
3 files changed, 51 insertions(+), 11 deletions(-)
diffs (183 lines):
diff -r 7ea4d380f524 -r bcca3dc4f68d omemo/__init__.py
--- a/omemo/__init__.py Sat Jun 04 16:19:18 2016 +0200
+++ b/omemo/__init__.py Sat Jun 04 17:10:50 2016 +0200
@@ -314,7 +314,7 @@
log.debug(account_name + " ⇒ Adding OMEMO ui for " + contact_jid)
omemo_enabled = state.encryption.is_active(contact_jid)
self.ui_list[account_name][contact_jid] = Ui(self, chat_control,
- omemo_enabled)
+ omemo_enabled, state)
else:
log.warn(account_name + " ⇒ No OMEMO dev_keys for " + contact_jid)
@@ -429,6 +429,9 @@
if state.build_session(recipient_id, device_id, bundle_dict):
log.warn(recipient_id + ' => session created')
+ # Warn User about new Fingerprints in DB if Chat Window is Open
+ if self.ui_list[account_name][recipient_id]:
+
self.ui_list[account_name][recipient_id].WarnIfUndecidedFingerprints()
@log_calls('OmemoPlugin')
def announce_support(self, account):
diff -r 7ea4d380f524 -r bcca3dc4f68d omemo/omemo/liteidentitykeystore.py
--- a/omemo/omemo/liteidentitykeystore.py Sat Jun 04 16:19:18 2016 +0200
+++ b/omemo/omemo/liteidentitykeystore.py Sat Jun 04 17:10:50 2016 +0200
@@ -110,6 +110,17 @@
result.append((row[0], row[1], row[2], row[3]))
return result
+ def getUndecidedFingerprints(self, jid):
+ q = "SELECT trust FROM identities " + \
+ "WHERE recipient_id = '" + jid + "' AND trust = '2'"
+ c = self.dbConn.cursor()
+
+ result = []
+ c.execute(q)
+ result = c.fetchone()
+
+ return result
+
def setTrust(self, _id, trust):
q = "UPDATE identities SET trust = '" + str(trust) + "'" + \
"WHERE _id = '" + str(_id) + "'"
diff -r 7ea4d380f524 -r bcca3dc4f68d omemo/ui.py
--- a/omemo/ui.py Sat Jun 04 16:19:18 2016 +0200
+++ b/omemo/ui.py Sat Jun 04 17:10:50 2016 +0200
@@ -46,12 +46,13 @@
class Checkbox(gtk.CheckButton):
- def __init__(self, plugin, chat_control):
+ def __init__(self, plugin, chat_control, ui):
super(Checkbox, self).__init__(label='OMEMO')
self.chat_control = chat_control
self.contact = chat_control.contact
self.plugin = plugin
self.connect('clicked', self.on_click)
+ self.ui = ui
def on_click(self, widget):
enabled = self.get_active()
@@ -59,16 +60,14 @@
log.info(self.contact.account.name + ' ⇒ Enable OMEMO for ' +
self.contact.jid)
self.plugin.omemo_enable_for(self.contact)
- self.chat_control._show_lock_image(True, 'OMEMO',
- True, True, False)
+ self.ui.WarnIfUndecidedFingerprints()
self.chat_control.print_conversation_line(
u'OMEMO encryption enabled ', 'status', '', None)
else:
log.info(self.contact.account.name + ' ⇒ Disable OMEMO for ' +
self.contact.jid)
self.plugin.omemo_disable_for(self.contact)
- self.chat_control._show_lock_image(False, 'OMEMO', False, True,
- False)
+ self.ui.refreshAuthLockSymbol()
self.chat_control.print_conversation_line(
u'OMEMO encryption disabled', 'status', '', None)
@@ -84,11 +83,12 @@
class Ui(object):
- def __init__(self, plugin, chat_control, enabled):
+ def __init__(self, plugin, chat_control, enabled, state):
self.contact = chat_control.contact
self.chat_control = chat_control
- self.checkbox = Checkbox(plugin, chat_control)
+ self.checkbox = Checkbox(plugin, chat_control, self)
self.finger_button = FingerprintButton(plugin, self.contact)
+ self.state = state
if enabled:
self.checkbox.set_active(True)
@@ -107,8 +107,7 @@
else:
log.info(self.contact.account.name + ' ⇒ Disable OMEMO for ' +
self.contact.jid)
- self.chat_control._show_lock_image(False, 'OMEMO', False, True,
- False)
+ self.refreshAuthLockSymbol()
self.chat_control.print_conversation_line(
u'OMEMO encryption disabled', 'status', '', None)
@@ -121,6 +120,26 @@
'Received plaintext message! ' +
'Your next message will still be encrypted!', 'status', '', None)
+ def WarnIfUndecidedFingerprints(self):
+ if
self.state.store.identityKeyStore.getUndecidedFingerprints(self.contact.jid):
+ msg = "You received a new Fingerprint. " + \
+ "Until you make a trust decision you can only " + \
+ "receive encrypted Messages from that Device."
+ self.chat_control.print_conversation_line(msg, 'status', '', None)
+ self.refreshAuthLockSymbol()
+
+ def refreshAuthLockSymbol(self):
+ if self.encryption_active():
+ if
self.state.store.identityKeyStore.getUndecidedFingerprints(self.contact.jid):
+ self.chat_control._show_lock_image(True, 'OMEMO', True, True,
+ False)
+ else:
+ self.chat_control._show_lock_image(True, 'OMEMO', True, True,
+ True)
+ else:
+ self.chat_control._show_lock_image(False, 'OMEMO', False, True,
+ False)
+
class OMEMOConfigDialog(GajimPluginConfigDialog):
def init(self):
@@ -184,6 +203,8 @@
if dlg.run() == gtk.RESPONSE_YES:
state.store.identityKeyStore.setTrust(_id, TRUSTED)
+ if self.plugin.ui_list[account][user]:
+
self.plugin.ui_list[account][user].refreshAuthLockSymbol()
dlg.destroy()
self.update_context_list()
@@ -214,6 +235,8 @@
if dlg.run() == gtk.RESPONSE_YES:
state.store.identityKeyStore.setTrust(_id, UNTRUSTED)
+ if self.plugin.ui_list[account][user]:
+
self.plugin.ui_list[account][user].refreshAuthLockSymbol()
dlg.destroy()
self.update_context_list()
@@ -251,7 +274,7 @@
gtk.Clipboard(selection='PRIMARY').set_text('\n'.join(fprs))
def update_context_list(self):
- trust = {None: "Not Set", 0: False, 1: True}
+ trust = {None: "Not Set", 0: False, 1: True, 2: "Undecided"}
self.fpr_model.clear()
active = self.B.get_object('account_combobox').get_active()
account = self.account_store[active][0]
@@ -290,6 +313,7 @@
buf += '{0} '.format(fpr[w:w + wordsize])
return buf.rstrip()
+
class FingerprintWindow(gtk.Dialog):
def __init__(self, plugin, contact, parent=None):
self.contact = contact
@@ -345,6 +369,7 @@
if dlg.run() == gtk.RESPONSE_YES:
state.store.identityKeyStore.setTrust(_id, TRUSTED)
+
self.plugin.ui_list[account][self.contact.jid].refreshAuthLockSymbol()
dlg.destroy()
self.update_context_list()
@@ -374,6 +399,7 @@
if dlg.run() == gtk.RESPONSE_YES:
state.store.identityKeyStore.setTrust(_id, UNTRUSTED)
+
self.plugin.ui_list[account][self.contact.jid].refreshAuthLockSymbol()
dlg.destroy()
self.update_context_list()
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits