aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-19 12:55:36 +0100
committerfiaxh <git@mx.ax.lt>2017-03-20 22:28:27 +0100
commitdb57a973534f099af2b150f1a1307d1948553d9f (patch)
tree238ae1d4e53412a33e3febd07318dfd38b0eb2f8 /plugins/omemo/src
parent233f2b35d033cd20d1ac648bf2d723bcb7a918fc (diff)
downloaddino-db57a973534f099af2b150f1a1307d1948553d9f.tar.gz
dino-db57a973534f099af2b150f1a1307d1948553d9f.zip
Add typed identity to manager modules and stream flags
Diffstat (limited to 'plugins/omemo/src')
-rw-r--r--plugins/omemo/src/encryption_list_entry.vala2
-rw-r--r--plugins/omemo/src/manager.vala23
-rw-r--r--plugins/omemo/src/stream_module.vala7
3 files changed, 12 insertions, 20 deletions
diff --git a/plugins/omemo/src/encryption_list_entry.vala b/plugins/omemo/src/encryption_list_entry.vala
index 753ffe67..7b769e85 100644
--- a/plugins/omemo/src/encryption_list_entry.vala
+++ b/plugins/omemo/src/encryption_list_entry.vala
@@ -16,7 +16,7 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object {
}}
public bool can_encrypt(Entities.Conversation conversation) {
- return Manager.get_instance(plugin.app.stream_interaction).can_encrypt(conversation);
+ return plugin.app.stream_interaction.get_module(Manager.IDENTITY).can_encrypt(conversation);
}
}
diff --git a/plugins/omemo/src/manager.vala b/plugins/omemo/src/manager.vala
index a48f4748..67b38bc5 100644
--- a/plugins/omemo/src/manager.vala
+++ b/plugins/omemo/src/manager.vala
@@ -7,7 +7,8 @@ using Gee;
namespace Dino.Plugins.Omemo {
public class Manager : StreamInteractionModule, Object {
- public const string id = "omemo_manager";
+ public static ModuleIdentity<Manager> IDENTITY = new ModuleIdentity<Manager>("omemo_manager");
+ public string id { get { return IDENTITY.id; } }
private StreamInteractor stream_interactor;
private Database db;
@@ -64,8 +65,8 @@ public class Manager : StreamInteractionModule, Object {
stream_interactor.stream_negotiated.connect(on_stream_negotiated);
stream_interactor.account_added.connect(on_account_added);
- MessageManager.get_instance(stream_interactor).pre_message_received.connect(on_pre_message_received);
- MessageManager.get_instance(stream_interactor).pre_message_send.connect(on_pre_message_send);
+ stream_interactor.get_module(MessageManager.IDENTITY).pre_message_received.connect(on_pre_message_received);
+ stream_interactor.get_module(MessageManager.IDENTITY).pre_message_send.connect(on_pre_message_send);
}
private void on_pre_message_received(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
@@ -143,8 +144,8 @@ public class Manager : StreamInteractionModule, Object {
}
}
foreach (Entities.Message msg in send_now) {
- Entities.Conversation conv = ConversationManager.get_instance(stream_interactor).get_conversation(msg.counterpart, account);
- MessageManager.get_instance(stream_interactor).send_xmpp_message(msg, conv, true);
+ Entities.Conversation conv = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(msg.counterpart, account);
+ stream_interactor.get_module(MessageManager.IDENTITY).send_xmpp_message(msg, conv, true);
}
}
@@ -167,8 +168,8 @@ public class Manager : StreamInteractionModule, Object {
}
}
foreach (Entities.Message msg in send_now) {
- Entities.Conversation conv = ConversationManager.get_instance(stream_interactor).get_conversation(msg.counterpart, account);
- MessageManager.get_instance(stream_interactor).send_xmpp_message(msg, conv, true);
+ Entities.Conversation conv = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(msg.counterpart, account);
+ stream_interactor.get_module(MessageManager.IDENTITY).send_xmpp_message(msg, conv, true);
}
}
@@ -222,18 +223,10 @@ public class Manager : StreamInteractionModule, Object {
return stream.get_module(StreamModule.IDENTITY).is_known_address(conversation.counterpart.bare_jid.to_string());
}
- internal string get_id() {
- return id;
- }
-
public static void start(StreamInteractor stream_interactor, Database db) {
Manager m = new Manager(stream_interactor, db);
stream_interactor.add_module(m);
}
-
- public static Manager? get_instance(StreamInteractor stream_interactor) {
- return (Manager) stream_interactor.get_module(id);
- }
}
} \ No newline at end of file
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 14b1a93e..480d8705 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -14,8 +14,7 @@ private const string NODE_VERIFICATION = NS_URI + ".verification";
private const int NUM_KEYS_TO_PUBLISH = 100;
public class StreamModule : XmppStreamModule {
- private const string ID = "omemo_module";
- public static ModuleIdentity<StreamModule> IDENTITY = new ModuleIdentity<StreamModule>(NS_URI, ID);
+ public static Core.ModuleIdentity<StreamModule> IDENTITY = new Core.ModuleIdentity<StreamModule>(NS_URI, "omemo_module");
private Store store;
private ConcurrentSet<string> active_bundle_requests = new ConcurrentSet<string>();
@@ -189,7 +188,7 @@ public class StreamModule : XmppStreamModule {
public void on_devicelist(XmppStream stream, string jid, string id, StanzaNode? node_) {
StanzaNode? node = node_;
- if (jid == get_bare_jid(Bind.Flag.get_flag(stream).my_jid) && store.local_registration_id != 0) {
+ if (jid == get_bare_jid(stream.get_flag(Bind.Flag.IDENTITY).my_jid) && store.local_registration_id != 0) {
if (node == null) {
node = new StanzaNode.build("list", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("device", NS_URI));
}
@@ -422,7 +421,7 @@ public class StreamModule : XmppStreamModule {
}
public override string get_id() {
- return ID;
+ return IDENTITY.id;
}
}