From 6511d61b139d95851620052f7734703817cdec46 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 15 Jun 2017 23:27:30 +0100 Subject: [PATCH] Show message when server does not support ping --- src/command/cmd_funcs.c | 5 +++++ src/xmpp/xmpp.h | 1 + tests/functionaltests/functionaltests.c | 1 + tests/functionaltests/test_ping.c | 26 +++++++++++++++++++++++++ tests/functionaltests/test_ping.h | 1 + 5 files changed, 34 insertions(+) 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", + "" + "" + "" + "" + "" + "" + ); + stbbr_for_id("prof_ping_4", "" ); @@ -40,6 +49,23 @@ ping_multiple(void **state) assert_true(prof_output_exact("Ping response from server")); } +void +ping_not_supported(void **state) +{ + stbbr_for_id("prof_disco_info_onconnect_2", + "" + "" + "" + "" + "" + ); + + prof_connect(); + + prof_input("/ping"); + assert_true(prof_output_exact("Server does not support ping requests.")); +} + void ping_responds(void **state) { 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);