2017-04-07 09:09:47 +00:00
|
|
|
extern const string GETTEXT_PACKAGE;
|
|
|
|
extern const string LOCALE_INSTALL_DIR;
|
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
namespace Dino.Plugins.Omemo {
|
2017-03-11 00:29:38 +00:00
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
public class Plugin : RootInterface, Object {
|
2017-03-15 16:23:13 +00:00
|
|
|
public const bool DEBUG = false;
|
2017-04-18 15:55:20 +00:00
|
|
|
private static Signal.Context? _context;
|
|
|
|
public static Signal.Context get_context() {
|
|
|
|
assert(_context != null);
|
|
|
|
return (!)_context;
|
|
|
|
}
|
|
|
|
public static bool ensure_context() {
|
|
|
|
lock(_context) {
|
|
|
|
try {
|
|
|
|
if (_context == null) {
|
|
|
|
_context = new Signal.Context(DEBUG);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} catch (Error e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-11 00:29:38 +00:00
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
public Dino.Application app;
|
|
|
|
public Database db;
|
|
|
|
public EncryptionListEntry list_entry;
|
|
|
|
public AccountSettingsEntry settings_entry;
|
2017-05-13 15:48:13 +00:00
|
|
|
public ContactDetailsProvider contact_details_provider;
|
2017-03-11 00:29:38 +00:00
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
public void registered(Dino.Application app) {
|
2017-10-28 21:48:07 +00:00
|
|
|
ensure_context();
|
|
|
|
this.app = app;
|
|
|
|
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "omemo.db"));
|
|
|
|
this.list_entry = new EncryptionListEntry(this);
|
|
|
|
this.settings_entry = new AccountSettingsEntry(this);
|
|
|
|
this.contact_details_provider = new ContactDetailsProvider(this);
|
|
|
|
this.app.plugin_registry.register_encryption_list_entry(list_entry);
|
|
|
|
this.app.plugin_registry.register_account_settings_entry(settings_entry);
|
|
|
|
this.app.plugin_registry.register_contact_details_entry(contact_details_provider);
|
|
|
|
this.app.stream_interactor.module_manager.initialize_account_modules.connect((account, list) => {
|
|
|
|
list.add(new StreamModule());
|
|
|
|
});
|
|
|
|
Manager.start(this.app.stream_interactor, db);
|
2017-04-07 09:09:47 +00:00
|
|
|
|
2017-10-28 21:48:07 +00:00
|
|
|
string locales_dir;
|
|
|
|
if (app.search_path_generator != null) {
|
|
|
|
locales_dir = ((!)app.search_path_generator).get_locale_path(GETTEXT_PACKAGE, LOCALE_INSTALL_DIR);
|
|
|
|
} else {
|
|
|
|
locales_dir = LOCALE_INSTALL_DIR;
|
2017-03-11 00:29:38 +00:00
|
|
|
}
|
2017-10-28 21:48:07 +00:00
|
|
|
internationalize(GETTEXT_PACKAGE, locales_dir);
|
2017-03-11 00:29:38 +00:00
|
|
|
}
|
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
public void shutdown() {
|
|
|
|
// Nothing to do
|
|
|
|
}
|
2017-03-11 00:29:38 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 19:20:09 +00:00
|
|
|
}
|