From 654832961646d4043da47d0361d239fb7b84ae28 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Tue, 27 Jan 2026 11:26:53 +0100 Subject: [PATCH] [WORK IN PROGRESS] feat: warning if autoping is disabled --- src/config/account.h | 1 + src/config/preferences.c | 3 +++ src/config/preferences.h | 3 ++- src/ui/console.c | 5 +++++ src/xmpp/iq.c | 22 ++++++++++++++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/config/account.h b/src/config/account.h index e8bda927..2adbd2f8 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -57,6 +57,7 @@ typedef struct prof_account_t gchar* muc_service; gchar* muc_nick; gboolean enabled; + gboolean autoping_received; gchar* otr_policy; GList* otr_manual; GList* otr_opportunistic; diff --git a/src/config/preferences.c b/src/config/preferences.c index bad809c8..4338f56f 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1816,6 +1816,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: @@ -2156,6 +2157,8 @@ _get_key(preference_t pref) return "force-encryption.enabled"; case PREF_FORCE_ENCRYPTION_MODE: return "force-encryption.policy"; + case PREF_AUTOPING_WARNING: + return "autoping.warning"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 750a87ee..8e83de28 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -188,7 +188,8 @@ typedef enum { PREF_VCARD_PHOTO_CMD, PREF_STATUSBAR_TABMODE, PREF_FORCE_ENCRYPTION, - PREF_FORCE_ENCRYPTION_MODE + PREF_FORCE_ENCRYPTION_MODE, + PREF_AUTOPING_WARNING } preference_t; typedef struct prof_alias_t diff --git a/src/ui/console.c b/src/ui/console.c index 616636bc..5cdb75d6 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1739,6 +1739,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"); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 5609d2ec..d36cfb49 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -129,6 +129,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); @@ -2439,6 +2440,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); @@ -2446,6 +2448,26 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con return 0; } +static int +_disco_autoping_warning_message(GHashTable* features) +{ + gboolean supports_ping = g_hash_table_contains(features, "urn:xmpp:ping"); + gboolean is_autoping_disabled = prefs_get_autoping() == 0; + + // if "autoping" in disco + user wasn't alerted earlier after login + prefs for autoping recommendation alert is set + // then cons_show("Autoping is disabled, but server supports autoping.") + + if (supports_ping && is_autoping_disabled) { // && !connection->disco_ping_alert_shown + // TODO: later add preference check: if (prefs_autoping_recommendation_enabled()) + 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."); + // connection->disco_ping_alert_shown = TRUE; + } + return 0; +} + static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata) {