diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/omemo/src/encryption_list_entry.vala | 2 | ||||
-rw-r--r-- | plugins/omemo/src/manager.vala | 23 | ||||
-rw-r--r-- | plugins/omemo/src/stream_module.vala | 7 | ||||
-rw-r--r-- | plugins/openpgp/src/encryption_list_entry.vala | 2 | ||||
-rw-r--r-- | plugins/openpgp/src/manager.vala | 20 | ||||
-rw-r--r-- | plugins/openpgp/src/stream_flag.vala | 9 | ||||
-rw-r--r-- | plugins/openpgp/src/stream_module.vala | 7 |
7 files changed, 26 insertions, 44 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; } } diff --git a/plugins/openpgp/src/encryption_list_entry.vala b/plugins/openpgp/src/encryption_list_entry.vala index 96607e1e..9aac3db2 100644 --- a/plugins/openpgp/src/encryption_list_entry.vala +++ b/plugins/openpgp/src/encryption_list_entry.vala @@ -19,7 +19,7 @@ private class EncryptionListEntry : Plugins.EncryptionListEntry, Object { }} public bool can_encrypt(Entities.Conversation conversation) { - return Manager.get_instance(stream_interactor).get_key_id(conversation.account, conversation.counterpart) != null; + return stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart) != null; } } diff --git a/plugins/openpgp/src/manager.vala b/plugins/openpgp/src/manager.vala index 0941362e..a261c2cb 100644 --- a/plugins/openpgp/src/manager.vala +++ b/plugins/openpgp/src/manager.vala @@ -7,7 +7,8 @@ using Dino.Entities; namespace Dino.Plugins.OpenPgp { public class Manager : StreamInteractionModule, Object { - public const string id = "pgp_manager"; + public static ModuleIdentity<Manager> IDENTITY = new ModuleIdentity<Manager>("pgp_manager"); + public string id { get { return IDENTITY.id; } } public const string MESSAGE_ENCRYPTED = "pgp"; @@ -25,8 +26,8 @@ namespace Dino.Plugins.OpenPgp { this.db = db; 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) { @@ -40,7 +41,8 @@ namespace Dino.Plugins.OpenPgp { string? key_id = get_key_id(conversation.account, message.counterpart); bool encrypted = false; if (key_id != null) { - encrypted = stream_interactor.get_stream(conversation.account).get_module(Module.IDENTITY).encrypt(message_stanza, key_id); + Core.XmppStream? stream = stream_interactor.get_stream(conversation.account); + if (stream != null) encrypted = stream.get_module(Module.IDENTITY).encrypt(message_stanza, key_id); } if (!encrypted) { message.marked = Entities.Message.Marked.WONTSEND; @@ -52,14 +54,6 @@ namespace Dino.Plugins.OpenPgp { return db.get_contact_key(jid); } - public static Manager? get_instance(StreamInteractor stream_interactor) { - return (Manager) stream_interactor.get_module(id); - } - - internal string get_id() { - return id; - } - private void on_account_added(Account account) { stream_interactor.module_manager.get_module(account, Module.IDENTITY).received_jid_key_id.connect((stream, jid, key_id) => { on_jid_key_received(account, new Jid(jid), key_id); @@ -69,7 +63,7 @@ namespace Dino.Plugins.OpenPgp { private void on_jid_key_received(Account account, Jid jid, string key_id) { lock (pgp_key_ids) { if (!pgp_key_ids.has_key(jid) || pgp_key_ids[jid] != key_id) { - if (!MucManager.get_instance(stream_interactor).is_groupchat_occupant(jid, account)) { + if (!stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid, account)) { db.set_contact_key(jid.bare_jid, key_id); } } diff --git a/plugins/openpgp/src/stream_flag.vala b/plugins/openpgp/src/stream_flag.vala index 5ace26bd..165327b9 100644 --- a/plugins/openpgp/src/stream_flag.vala +++ b/plugins/openpgp/src/stream_flag.vala @@ -6,20 +6,17 @@ using Xmpp.Core; namespace Dino.Plugins.OpenPgp { public class Flag : XmppStreamFlag { - public const string ID = "pgp"; + public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "pgp"); + public HashMap<string, string> key_ids = new HashMap<string, string>(); public string? get_key_id(string jid) { return key_ids[get_bare_jid(jid)]; } public void set_key_id(string jid, string key) { key_ids[get_bare_jid(jid)] = key; } - public static Flag? get_flag(XmppStream stream) { return (Flag?) stream.get_flag(NS_URI, ID); } - - public static bool has_flag(XmppStream stream) { return get_flag(stream) != null; } - public override string get_ns() { return NS_URI; } - public override string get_id() { return ID; } + public override string get_id() { return IDENTITY.id; } } }
\ No newline at end of file diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala index 6de97066..b9742624 100644 --- a/plugins/openpgp/src/stream_module.vala +++ b/plugins/openpgp/src/stream_module.vala @@ -9,8 +9,7 @@ namespace Dino.Plugins.OpenPgp { private const string NS_URI_SIGNED = NS_URI + ":signed"; public class Module : XmppStreamModule { - public const string ID = "0027_current_pgp_usage"; - public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, ID); + public static Core.ModuleIdentity<Module> IDENTITY = new Core.ModuleIdentity<Module>(NS_URI, "0027_current_pgp_usage"); public signal void received_jid_key_id(XmppStream stream, string jid, string key_id); @@ -69,7 +68,7 @@ namespace Dino.Plugins.OpenPgp { } public override string get_ns() { return NS_URI; } - public override string get_id() { return ID; } + public override string get_id() { return IDENTITY.id; } private void on_received_presence(XmppStream stream, Presence.Stanza presence) { StanzaNode x_node = presence.stanza.get_subnode("x", NS_URI_SIGNED); @@ -79,7 +78,7 @@ namespace Dino.Plugins.OpenPgp { string signed_data = presence.status == null ? "" : presence.status; string? key_id = get_sign_key(sig, signed_data); if (key_id != null) { - Flag.get_flag(stream).set_key_id(presence.from, key_id); + stream.get_flag(Flag.IDENTITY).set_key_id(presence.from, key_id); received_jid_key_id(stream, presence.from, key_id); } } |