diff options
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/account.c | 9 | ||||
-rw-r--r-- | src/config/account.h | 3 | ||||
-rw-r--r-- | src/config/accounts.c | 26 | ||||
-rw-r--r-- | src/config/accounts.h | 2 |
4 files changed, 37 insertions, 3 deletions
diff --git a/src/config/account.c b/src/config/account.c index 749eb885..b1532b38 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -51,7 +51,7 @@ account_new(const gchar * const name, const gchar * const jid, 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) + GList *otr_always, const gchar * const pgp_keyid) { ProfAccount *new_account = malloc(sizeof(ProfAccount)); @@ -144,6 +144,12 @@ account_new(const gchar * const name, const gchar * const jid, new_account->otr_opportunistic = otr_opportunistic; new_account->otr_always = otr_always; + if (pgp_keyid != NULL) { + new_account->pgp_keyid = strdup(pgp_keyid); + } else { + new_account->pgp_keyid = NULL; + } + return new_account; } @@ -210,6 +216,7 @@ account_free(ProfAccount *account) free(account->muc_service); free(account->muc_nick); free(account->otr_policy); + free(account->pgp_keyid); g_list_free_full(account->otr_manual, g_free); g_list_free_full(account->otr_opportunistic, g_free); g_list_free_full(account->otr_always, g_free); diff --git a/src/config/account.h b/src/config/account.h index 218f8ce7..22c29161 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -59,6 +59,7 @@ typedef struct prof_account_t { GList *otr_manual; GList *otr_opportunistic; GList *otr_always; + gchar *pgp_keyid; } ProfAccount; ProfAccount* account_new(const gchar * const name, const gchar * const jid, @@ -68,7 +69,7 @@ ProfAccount* account_new(const gchar * const name, const gchar * const jid, 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); + GList *otr_always, const gchar * const pgp_keyid); char* account_create_full_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 6c04549c..b18974ca 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -280,11 +280,16 @@ accounts_get_account(const char * const name) g_strfreev(always); } + gchar *pgp_keyid = NULL; + if (g_key_file_has_key(accounts, name, "pgp.keyid", NULL)) { + pgp_keyid = g_key_file_get_string(accounts, name, "pgp.keyid", NULL); + } + ProfAccount *new_account = account_new(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); + otr_opportunistic, otr_always, pgp_keyid); g_free(jid); g_free(password); @@ -296,6 +301,7 @@ accounts_get_account(const char * const name) g_free(muc_service); g_free(muc_nick); g_free(otr_policy); + g_free(pgp_keyid); return new_account; } @@ -454,6 +460,15 @@ accounts_set_eval_password(const char * const account_name, const char * const v } void +accounts_set_pgp_keyid(const char * const account_name, const char * const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "pgp.keyid", value); + _save_accounts(); + } +} + +void accounts_clear_password(const char * const account_name) { if (accounts_account_exists(account_name)) { @@ -490,6 +505,15 @@ accounts_clear_port(const char * const account_name) } void +accounts_clear_pgp_keyid(const char * const account_name) +{ + if (accounts_account_exists(account_name)) { + g_key_file_remove_key(accounts, account_name, "pgp.keyid", NULL); + _save_accounts(); + } +} + +void accounts_clear_otr(const char * const account_name) { if (accounts_account_exists(account_name)) { diff --git a/src/config/accounts.h b/src/config/accounts.h index 50307b5b..eb981cb8 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -77,11 +77,13 @@ void accounts_set_priority_dnd(const char * const account_name, const gint value void accounts_set_priority_all(const char * const account_name, const gint value); gint accounts_get_priority_for_presence_type(const char * const account_name, resource_presence_t presence_type); +void accounts_set_pgp_keyid(const char * const account_name, const char * const value); 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); void accounts_clear_port(const char * const account_name); void accounts_clear_otr(const char * const account_name); +void accounts_clear_pgp_keyid(const char * const account_name); void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy); #endif |