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-03-12 01:28:23 +00:00
|
|
|
public static Signal.Context context;
|
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-03-11 00:29:38 +00:00
|
|
|
|
2017-03-12 01:28:23 +00:00
|
|
|
public void registered(Dino.Application app) {
|
|
|
|
try {
|
2017-03-15 16:23:13 +00:00
|
|
|
context = new Signal.Context(DEBUG);
|
2017-03-11 00:29:38 +00:00
|
|
|
this.app = app;
|
2017-03-12 12:19:04 +00:00
|
|
|
this.db = new Database(Path.build_filename(Application.get_storage_dir(), "omemo.db"));
|
2017-03-11 00:29:38 +00:00
|
|
|
this.list_entry = new EncryptionListEntry(this);
|
|
|
|
this.settings_entry = new AccountSettingsEntry(this);
|
2017-03-12 01:28:23 +00:00
|
|
|
this.app.plugin_registry.register_encryption_list_entry(list_entry);
|
|
|
|
this.app.plugin_registry.register_account_settings_entry(settings_entry);
|
|
|
|
this.app.stream_interaction.module_manager.initialize_account_modules.connect((account, list) => {
|
|
|
|
list.add(new StreamModule());
|
2017-03-11 00:29:38 +00:00
|
|
|
});
|
2017-03-12 01:28:23 +00:00
|
|
|
Manager.start(this.app.stream_interaction, db);
|
|
|
|
} catch (Error e) {
|
|
|
|
print(@"Error initializing OMEMO: $(e.message)\n");
|
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-03-12 01:28:23 +00:00
|
|
|
}
|