void accounts_clear_otr(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "otr.policy", NULL); _save_accounts(); } }
void accounts_set_muc_nick(const char *const account_name, const char *const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "muc.nick", value); _save_accounts(); } }
void accounts_clear_muc(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "muc.service", NULL); _save_accounts(); } }
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(); } }
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_script_start(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "script.start", NULL); _save_accounts(); } }
void accounts_clear_eval_password(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "eval_password", NULL); _save_accounts(); } }
void accounts_set_login_presence(const char *const account_name, const char *const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "presence.login", value); _save_accounts(); } }
void accounts_set_script_start(const char *const account_name, const char *const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "script.start", value); _save_accounts(); } }
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_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_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(); } }
static void _accounts_set_priority_online(const char * const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.online", value); _save_accounts(); } }
void accounts_set_tls_policy(const char *const account_name, const char *const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "tls.policy", value); _save_accounts(); } }
void accounts_clear_server(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "server", NULL); _save_accounts(); } }
void accounts_set_priority_dnd(const char *const account_name, const gint value) { if (accounts_account_exists(account_name)) { g_key_file_set_integer(accounts, account_name, "priority.dnd", value); _save_accounts(); } }
void accounts_clear_resource(const char *const account_name) { if (accounts_account_exists(account_name)) { g_key_file_remove_key(accounts, account_name, "resource", NULL); _save_accounts(); } }
static void _accounts_set_muc_service(const char * const account_name, const char * const value) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "muc.service", value); _save_accounts(); } }
char* accounts_get_last_activity(const char *const account_name) { if (accounts_account_exists(account_name)) { return g_key_file_get_string(accounts, account_name, "last.activity", NULL); } else { return NULL; } }
void accounts_set_last_status(const char *const account_name, const char *const value) { if (accounts_account_exists(account_name)) { if (value) { g_key_file_set_string(accounts, account_name, "presence.laststatus", value); } else { g_key_file_remove_key(accounts, account_name, "presence.laststatus", NULL); } _save_accounts(); } }
void accounts_set_priority_all(const char *const account_name, const gint value) { if (accounts_account_exists(account_name)) { accounts_set_priority_online(account_name, value); accounts_set_priority_chat(account_name, value); accounts_set_priority_away(account_name, value); accounts_set_priority_xa(account_name, value); accounts_set_priority_dnd(account_name, value); _save_accounts(); } }
void accounts_set_last_activity(const char *const account_name) { if (accounts_account_exists(account_name)) { GDateTime *nowdt = g_date_time_new_now_utc(); GTimeVal nowtv; gboolean res = g_date_time_to_timeval(nowdt, &nowtv); g_date_time_unref(nowdt); if (res) { char *timestr = g_time_val_to_iso8601(&nowtv); g_key_file_set_string(accounts, account_name, "last.activity", timestr); free(timestr); _save_accounts(); } } }
void accounts_set_jid(const char *const account_name, const char *const value) { Jid *jid = jid_create(value); if (jid) { if (accounts_account_exists(account_name)) { g_key_file_set_string(accounts, account_name, "jid", jid->barejid); if (jid->resourcepart) { g_key_file_set_string(accounts, account_name, "resource", jid->resourcepart); } if (jid->localpart == NULL) { g_key_file_set_string(accounts, account_name, "muc.nick", jid->domainpart); } else { g_key_file_set_string(accounts, account_name, "muc.nick", jid->localpart); } _save_accounts(); } jid_destroy(jid); } }
void accounts_add_otr_policy(const char *const account_name, const char *const contact_jid, const char *const policy) { if (accounts_account_exists(account_name)) { GString *key = g_string_new("otr."); g_string_append(key, policy); gsize length; gchar **list = g_key_file_get_string_list(accounts, account_name, key->str, &length, NULL); GList *glist = NULL; // list found if (list) { int i = 0; for (i = 0; i < length; i++) { // item already in list, exit function if (strcmp(list[i], contact_jid) == 0) { g_list_free_full(glist, g_free); g_strfreev(list); return; } // add item to our g_list glist = g_list_append(glist, strdup(list[i])); } // item not found, add to our g_list glist = g_list_append(glist, strdup(contact_jid)); // create the new list entry const gchar* new_list[g_list_length(glist)+1]; GList *curr = glist; i = 0; while (curr) { new_list[i++] = strdup(curr->data); curr = g_list_next(curr); } new_list[i] = NULL; g_key_file_set_string_list(accounts, account_name, key->str, new_list, g_list_length(glist)); // list not found } else { const gchar* new_list[2]; new_list[0] = strdup(contact_jid); new_list[1] = NULL; g_key_file_set_string_list(accounts, account_name, key->str, new_list, 1); } g_strfreev(list); g_list_free_full(glist, g_free); g_string_free(key, TRUE); // check for and remove from other lists if (strcmp(policy, "manual") == 0) { _remove_from_list(accounts, account_name, "otr.opportunistic", contact_jid); _remove_from_list(accounts, account_name, "otr.always", contact_jid); } if (strcmp(policy, "opportunistic") == 0) { _remove_from_list(accounts, account_name, "otr.manual", contact_jid); _remove_from_list(accounts, account_name, "otr.always", contact_jid); } if (strcmp(policy, "always") == 0) { _remove_from_list(accounts, account_name, "otr.opportunistic", contact_jid); _remove_from_list(accounts, account_name, "otr.manual", contact_jid); } _save_accounts(); } }