aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala')
-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
7 files changed, 35 insertions, 10 deletions
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; }