diff options
author | James Booth <boothj5@gmail.com> | 2015-09-27 23:08:30 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-09-27 23:08:30 +0100 |
commit | 54e225aa5330b7a3c20bda38264e5ad0cfdfcdc5 (patch) | |
tree | 059b5e62ea42a173cad18dae4edf0cde535ed7de /src/config | |
parent | fe22fea9a81d097f8b4cda60d6a63db3a5220a5a (diff) | |
download | profani-tty-54e225aa5330b7a3c20bda38264e5ad0cfdfcdc5.tar.gz |
Added auto xa option, tidied autoaway code
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/accounts.c | 19 | ||||
-rw-r--r-- | src/config/accounts.h | 2 | ||||
-rw-r--r-- | src/config/preferences.c | 37 | ||||
-rw-r--r-- | src/config/preferences.h | 3 |
4 files changed, 58 insertions, 3 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c index d43cc3a3..9b838f59 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -762,6 +762,19 @@ accounts_set_last_presence(const char * const account_name, const char * const v } 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_last_activity(const char * const account_name) { if (accounts_account_exists(account_name)) { @@ -815,6 +828,12 @@ accounts_get_last_presence(const char * const account_name) return result; } +char * +accounts_get_last_status(const char * const account_name) +{ + return g_key_file_get_string(accounts, account_name, "presence.laststatus", NULL); +} + resource_presence_t accounts_get_login_presence(const char * const account_name) { diff --git a/src/config/accounts.h b/src/config/accounts.h index 65106365..14bdbf97 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -66,9 +66,11 @@ void accounts_set_muc_service(const char * const account_name, const char * cons 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_last_status(const char * const account_name, const char * const value); void accounts_set_last_activity(const char * const account_name); 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); +char * accounts_get_last_status(const char * const account_name); resource_presence_t accounts_get_last_presence(const char * const account_name); void accounts_set_priority_online(const char * const account_name, const gint value); void accounts_set_priority_chat(const char * const account_name, const gint value); diff --git a/src/config/preferences.c b/src/config/preferences.c index 7a198ac7..e594e9f6 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -93,6 +93,21 @@ prefs_load(void) g_error_free(err); } + // move pre 0.4.8 autoaway.time to autoaway.awaytime + if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL)) { + gint time = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL); + g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", time); + g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL); + } + + // move pre 0.4.8 autoaway.message to autoaway.awaymessage + if (g_key_file_has_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL)) { + char *message = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL); + g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.awaymessage", message); + g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL); + prefs_free_string(message); + } + // move pre 0.4.7 otr.warn to enc.warn err = NULL; gboolean otr_warn = g_key_file_get_boolean(prefs, PREF_GROUP_UI, "otr.warn", &err); @@ -322,7 +337,7 @@ prefs_set_autoping(gint value) gint prefs_get_autoaway_time(void) { - gint result = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL); + gint result = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", NULL); if (result == 0) { return 15; @@ -331,10 +346,23 @@ prefs_get_autoaway_time(void) } } +gint +prefs_get_autoxa_time(void) +{ + return g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.xatime", NULL); +} + void prefs_set_autoaway_time(gint value) { - g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", value); + g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.awaytime", value); + _save_prefs(); +} + +void +prefs_set_autoxa_time(gint value) +{ + g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.xatime", value); _save_prefs(); } @@ -606,6 +634,7 @@ _get_group(preference_t pref) case PREF_AUTOAWAY_CHECK: case PREF_AUTOAWAY_MODE: case PREF_AUTOAWAY_MESSAGE: + case PREF_AUTOXA_MESSAGE: return PREF_GROUP_PRESENCE; case PREF_CONNECT_ACCOUNT: case PREF_DEFAULT_ACCOUNT: @@ -702,7 +731,9 @@ _get_key(preference_t pref) case PREF_AUTOAWAY_MODE: return "autoaway.mode"; case PREF_AUTOAWAY_MESSAGE: - return "autoaway.message"; + return "autoaway.awaymessage"; + case PREF_AUTOXA_MESSAGE: + return "autoaway.xamessage"; case PREF_CONNECT_ACCOUNT: return "account"; case PREF_DEFAULT_ACCOUNT: diff --git a/src/config/preferences.h b/src/config/preferences.h index 89b3fe24..1879c7d3 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -93,6 +93,7 @@ typedef enum { PREF_AUTOAWAY_CHECK, PREF_AUTOAWAY_MODE, PREF_AUTOAWAY_MESSAGE, + PREF_AUTOXA_MESSAGE, PREF_CONNECT_ACCOUNT, PREF_DEFAULT_ACCOUNT, PREF_LOG_ROTATE, @@ -143,6 +144,8 @@ gint prefs_get_roster_size(void); gint prefs_get_autoaway_time(void); void prefs_set_autoaway_time(gint value); +gint prefs_get_autoxa_time(void); +void prefs_set_autoxa_time(gint value); char prefs_get_otr_char(void); void prefs_set_otr_char(char ch); |