1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-10-27 20:30:13 -04:00

Show message when server does not support ping

This commit is contained in:
James Booth 2017-06-15 23:27:30 +01:00
parent cbaa419a31
commit 6511d61b13
5 changed files with 34 additions and 0 deletions

View File

@ -5863,6 +5863,11 @@ cmd_ping(ProfWin *window, const char *const command, gchar **args)
return TRUE; 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]); iq_send_ping(args[0]);
if (args[0] == NULL) { if (args[0] == NULL) {

View File

@ -55,6 +55,7 @@
#define JABBER_PRIORITY_MIN -128 #define JABBER_PRIORITY_MIN -128
#define JABBER_PRIORITY_MAX 127 #define JABBER_PRIORITY_MAX 127
#define XMPP_FEATURE_PING "urn:xmpp:ping"
#define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking" #define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking"
#define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts" #define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts"
#define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last" #define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last"

View File

@ -36,6 +36,7 @@ int main(int argc, char* argv[]) {
PROF_FUNC_TEST(connect_shows_presence_updates), PROF_FUNC_TEST(connect_shows_presence_updates),
PROF_FUNC_TEST(ping_multiple), PROF_FUNC_TEST(ping_multiple),
PROF_FUNC_TEST(ping_not_supported),
PROF_FUNC_TEST(ping_responds), PROF_FUNC_TEST(ping_responds),
PROF_FUNC_TEST(rooms_query), PROF_FUNC_TEST(rooms_query),

View File

@ -14,6 +14,15 @@
void void
ping_multiple(void **state) 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", stbbr_for_id("prof_ping_4",
"<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>" "<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>"
); );
@ -40,6 +49,23 @@ ping_multiple(void **state)
assert_true(prof_output_exact("Ping response from server")); assert_true(prof_output_exact("Ping response from server"));
} }
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 void
ping_responds(void **state) ping_responds(void **state)
{ {

View File

@ -1,2 +1,3 @@
void ping_multiple(void **state); void ping_multiple(void **state);
void ping_not_supported(void **state);
void ping_responds(void **state); void ping_responds(void **state);