Add sessions_alarm

Introduce new feature: sessions_alarm.

Added new account setting: max_connections. On exceeding this number,
user will get an alert. If number is less than 1, no alert will happen.

Tests altered to fit new feature.
This commit is contained in:
John Hernandez
2023-04-13 17:16:24 +02:00
parent 9bce23e075
commit 07cc19ce10
17 changed files with 179 additions and 24 deletions

View File

@@ -347,13 +347,15 @@ accounts_get_account(const char* const name)
gchar* auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL);
int max_sessions = g_key_file_get_integer(accounts, name, "max.sessions", 0);
ProfAccount* new_account = account_new(g_strdup(name), jid, password, eval_password, enabled,
server, port, resource, last_presence, login_presence,
priority_online, priority_chat, priority_away, priority_xa,
priority_dnd, muc_service, muc_nick, otr_policy, otr_manual,
otr_opportunistic, otr_always, omemo_policy, omemo_enabled,
omemo_disabled, ox_enabled, pgp_enabled, pgp_keyid,
startscript, theme, tls_policy, auth_policy, client);
startscript, theme, tls_policy, auth_policy, client, max_sessions);
return new_account;
}
@@ -568,6 +570,12 @@ accounts_set_theme(const char* const account_name, const char* const value)
_accounts_set_string_option(account_name, "theme", value);
}
void
accounts_set_max_sessions(const char* const account_name, const int value)
{
_accounts_set_int_option(account_name, "max.sessions", value);
}
void
accounts_clear_password(const char* const account_name)
{
@@ -634,6 +642,12 @@ accounts_clear_otr(const char* const account_name)
_accounts_clear_string_option(account_name, "otr.policy");
}
void
accounts_clear_max_sessions(const char* const account_name)
{
_accounts_clear_string_option(account_name, "max.sessions");
}
void
accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy)
{
@@ -865,6 +879,24 @@ accounts_get_last_activity(const char* const account_name)
}
}
char*
accounts_get_resource(const char* const account_name)
{
if (!accounts_account_exists(account_name)) {
return NULL;
}
return g_key_file_get_string(accounts, account_name, "resource", NULL);
}
int
accounts_get_max_sessions(const char* const account_name)
{
if (!accounts_account_exists(account_name)) {
return 0;
}
return g_key_file_get_integer(accounts, account_name, "max.sessions", 0);
}
void
accounts_set_login_presence(const char* const account_name, const char* const value)
{