aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src/plugin.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-12 14:44:09 +0100
committerfiaxh <git@mx.ax.lt>2017-03-12 14:44:09 +0100
commitf24b47c44db03a8d9ba611f827e71aeb1f63d0bd (patch)
tree85a2622877dab97b15ff4862505f3770adaf4bd0 /plugins/openpgp/src/plugin.vala
parentdbbe5e39d069196aa17951b12575492cfa8c7976 (diff)
downloaddino-f24b47c44db03a8d9ba611f827e71aeb1f63d0bd.tar.gz
dino-f24b47c44db03a8d9ba611f827e71aeb1f63d0bd.zip
PGP module: store data in own db, use pgp key as specified in account settings
Diffstat (limited to 'plugins/openpgp/src/plugin.vala')
-rw-r--r--plugins/openpgp/src/plugin.vala26
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/openpgp/src/plugin.vala b/plugins/openpgp/src/plugin.vala
index d25c8cd0..b69f7b7a 100644
--- a/plugins/openpgp/src/plugin.vala
+++ b/plugins/openpgp/src/plugin.vala
@@ -1,28 +1,36 @@
+using Gee;
+
+using Dino.Entities;
+
namespace Dino.Plugins.OpenPgp {
public class Plugin : Plugins.RootInterface, Object {
public Dino.Application app;
public Database db;
+ public HashMap<Account, Module> modules = new HashMap<Account, Module>(Account.hash_func, Account.equals_func);
- private Module module;
private EncryptionListEntry list_entry;
private AccountSettingsEntry settings_entry;
public void registered(Dino.Application app) {
this.app = app;
- this.module = new Module();
+ this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db"));
this.list_entry = new EncryptionListEntry(app.stream_interaction);
- this.settings_entry = new AccountSettingsEntry();
+ this.settings_entry = new AccountSettingsEntry(this);
+
app.plugin_registry.register_encryption_list_entry(list_entry);
app.plugin_registry.register_account_settings_entry(settings_entry);
- app.stream_interaction.module_manager.initialize_account_modules.connect((account, list) => {
- list.add(new Module());
- });
- Manager.start(app.stream_interaction, app.db);
+ app.stream_interaction.module_manager.initialize_account_modules.connect(on_initialize_account_modules);
+
+ Manager.start(app.stream_interaction, db);
}
- public void shutdown() {
- // Nothing to do
+ public void shutdown() { }
+
+ private void on_initialize_account_modules(Account account, ArrayList<Xmpp.Core.XmppStreamModule> modules) {
+ Module module = new Module(db.get_account_key(account));
+ this.modules[account] = module;
+ modules.add(module);
}
}