[omemo] Add Blind Trust Before Verification

Fixes #310
This commit is contained in:
lovetox
2020-06-24 21:08:50 +02:00
parent 50db85fad3
commit 77452756cb
6 changed files with 133 additions and 13 deletions

View File

@@ -58,6 +58,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self.update_account_store()
self.update_account_combobox()
self.update_disabled_account_view()
self.update_settings()
def is_in_accountstore(self, account):
for row in self._ui.account_store:
@@ -127,6 +128,9 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
def refresh_button_clicked_cb(self, button, *args):
self.update_context_list()
def _on_blind_trust(self, button):
self.plugin.config['BLIND_TRUST'] = button.get_active()
def update_context_list(self):
self._ui.deviceid_store.clear()
@@ -158,3 +162,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
# Set Device ID List
for item in omemo.backend.get_devices(own_jid):
self._ui.deviceid_store.append([item])
def update_settings(self):
self._ui.blind_trust_checkbutton.set_active(
self.plugin.config['BLIND_TRUST'])

View File

@@ -522,6 +522,80 @@ It is advised to go online with all of your actively used devices after clearing
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">12</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="blind_trust_checkbutton">
<property name="label" translatable="yes">Blind Trust Before Verification</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="_on_blind_trust" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">General</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Settings</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<object class="GtkListStore" id="fingerprint_store">
<columns>

View File

@@ -47,7 +47,10 @@ TRUST_DATA = {
'warning-color'),
Trust.VERIFIED: ('security-high-symbolic',
_('Verified'),
'encrypted-color')
'encrypted-color'),
Trust.BLIND: ('security-medium-symbolic',
_('Blind Trust'),
'encrypted-color')
}
@@ -352,11 +355,7 @@ class TrustPopver(Gtk.Popover):
self._row = row
self._listbox = Gtk.ListBox()
self._listbox.set_selection_mode(Gtk.SelectionMode.NONE)
if row.trust != Trust.VERIFIED:
self._listbox.add(VerifiedOption())
if row.trust != Trust.UNTRUSTED:
self._listbox.add(NotTrustedOption())
self._listbox.add(DeleteOption())
self.update()
self.add(self._listbox)
self._listbox.show_all()
self._listbox.connect('row-activated', self._activated)
@@ -376,6 +375,8 @@ class TrustPopver(Gtk.Popover):
self._listbox.foreach(self._listbox.remove)
if self._row.trust != Trust.VERIFIED:
self._listbox.add(VerifiedOption())
if self._row.trust != Trust.BLIND:
self._listbox.add(BlindOption())
if self._row.trust != Trust.UNTRUSTED:
self._listbox.add(NotTrustedOption())
self._listbox.add(DeleteOption())
@@ -398,6 +399,17 @@ class MenuOption(Gtk.ListBoxRow):
self.show_all()
class BlindOption(MenuOption):
type_ = Trust.BLIND
icon = 'security-medium-symbolic'
label = _('Blind Trust')
color = 'encrypted-color'
def __init__(self):
MenuOption.__init__(self)
class VerifiedOption(MenuOption):
type_ = Trust.VERIFIED