about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_funcs.c5
-rw-r--r--src/xmpp/xmpp.h1
-rw-r--r--tests/functionaltests/functionaltests.c1
-rw-r--r--tests/functionaltests/test_ping.c26
-rw-r--r--tests/functionaltests/test_ping.h1
5 files changed, 34 insertions, 0 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 71c8816a..42553f5a 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -5863,6 +5863,11 @@ cmd_ping(ProfWin *window, const char *const command, gchar **args)
         return TRUE;
     }
 
+    if (args[0] == NULL && connection_supports(XMPP_FEATURE_PING) == FALSE) {
+        cons_show("Server does not support ping requests.");
+        return TRUE;
+    }
+
     iq_send_ping(args[0]);
 
     if (args[0] == NULL) {
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 2befccd2..fa36cf19 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -55,6 +55,7 @@
 #define JABBER_PRIORITY_MIN -128
 #define JABBER_PRIORITY_MAX 127
 
+#define XMPP_FEATURE_PING "urn:xmpp:ping"
 #define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking"
 #define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts"
 #define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last"
diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 1e01071d..170cde81 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -36,6 +36,7 @@ int main(int argc, char* argv[]) {
         PROF_FUNC_TEST(connect_shows_presence_updates),
 
         PROF_FUNC_TEST(ping_multiple),
+        PROF_FUNC_TEST(ping_not_supported),
         PROF_FUNC_TEST(ping_responds),
 
         PROF_FUNC_TEST(rooms_query),
diff --git a/tests/functionaltests/test_ping.c b/tests/functionaltests/test_ping.c
index ecbbfee1..99b0c7ce 100644
--- a/tests/functionaltests/test_ping.c
+++ b/tests/functionaltests/test_ping.c
@@ -14,6 +14,15 @@
 void
 ping_multiple(void **state)
 {
+    stbbr_for_id("prof_disco_info_onconnect_2",
+        "<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
+            "<query xmlns='http://jabber.org/protocol/disco#info'>"
+                "<identity category='server' type='im' name='Prosody'/>"
+                "<feature var='urn:xmpp:ping'/>"
+            "</query>"
+        "</iq>"
+    );
+
     stbbr_for_id("prof_ping_4",
         "<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>"
     );
@@ -41,6 +50,23 @@ ping_multiple(void **state)
 }
 
 void
+ping_not_supported(void **state)
+{
+    stbbr_for_id("prof_disco_info_onconnect_2",
+        "<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
+            "<query xmlns='http://jabber.org/protocol/disco#info'>"
+                "<identity category='server' type='im' name='Prosody'/>"
+            "</query>"
+        "</iq>"
+    );
+
+    prof_connect();
+
+    prof_input("/ping");
+    assert_true(prof_output_exact("Server does not support ping requests."));
+}
+
+void
 ping_responds(void **state)
 {
     prof_connect();
diff --git a/tests/functionaltests/test_ping.h b/tests/functionaltests/test_ping.h
index a222a486..9992c9fb 100644
--- a/tests/functionaltests/test_ping.h
+++ b/tests/functionaltests/test_ping.h
@@ -1,2 +1,3 @@
 void ping_multiple(void **state);
+void ping_not_supported(void **state);
 void ping_responds(void **state);