diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/account.c | 12 | ||||
-rw-r--r-- | src/config/account.h | 3 | ||||
-rw-r--r-- | src/config/accounts.c | 21 | ||||
-rw-r--r-- | src/config/accounts.h | 1 |
4 files changed, 31 insertions, 6 deletions
diff --git a/src/config/account.c b/src/config/account.c index 4f52d280..d982fb88 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -34,7 +34,7 @@ account_new(const gchar * const name, const gchar * const jid, 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 muc_service, const gchar * const muc_nick, const gchar * const otr_policy) { ProfAccount *new_account = malloc(sizeof(ProfAccount)); @@ -111,6 +111,12 @@ account_new(const gchar * const name, const gchar * const jid, new_account->muc_nick = strdup(muc_nick); } + if (otr_policy != NULL) { + new_account->otr_policy = strdup(otr_policy); + } else { + new_account->otr_policy = NULL; + } + return new_account; } @@ -137,7 +143,7 @@ account_free(ProfAccount *account) free(account->login_presence); free(account->muc_service); free(account->muc_nick); + free(account->otr_policy); free(account); } -} - +} \ No newline at end of file diff --git a/src/config/account.h b/src/config/account.h index 6050b861..549e9124 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -42,6 +42,7 @@ typedef struct prof_account_t { gchar *muc_service; gchar *muc_nick; gboolean enabled; + gchar *otr_policy; } ProfAccount; ProfAccount* account_new(const gchar * const name, const gchar * const jid, @@ -49,7 +50,7 @@ ProfAccount* account_new(const gchar * const name, const gchar * const jid, 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 muc_service, const gchar * const muc_nick, const gchar * const otr_policy); char* account_create_full_jid(ProfAccount *account); diff --git a/src/config/accounts.c b/src/config/accounts.c index 4b1ddb1e..0f7be510 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -50,7 +50,8 @@ static gchar *string_keys[] = { "presence.last", "presence.login", "muc.service", - "muc.nick" + "muc.nick", + "otr.policy" }; static void _fix_legacy_accounts(const char * const account_name); @@ -212,10 +213,15 @@ _accounts_get_account(const char * const name) gchar *muc_service = g_key_file_get_string(accounts, name, "muc.service", NULL); gchar *muc_nick = g_key_file_get_string(accounts, name, "muc.nick", NULL); + gchar *otr_policy = NULL; + if (g_key_file_has_key(accounts, name, "otr.policy", NULL)) { + otr_policy = g_key_file_get_string(accounts, name, "otr.policy", NULL); + } + ProfAccount *new_account = account_new(name, jid, password, enabled, server, port, resource, last_presence, login_presence, priority_online, priority_chat, priority_away, priority_xa, - priority_dnd, muc_service, muc_nick); + priority_dnd, muc_service, muc_nick, otr_policy); g_free(jid); g_free(password); @@ -225,6 +231,7 @@ _accounts_get_account(const char * const name) g_free(login_presence); g_free(muc_service); g_free(muc_nick); + g_free(otr_policy); return new_account; } @@ -401,6 +408,15 @@ _accounts_set_muc_nick(const char * const account_name, const char * const value } static void +_accounts_set_otr_policy(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "otr.policy", value); + _save_accounts(); + } +} + +static void _accounts_set_priority_online(const char * const account_name, const gint value) { if (accounts_account_exists(account_name)) { @@ -660,6 +676,7 @@ accounts_init_module(void) accounts_set_password = _accounts_set_password; accounts_set_muc_service = _accounts_set_muc_service; accounts_set_muc_nick = _accounts_set_muc_nick; + accounts_set_otr_policy = _accounts_set_otr_policy; accounts_set_last_presence = _accounts_set_last_presence; accounts_set_login_presence = _accounts_set_login_presence; accounts_get_last_presence = _accounts_get_last_presence; diff --git a/src/config/accounts.h b/src/config/accounts.h index 335eba9d..de3c2a0f 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -52,6 +52,7 @@ void (*accounts_set_resource)(const char * const account_name, const char * cons void (*accounts_set_password)(const char * const account_name, const char * const value); void (*accounts_set_muc_service)(const char * const account_name, const char * const value); void (*accounts_set_muc_nick)(const char * const account_name, const char * const value); +void (*accounts_set_otr_policy)(const char * const account_name, const char * const value); void (*accounts_set_last_presence)(const char * const account_name, const char * const value); void (*accounts_set_login_presence)(const char * const account_name, const char * const value); resource_presence_t (*accounts_get_login_presence)(const char * const account_name); |