diff options
author | James Booth <boothj5@gmail.com> | 2016-01-22 01:06:28 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-01-22 01:06:28 +0000 |
commit | 53fc89f71120a7ceba494cb1eed18667c24d1775 (patch) | |
tree | 5564e45185ba286f8ae5860bdf84145fbb2e4b3c /src/config | |
parent | 72bbb5c2b9953237c39c4003cabb95ad420afe64 (diff) | |
download | profani-tty-53fc89f71120a7ceba494cb1eed18667c24d1775.tar.gz |
Added account theme property
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 | 27 | ||||
-rw-r--r-- | src/config/accounts.h | 2 | ||||
-rw-r--r-- | src/config/theme.c | 16 | ||||
-rw-r--r-- | src/config/theme.h | 1 |
6 files changed, 55 insertions, 3 deletions
diff --git a/src/config/account.c b/src/config/account.c index da6a4317..d31f426b 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -52,7 +52,7 @@ account_new(const gchar *const name, const gchar *const jid, 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 pgp_keyid, const char *const startscript, - gchar *tls_policy) + const char *const theme, gchar *tls_policy) { ProfAccount *new_account = malloc(sizeof(ProfAccount)); @@ -157,6 +157,12 @@ account_new(const gchar *const name, const gchar *const jid, new_account->startscript = NULL; } + 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 { @@ -231,6 +237,7 @@ account_free(ProfAccount *account) free(account->otr_policy); free(account->pgp_keyid); free(account->startscript); + free(account->theme); free(account->tls_policy); g_list_free_full(account->otr_manual, g_free); g_list_free_full(account->otr_opportunistic, g_free); diff --git a/src/config/account.h b/src/config/account.h index 2d45bdbd..a160c3b5 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -61,6 +61,7 @@ typedef struct prof_account_t { GList *otr_always; gchar *pgp_keyid; gchar *startscript; + gchar *theme; gchar *tls_policy; } ProfAccount; @@ -72,7 +73,7 @@ ProfAccount* account_new(const gchar *const name, const gchar *const jid, 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 pgp_keyid, const char *const startscript, - gchar *tls_policy); + const char *const theme, gchar *tls_policy); 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 385e86f3..7049039a 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -272,6 +272,11 @@ accounts_get_account(const char *const name) startscript = g_key_file_get_string(accounts, name, "script.start", NULL); } + gchar *theme = NULL; + if (g_key_file_has_key(accounts, name, "theme", NULL)) { + theme = g_key_file_get_string(accounts, name, "theme", NULL); + } + gchar *tls_policy = g_key_file_get_string(accounts, name, "tls.policy", NULL); if (tls_policy && ((g_strcmp0(tls_policy, "force") != 0) && (g_strcmp0(tls_policy, "allow") != 0) && @@ -284,7 +289,7 @@ accounts_get_account(const char *const name) 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, pgp_keyid, startscript, tls_policy); + otr_opportunistic, otr_always, pgp_keyid, startscript, theme, tls_policy); g_free(jid); g_free(password); @@ -298,6 +303,7 @@ accounts_get_account(const char *const name) g_free(otr_policy); g_free(pgp_keyid); g_free(startscript); + g_free(theme); g_free(tls_policy); return new_account; @@ -491,6 +497,15 @@ accounts_set_script_start(const char *const account_name, const char *const valu } void +accounts_set_theme(const char *const account_name, const char *const value) +{ + if (accounts_account_exists(account_name)) { + g_key_file_set_string(accounts, account_name, "theme", value); + _save_accounts(); + } +} + +void accounts_clear_password(const char *const account_name) { if (accounts_account_exists(account_name)) { @@ -543,6 +558,16 @@ accounts_clear_script_start(const char *const account_name) _save_accounts(); } } + +void +accounts_clear_theme(const char *const account_name) +{ + if (accounts_account_exists(account_name)) { + g_key_file_remove_key(accounts, account_name, "theme", NULL); + _save_accounts(); + } +} + void accounts_clear_otr(const char *const account_name) { diff --git a/src/config/accounts.h b/src/config/accounts.h index 0417b6bd..a73e5c9a 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -84,6 +84,7 @@ 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_set_script_start(const char *const account_name, const char *const value); +void accounts_set_theme(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); @@ -91,6 +92,7 @@ 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_clear_script_start(const char *const account_name); +void accounts_clear_theme(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 diff --git a/src/config/theme.c b/src/config/theme.c index b9397a18..14c165f6 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -145,6 +145,22 @@ theme_init(const char *const theme_name) } gboolean +theme_exists(const char *const theme_name) +{ + if (g_strcmp0(theme_name, "default") == 0) { + return TRUE; + } + + GString *new_theme_file = _theme_find(theme_name); + if (new_theme_file == NULL) { + return FALSE; + } + + g_string_free(new_theme_file, TRUE); + return TRUE; +} + +gboolean theme_load(const char *const theme_name) { if (_theme_load_file(theme_name)) { diff --git a/src/config/theme.h b/src/config/theme.h index 3c0f0fa9..f4eac724 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -128,6 +128,7 @@ typedef enum { void theme_init(const char *const theme_name); void theme_init_colours(void); gboolean theme_load(const char *const theme_name); +gboolean theme_exists(const char *const theme_name); GSList* theme_list(void); void theme_close(void); int theme_attrs(theme_item_t attrs); |