Compare commits

..

1 Commits

Author SHA1 Message Date
1f38ff0522 feat: Autoping availability warning
Some checks failed
CI Code / Check spelling (pull_request) Successful in 27s
CI Code / Check coding style (pull_request) Failing after 34s
CI Code / Linux (debian) (pull_request) Successful in 16m21s
CI Code / Code Coverage (pull_request) Successful in 18m3s
CI Code / Linux (ubuntu) (pull_request) Successful in 18m21s
CI Code / Linux (arch) (pull_request) Successful in 20m32s
2026-01-27 20:56:28 +01:00
6 changed files with 22 additions and 17 deletions

View File

@@ -1959,12 +1959,14 @@ static const struct cmd_t command_defs[] = {
CMD_TAG_CONNECTION) CMD_TAG_CONNECTION)
CMD_SYN( CMD_SYN(
"/autoping set <seconds>", "/autoping set <seconds>",
"/autoping timeout <seconds>") "/autoping timeout <seconds>",
"/autoping warning enable|disable")
CMD_DESC( CMD_DESC(
"Set the interval between sending ping requests to the server to ensure the connection is kept alive.") "Set the interval between sending ping requests to the server to ensure the connection is kept alive.")
CMD_ARGS( CMD_ARGS(
{ "set <seconds>", "Number of seconds between sending pings, a value of 0 disables autoping." }, { "set <seconds>", "Number of seconds between sending pings, a value of 0 disables autoping." },
{ "timeout <seconds>", "Seconds to wait for autoping responses, after which the connection is considered broken." }) { "timeout <seconds>", "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", { CMD_PREAMBLE("/ping",

View File

@@ -6350,6 +6350,8 @@ cmd_autoping(ProfWin* window, const char* const command, gchar** args)
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
} }
} else if (g_strcmp0(cmd, "warning") == 0) {
_cmd_set_boolean_preference(value, "Autoping availability warning", PREF_AUTOPING_WARNING);
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
} }

View File

@@ -57,7 +57,6 @@ typedef struct prof_account_t
gchar* muc_service; gchar* muc_service;
gchar* muc_nick; gchar* muc_nick;
gboolean enabled; gboolean enabled;
gboolean autoping_received;
gchar* otr_policy; gchar* otr_policy;
GList* otr_manual; GList* otr_manual;
GList* otr_opportunistic; GList* otr_opportunistic;

View File

@@ -2211,6 +2211,7 @@ _get_default_boolean(preference_t pref)
case PREF_MOOD: case PREF_MOOD:
case PREF_STROPHE_SM_ENABLED: case PREF_STROPHE_SM_ENABLED:
case PREF_STROPHE_SM_RESEND: case PREF_STROPHE_SM_RESEND:
case PREF_AUTOPING_WARNING:
return TRUE; return TRUE;
case PREF_PGP_PUBKEY_AUTOIMPORT: case PREF_PGP_PUBKEY_AUTOIMPORT:
case PREF_FORCE_ENCRYPTION: case PREF_FORCE_ENCRYPTION:

View File

@@ -2053,21 +2053,27 @@ cons_autoping_setting(void)
{ {
gint autoping_interval = prefs_get_autoping(); gint autoping_interval = prefs_get_autoping();
if (autoping_interval == 0) { if (autoping_interval == 0) {
cons_show("Autoping interval (/autoping) : OFF"); cons_show("Autoping interval (/autoping) : OFF");
} else if (autoping_interval == 1) { } else if (autoping_interval == 1) {
cons_show("Autoping interval (/autoping) : 1 second"); cons_show("Autoping interval (/autoping) : 1 second");
} else { } 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(); gint autoping_timeout = prefs_get_autoping_timeout();
if (autoping_timeout == 0) { if (autoping_timeout == 0) {
cons_show("Autoping timeout (/autoping) : OFF"); cons_show("Autoping timeout (/autoping) : OFF");
} else if (autoping_timeout == 1) { } else if (autoping_timeout == 1) {
cons_show("Autoping timeout (/autoping) : 1 second"); cons_show("Autoping timeout (/autoping) : 1 second");
} else { } 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 void

View File

@@ -2451,19 +2451,14 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
static int static int
_disco_autoping_warning_message(GHashTable* features) _disco_autoping_warning_message(GHashTable* features)
{ {
gboolean supports_ping = g_hash_table_contains(features, "urn:xmpp:ping"); gboolean server_supports_ping = g_hash_table_contains(features, "urn:xmpp:ping");
gboolean is_autoping_disabled = prefs_get_autoping() == 0; gboolean users_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING);
// if "autoping" in disco + user wasn't alerted earlier after login + prefs for autoping recommendation alert is set if (server_supports_ping && users_prefers_warning) {
// 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" cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n"
"but autoping feature is currently disabled in settings.\n" "but autoping feature is currently disabled in settings.\n"
"Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n" "Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n"
"Use `/autoping warn disable` to disable this message."); "Use `/autoping warn disable` to disable this message.");
// connection->disco_ping_alert_shown = TRUE;
} }
return 0; return 0;
} }