aboutsummaryrefslogtreecommitdiff
path: root/plugins/openpgp/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-11-21 23:27:27 +0100
committerfiaxh <git@mx.ax.lt>2017-11-22 00:40:41 +0100
commitde133218dab0ac1729dbfc32177979133c15f53b (patch)
tree1cecc41b9f54841dd44cc348a564d9fd7f999f9e /plugins/openpgp/src
parentf3063f56b7e2ccfef255256d5bf527988fcf2957 (diff)
downloaddino-de133218dab0ac1729dbfc32177979133c15f53b.tar.gz
dino-de133218dab0ac1729dbfc32177979133c15f53b.zip
Disconnect stanza listeners from pipeline
Diffstat (limited to 'plugins/openpgp/src')
-rw-r--r--plugins/openpgp/src/stream_module.vala31
1 files changed, 15 insertions, 16 deletions
diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala
index 6264ce49..a2b48dd9 100644
--- a/plugins/openpgp/src/stream_module.vala
+++ b/plugins/openpgp/src/stream_module.vala
@@ -15,6 +15,7 @@ namespace Dino.Plugins.OpenPgp {
private string? signed_status = null;
private Key? own_key = null;
+ private ReceivedPipelineDecryptListener received_pipeline_decrypt_listener = new ReceivedPipelineDecryptListener();
public Module(string? own_key_id = null) {
set_private_key_id(own_key_id);
@@ -28,7 +29,6 @@ namespace Dino.Plugins.OpenPgp {
} catch (Error e) { }
if (own_key != null) {
signed_status = gpg_sign("", own_key);
- get_sign_key(signed_status, "");
}
}
}
@@ -46,13 +46,14 @@ namespace Dino.Plugins.OpenPgp {
public override void attach(XmppStream stream) {
stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(new ReceivedPipelineDecryptListener());
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_decrypt_listener);
stream.add_flag(new Flag());
}
public override void detach(XmppStream stream) {
stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza);
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_decrypt_listener);
}
public static void require(XmppStream stream) {
@@ -63,21 +64,19 @@ namespace Dino.Plugins.OpenPgp {
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);
+ if (x_node == null) return;
+ string? sig = x_node.get_string_content();
+ if (sig == null) return;
new Thread<void*> (null, () => {
- StanzaNode x_node = presence.stanza.get_subnode("x", NS_URI_SIGNED);
- if (x_node != null) {
- string? sig = x_node.get_string_content();
- if (sig != null) {
- string signed_data = presence.status == null ? "" : presence.status;
- string? key_id = get_sign_key(sig, signed_data);
- if (key_id != null) {
- stream.get_flag(Flag.IDENTITY).set_key_id(presence.from, key_id);
- Idle.add(() => {
- received_jid_key_id(stream, presence.from, key_id);
- return false;
- });
- }
- }
+ string signed_data = presence.status == null ? "" : presence.status;
+ string? key_id = get_sign_key(sig, signed_data);
+ if (key_id != null) {
+ stream.get_flag(Flag.IDENTITY).set_key_id(presence.from, key_id);
+ Idle.add(() => {
+ received_jid_key_id(stream, presence.from, key_id);
+ return false;
+ });
}
return null;
});