feat: Autoping availability warning
Some checks failed
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Failing after 36s
CI Code / Linux (debian) (pull_request) Successful in 16m7s
CI Code / Linux (arch) (pull_request) Successful in 21m2s
CI Code / Linux (ubuntu) (pull_request) Successful in 16m21s
CI Code / Code Coverage (pull_request) Successful in 15m24s
Some checks failed
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Failing after 36s
CI Code / Linux (debian) (pull_request) Successful in 16m7s
CI Code / Linux (arch) (pull_request) Successful in 21m2s
CI Code / Linux (ubuntu) (pull_request) Successful in 16m21s
CI Code / Code Coverage (pull_request) Successful in 15m24s
This commit is contained in:
@@ -1959,12 +1959,14 @@ static const struct cmd_t command_defs[] = {
|
||||
CMD_TAG_CONNECTION)
|
||||
CMD_SYN(
|
||||
"/autoping set <seconds>",
|
||||
"/autoping timeout <seconds>")
|
||||
"/autoping timeout <seconds>",
|
||||
"/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 <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",
|
||||
|
||||
@@ -6350,6 +6350,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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -2208,6 +2211,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_PGP_PUBKEY_AUTOIMPORT:
|
||||
case PREF_FORCE_ENCRYPTION:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
@@ -2048,21 +2053,27 @@ 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
|
||||
|
||||
@@ -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,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user