2017-03-12 13:44:09 +00:00
|
|
|
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 {
|
|
|
|
|
2017-08-14 11:48:43 +00:00
|
|
|
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 EncryptionListEntry list_entry;
|
|
|
|
private AccountSettingsEntry settings_entry;
|
|
|
|
private ContactDetailsProvider contact_details_provider;
|
|
|
|
|
|
|
|
public void registered(Dino.Application app) {
|
|
|
|
this.app = app;
|
|
|
|
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "pgp.db"));
|
2019-08-02 01:15:12 +00:00
|
|
|
this.list_entry = new EncryptionListEntry(app.stream_interactor, db);
|
2017-08-14 11:48:43 +00:00
|
|
|
this.settings_entry = new AccountSettingsEntry(this);
|
2017-08-25 19:20:09 +00:00
|
|
|
this.contact_details_provider = new ContactDetailsProvider(app.stream_interactor);
|
2017-08-14 11:48:43 +00:00
|
|
|
|
|
|
|
app.plugin_registry.register_encryption_list_entry(list_entry);
|
|
|
|
app.plugin_registry.register_account_settings_entry(settings_entry);
|
|
|
|
app.plugin_registry.register_contact_details_entry(contact_details_provider);
|
2017-08-25 19:20:09 +00:00
|
|
|
app.stream_interactor.module_manager.initialize_account_modules.connect(on_initialize_account_modules);
|
2017-08-14 11:48:43 +00:00
|
|
|
|
2017-08-25 19:20:09 +00:00
|
|
|
Manager.start(app.stream_interactor, db);
|
2019-07-18 00:03:42 +00:00
|
|
|
app.stream_interactor.get_module(FileManager.IDENTITY).add_file_encryptor(new PgpFileEncryptor(app.stream_interactor));
|
|
|
|
app.stream_interactor.get_module(FileManager.IDENTITY).add_file_decryptor(new PgpFileDecryptor());
|
2017-08-14 11:48:43 +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
|
|
|
|
2017-08-14 11:48:43 +00:00
|
|
|
public void shutdown() { }
|
2017-03-12 13:44:09 +00:00
|
|
|
|
2018-01-12 20:03:09 +00:00
|
|
|
private void on_initialize_account_modules(Account account, ArrayList<Xmpp.XmppStreamModule> modules) {
|
2017-08-14 11:48:43 +00:00
|
|
|
Module module = new Module(db.get_account_key(account));
|
|
|
|
this.modules[account] = module;
|
|
|
|
modules.add(module);
|
2017-03-12 01:49:53 +00:00
|
|
|
}
|
2017-08-14 11:48:43 +00:00
|
|
|
}
|
2017-03-12 01:49:53 +00:00
|
|
|
|
|
|
|
}
|