diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/account.c | 4 | ||||
-rw-r--r-- | src/config/account.h | 3 | ||||
-rw-r--r-- | src/config/accounts.c | 34 | ||||
-rw-r--r-- | src/config/accounts.h | 4 |
4 files changed, 42 insertions, 3 deletions
diff --git a/src/config/account.c b/src/config/account.c index 73740b3a..42fd1cd0 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -57,7 +57,7 @@ account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboo gchar* omemo_policy, GList* omemo_enabled, GList* omemo_disabled, GList* ox_enabled, GList* pgp_enabled, gchar* pgp_keyid, gchar* startscript, gchar* theme, gchar* tls_policy, gchar* auth_policy, - gchar* client) + gchar* client, int max_sessions) { ProfAccount* new_account = calloc(1, sizeof(ProfAccount)); @@ -140,6 +140,8 @@ account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboo new_account->auth_policy = auth_policy; + new_account->max_sessions = max_sessions; + return new_account; } diff --git a/src/config/account.h b/src/config/account.h index f82a3e11..e8bda927 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -72,6 +72,7 @@ typedef struct prof_account_t gchar* tls_policy; gchar* auth_policy; gchar* client; + int max_sessions; } ProfAccount; ProfAccount* account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboolean enabled, @@ -82,7 +83,7 @@ ProfAccount* account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_p gchar* omemo_policy, GList* omemo_enabled, GList* omemo_disabled, GList* ox_enabled, GList* pgp_enabled, gchar* pgp_keyid, gchar* startscript, gchar* theme, gchar* tls_policy, gchar* auth_policy, - gchar* client); + gchar* client, int max_sessions); char* account_create_connect_jid(ProfAccount* account); gboolean account_eval_password(ProfAccount* account); void account_free(ProfAccount* account); diff --git a/src/config/accounts.c b/src/config/accounts.c index f7e6e456..d5747cbf 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -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; } @@ -569,6 +571,12 @@ accounts_set_theme(const char* const account_name, const char* const 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) { _accounts_clear_string_option(account_name, "password"); @@ -635,6 +643,12 @@ accounts_clear_otr(const char* const account_name) } 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) { if (accounts_account_exists(account_name)) { @@ -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) { diff --git a/src/config/accounts.h b/src/config/accounts.h index c5b829c0..8d111544 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -61,6 +61,7 @@ void accounts_set_jid(const char* const account_name, const char* const value); void accounts_set_server(const char* const account_name, const char* const value); void accounts_set_port(const char* const account_name, const int value); void accounts_set_resource(const char* const account_name, const char* const value); +char* accounts_get_resource(const char* const account_name); void accounts_set_password(const char* const account_name, const char* const value); void accounts_set_eval_password(const char* const account_name, const char* const value); void accounts_set_muc_service(const char* const account_name, const char* const value); @@ -89,6 +90,8 @@ void accounts_set_pgp_keyid(const char* const account_name, const char* const va void accounts_set_script_start(const char* const account_name, const char* const value); void accounts_set_client(const char* const account_name, const char* const value); void accounts_set_theme(const char* const account_name, const char* const value); +void accounts_set_max_sessions(const char* const account_name, const int value); +int accounts_get_max_sessions(const char* const account_name); void accounts_clear_password(const char* const account_name); void accounts_clear_eval_password(const char* const account_name); void accounts_clear_server(const char* const account_name); @@ -100,6 +103,7 @@ void accounts_clear_client(const char* const account_name); void accounts_clear_theme(const char* const account_name); void accounts_clear_muc(const char* const account_name); void accounts_clear_resource(const char* const account_name); +void accounts_clear_max_sessions(const char* const account_name); void accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy); void accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled); void accounts_add_ox_state(const char* const account_name, const char* const contact_jid, gboolean enabled); |