From 0f7741fdfae141a9aa37f7eb58f48b82568116df Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Tue, 27 Jan 2026 20:56:28 +0100 Subject: [PATCH 1/8] feat: Autoping availability warning --- src/command/cmd_defs.c | 6 ++++-- src/command/cmd_funcs.c | 2 ++ src/config/preferences.c | 4 ++++ src/config/preferences.h | 1 + src/ui/console.c | 22 ++++++++++++++++------ src/xmpp/iq.c | 18 ++++++++++++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index e3e26ddf..146df104 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1964,12 +1964,14 @@ static const struct cmd_t command_defs[] = { CMD_TAG_CONNECTION) CMD_SYN( "/autoping set ", - "/autoping timeout ") + "/autoping timeout ", + "/autoping warning enable|disable") CMD_DESC( "Set the interval between sending ping requests to the server to ensure the connection is kept alive.") CMD_ARGS( { "set ", "Number of seconds between sending pings, a value of 0 disables autoping." }, - { "timeout ", "Seconds to wait for autoping responses, after which the connection is considered broken." }) + { "timeout ", "Seconds to wait for autoping responses, after which the connection is considered broken." }, + {"warning enable|disable", "Enable or disable autoping availability warning."}) }, { CMD_PREAMBLE("/ping", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 3fad000a..7fbc5f05 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6374,6 +6374,8 @@ cmd_autoping(ProfWin* window, const char* const command, gchar** args) cons_bad_cmd_usage(command); } + } else if (g_strcmp0(cmd, "warning") == 0) { + _cmd_set_boolean_preference(value, "Autoping availability warning", PREF_AUTOPING_WARNING); } else { cons_bad_cmd_usage(command); } diff --git a/src/config/preferences.c b/src/config/preferences.c index 9f9db2e8..04d3dda5 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -2290,6 +2290,7 @@ _get_group(preference_t pref) case PREF_TRAY: case PREF_TRAY_READ: case PREF_ADV_NOTIFY_DISCO_OR_VERSION: + case PREF_AUTOPING_WARNING: return PREF_GROUP_NOTIFICATIONS; case PREF_DBLOG: case PREF_CHLOG: @@ -2646,6 +2647,8 @@ _get_key(preference_t pref) return "enabled"; case PREF_SPELLCHECK_LANG: return "lang"; + case PREF_AUTOPING_WARNING: + return "autoping.warning"; default: return NULL; } @@ -2699,6 +2702,7 @@ _get_default_boolean(preference_t pref) case PREF_MOOD: case PREF_STROPHE_SM_ENABLED: case PREF_STROPHE_SM_RESEND: + case PREF_AUTOPING_WARNING: return TRUE; case PREF_SPELLCHECK_ENABLE: case PREF_PGP_PUBKEY_AUTOIMPORT: diff --git a/src/config/preferences.h b/src/config/preferences.h index 962e607b..4e422a05 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -169,6 +169,7 @@ typedef enum { PREF_FORCE_ENCRYPTION_MODE, PREF_SPELLCHECK_ENABLE, PREF_SPELLCHECK_LANG, + PREF_AUTOPING_WARNING } preference_t; typedef struct prof_alias_t diff --git a/src/ui/console.c b/src/ui/console.c index a98577a7..637cdd1c 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1703,6 +1703,11 @@ cons_notify_setting(void) else cons_show("Subscription requests (/notify sub) : OFF"); + if (prefs_get_boolean(PREF_AUTOPING_WARNING)) + cons_show("Autoping warning (/autoping warn) : ON"); + else + cons_show("Autoping warning (/autoping warn) : OFF"); + gint remind_period = prefs_get_notify_remind(); if (remind_period == 0) { cons_show("Reminder period (/notify remind) : OFF"); @@ -2003,21 +2008,26 @@ cons_autoping_setting(void) { gint autoping_interval = prefs_get_autoping(); if (autoping_interval == 0) { - cons_show("Autoping interval (/autoping) : OFF"); + cons_show("Autoping interval (/autoping) : OFF"); } else if (autoping_interval == 1) { - cons_show("Autoping interval (/autoping) : 1 second"); + cons_show("Autoping interval (/autoping) : 1 second"); } else { - cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval); + cons_show("Autoping interval (/autoping) : %d seconds", autoping_interval); } gint autoping_timeout = prefs_get_autoping_timeout(); if (autoping_timeout == 0) { - cons_show("Autoping timeout (/autoping) : OFF"); + cons_show("Autoping timeout (/autoping) : OFF"); } else if (autoping_timeout == 1) { - cons_show("Autoping timeout (/autoping) : 1 second"); + cons_show("Autoping timeout (/autoping) : 1 second"); } else { - cons_show("Autoping timeout (/autoping) : %d seconds", autoping_timeout); + cons_show("Autoping timeout (/autoping) : %d seconds", autoping_timeout); } + + if (prefs_get_boolean(PREF_AUTOPING_WARNING)) + cons_show("Autoping warning (/autoping warn) : ON"); + else + cons_show("Autoping warning (/autoping warn) : OFF"); } void diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 377f444c..6511a49c 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -103,6 +103,7 @@ static void _ping_get_handler(xmpp_stanza_t* const stanza); static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata); +static int _disco_autoping_warning_message(GHashTable* features); static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx); static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); @@ -2429,6 +2430,7 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con } child = xmpp_stanza_get_next(child); } + _disco_autoping_warning_message(features); } connection_features_received(from); @@ -2436,6 +2438,22 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con return 0; } +static int +_disco_autoping_warning_message(GHashTable* features) +{ + gboolean server_supports_ping = g_hash_table_contains(features, "urn:xmpp:ping"); + gboolean users_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING); + gboolean is_autoping_enabled = prefs_get_autoping() != 0; + + if (!is_autoping_enabled && server_supports_ping && users_prefers_warning) { + cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n" + "but autoping feature is currently disabled in settings.\n" + "Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n" + "Use `/autoping warn disable` to disable this message."); + } + return 0; +} + static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) { -- 2.49.1 From 15a1a343d23373608dad1af2b2ed581b4df9dd9c Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Sat, 20 Jun 2026 14:35:50 +0300 Subject: [PATCH 2/8] fix(autoping): align warning command with on|off The warning toggle uses _cmd_set_boolean_preference (accepts on|off) and the subcommand is "warning", but the help syntax, console status lines and warning text advertised "warning enable|disable" and "/autoping warn", none of which work. - cmd_defs: document "/autoping warning on|off" - console: show "(/autoping warning)" in the status lines - iq: point the warning text at "/autoping warning off" - cmd_ac: register "warning" and complete on|off via a dedicated _autoping_autocomplete (moved off the generic single-level table) --- src/command/cmd_ac.c | 18 +++++++++++++++++- src/command/cmd_defs.c | 4 ++-- src/ui/console.c | 8 ++++---- src/xmpp/iq.c | 2 +- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index d7949bad..99c2ac36 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -47,6 +47,7 @@ static char* _notify_autocomplete(ProfWin* window, const char* const input, gboo static char* _theme_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _spellcheck_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _autoaway_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _autoping_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _autoconnect_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _account_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _who_autocomplete(ProfWin* window, const char* const input, gboolean previous); @@ -1056,6 +1057,7 @@ cmd_ac_init(void) autocomplete_add(autoping_ac, "set"); autocomplete_add(autoping_ac, "timeout"); + autocomplete_add(autoping_ac, "warning"); autocomplete_add(plugins_ac, "install"); autocomplete_add(plugins_ac, "update"); @@ -1407,6 +1409,7 @@ cmd_ac_init(void) g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); g_hash_table_insert(ac_funcs, "/autoaway", _autoaway_autocomplete); g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete); + g_hash_table_insert(ac_funcs, "/autoping", _autoping_autocomplete); g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete); g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete); g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); @@ -1934,7 +1937,6 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ { "/prefs", prefs_ac }, { "/disco", disco_ac }, { "/room", room_ac }, - { "/autoping", autoping_ac }, { "/mainwin", winpos_ac }, { "/inputwin", winpos_ac }, }; @@ -4264,6 +4266,20 @@ _executable_autocomplete(ProfWin* window, const char* const input, gboolean prev return result; } +static char* +_autoping_autocomplete(ProfWin* window, const char* const input, gboolean previous) +{ + char* result = NULL; + + result = autocomplete_param_with_ac(input, "/autoping", autoping_ac, TRUE, previous); + if (result) { + return result; + } + + result = autocomplete_param_with_func(input, "/autoping warning", prefs_autocomplete_boolean_choice, previous, NULL); + return result; +} + static char* _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous) { diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 146df104..ccd9f1da 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1965,13 +1965,13 @@ static const struct cmd_t command_defs[] = { CMD_SYN( "/autoping set ", "/autoping timeout ", - "/autoping warning enable|disable") + "/autoping warning on|off") CMD_DESC( "Set the interval between sending ping requests to the server to ensure the connection is kept alive.") CMD_ARGS( { "set ", "Number of seconds between sending pings, a value of 0 disables autoping." }, { "timeout ", "Seconds to wait for autoping responses, after which the connection is considered broken." }, - {"warning enable|disable", "Enable or disable autoping availability warning."}) + { "warning on|off", "Enable or disable autoping availability warning." }) }, { CMD_PREAMBLE("/ping", diff --git a/src/ui/console.c b/src/ui/console.c index 637cdd1c..de565d38 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1704,9 +1704,9 @@ cons_notify_setting(void) cons_show("Subscription requests (/notify sub) : OFF"); if (prefs_get_boolean(PREF_AUTOPING_WARNING)) - cons_show("Autoping warning (/autoping warn) : ON"); + cons_show("Autoping warning (/autoping warning): ON"); else - cons_show("Autoping warning (/autoping warn) : OFF"); + cons_show("Autoping warning (/autoping warning): OFF"); gint remind_period = prefs_get_notify_remind(); if (remind_period == 0) { @@ -2025,9 +2025,9 @@ cons_autoping_setting(void) } if (prefs_get_boolean(PREF_AUTOPING_WARNING)) - cons_show("Autoping warning (/autoping warn) : ON"); + cons_show("Autoping warning (/autoping warning): ON"); else - cons_show("Autoping warning (/autoping warn) : OFF"); + cons_show("Autoping warning (/autoping warning): OFF"); } void diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 6511a49c..67d7ddb8 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2449,7 +2449,7 @@ _disco_autoping_warning_message(GHashTable* features) cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n" "but autoping feature is currently disabled in settings.\n" "Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n" - "Use `/autoping warn disable` to disable this message."); + "Use `/autoping warning off` to disable this message."); } return 0; } -- 2.49.1 From 45b81cf2de2d34a41467dff5ec656e56c65b3d98 Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Sat, 20 Jun 2026 14:35:50 +0300 Subject: [PATCH 3/8] test(autoping): cover availability-warning conditions Functional tests for the on-connect warning: shown when the server advertises urn:xmpp:ping while autoping is disabled and the warning preference is on; suppressed when ping is unsupported, when autoping is enabled, or when the user turned the warning off. Refs #80 --- tests/functionaltests/functionaltests.c | 6 ++ tests/functionaltests/test_autoping.c | 96 +++++++++++++++++++++++++ tests/functionaltests/test_autoping.h | 4 ++ 3 files changed, 106 insertions(+) diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index 8102f928..388da85f 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -150,6 +150,12 @@ main(int argc, char* argv[]) PROF_FUNC_TEST(autoping_sends_ping_after_interval), PROF_FUNC_TEST(autoping_server_not_supporting_ping), + /* Autoping availability warning - negative cases wait ~3s */ + PROF_FUNC_TEST(autoping_warning_shown_when_disabled), + PROF_FUNC_TEST(autoping_warning_not_shown_when_server_unsupported), + PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled), + PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled), + /* Service Discovery - XEP-0030 */ PROF_FUNC_TEST(disco_info_shows_identity), PROF_FUNC_TEST(disco_info_shows_features), diff --git a/tests/functionaltests/test_autoping.c b/tests/functionaltests/test_autoping.c index 1e1a1332..f3539c26 100644 --- a/tests/functionaltests/test_autoping.c +++ b/tests/functionaltests/test_autoping.c @@ -112,3 +112,99 @@ autoping_server_not_supporting_ping(void** state) // Should show error about ping not being supported assert_true(prof_output_regex("Server ping not supported")); } + +/* + * Autoping availability warning. + * + * The warning fires from the on-connect disco handler, so the three inputs + * (server ping support, autoping interval, warning preference) must all be + * set before prof_connect(). + */ + +/* Stable substring of the warning text emitted by iq.c. */ +#define AUTOPING_WARNING_MATCH "This server supports XEP-0199" + +static void +_stub_server_disco(gboolean with_ping) +{ + if (with_ping) { + stbbr_for_query("http://jabber.org/protocol/disco#info", + "" + "" + "" + "" + "" + "" + ); + } else { + stbbr_for_query("http://jabber.org/protocol/disco#info", + "" + "" + "" + "" + "" + ); + } +} + +void +autoping_warning_shown_when_disabled(void** state) +{ + // All conditions met: server supports ping, autoping off, warning on (default). + _stub_server_disco(TRUE); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_connect(); + + assert_true(prof_output_regex(AUTOPING_WARNING_MATCH)); +} + +void +autoping_warning_not_shown_when_server_unsupported(void** state) +{ + // Server does not advertise urn:xmpp:ping -> no warning even with autoping off. + _stub_server_disco(FALSE); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} + +void +autoping_warning_not_shown_when_autoping_enabled(void** state) +{ + // Warning is suppressed while autoping is enabled. + _stub_server_disco(TRUE); + + prof_input("/autoping set 30"); + assert_true(prof_output_exact("Autoping interval set to 30 seconds.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} + +void +autoping_warning_not_shown_when_user_disabled(void** state) +{ + // User opted out -> no warning. Command takes on|off ("enable|disable" doc is wrong). + _stub_server_disco(TRUE); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_input("/autoping warning off"); + assert_true(prof_output_exact("Autoping availability warning disabled.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} diff --git a/tests/functionaltests/test_autoping.h b/tests/functionaltests/test_autoping.h index 9456a50d..c4915cbf 100644 --- a/tests/functionaltests/test_autoping.h +++ b/tests/functionaltests/test_autoping.h @@ -4,3 +4,7 @@ void autoping_timeout_set(void** state); void autoping_timeout_zero_disables(void** state); void autoping_sends_ping_after_interval(void** state); void autoping_server_not_supporting_ping(void** state); +void autoping_warning_shown_when_disabled(void** state); +void autoping_warning_not_shown_when_server_unsupported(void** state); +void autoping_warning_not_shown_when_autoping_enabled(void** state); +void autoping_warning_not_shown_when_user_disabled(void** state); -- 2.49.1 From 2012e15c0b290fa964fbf7b7c12b28c388be7a87 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Sat, 20 Jun 2026 12:47:19 +0000 Subject: [PATCH 4/8] fix(disco): avoid autoping warning on disco#info responses from users The autoping availability warning should only trigger for disco#info responses from the XMPP server (no 'from' attribute), otherwise the warning message is displayed excessive amount of times. Refs #80 --- src/xmpp/iq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 67d7ddb8..4b3708a9 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2430,7 +2430,11 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con } child = xmpp_stanza_get_next(child); } - _disco_autoping_warning_message(features); + + // only fire on server responses (no '@' in JID), not user disco#info + if (!from || !strstr(from, "@")) { + _disco_autoping_warning_message(features); + } } connection_features_received(from); -- 2.49.1 From 7fd0cded3d29d46890f9d1f02cb9342a1f46971d Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Sat, 20 Jun 2026 20:47:05 +0000 Subject: [PATCH 5/8] test(autoping): add test for autoping warning exclusion on user JIDs --- src/xmpp/iq.c | 1 - tests/functionaltests/functionaltests.c | 1 + tests/functionaltests/test_autoping.c | 25 ++++++++++++++++++++++++- tests/functionaltests/test_autoping.h | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 4b3708a9..c9e1f0bb 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2431,7 +2431,6 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con child = xmpp_stanza_get_next(child); } - // only fire on server responses (no '@' in JID), not user disco#info if (!from || !strstr(from, "@")) { _disco_autoping_warning_message(features); } diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index 388da85f..b42e3a21 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -155,6 +155,7 @@ main(int argc, char* argv[]) PROF_FUNC_TEST(autoping_warning_not_shown_when_server_unsupported), PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled), PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled), + PROF_FUNC_TEST(autoping_warning_not_shown_for_user_jid), /* Service Discovery - XEP-0030 */ PROF_FUNC_TEST(disco_info_shows_identity), diff --git a/tests/functionaltests/test_autoping.c b/tests/functionaltests/test_autoping.c index f3539c26..070254ae 100644 --- a/tests/functionaltests/test_autoping.c +++ b/tests/functionaltests/test_autoping.c @@ -194,7 +194,7 @@ autoping_warning_not_shown_when_autoping_enabled(void** state) void autoping_warning_not_shown_when_user_disabled(void** state) { - // User opted out -> no warning. Command takes on|off ("enable|disable" doc is wrong). + // User opted out -> no warning. _stub_server_disco(TRUE); prof_input("/autoping set 0"); @@ -208,3 +208,26 @@ autoping_warning_not_shown_when_user_disabled(void** state) prof_timeout(NEGATIVE_ASSERT_TIMEOUT); assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); } + +void +autoping_warning_not_shown_for_user_jid(void** state) +{ + // disco#info from a user JID (with '@') should not trigger the warning, + // only server responses (no '@') should. + stbbr_for_query("http://jabber.org/protocol/disco#info", + "" + "" + "" + "" + "" + "" + ); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} diff --git a/tests/functionaltests/test_autoping.h b/tests/functionaltests/test_autoping.h index c4915cbf..73d29931 100644 --- a/tests/functionaltests/test_autoping.h +++ b/tests/functionaltests/test_autoping.h @@ -8,3 +8,4 @@ void autoping_warning_shown_when_disabled(void** state); void autoping_warning_not_shown_when_server_unsupported(void** state); void autoping_warning_not_shown_when_autoping_enabled(void** state); void autoping_warning_not_shown_when_user_disabled(void** state); +void autoping_warning_not_shown_for_user_jid(void** state); -- 2.49.1 From b5bbad8d2c02acd48907ddee41e4c3bfbc3df525 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Sun, 21 Jun 2026 15:37:16 +0000 Subject: [PATCH 6/8] fix(xmpp): prevent autoping warning repetition on disco items The previous logic triggered warnings for disco items. This change restricts the check to only the connection domain, ensuring that auto-discovered items do not trigger duplicate warnings. --- src/xmpp/iq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index c9e1f0bb..1351c64b 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2431,7 +2431,8 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con child = xmpp_stanza_get_next(child); } - if (!from || !strstr(from, "@")) { + // Prevent repetitions by avoiding checks of disco items (from connection_set_disco_items) + if (from && g_strcmp0(from, connection_get_domain()) == 0) { _disco_autoping_warning_message(features); } } -- 2.49.1 From 19bfad76ba0ea55fcc79c7e17398c1e64a996ab2 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Mon, 22 Jun 2026 09:17:49 +0000 Subject: [PATCH 7/8] test(autoping): add test for autoping warning exclusion on subdomain services The new test verifies that disco#info responses from subdomain services (e.g., conference servers) do not trigger the autoping warning, ensuring the check is correctly restricted to the server's own domain. --- tests/functionaltests/functionaltests.c | 1 + tests/functionaltests/test_autoping.c | 22 ++++++++++++++++++++++ tests/functionaltests/test_autoping.h | 1 + 3 files changed, 24 insertions(+) diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index b42e3a21..394b31d9 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -156,6 +156,7 @@ main(int argc, char* argv[]) PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled), PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled), PROF_FUNC_TEST(autoping_warning_not_shown_for_user_jid), + PROF_FUNC_TEST(autoping_warning_not_shown_for_subdomain_service), /* Service Discovery - XEP-0030 */ PROF_FUNC_TEST(disco_info_shows_identity), diff --git a/tests/functionaltests/test_autoping.c b/tests/functionaltests/test_autoping.c index 070254ae..c8853af1 100644 --- a/tests/functionaltests/test_autoping.c +++ b/tests/functionaltests/test_autoping.c @@ -231,3 +231,25 @@ autoping_warning_not_shown_for_user_jid(void** state) prof_timeout(NEGATIVE_ASSERT_TIMEOUT); assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); } + +void +autoping_warning_not_shown_for_subdomain_service(void** state) +{ + // disco#info from a subdomain service should not trigger the warning, only the server's own domain should + stbbr_for_query("http://jabber.org/protocol/disco#info", + "" + "" + "" + "" + "" + "" + ); + + prof_input("/autoping set 0"); + assert_true(prof_output_exact("Autoping disabled.")); + + prof_connect(); + + prof_timeout(NEGATIVE_ASSERT_TIMEOUT); + assert_false(prof_output_regex(AUTOPING_WARNING_MATCH)); +} diff --git a/tests/functionaltests/test_autoping.h b/tests/functionaltests/test_autoping.h index 73d29931..3226f9ee 100644 --- a/tests/functionaltests/test_autoping.h +++ b/tests/functionaltests/test_autoping.h @@ -9,3 +9,4 @@ void autoping_warning_not_shown_when_server_unsupported(void** state); void autoping_warning_not_shown_when_autoping_enabled(void** state); void autoping_warning_not_shown_when_user_disabled(void** state); void autoping_warning_not_shown_for_user_jid(void** state); +void autoping_warning_not_shown_for_subdomain_service(void** state); -- 2.49.1 From 14fb6e3b41c8bab306d4ad3c87494f5f6933f14e Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Tue, 23 Jun 2026 10:57:59 +0000 Subject: [PATCH 8/8] fix(disco): clean up autoping warning message handling Remove unused return value from _disco_autoping_warning_message by changing its return type to void. Rename local variable from users_prefers_warning to user_prefers_warning for correct grammar. Use g_ascii_strcasecmp instead of g_strcmp0 for the domain match check, so the warning fires correctly regardless of case differences between the stanza 'from' field and the bound domain. Remove duplicate autoping warning display from cons_notify_setting(), keeping it only in cons_autoping_setting() where it belongs. --- src/xmpp/iq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 1351c64b..c3a2c13d 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -99,11 +99,11 @@ static void _disco_items_result_handler(xmpp_stanza_t* const stanza); static void _last_activity_get_handler(xmpp_stanza_t* const stanza); static void _version_get_handler(xmpp_stanza_t* const stanza); static void _ping_get_handler(xmpp_stanza_t* const stanza); +static void _disco_autoping_warning_message(GHashTable* features); static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata); -static int _disco_autoping_warning_message(GHashTable* features); static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx); static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata); @@ -2432,7 +2432,7 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con } // Prevent repetitions by avoiding checks of disco items (from connection_set_disco_items) - if (from && g_strcmp0(from, connection_get_domain()) == 0) { + if (from && g_ascii_strcasecmp(from, connection_get_domain()) == 0) { _disco_autoping_warning_message(features); } } @@ -2442,20 +2442,19 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con return 0; } -static int +static void _disco_autoping_warning_message(GHashTable* features) { gboolean server_supports_ping = g_hash_table_contains(features, "urn:xmpp:ping"); - gboolean users_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING); + gboolean user_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING); gboolean is_autoping_enabled = prefs_get_autoping() != 0; - if (!is_autoping_enabled && server_supports_ping && users_prefers_warning) { + if (!is_autoping_enabled && server_supports_ping && user_prefers_warning) { cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n" "but autoping feature is currently disabled in settings.\n" "Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n" "Use `/autoping warning off` to disable this message."); } - return 0; } static int -- 2.49.1