aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/CMakeLists.txt1
-rw-r--r--xmpp-vala/src/module/xep/0199_ping.vala4
-rw-r--r--xmpp-vala/src/module/xep/0410_muc_self_ping.vala18
3 files changed, 21 insertions, 2 deletions
diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt
index 6691f950..f2e89b4e 100644
--- a/xmpp-vala/CMakeLists.txt
+++ b/xmpp-vala/CMakeLists.txt
@@ -94,6 +94,7 @@ SOURCES
"src/module/xep/0368_srv_records_tls.vala"
"src/module/xep/0380_explicit_encryption.vala"
"src/module/xep/0391_jingle_encrypted_transports.vala"
+ "src/module/xep/0410_muc_self_ping.vala"
"src/module/xep/pixbuf_storage.vala"
"src/util.vala"
diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala
index 12997f32..f3e68660 100644
--- a/xmpp-vala/src/module/xep/0199_ping.vala
+++ b/xmpp-vala/src/module/xep/0199_ping.vala
@@ -6,10 +6,10 @@ namespace Xmpp.Xep.Ping {
public class Module : XmppStreamModule, Iq.Handler {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping");
- public async void send_ping(XmppStream stream, Jid jid) {
+ public async Iq.Stanza send_ping(XmppStream stream, Jid jid) {
StanzaNode ping_node = new StanzaNode.build("ping", NS_URI).add_self_xmlns();
Iq.Stanza iq = new Iq.Stanza.get(ping_node) { to=jid };
- yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
+ return yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
}
public override void attach(XmppStream stream) {
diff --git a/xmpp-vala/src/module/xep/0410_muc_self_ping.vala b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala
new file mode 100644
index 00000000..84772333
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala
@@ -0,0 +1,18 @@
+namespace Xmpp.Xep.MucSelfPing {
+
+ public static async bool is_joined(XmppStream stream, Jid jid) {
+ Iq.Stanza iq_result = yield stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, jid);
+
+ if (!iq_result.is_error()) {
+ return true;
+ } else {
+ var error_stanza = iq_result.get_error();
+ if (error_stanza.condition in new string[] {ErrorStanza.CONDITION_SERVICE_UNAVAILABLE, ErrorStanza.CONDITION_FEATURE_NOT_IMPLEMENTED}) {
+ // the client is joined, but the pinged client does not implement XMPP Ping
+ return true;
+ }
+ }
+ return false;
+ }
+
+}