diff options
author | fiaxh <git@mx.ax.lt> | 2018-01-19 22:37:02 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2018-01-28 13:37:53 +0100 |
commit | 57c72d2818dec6c713834cfbb8c4c566a1602907 (patch) | |
tree | 0f7102171049cce6f6732b658d005b3c57140271 /plugins/openpgp/src | |
parent | ca331e85efe2a74a6b9b5a5ff0fbcd10a36758ce (diff) | |
download | dino-57c72d2818dec6c713834cfbb8c4c566a1602907.tar.gz dino-57c72d2818dec6c713834cfbb8c4c566a1602907.zip |
Pipeline for incoming messages in libdino
Diffstat (limited to 'plugins/openpgp/src')
-rw-r--r-- | plugins/openpgp/src/manager.vala | 23 | ||||
-rw-r--r-- | plugins/openpgp/src/stream_module.vala | 3 |
2 files changed, 18 insertions, 8 deletions
diff --git a/plugins/openpgp/src/manager.vala b/plugins/openpgp/src/manager.vala index 79e832ff..4f8b87bb 100644 --- a/plugins/openpgp/src/manager.vala +++ b/plugins/openpgp/src/manager.vala @@ -15,6 +15,7 @@ public class Manager : StreamInteractionModule, Object { private StreamInteractor stream_interactor; private Database db; private HashMap<Jid, string> pgp_key_ids = new HashMap<Jid, string>(Jid.hash_bare_func, Jid.equals_bare_func); + private ReceivedMessageListener received_message_listener = new ReceivedMessageListener(); public static void start(StreamInteractor stream_interactor, Database db) { Manager m = new Manager(stream_interactor, db); @@ -26,7 +27,7 @@ public class Manager : StreamInteractionModule, Object { this.db = db; stream_interactor.account_added.connect(on_account_added); - stream_interactor.get_module(MessageProcessor.IDENTITY).pre_message_received.connect(on_pre_message_received); + stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(received_message_listener); stream_interactor.get_module(MessageProcessor.IDENTITY).pre_message_send.connect(check_encypt); } @@ -63,12 +64,6 @@ public class Manager : StreamInteractionModule, Object { return gpgkeys; } - private void on_pre_message_received(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) { - if (MessageFlag.get_flag(message_stanza) != null && MessageFlag.get_flag(message_stanza).decrypted) { - message.encryption = Encryption.PGP; - } - } - private void check_encypt(Entities.Message message, Xmpp.MessageStanza message_stanza, Conversation conversation) { try { if (message.encryption == Encryption.PGP) { @@ -104,6 +99,20 @@ public class Manager : StreamInteractionModule, Object { pgp_key_ids[jid] = key_id; } } + + private class ReceivedMessageListener : MessageListener { + + public string[] after_actions_const = new string[]{ "" }; + public override string action_group { get { return "DECRYPT"; } } + public override string[] after_actions { get { return after_actions_const; } } + + public override async bool run(Entities.Message message, Xmpp.MessageStanza stanza, Conversation conversation) { + if (MessageFlag.get_flag(stanza) != null && MessageFlag.get_flag(stanza).decrypted) { + message.encryption = Encryption.PGP; + } + return false; + } + } } } diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala index a8b821de..3bcc3326 100644 --- a/plugins/openpgp/src/stream_module.vala +++ b/plugins/openpgp/src/stream_module.vala @@ -140,7 +140,7 @@ public class ReceivedPipelineDecryptListener : StanzaListener<MessageStanza> { public override string action_group { get { return "ENCRYPT_BODY"; } } public override string[] after_actions { get { return after_actions_const; } } - public override async void run(XmppStream stream, MessageStanza message) { + public override async bool run(XmppStream stream, MessageStanza message) { string? encrypted = get_cyphertext(message); if (encrypted != null) { MessageFlag flag = new MessageFlag(); @@ -151,6 +151,7 @@ public class ReceivedPipelineDecryptListener : StanzaListener<MessageStanza> { message.body = decrypted; } } + return false; } private static async string? gpg_decrypt(string enc) { |