aboutsummaryrefslogtreecommitdiff
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
parentf3063f56b7e2ccfef255256d5bf527988fcf2957 (diff)
downloaddino-de133218dab0ac1729dbfc32177979133c15f53b.tar.gz
dino-de133218dab0ac1729dbfc32177979133c15f53b.zip
Disconnect stanza listeners from pipeline
-rw-r--r--main/data/im.dino.desktop2
-rw-r--r--plugins/http-files/src/file_provider.vala2
-rw-r--r--plugins/omemo/src/stream_module.vala12
-rw-r--r--plugins/openpgp/src/stream_module.vala31
-rw-r--r--xmpp-vala/src/module/util.vala9
-rw-r--r--xmpp-vala/src/module/xep/0085_chat_state_notifications.vala5
-rw-r--r--xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala5
-rw-r--r--xmpp-vala/src/module/xep/0203_delayed_delivery.vala8
-rw-r--r--xmpp-vala/src/module/xep/0280_message_carbons.vala5
-rw-r--r--xmpp-vala/src/module/xep/0313_message_archive_management.vala8
-rw-r--r--xmpp-vala/src/module/xep/0333_chat_markers.vala5
11 files changed, 59 insertions, 33 deletions
diff --git a/main/data/im.dino.desktop b/main/data/im.dino.desktop
index 6e2d2016..b53ef111 100644
--- a/main/data/im.dino.desktop
+++ b/main/data/im.dino.desktop
@@ -3,7 +3,7 @@ Version=1.0
Name=Dino
GenericName=Jabber/XMPP Client
Keywords=chat;talk;im;message;xmpp;jabber;
-Exec=dino
+Exec=dino %U
Icon=dino
StartupNotify=false
Terminal=false
diff --git a/plugins/http-files/src/file_provider.vala b/plugins/http-files/src/file_provider.vala
index 53fe3bb0..58ff6445 100644
--- a/plugins/http-files/src/file_provider.vala
+++ b/plugins/http-files/src/file_provider.vala
@@ -17,7 +17,7 @@ public class FileProvider : Dino.FileProvider, Object {
public FileProvider(StreamInteractor stream_interactor, Dino.Database dino_db) {
this.stream_interactor = stream_interactor;
this.url_regex = new Regex("""^(?i)\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))$""");
- this.file_ext_regex = new Regex("""\.(png|jpg|jpeg|svg|gif)""");
+ this.file_ext_regex = new Regex("""\.(png|jpg|jpeg|svg|gif|pgp)""");
stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(check_message);
stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(check_message);
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 75a919f7..1aa92801 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -21,6 +21,7 @@ public class StreamModule : XmppStreamModule {
private ConcurrentSet<string> active_devicelist_requests = new ConcurrentSet<string>();
private Map<string, ArrayList<int32>> device_lists = new HashMap<string, ArrayList<int32>>();
private Map<string, ArrayList<int32>> ignored_devices = new HashMap<string, ArrayList<int32>>();
+ private ReceivedPipelineListener received_pipeline_listener;
public signal void store_created(Store store);
public signal void device_list_loaded(string jid);
@@ -117,10 +118,15 @@ public class StreamModule : XmppStreamModule {
this.store = Plugin.get_context().create_store();
store_created(store);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(new ReceivedPipelineListener(store));
+ received_pipeline_listener = new ReceivedPipelineListener(store);
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node));
}
+ public override void detach(XmppStream stream) {
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
+ }
+
public void request_user_devicelist(XmppStream stream, string jid) {
if (active_devicelist_requests.add(jid)) {
if (Plugin.DEBUG) print(@"OMEMO: requesting device list for $jid\n");
@@ -369,10 +375,6 @@ public class StreamModule : XmppStreamModule {
stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, @"$NODE_BUNDLES:$device_id", @"$NODE_BUNDLES:$device_id", "1", bundle);
}
- public override void detach(XmppStream stream) {
-
- }
-
public override string get_ns() {
return NS_URI;
}
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;
});
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index e6626049..812b09ad 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -30,13 +30,18 @@ public abstract class StanzaListener<T> : Object {
}
public class StanzaListenerHolder<T> : Object {
- private Gee.List<StanzaListener<T>> listeners = new ArrayList<StanzaListener<T>>();
+ private ArrayList<StanzaListener<T>> listeners = new ArrayList<StanzaListener<T>>();
public new void connect(StanzaListener<T> listener) {
listeners.add(listener);
resort_list();
}
+ public new void disconnect(StanzaListener<T> listener) {
+ listeners.remove(listener);
+ resort_list();
+ }
+
public async void run(Core.XmppStream stream, T stanza) {
foreach (StanzaListener<T> l in listeners) {
yield l.run(stream, stanza);
@@ -63,7 +68,7 @@ public class StanzaListenerHolder<T> : Object {
}
private void resort_list() {
- Gee.List<StanzaListener<T>> new_list = new ArrayList<StanzaListener<T>>();
+ ArrayList<StanzaListener<T>> new_list = new ArrayList<StanzaListener<T>>();
while (listeners.size > new_list.size) {
bool changed = false;
foreach (StanzaListener<T> l in listeners) {
diff --git a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
index 3ca97282..e92763fb 100644
--- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
+++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala
@@ -18,6 +18,8 @@ public class Module : XmppStreamModule {
public signal void chat_state_received(XmppStream stream, string jid, string state);
+ private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
+
/**
* "A message stanza that does not contain standard messaging content [...] SHOULD be a state other than <active/>" (0085, 5.6)
*/
@@ -31,12 +33,13 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(new SendPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
index c9cb2d40..826b8726 100644
--- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
+++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala
@@ -8,6 +8,8 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
public signal void receipt_received(XmppStream stream, string jid, string id);
+ private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
+
public void send_received(XmppStream stream, string from, string message_id) {
Message.Stanza received_message = new Message.Stanza();
received_message.to = from;
@@ -22,11 +24,12 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
stream.get_module(Message.Module.IDENTITY).received_message.connect(received_message);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(new SendPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
}
public override void detach(XmppStream stream) {
stream.get_module(Message.Module.IDENTITY).received_message.disconnect(received_message);
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
diff --git a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
index 89c761f2..b36932b0 100644
--- a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
+++ b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala
@@ -6,6 +6,8 @@ namespace Xmpp.Xep.DelayedDelivery {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0203_delayed_delivery");
+ private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
+
public static void set_message_delay(Message.Stanza message, DateTime datetime) {
StanzaNode delay_node = (new StanzaNode.build("delay", NS_URI)).add_self_xmlns();
delay_node.put_attribute("stamp", DateTimeProfiles.to_datetime(datetime));
@@ -27,10 +29,12 @@ namespace Xmpp.Xep.DelayedDelivery {
}
public override void attach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(new ReceivedPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
}
- public override void detach(XmppStream stream) { }
+ public override void detach(XmppStream stream) {
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
+ }
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala
index 930c5234..8dc4e00c 100644
--- a/xmpp-vala/src/module/xep/0280_message_carbons.vala
+++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala
@@ -6,6 +6,8 @@ namespace Xmpp.Xep.MessageCarbons {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0280_message_carbons_module");
+ private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
+
public void enable(XmppStream stream) {
Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns());
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
@@ -18,12 +20,13 @@ namespace Xmpp.Xep.MessageCarbons {
public override void attach(XmppStream stream) {
stream.stream_negotiated.connect(enable);
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(new ReceivedPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
}
public override void detach(XmppStream stream) {
stream.stream_negotiated.disconnect(enable);
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
}
public override string get_ns() { return NS_URI; }
diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
index ac68e190..0e3ac0c7 100644
--- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala
+++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala
@@ -14,6 +14,8 @@ public class Module : XmppStreamModule {
public signal void feature_available(XmppStream stream);
+ private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
+
public void query_archive(XmppStream stream, string? jid, DateTime? start, DateTime? end) {
if (stream.get_flag(Flag.IDENTITY) == null) return;
@@ -42,11 +44,13 @@ public class Module : XmppStreamModule {
}
public override void attach(XmppStream stream) {
- stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(new ReceivedPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.connect(received_pipeline_listener);
stream.stream_negotiated.connect(query_availability);
}
- public override void detach(XmppStream stream) { }
+ public override void detach(XmppStream stream) {
+ stream.get_module(Message.Module.IDENTITY).received_pipeline.disconnect(received_pipeline_listener);
+ }
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala
index 9c3251dc..27cbd107 100644
--- a/xmpp-vala/src/module/xep/0333_chat_markers.vala
+++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala
@@ -16,6 +16,8 @@ public class Module : XmppStreamModule {
public signal void marker_received(XmppStream stream, string jid, string marker, string id);
+ private SendPipelineListener send_pipeline_listener = new SendPipelineListener();
+
public void send_marker(XmppStream stream, string jid, string message_id, string type_, string marker) {
Message.Stanza received_message = new Message.Stanza();
received_message.to = jid;
@@ -31,12 +33,13 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
- stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(new SendPipelineListener());
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.connect(send_pipeline_listener);
stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
}
public override void detach(XmppStream stream) {
stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
+ stream.get_module(Message.Module.IDENTITY).send_pipeline.disconnect(send_pipeline_listener);
}
public override string get_ns() { return NS_URI; }