[openpgp] 1.4.8

This commit is contained in:
wurstsalat
2022-10-06 17:15:49 +02:00
parent 7601311c7d
commit 29260fcc6f
5 changed files with 38 additions and 38 deletions

View File

@@ -56,7 +56,7 @@ class KeyDialog(Gtk.Dialog):
self.get_style_context().add_class('openpgp-key-dialog') self.get_style_context().add_class('openpgp-key-dialog')
self.con = app.connections[account] self._client = app.get_client(account)
self._listbox = Gtk.ListBox() self._listbox = Gtk.ListBox()
self._listbox.set_selection_mode(Gtk.SelectionMode.NONE) self._listbox.set_selection_mode(Gtk.SelectionMode.NONE)
@@ -69,7 +69,8 @@ class KeyDialog(Gtk.Dialog):
box = self.get_content_area() box = self.get_content_area()
box.pack_start(self._scrolled, True, True, 0) box.pack_start(self._scrolled, True, True, 0)
keys = self.con.get_module('OpenPGP').get_keys(jid, only_trusted=False) keys = self._client.get_module('OpenPGP').get_keys(
jid, only_trusted=False)
for key in keys: for key in keys:
log.info('Load: %s', key.fingerprint) log.info('Load: %s', key.fingerprint)
self._listbox.add(KeyRow(key)) self._listbox.add(KeyRow(key))

View File

@@ -38,7 +38,7 @@ class KeyWizard(Gtk.Assistant):
def __init__(self, plugin, account, chat_control): def __init__(self, plugin, account, chat_control):
Gtk.Assistant.__init__(self) Gtk.Assistant.__init__(self)
self._con = app.connections[account] self._client = app.get_client(account)
self._plugin = plugin self._plugin = plugin
self._account = account self._account = account
self._data_form_widget = None self._data_form_widget = None
@@ -55,7 +55,7 @@ class KeyWizard(Gtk.Assistant):
self._add_page(WelcomePage()) self._add_page(WelcomePage())
# self._add_page(BackupKeyPage()) # self._add_page(BackupKeyPage())
self._add_page(NewKeyPage(self, self._con)) self._add_page(NewKeyPage(self, self._client))
# self._add_page(SaveBackupCodePage()) # self._add_page(SaveBackupCodePage())
self._add_page(SuccessfulPage()) self._add_page(SuccessfulPage())
self._add_page(ErrorPage()) self._add_page(ErrorPage())
@@ -85,7 +85,7 @@ class KeyWizard(Gtk.Assistant):
def _on_page_change(self, assistant, page): def _on_page_change(self, assistant, page):
if self.get_current_page() == Page.NEWKEY: if self.get_current_page() == Page.NEWKEY:
if self._con.get_module('OpenPGP').secret_key_available: if self._client.get_module('OpenPGP').secret_key_available:
self.set_current_page(Page.SUCCESS) self.set_current_page(Page.SUCCESS)
else: else:
page.generate() page.generate()
@@ -150,10 +150,10 @@ class NewKeyPage(RequestPage):
title = _('Generating new Key') title = _('Generating new Key')
complete = False complete = False
def __init__(self, assistant, con): def __init__(self, assistant, client):
super().__init__() super().__init__()
self._assistant = assistant self._assistant = assistant
self._con = con self._client = client
def generate(self): def generate(self):
log.info('Creating Key') log.info('Creating Key')
@@ -163,7 +163,7 @@ class NewKeyPage(RequestPage):
def worker(self): def worker(self):
text = None text = None
try: try:
self._con.get_module('OpenPGP').generate_key() self._client.get_module('OpenPGP').generate_key()
except Exception as error: except Exception as error:
text = str(error) text = str(error)
@@ -171,9 +171,9 @@ class NewKeyPage(RequestPage):
def finished(self, error): def finished(self, error):
if error is None: if error is None:
self._con.get_module('OpenPGP').get_own_key_details() self._client.get_module('OpenPGP').get_own_key_details()
self._con.get_module('OpenPGP').set_public_key() self._client.get_module('OpenPGP').set_public_key()
self._con.get_module('OpenPGP').request_keylist() self._client.get_module('OpenPGP').request_keylist()
self._assistant.set_current_page(Page.SUCCESS) self._assistant.set_current_page(Page.SUCCESS)
else: else:
error_page = self._assistant.get_nth_page(Page.ERROR) error_page = self._assistant.get_nth_page(Page.ERROR)

View File

@@ -73,8 +73,8 @@ class OpenPGP(BaseModule):
'request_secret_key', 'request_secret_key',
] ]
def __init__(self, con): def __init__(self, client):
BaseModule.__init__(self, con) BaseModule.__init__(self, client)
self.handlers = [ self.handlers = [
StanzaHandler(name='message', StanzaHandler(name='message',
@@ -85,7 +85,7 @@ class OpenPGP(BaseModule):
self._register_pubsub_handler(self._keylist_notification_received) self._register_pubsub_handler(self._keylist_notification_received)
self.own_jid = self._con.get_own_jid() self.own_jid = self._client.get_own_jid()
own_bare_jid = self.own_jid.bare own_bare_jid = self.own_jid.bare
path = Path(configpaths.get('MY_DATA')) / 'openpgp' / own_bare_jid path = Path(configpaths.get('MY_DATA')) / 'openpgp' / own_bare_jid
@@ -265,7 +265,7 @@ class OpenPGP(BaseModule):
if error: if error:
log.error('Error: %s', error) log.error('Error: %s', error)
app.ged.raise_event( app.ged.raise_event(
MessageNotSent(client=self._con, MessageNotSent(client=self._client,
jid=obj.jid, jid=obj.jid,
message=obj.message, message=obj.message,
error=error, error=error,

View File

@@ -104,24 +104,23 @@ class OpenPGPPlugin(GajimPlugin):
keyring_path.mkdir() keyring_path.mkdir()
def signed_in(self, event): def signed_in(self, event):
account = event.conn.name client = app.get_client(event.account)
con = app.connections[account] if client.get_module('OpenPGP').secret_key_available:
if con.get_module('OpenPGP').secret_key_available:
log.info('%s => Publish keylist and public key after sign in', log.info('%s => Publish keylist and public key after sign in',
account) event.account)
con.get_module('OpenPGP').request_keylist() client.get_module('OpenPGP').request_keylist()
con.get_module('OpenPGP').set_public_key() client.get_module('OpenPGP').set_public_key()
def activate(self): def activate(self):
for account in app.connections: for account in app.settings.get_active_accounts():
con = app.connections[account] client = app.get_client(account)
con.get_module('Caps').update_caps() client.get_module('Caps').update_caps()
if app.account_is_connected(account): if app.account_is_connected(account):
if con.get_module('OpenPGP').secret_key_available: if client.get_module('OpenPGP').secret_key_available:
log.info('%s => Publish keylist and public key ' log.info('%s => Publish keylist and public key '
'after plugin activation', account) 'after plugin activation', account)
con.get_module('OpenPGP').request_keylist() client.get_module('OpenPGP').request_keylist()
con.get_module('OpenPGP').set_public_key() client.get_module('OpenPGP').set_public_key()
def deactivate(self): def deactivate(self):
pass pass
@@ -133,12 +132,12 @@ class OpenPGPPlugin(GajimPlugin):
def activate_encryption(self, chat_control): def activate_encryption(self, chat_control):
account = chat_control.account account = chat_control.account
jid = chat_control.contact.jid jid = chat_control.contact.jid
con = app.connections[account] client = app.get_client(account)
if con.get_module('OpenPGP').secret_key_available: if client.get_module('OpenPGP').secret_key_available:
keys = app.connections[account].get_module('OpenPGP').get_keys( keys = client.get_module('OpenPGP').get_keys(
jid, only_trusted=False) jid, only_trusted=False)
if not keys: if not keys:
con.get_module('OpenPGP').request_keylist(JID.from_string(jid)) client.get_module('OpenPGP').request_keylist(JID.from_string(jid))
return True return True
from openpgp.gtk.wizard import KeyWizard from openpgp.gtk.wizard import KeyWizard
@@ -161,14 +160,14 @@ class OpenPGPPlugin(GajimPlugin):
def _before_sendmessage(self, chat_control): def _before_sendmessage(self, chat_control):
account = chat_control.account account = chat_control.account
jid = chat_control.contact.jid jid = chat_control.contact.jid
con = app.connections[account] client = app.get_client(account)
if not con.get_module('OpenPGP').secret_key_available: if not client.get_module('OpenPGP').secret_key_available:
from openpgp.gtk.wizard import KeyWizard from openpgp.gtk.wizard import KeyWizard
KeyWizard(self, account, chat_control) KeyWizard(self, account, chat_control)
return return
keys = con.get_module('OpenPGP').get_keys(jid) keys = client.get_module('OpenPGP').get_keys(jid)
if not keys: if not keys:
ErrorDialog( ErrorDialog(
_('Not Trusted'), _('Not Trusted'),
@@ -176,7 +175,7 @@ class OpenPGPPlugin(GajimPlugin):
chat_control.sendmessage = False chat_control.sendmessage = False
@staticmethod @staticmethod
def _encrypt_message(con, obj, callback): def _encrypt_message(client, obj, callback):
if not con.get_module('OpenPGP').secret_key_available: if not client.get_module('OpenPGP').secret_key_available:
return return
con.get_module('OpenPGP').encrypt_message(obj, callback) client.get_module('OpenPGP').encrypt_message(obj, callback)

View File

@@ -16,5 +16,5 @@
"gajim>=1.4.0" "gajim>=1.4.0"
], ],
"short_name": "pgp", "short_name": "pgp",
"version": "1.4.7" "version": "1.4.8"
} }