From 401835f32a61c6e47bd34be20753f4555c56b064 Mon Sep 17 00:00:00 2001 From: Peter Vilim Date: Tue, 6 Jan 2015 23:00:02 -0600 Subject: Add support for evaluated password --- src/config/account.c | 10 ++++++++-- src/config/account.h | 3 ++- src/config/accounts.c | 20 ++++++++++++++++++-- src/config/accounts.h | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src/config') diff --git a/src/config/account.c b/src/config/account.c index 64819d8c..3ca63db0 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -43,7 +43,7 @@ ProfAccount* account_new(const gchar * const name, const gchar * const jid, - const gchar * const password, gboolean enabled, const gchar * const server, + 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, @@ -67,6 +67,12 @@ account_new(const gchar * const name, const gchar * const jid, new_account->password = NULL; } + if (eval_password != NULL) { + new_account->eval_password = strdup(eval_password); + } else { + new_account->eval_password = NULL; + } + new_account->enabled = enabled; if (server != NULL) { @@ -168,4 +174,4 @@ account_free(ProfAccount *account) g_list_free_full(account->otr_always, g_free); free(account); } -} \ No newline at end of file +} diff --git a/src/config/account.h b/src/config/account.h index 49477f95..ab43234d 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -41,6 +41,7 @@ typedef struct prof_account_t { gchar *name; gchar *jid; gchar *password; + gchar *eval_password; gchar *resource; gchar *server; int port; @@ -61,7 +62,7 @@ typedef struct prof_account_t { } ProfAccount; ProfAccount* account_new(const gchar * const name, const gchar * const jid, - const gchar * const passord, gboolean enabled, const gchar * const server, + 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, diff --git a/src/config/accounts.c b/src/config/accounts.c index efbaccb9..c3478bd5 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -46,6 +46,7 @@ #include "log.h" #include "tools/autocomplete.h" #include "xmpp/xmpp.h" +#include "ui/ui.h" static gchar *accounts_loc; static GKeyFile *accounts; @@ -224,6 +225,11 @@ accounts_get_account(const char * const name) } gchar *password = g_key_file_get_string(accounts, name, "password", NULL); + gchar *eval_password = g_key_file_get_string(accounts, name, "eval_password", NULL); + if (eval_password != NULL) { + FILE *evaled_password = popen(eval_password, "r"); + fscanf(evaled_password, "%s", password); + } gboolean enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL); gchar *server = g_key_file_get_string(accounts, name, "server", NULL); @@ -278,7 +284,7 @@ accounts_get_account(const char * const name) g_strfreev(always); } - ProfAccount *new_account = account_new(name, jid, password, enabled, + 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, @@ -286,6 +292,7 @@ accounts_get_account(const char * const name) g_free(jid); g_free(password); + g_free(eval_password); g_free(server); g_free(resource); g_free(last_presence); @@ -441,6 +448,15 @@ 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) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "eval_password", value); + _save_accounts(); + } +} + void accounts_clear_password(const char * const account_name) { @@ -859,4 +875,4 @@ _get_accounts_file(void) g_string_free(logfile, TRUE); return result; -} \ No newline at end of file +} diff --git a/src/config/accounts.h b/src/config/accounts.h index 78b186b4..09b5d29a 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -61,6 +61,7 @@ void accounts_set_server(const char * const account_name, const char * const val 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); 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); 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); -- cgit 1.4.1-2-gfad0