[omemo] Don’t use GajimPluginConfigDialog

It will be removed in the future
This commit is contained in:
lovetox
2022-04-24 17:48:22 +02:00
parent 479fea239e
commit b5619414b7
2 changed files with 35 additions and 18 deletions

View File

@@ -18,43 +18,58 @@
import logging import logging
from gi.repository import Gtk
from gi.repository import Gdk
from gajim.common import app from gajim.common import app
from gajim.plugins.gui import GajimPluginConfigDialog
from gajim.plugins.helpers import get_builder from gajim.plugins.helpers import get_builder
from gajim.plugins.plugins_i18n import _
from omemo.backend.util import get_fingerprint from omemo.backend.util import get_fingerprint
log = logging.getLogger('gajim.p.omemo') log = logging.getLogger('gajim.p.omemo')
class OMEMOConfigDialog(GajimPluginConfigDialog): class OMEMOConfigDialog(Gtk.ApplicationWindow):
def init(self): def __init__(self, plugin, transient):
# pylint: disable=attribute-defined-outside-init Gtk.ApplicationWindow.__init__(self)
path = self.plugin.local_file_path('gtk/config.ui') self.set_application(app.app)
self.set_show_menubar(False)
self.set_title(_('OMEMO Settings'))
self.set_transient_for(transient)
self.set_default_size(400, 400)
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
self.set_destroy_with_parent(True)
self._plugin = plugin
path = self._plugin.local_file_path('gtk/config.ui')
self._ui = get_builder(path) self._ui = get_builder(path)
image_path = self.plugin.local_file_path('omemo.png') image_path = self._plugin.local_file_path('omemo.png')
self._ui.image.set_from_file(image_path) self._ui.image.set_from_file(image_path)
try: try:
self.disabled_accounts = self.plugin.config['DISABLED_ACCOUNTS'] self.disabled_accounts = self._plugin.config['DISABLED_ACCOUNTS']
except KeyError: except KeyError:
self.plugin.config['DISABLED_ACCOUNTS'] = [] self._plugin.config['DISABLED_ACCOUNTS'] = []
self.disabled_accounts = self.plugin.config['DISABLED_ACCOUNTS'] self.disabled_accounts = self._plugin.config['DISABLED_ACCOUNTS']
box = self.get_content_area() box = Gtk.Box()
box.pack_start(self._ui.notebook1, True, True, 0) box.pack_start(self._ui.notebook1, True, True, 0)
self.add(box)
self._ui.connect_signals(self) self._ui.connect_signals(self)
self.show_all()
self.plugin_active = False self.plugin_active = False
def on_run(self):
for plugin in app.plugin_manager.active_plugins: for plugin in app.plugin_manager.active_plugins:
log.debug(type(plugin)) log.debug(type(plugin))
if type(plugin).__name__ == 'OmemoPlugin': if type(plugin).__name__ == 'OmemoPlugin':
self.plugin_active = True self.plugin_active = True
break break
self.update_account_store() self.update_account_store()
self.update_account_combobox() self.update_account_combobox()
self.update_disabled_account_view() self.update_disabled_account_view()
@@ -102,7 +117,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self._ui.account_store.append(row=(account[0],)) self._ui.account_store.append(row=(account[0],))
self.disabled_accounts.remove(account[0]) self.disabled_accounts.remove(account[0])
self.update_disabled_account_view() self.update_disabled_account_view()
self.plugin.config['DISABLED_ACCOUNTS'] = self.disabled_accounts self._plugin.config['DISABLED_ACCOUNTS'] = self.disabled_accounts
self.update_account_combobox() self.update_account_combobox()
def disable_accounts_btn_clicked(self, _button, *args): def disable_accounts_btn_clicked(self, _button, *args):
@@ -116,7 +131,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self.disabled_accounts.append(account[0]) self.disabled_accounts.append(account[0])
self._ui.account_store.remove(it) self._ui.account_store.remove(it)
self.update_disabled_account_view() self.update_disabled_account_view()
self.plugin.config['DISABLED_ACCOUNTS'] = self.disabled_accounts self._plugin.config['DISABLED_ACCOUNTS'] = self.disabled_accounts
self.update_account_combobox() self.update_account_combobox()
def cleardevice_button_clicked_cb(self, button, *args): def cleardevice_button_clicked_cb(self, button, *args):
@@ -129,7 +144,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self.update_context_list() self.update_context_list()
def _on_blind_trust(self, button): def _on_blind_trust(self, button):
self.plugin.config['BLIND_TRUST'] = button.get_active() self._plugin.config['BLIND_TRUST'] = button.get_active()
def update_context_list(self): def update_context_list(self):
self._ui.deviceid_store.clear() self._ui.deviceid_store.clear()
@@ -151,7 +166,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
self._ui.cleardevice_button.set_sensitive(True) self._ui.cleardevice_button.set_sensitive(True)
# Set FPR Label and DeviceID # Set FPR Label and DeviceID
omemo = self.plugin.get_omemo(account) omemo = self._plugin.get_omemo(account)
self._ui.ID.set_markup('<tt>%s</tt>' % omemo.backend.own_device) self._ui.ID.set_markup('<tt>%s</tt>' % omemo.backend.own_device)
identity_key = omemo.backend.storage.getIdentityKeyPair() identity_key = omemo.backend.storage.getIdentityKeyPair()
@@ -165,4 +180,4 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
def update_settings(self): def update_settings(self):
self._ui.blind_trust_checkbutton.set_active( self._ui.blind_trust_checkbutton.set_active(
self.plugin.config['BLIND_TRUST']) self._plugin.config['BLIND_TRUST'])

View File

@@ -21,6 +21,7 @@ import binascii
import threading import threading
from enum import IntEnum, unique from enum import IntEnum, unique
from pathlib import Path from pathlib import Path
from functools import partial
from gi.repository import GLib from gi.repository import GLib
from gi.repository import Gtk from gi.repository import Gtk
@@ -95,7 +96,8 @@ class OmemoPlugin(GajimPlugin):
'room-joined': (ged.GUI1, self._on_muc_joined), 'room-joined': (ged.GUI1, self._on_muc_joined),
} }
self.modules = [omemo] self.modules = [omemo]
self.config_dialog = OMEMOConfigDialog(self)
self.config_dialog = partial(OMEMOConfigDialog, self)
self.gui_extension_points = { self.gui_extension_points = {
'encrypt' + self.encryption_name: (self._encrypt_message, None), 'encrypt' + self.encryption_name: (self._encrypt_message, None),
'gc_encrypt' + self.encryption_name: ( 'gc_encrypt' + self.encryption_name: (