dino/plugins/openpgp/src/plugin.vala

43 lines
1.6 KiB
Vala
Raw Normal View History

using Gee;
using Dino.Entities;
2017-04-07 09:09:47 +00:00
extern const string GETTEXT_PACKAGE;
extern const string LOCALE_INSTALL_DIR;
2017-03-12 01:49:53 +00:00
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);
2017-03-12 01:49:53 +00:00
private EncryptionListEntry list_entry;
private AccountSettingsEntry settings_entry;
public void registered(Dino.Application app) {
this.app = app;
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db"));
2017-03-12 01:49:53 +00:00
this.list_entry = new EncryptionListEntry(app.stream_interaction);
this.settings_entry = new AccountSettingsEntry(this);
2017-03-12 01:49:53 +00:00
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(on_initialize_account_modules);
Manager.start(app.stream_interaction, db);
2017-04-07 09:09:47 +00:00
internationalize(GETTEXT_PACKAGE, app.search_path_generator.get_locale_path(GETTEXT_PACKAGE, LOCALE_INSTALL_DIR));
2017-03-12 01:49:53 +00:00
}
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);
2017-03-12 01:49:53 +00:00
}
}
}