diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/account.c | 110 | ||||
-rw-r--r-- | src/config/account.h | 19 | ||||
-rw-r--r-- | src/config/accounts.c | 19 | ||||
-rw-r--r-- | src/config/preferences.c | 19 | ||||
-rw-r--r-- | src/config/preferences.h | 7 |
5 files changed, 59 insertions, 115 deletions
diff --git a/src/config/account.c b/src/config/account.c index 238c2ef1..89436f9a 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -49,71 +49,53 @@ #include "xmpp/resource.h" ProfAccount* -account_new(const gchar* const name, const gchar* const jid, - const gchar* const password, const gchar* eval_password, gboolean enabled, const gchar* const server, - int port, const gchar* const resource, const gchar* const last_presence, - const gchar* const login_presence, int priority_online, int priority_chat, - int priority_away, int priority_xa, int priority_dnd, - const gchar* const muc_service, const gchar* const muc_nick, - const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic, - GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled, - GList* omemo_disabled, GList* ox_enabled, GList* pgp_enabled, - const gchar* const pgp_keyid, const char* const startscript, const char* const theme, - gchar* tls_policy, gchar* auth_policy) +account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboolean enabled, + gchar* server, int port, gchar* resource, gchar* last_presence, gchar* login_presence, + int priority_online, int priority_chat, int priority_away, int priority_xa, int priority_dnd, + gchar* muc_service, gchar* muc_nick, + gchar* otr_policy, GList* otr_manual, GList* otr_opportunistic, GList* otr_always, + 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) { - ProfAccount* new_account = malloc(sizeof(ProfAccount)); - memset(new_account, 0, sizeof(ProfAccount)); + ProfAccount* new_account = calloc(1, sizeof(ProfAccount)); - new_account->name = strdup(name); + new_account->name = name; if (jid) { - new_account->jid = strdup(jid); + new_account->jid = jid; } else { new_account->jid = strdup(name); } - if (password) { - new_account->password = strdup(password); - } else { - new_account->password = NULL; - } + new_account->password = password; - if (eval_password) { - new_account->eval_password = strdup(eval_password); - } else { - new_account->eval_password = NULL; - } + new_account->eval_password = eval_password; new_account->enabled = enabled; - if (server) { - new_account->server = strdup(server); - } else { - new_account->server = NULL; - } + new_account->server = server; - if (resource) { - new_account->resource = strdup(resource); - } else { - new_account->resource = NULL; - } + new_account->resource = resource; new_account->port = port; if (last_presence == NULL || !valid_resource_presence_string(last_presence)) { new_account->last_presence = strdup("online"); + g_free(last_presence); } else { - new_account->last_presence = strdup(last_presence); + new_account->last_presence = last_presence; } if (login_presence == NULL) { new_account->login_presence = strdup("online"); } else if (strcmp(login_presence, "last") == 0) { - new_account->login_presence = strdup(login_presence); + new_account->login_presence = login_presence; } else if (!valid_resource_presence_string(login_presence)) { new_account->login_presence = strdup("online"); + g_free(login_presence); } else { - new_account->login_presence = strdup(login_presence); + new_account->login_presence = login_presence; } new_account->priority_online = priority_online; @@ -122,72 +104,38 @@ account_new(const gchar* const name, const gchar* const jid, new_account->priority_xa = priority_xa; new_account->priority_dnd = priority_dnd; - if (muc_service) { - new_account->muc_service = strdup(muc_service); - } else { - new_account->muc_service = NULL; - } + new_account->muc_service = muc_service; if (muc_nick == NULL) { Jid* jidp = jid_create(new_account->jid); new_account->muc_nick = strdup(jidp->domainpart); jid_destroy(jidp); } else { - new_account->muc_nick = strdup(muc_nick); + new_account->muc_nick = muc_nick; } - if (otr_policy) { - new_account->otr_policy = strdup(otr_policy); - } else { - new_account->otr_policy = NULL; - } + new_account->otr_policy = otr_policy; new_account->otr_manual = otr_manual; new_account->otr_opportunistic = otr_opportunistic; new_account->otr_always = otr_always; - if (omemo_policy) { - new_account->omemo_policy = strdup(omemo_policy); - } else { - new_account->omemo_policy = NULL; - } - + new_account->omemo_policy = omemo_policy; new_account->omemo_enabled = omemo_enabled; new_account->omemo_disabled = omemo_disabled; new_account->ox_enabled = ox_enabled; new_account->pgp_enabled = pgp_enabled; + new_account->pgp_keyid = pgp_keyid; - if (pgp_keyid != NULL) { - new_account->pgp_keyid = strdup(pgp_keyid); - } else { - new_account->pgp_keyid = NULL; - } + new_account->startscript = startscript; - if (startscript != NULL) { - new_account->startscript = strdup(startscript); - } else { - new_account->startscript = NULL; - } + new_account->theme = theme; - if (theme != NULL) { - new_account->theme = strdup(theme); - } else { - new_account->theme = NULL; - } - - if (tls_policy != NULL) { - new_account->tls_policy = strdup(tls_policy); - } else { - new_account->tls_policy = NULL; - } + new_account->tls_policy = tls_policy; - if (auth_policy != NULL) { - new_account->auth_policy = strdup(auth_policy); - } else { - new_account->auth_policy = NULL; - } + new_account->auth_policy = auth_policy; return new_account; } diff --git a/src/config/account.h b/src/config/account.h index ce49883e..a469e068 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -73,17 +73,14 @@ typedef struct prof_account_t gchar* auth_policy; } ProfAccount; -ProfAccount* account_new(const gchar* const name, const gchar* const jid, - const gchar* const passord, const gchar* eval_password, gboolean enabled, const gchar* const server, - int port, const gchar* const resource, const gchar* const last_presence, - const gchar* const login_presence, int priority_online, int priority_chat, - int priority_away, int priority_xa, int priority_dnd, - const gchar* const muc_service, const gchar* const muc_nick, - const gchar* const otr_policy, GList* otr_manual, GList* otr_opportunistic, - GList* otr_always, const gchar* const omemo_policy, GList* omemo_enabled, - GList* omemo_disabled, GList* ox_enabled, GList* pgp_enabled, const gchar* const pgp_keyid, - const char* const startscript, const char* const theme, gchar* tls_policy, - gchar* auth_policy); +ProfAccount* account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboolean enabled, + gchar* server, int port, gchar* resource, gchar* last_presence, gchar* login_presence, + int priority_online, int priority_chat, int priority_away, int priority_xa, int priority_dnd, + gchar* muc_service, gchar* muc_nick, + gchar* otr_policy, GList* otr_manual, GList* otr_opportunistic, GList* otr_always, + 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); 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 cf1c1754..9c7eddf9 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -342,7 +342,7 @@ accounts_get_account(const char* const name) gchar* auth_policy = g_key_file_get_string(accounts, name, "auth.policy", NULL); - ProfAccount* new_account = account_new(name, jid, password, eval_password, enabled, + 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, @@ -350,23 +350,6 @@ accounts_get_account(const char* const name) omemo_disabled, ox_enabled, pgp_enabled, pgp_keyid, startscript, theme, tls_policy, auth_policy); - g_free(jid); - g_free(password); - g_free(eval_password); - g_free(server); - g_free(resource); - g_free(last_presence); - g_free(login_presence); - g_free(muc_service); - g_free(muc_nick); - g_free(otr_policy); - g_free(omemo_policy); - g_free(pgp_keyid); - g_free(startscript); - g_free(theme); - g_free(tls_policy); - g_free(auth_policy); - return new_account; } } diff --git a/src/config/preferences.c b/src/config/preferences.c index de455245..f15952cd 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -533,7 +533,7 @@ prefs_set_boolean(preference_t pref, gboolean value) g_key_file_set_boolean(prefs, group, key, value); } -char* +gchar* prefs_get_string(preference_t pref) { const char* group = _get_group(pref); @@ -553,14 +553,14 @@ prefs_get_string(preference_t pref) } } -char* +gchar* prefs_get_string_with_option(preference_t pref, gchar* option) { const char* group = _get_group(pref); const char* key = _get_key(pref); char* def = _get_default_string(pref); - char* result = g_key_file_get_locale_string(prefs, group, key, option, NULL); + gchar* result = g_key_file_get_locale_string(prefs, group, key, option, NULL); if (result == NULL) { // check for user set default @@ -1869,6 +1869,9 @@ _get_group(preference_t pref) case PREF_CORRECTION_ALLOW: case PREF_MAM: case PREF_SILENCE_NON_ROSTER: + case PREF_STROPHE_VERBOSITY: + case PREF_STROPHE_SM_ENABLED: + case PREF_STROPHE_SM_RESEND: return PREF_GROUP_CONNECTION; case PREF_OTR_LOG: case PREF_OTR_POLICY: @@ -2165,6 +2168,12 @@ _get_key(preference_t pref) return "mood"; case PREF_VCARD_PHOTO_CMD: return "vcard.photo.cmd"; + case PREF_STROPHE_VERBOSITY: + return "strophe.verbosity"; + case PREF_STROPHE_SM_ENABLED: + return "strophe.sm.enabled"; + case PREF_STROPHE_SM_RESEND: + return "strophe.sm.resend"; default: return NULL; } @@ -2217,6 +2226,8 @@ _get_default_boolean(preference_t pref) case PREF_INTYPE_CONSOLE: case PREF_NOTIFY_MENTION_WHOLE_WORD: case PREF_MOOD: + case PREF_STROPHE_SM_ENABLED: + case PREF_STROPHE_SM_RESEND: return TRUE; default: return FALSE; @@ -2316,6 +2327,8 @@ _get_default_string(preference_t pref) return NULL; // Default to built-in method. case PREF_OX_LOG: return "on"; + case PREF_STROPHE_VERBOSITY: + return "0"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 95a84865..ca8acea4 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -182,6 +182,9 @@ typedef enum { PREF_NOTIFY_ROOM_OFFLINE, PREF_OX_LOG, PREF_MOOD, + PREF_STROPHE_VERBOSITY, + PREF_STROPHE_SM_ENABLED, + PREF_STROPHE_SM_RESEND, PREF_VCARD_PHOTO_CMD, } preference_t; @@ -329,8 +332,8 @@ void prefs_save_win_placement(ProfWinPlacement* placement); gboolean prefs_get_boolean(preference_t pref); void prefs_set_boolean(preference_t pref, gboolean value); -char* prefs_get_string(preference_t pref); -char* prefs_get_string_with_option(preference_t pref, gchar* option); +gchar* prefs_get_string(preference_t pref); +gchar* prefs_get_string_with_option(preference_t pref, gchar* option); void prefs_set_string(preference_t pref, char* value); void prefs_set_string_with_option(preference_t pref, char* option, char* value); void prefs_set_string_list_with_option(preference_t pref, char* option, const gchar* const* values); |