about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c8
-rw-r--r--src/config/preferences.c275
-rw-r--r--src/config/preferences.h37
-rw-r--r--src/profanity.c6
-rw-r--r--src/ui/inputwin.c4
-rw-r--r--src/ui/windows.c64
-rw-r--r--src/xmpp/message.c6
7 files changed, 206 insertions, 194 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 05123015..a95d064a 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -918,7 +918,7 @@ cmd_execute_default(const char * const inp)
             char *recipient = win_current_get_recipient();
             message_send(inp, recipient);
 
-            if (win_current_is_chat() && prefs_get_chlog()) {
+            if (win_current_is_chat() && prefs_get_boolean(PREF_CHLOG)) {
                 const char *jid = jabber_get_jid();
                 Jid *jidp = jid_create(jid);
                 chat_log_chat(jidp->barejid, recipient, inp, PROF_OUT_LOG, NULL);
@@ -1738,7 +1738,7 @@ _cmd_msg(gchar **args, struct cmd_help_t help)
             message_send(msg, usr);
             win_show_outgoing_msg("me", usr, msg);
 
-            if (win_current_is_chat() && prefs_get_chlog()) {
+            if (win_current_is_chat() && prefs_get_boolean(PREF_CHLOG)) {
                 const char *jid = jabber_get_jid();
                 Jid *jidp = jid_create(jid);
                 chat_log_chat(jidp->barejid, usr, msg, PROF_OUT_LOG, NULL);
@@ -1936,7 +1936,7 @@ _cmd_tiny(gchar **args, struct cmd_help_t help)
                 char *recipient = win_current_get_recipient();
                 message_send(tiny, recipient);
 
-                if (prefs_get_chlog()) {
+                if (prefs_get_boolean(PREF_CHLOG)) {
                     const char *jid = jabber_get_jid();
                     Jid *jidp = jid_create(jid);
                     chat_log_chat(jidp->barejid, recipient, tiny, PROF_OUT_LOG, NULL);
@@ -1984,7 +1984,7 @@ _cmd_close(gchar **args, struct cmd_help_t help)
             presence_leave_chat_room(room_jid);
         } else if (win_current_is_chat() || win_current_is_private()) {
 
-            if (prefs_get_states()) {
+            if (prefs_get_boolean(PREF_STATES)) {
                 char *recipient = win_current_get_recipient();
 
                 // send <gone/> chat state before closing
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 0a807a48..bbedb334 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -37,6 +37,13 @@
 #include "preferences.h"
 #include "tools/autocomplete.h"
 
+#define PREF_GROUP_LOGGING "logging"
+#define PREF_GROUP_CHATSTATES "chatstates"
+#define PREF_GROUP_UI "ui"
+#define PREF_GROUP_NOTIFICATIONS "notifications"
+#define PREF_GROUP_PRESENCE "presence"
+#define PREF_GROUP_CONNECTION "connection"
+
 static gchar *prefs_loc;
 static GKeyFile *prefs;
 gint log_maxsize = 0;
@@ -59,7 +66,7 @@ prefs_load(void)
         NULL);
 
     err = NULL;
-    log_maxsize = g_key_file_get_integer(prefs, "logging", "maxsize", &err);
+    log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err);
     if (err != NULL) {
         log_maxsize = 0;
         g_error_free(err);
@@ -89,107 +96,178 @@ prefs_reset_boolean_choice(void)
     autocomplete_reset(boolean_choice_ac);
 }
 
+static const char *
+_get_group(preference_t pref)
+{
+    switch (pref)
+    {
+        case PREF_SPLASH:
+        case PREF_BEEP:
+        case PREF_THEME:
+        case PREF_VERCHECK:
+        case PREF_TITLEBARVERSION:
+        case PREF_FLASH:
+        case PREF_INTYPE:
+        case PREF_HISTORY:
+        case PREF_MOUSE:
+        case PREF_STATUSES:
+            return "ui";
+        case PREF_STATES:
+        case PREF_OUTTYPE:
+            return "chatstates";
+        case PREF_NOTIFY_TYPING:
+        case PREF_NOTIFY_MESSAGE:
+            return "notifications";
+        case PREF_CHLOG:
+            return "logging";
+        case PREF_AUTOAWAY_CHECK:
+            return "presence";
+        default:
+            return NULL;
+    }
+}
+
+static const char *
+_get_key(preference_t pref)
+{
+    switch (pref)
+    {
+        case PREF_SPLASH:
+            return "splash";
+        case PREF_BEEP:
+            return "beep";
+        case PREF_THEME:
+            return "theme";
+        case PREF_VERCHECK:
+            return "vercheck";
+        case PREF_TITLEBARVERSION:
+            return "titlebar.version";
+        case PREF_FLASH:
+            return "flash";
+        case PREF_INTYPE:
+            return "intype";
+        case PREF_HISTORY:
+            return "history";
+        case PREF_MOUSE:
+            return "mouse";
+        case PREF_STATUSES:
+            return "statuses";
+        case PREF_STATES:
+            return "enabled";
+        case PREF_OUTTYPE:
+            return "outtype";
+        case PREF_NOTIFY_TYPING:
+            return "typing";
+        case PREF_NOTIFY_MESSAGE:
+            return "message";
+        case PREF_CHLOG:
+            return "chlog";
+        case PREF_AUTOAWAY_CHECK:
+            return "autoaway.check";
+        default:
+            return NULL;
+    }
+}
+
+static gboolean
+_get_default_boolean(preference_t pref)
+{
+    switch (pref)
+    {
+        case PREF_MOUSE:
+        case PREF_STATUSES:
+        case PREF_AUTOAWAY_CHECK:
+            return TRUE;
+        default:
+            return FALSE;
+    }
+}
+
 gboolean
-prefs_get_beep(void)
+prefs_get_boolean(preference_t pref)
 {
-    return g_key_file_get_boolean(prefs, "ui", "beep", NULL);
+    const char *group = _get_group(pref);
+    const char *key = _get_key(pref);
+    gboolean def = _get_default_boolean(pref);
+
+    if (!g_key_file_has_key(prefs, group, key, NULL)) {
+        return def;
+    }
+
+    return g_key_file_get_boolean(prefs, group, key, NULL);
 }
 
 void
 prefs_set_beep(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "beep", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "beep", value);
     _save_prefs();
 }
 
 gchar *
 prefs_get_theme(void)
 {
-    return g_key_file_get_string(prefs, "ui", "theme", NULL);
+    return g_key_file_get_string(prefs, PREF_GROUP_UI, "theme", NULL);
 }
 
 void
 prefs_set_theme(gchar *value)
 {
-    g_key_file_set_string(prefs, "ui", "theme", value);
+    g_key_file_set_string(prefs, PREF_GROUP_UI, "theme", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_states(void)
-{
-    return g_key_file_get_boolean(prefs, "chatstates", "enabled", NULL);
-}
-
 void
 prefs_set_states(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "chatstates", "enabled", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_CHATSTATES, "enabled", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_outtype(void)
-{
-    return g_key_file_get_boolean(prefs, "chatstates", "outtype", NULL);
-}
-
 void
 prefs_set_outtype(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "chatstates", "outtype", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_CHATSTATES, "outtype", value);
     _save_prefs();
 }
 
 gint
 prefs_get_gone(void)
 {
-    return g_key_file_get_integer(prefs, "chatstates", "gone", NULL);
+    return g_key_file_get_integer(prefs, PREF_GROUP_CHATSTATES, "gone", NULL);
 }
 
 void
 prefs_set_gone(gint value)
 {
-    g_key_file_set_integer(prefs, "chatstates", "gone", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_CHATSTATES, "gone", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_notify_typing(void)
-{
-    return g_key_file_get_boolean(prefs, "notifications", "typing", NULL);
-}
-
 void
 prefs_set_notify_typing(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "notifications", "typing", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "typing", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_notify_message(void)
-{
-    return g_key_file_get_boolean(prefs, "notifications", "message", NULL);
-}
-
 void
 prefs_set_notify_message(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "notifications", "message", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_NOTIFICATIONS, "message", value);
     _save_prefs();
 }
 
 gint
 prefs_get_notify_remind(void)
 {
-    return g_key_file_get_integer(prefs, "notifications", "remind", NULL);
+    return g_key_file_get_integer(prefs, PREF_GROUP_NOTIFICATIONS, "remind", NULL);
 }
 
 void
 prefs_set_notify_remind(gint value)
 {
-    g_key_file_set_integer(prefs, "notifications", "remind", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_NOTIFICATIONS, "remind", value);
     _save_prefs();
 }
 
@@ -206,131 +284,95 @@ void
 prefs_set_max_log_size(gint value)
 {
     log_maxsize = value;
-    g_key_file_set_integer(prefs, "logging", "maxsize", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_LOGGING, "maxsize", value);
     _save_prefs();
 }
 
 gint
 prefs_get_priority(void)
 {
-    return g_key_file_get_integer(prefs, "presence", "priority", NULL);
+    return g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "priority", NULL);
 }
 
 void
 prefs_set_priority(gint value)
 {
-    g_key_file_set_integer(prefs, "presence", "priority", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "priority", value);
     _save_prefs();
 }
 
 gint
 prefs_get_reconnect(void)
 {
-    return g_key_file_get_integer(prefs, "connection", "reconnect", NULL);
+    return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "reconnect", NULL);
 }
 
 void
 prefs_set_reconnect(gint value)
 {
-    g_key_file_set_integer(prefs, "connection", "reconnect", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_CONNECTION, "reconnect", value);
     _save_prefs();
 }
 
 gint
 prefs_get_autoping(void)
 {
-    return g_key_file_get_integer(prefs, "connection", "autoping", NULL);
+    return g_key_file_get_integer(prefs, PREF_GROUP_CONNECTION, "autoping", NULL);
 }
 
 void
 prefs_set_autoping(gint value)
 {
-    g_key_file_set_integer(prefs, "connection", "autoping", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_CONNECTION, "autoping", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_vercheck(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "vercheck", NULL);
-}
-
 void
 prefs_set_vercheck(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "vercheck", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "vercheck", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_titlebarversion(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "titlebar.version", NULL);
-}
-
 void
 prefs_set_titlebarversion(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "titlebar.version", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "titlebar.version", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_flash(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "flash", NULL);
-}
-
 void
 prefs_set_flash(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "flash", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "flash", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_intype(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "intype", NULL);
-}
-
 void
 prefs_set_intype(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "intype", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "intype", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_chlog(void)
-{
-    return g_key_file_get_boolean(prefs, "logging", "chlog", NULL);
-}
-
 void
 prefs_set_chlog(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "logging", "chlog", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_LOGGING, "chlog", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_history(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "history", NULL);
-}
-
 void
 prefs_set_history(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "history", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "history", value);
     _save_prefs();
 }
 
 gchar *
 prefs_get_autoaway_mode(void)
 {
-    gchar *result = g_key_file_get_string(prefs, "presence", "autoaway.mode", NULL);
+    gchar *result = g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.mode", NULL);
     if (result == NULL) {
         return strdup("off");
     } else {
@@ -341,14 +383,14 @@ prefs_get_autoaway_mode(void)
 void
 prefs_set_autoaway_mode(gchar *value)
 {
-    g_key_file_set_string(prefs, "presence", "autoaway.mode", value);
+    g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.mode", value);
     _save_prefs();
 }
 
 gint
 prefs_get_autoaway_time(void)
 {
-    gint result = g_key_file_get_integer(prefs, "presence", "autoaway.time", NULL);
+    gint result = g_key_file_get_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", NULL);
 
     if (result == 0) {
         return 15;
@@ -360,89 +402,52 @@ prefs_get_autoaway_time(void)
 void
 prefs_set_autoaway_time(gint value)
 {
-    g_key_file_set_integer(prefs, "presence", "autoaway.time", value);
+    g_key_file_set_integer(prefs, PREF_GROUP_PRESENCE, "autoaway.time", value);
     _save_prefs();
 }
 
 gchar *
 prefs_get_autoaway_message(void)
 {
-    return g_key_file_get_string(prefs, "presence", "autoaway.message", NULL);
+    return g_key_file_get_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
 }
 
 void
 prefs_set_autoaway_message(gchar *value)
 {
     if (value == NULL) {
-        g_key_file_remove_key(prefs, "presence", "autoaway.message", NULL);
+        g_key_file_remove_key(prefs, PREF_GROUP_PRESENCE, "autoaway.message", NULL);
     } else {
-        g_key_file_set_string(prefs, "presence", "autoaway.message", value);
+        g_key_file_set_string(prefs, PREF_GROUP_PRESENCE, "autoaway.message", value);
     }
     _save_prefs();
 }
 
-gboolean
-prefs_get_autoaway_check(void)
-{
-    if (g_key_file_has_key(prefs, "presence", "autoaway.check", NULL)) {
-        return g_key_file_get_boolean(prefs, "presence", "autoaway.check", NULL);
-    } else {
-        return TRUE;
-    }
-}
-
 void
 prefs_set_autoaway_check(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "presence", "autoaway.check", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_PRESENCE, "autoaway.check", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_splash(void)
-{
-    return g_key_file_get_boolean(prefs, "ui", "splash", NULL);
-}
-
 void
 prefs_set_splash(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "splash", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "splash", value);
     _save_prefs();
 }
 
-gboolean
-prefs_get_mouse(void)
-{
-    // default to true
-    if (!g_key_file_has_key(prefs, "ui", "mouse", NULL)) {
-        return TRUE;
-    } else {
-        return g_key_file_get_boolean(prefs, "ui", "mouse", NULL);
-    }
-}
-
-gboolean
-prefs_get_statuses(void)
-{
-    if (g_key_file_has_key(prefs, "ui", "statuses", NULL)) {
-        return g_key_file_get_boolean(prefs, "ui", "statuses", NULL);
-    } else {
-        return TRUE;
-    }
-}
-
 void
 prefs_set_mouse(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "mouse", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "mouse", value);
     _save_prefs();
 }
 
 void
 prefs_set_statuses(gboolean value)
 {
-    g_key_file_set_boolean(prefs, "ui", "statuses", value);
+    g_key_file_set_boolean(prefs, PREF_GROUP_UI, "statuses", value);
     _save_prefs();
 }
 
diff --git a/src/config/preferences.h b/src/config/preferences.h
index a68dc16b..8a900d57 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -35,6 +35,26 @@
 #define PREFS_MIN_LOG_SIZE 64
 #define PREFS_MAX_LOG_SIZE 1048580
 
+typedef enum {
+    PREF_SPLASH,
+    PREF_BEEP,
+    PREF_VERCHECK,
+    PREF_THEME,
+    PREF_TITLEBARVERSION,
+    PREF_FLASH,
+    PREF_INTYPE,
+    PREF_HISTORY,
+    PREF_MOUSE,
+    PREF_STATUSES,
+    PREF_STATES,
+    PREF_OUTTYPE,
+    PREF_NOTIFY_TYPING,
+    PREF_NOTIFY_MESSAGE,
+    PREF_CHLOG,
+    PREF_AUTOAWAY_CHECK
+} preference_t;
+
+
 void prefs_load(void);
 void prefs_close(void);
 
@@ -43,39 +63,25 @@ void prefs_reset_login_search(void);
 char * prefs_autocomplete_boolean_choice(char *prefix);
 void prefs_reset_boolean_choice(void);
 
-gboolean prefs_get_beep(void);
 void prefs_set_beep(gboolean value);
-gboolean prefs_get_flash(void);
 void prefs_set_flash(gboolean value);
-gboolean prefs_get_chlog(void);
 void prefs_set_chlog(gboolean value);
-gboolean prefs_get_history(void);
 void prefs_set_history(gboolean value);
-gboolean prefs_get_splash(void);
 void prefs_set_splash(gboolean value);
-gboolean prefs_get_vercheck(void);
 void prefs_set_vercheck(gboolean value);
-gboolean prefs_get_titlebarversion(void);
 void prefs_set_titlebarversion(gboolean value);
-gboolean prefs_get_intype(void);
 void prefs_set_intype(gboolean value);
-gboolean prefs_get_states(void);
 void prefs_set_states(gboolean value);
-gboolean prefs_get_outtype(void);
 void prefs_set_outtype(gboolean value);
 gint prefs_get_gone(void);
 void prefs_set_gone(gint value);
 gchar * prefs_get_theme(void);
 void prefs_set_theme(gchar *value);
-gboolean prefs_get_mouse(void);
 void prefs_set_mouse(gboolean value);
 void prefs_set_statuses(gboolean value);
-gboolean prefs_get_statuses(void);
 
 void prefs_set_notify_message(gboolean value);
-gboolean prefs_get_notify_message(void);
 void prefs_set_notify_typing(gboolean value);
-gboolean prefs_get_notify_typing(void);
 void prefs_set_notify_remind(gint period);
 gint prefs_get_notify_remind(void);
 void prefs_set_max_log_size(gint value);
@@ -93,9 +99,10 @@ gint prefs_get_autoaway_time(void);
 void prefs_set_autoaway_time(gint value);
 gchar* prefs_get_autoaway_message(void);
 void prefs_set_autoaway_message(gchar *value);
-gboolean prefs_get_autoaway_check(void);
 void prefs_set_autoaway_check(gboolean value);
 
 void prefs_add_login(const char *jid);
 
+gboolean prefs_get_boolean(preference_t pref);
+
 #endif
diff --git a/src/profanity.c b/src/profanity.c
index 83a955a6..8ea24825 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -111,7 +111,7 @@ prof_handle_incoming_message(char *from, char *message, gboolean priv)
     ui_show_incoming_msg(from, message, NULL, priv);
     win_current_page_off();
 
-    if (prefs_get_chlog() && !priv) {
+    if (prefs_get_boolean(PREF_CHLOG) && !priv) {
         Jid *from_jid = jid_create(from);
         const char *jid = jabber_get_jid();
         Jid *jidp = jid_create(jid);
@@ -128,7 +128,7 @@ prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
     ui_show_incoming_msg(from, message, &tv_stamp, priv);
     win_current_page_off();
 
-    if (prefs_get_chlog() && !priv) {
+    if (prefs_get_boolean(PREF_CHLOG) && !priv) {
         Jid *from_jid = jid_create(from);
         const char *jid = jabber_get_jid();
         Jid *jidp = jid_create(jid);
@@ -470,7 +470,7 @@ _handle_idle_time()
             idle = FALSE;
 
             // handle check
-            if (prefs_get_autoaway_check()) {
+            if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
                 if (strcmp(prefs_get_autoaway_mode(), "away") == 0) {
                     presence_update(PRESENCE_ONLINE, NULL, 0);
                     cons_show("No longer idle, status set to online.");
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 427d229c..9fd7196c 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -121,11 +121,11 @@ inp_get_char(char *input, int *size)
         in_command = TRUE;
     }
 
-    if (prefs_get_states()) {
+    if (prefs_get_boolean(PREF_STATES)) {
         if (result == ERR) {
             prof_handle_idle();
         }
-        if (prefs_get_outtype() && (result != ERR) && !in_command
+        if (prefs_get_boolean(PREF_OUTTYPE) && (result != ERR) && !in_command
                                                 && _printable(ch)) {
             prof_handle_activity();
         }
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 84628a1e..e71d89a2 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -122,7 +122,7 @@ ui_init(void)
     initscr();
     raw();
     keypad(stdscr, TRUE);
-    if (prefs_get_mouse()) {
+    if (prefs_get_boolean(PREF_MOUSE)) {
         mousemask(ALL_MOUSE_EVENTS, NULL);
         mouseinterval(5);
     }
@@ -163,7 +163,7 @@ _ui_draw_win_title(void)
 
     GString *version_str = g_string_new("");
 
-    if (prefs_get_titlebarversion()) {
+    if (prefs_get_boolean(PREF_TITLEBARVERSION)) {
         g_string_append(version_str, " ");
         g_string_append(version_str, PACKAGE_VERSION);
         if (strcmp(PACKAGE_STATUS, "development") == 0) {
@@ -273,7 +273,7 @@ ui_show_typing(const char * const from)
 {
     int win_index = _find_prof_win_index(from);
 
-    if (prefs_get_intype()) {
+    if (prefs_get_boolean(PREF_INTYPE)) {
         // no chat window for user
         if (win_index == NUM_WINS) {
             _cons_show_typing(from);
@@ -293,7 +293,7 @@ ui_show_typing(const char * const from)
        }
     }
 
-    if (prefs_get_notify_typing())
+    if (prefs_get_boolean(PREF_NOTIFY_TYPING))
         _notify_typing(from);
 }
 
@@ -314,7 +314,7 @@ ui_idle(void)
             } else if (chat_session_is_inactive(recipient) &&
                     !chat_session_get_sent(recipient)) {
                 message_send_inactive(recipient);
-            } else if (prefs_get_outtype() &&
+            } else if (prefs_get_boolean(PREF_OUTTYPE) &&
                     chat_session_is_paused(recipient) &&
                     !chat_session_get_sent(recipient)) {
                 message_send_paused(recipient);
@@ -411,11 +411,11 @@ ui_show_incoming_msg(const char * const from, const char * const message,
         } else {
             status_bar_new(win_index);
             _cons_show_incoming_message(from, win_index);
-            if (prefs_get_flash())
+            if (prefs_get_boolean(PREF_FLASH))
                 flash();
 
             windows[win_index]->unread++;
-            if (prefs_get_chlog() && prefs_get_history()) {
+            if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
                 _win_show_history(win, win_index, from);
             }
 
@@ -444,9 +444,9 @@ ui_show_incoming_msg(const char * const from, const char * const message,
         }
     }
 
-    if (prefs_get_beep())
+    if (prefs_get_boolean(PREF_BEEP))
         beep();
-    if (prefs_get_notify_message())
+    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
         _notify_message(display_from);
 
     g_free(display_from);
@@ -735,7 +735,7 @@ win_new_chat_win(const char * const to)
 
         win = windows[win_index]->win;
 
-        if (prefs_get_chlog() && prefs_get_history()) {
+        if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
             _win_show_history(win, win_index, to);
         }
 
@@ -778,7 +778,7 @@ win_show_outgoing_msg(const char * const from, const char * const to,
 
         win = windows[win_index]->win;
 
-        if (prefs_get_chlog() && prefs_get_history()) {
+        if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
             _win_show_history(win, win_index, to);
         }
 
@@ -1020,7 +1020,7 @@ win_show_room_message(const char * const room_jid, const char * const nick,
         }
 
         if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) {
-            if (prefs_get_flash()) {
+            if (prefs_get_boolean(PREF_FLASH)) {
                 flash();
             }
         }
@@ -1029,10 +1029,10 @@ win_show_room_message(const char * const room_jid, const char * const nick,
     }
 
     if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) {
-        if (prefs_get_beep()) {
+        if (prefs_get_boolean(PREF_BEEP)) {
             beep();
         }
-        if (prefs_get_notify_message()) {
+        if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
             _notify_message(nick);
         }
     }
@@ -1298,42 +1298,42 @@ cons_show_ui_prefs(void)
         cons_show("Theme (/theme)               : %s", theme);
     }
 
-    if (prefs_get_beep())
+    if (prefs_get_boolean(PREF_BEEP))
         cons_show("Terminal beep (/beep)        : ON");
     else
         cons_show("Terminal beep (/beep)        : OFF");
 
-    if (prefs_get_flash())
+    if (prefs_get_boolean(PREF_FLASH))
         cons_show("Terminal flash (/flash)      : ON");
     else
         cons_show("Terminal flash (/flash)      : OFF");
 
-    if (prefs_get_intype())
+    if (prefs_get_boolean(PREF_INTYPE))
         cons_show("Show typing (/intype)        : ON");
     else
         cons_show("Show typing (/intype)        : OFF");
 
-    if (prefs_get_splash())
+    if (prefs_get_boolean(PREF_SPLASH))
         cons_show("Splash screen (/splash)      : ON");
     else
         cons_show("Splash screen (/splash)      : OFF");
 
-    if (prefs_get_history())
+    if (prefs_get_boolean(PREF_HISTORY))
         cons_show("Chat history (/history)      : ON");
     else
         cons_show("Chat history (/history)      : OFF");
 
-    if (prefs_get_vercheck())
+    if (prefs_get_boolean(PREF_VERCHECK))
         cons_show("Version checking (/vercheck) : ON");
     else
         cons_show("Version checking (/vercheck) : OFF");
 
-    if (prefs_get_mouse())
+    if (prefs_get_boolean(PREF_MOUSE))
         cons_show("Mouse handling (/mouse)      : ON");
     else
         cons_show("Mouse handling (/mouse)      : OFF");
 
-    if (prefs_get_statuses())
+    if (prefs_get_boolean(PREF_STATUSES))
         cons_show("Status (/statuses)           : ON");
     else
         cons_show("Status (/statuses)           : OFF");
@@ -1345,12 +1345,12 @@ cons_show_desktop_prefs(void)
     cons_show("Desktop notification preferences:");
     cons_show("");
 
-    if (prefs_get_notify_message())
+    if (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
         cons_show("Messages (/notify message)       : ON");
     else
         cons_show("Messages (/notify message)       : OFF");
 
-    if (prefs_get_notify_typing())
+    if (prefs_get_boolean(PREF_NOTIFY_TYPING))
         cons_show("Composing (/notify typing)       : ON");
     else
         cons_show("Composing (/notify typing)       : OFF");
@@ -1371,12 +1371,12 @@ cons_show_chat_prefs(void)
     cons_show("Chat preferences:");
     cons_show("");
 
-    if (prefs_get_states())
+    if (prefs_get_boolean(PREF_STATES))
         cons_show("Send chat states (/states) : ON");
     else
         cons_show("Send chat states (/states) : OFF");
 
-    if (prefs_get_outtype())
+    if (prefs_get_boolean(PREF_OUTTYPE))
         cons_show("Send composing (/outtype)  : ON");
     else
         cons_show("Send composing (/outtype)  : OFF");
@@ -1399,7 +1399,7 @@ cons_show_log_prefs(void)
 
     cons_show("Max log size (/log maxsize) : %d bytes", prefs_get_max_log_size());
 
-    if (prefs_get_chlog())
+    if (prefs_get_boolean(PREF_CHLOG))
         cons_show("Chat logging (/chlog)       : ON");
     else
         cons_show("Chat logging (/chlog)       : OFF");
@@ -1426,7 +1426,7 @@ cons_show_presence_prefs(void)
         cons_show("Autoaway message (/autoaway message) : \"%s\"", prefs_get_autoaway_message());
     }
 
-    if (prefs_get_autoaway_check()) {
+    if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
         cons_show("Autoaway check (/autoaway check)     : ON");
     } else {
         cons_show("Autoaway check (/autoaway check)     : OFF");
@@ -1734,7 +1734,7 @@ cons_about(void)
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
 
-    if (prefs_get_splash()) {
+    if (prefs_get_boolean(PREF_SPLASH)) {
         _cons_splash_logo();
     } else {
         _win_show_time(console->win, '-');
@@ -1763,7 +1763,7 @@ cons_about(void)
     _win_show_time(console->win, '-');
     wprintw(console->win, "\n");
 
-    if (prefs_get_vercheck()) {
+    if (prefs_get_boolean(PREF_VERCHECK)) {
         cons_check_version(FALSE);
     }
 
@@ -2134,7 +2134,7 @@ _show_status_string(WINDOW *win, const char * const from,
     GDateTime *last_activity, const char * const pre,
     const char * const default_show)
 {
-    if (!prefs_get_statuses())
+    if (!prefs_get_boolean(PREF_STATUSES))
         return;
 
     _win_show_time(win, '-');
@@ -2312,7 +2312,7 @@ _win_handle_page(const wint_t * const ch)
     int page_space = rows - 4;
     int *page_start = &(current->y_pos);
 
-    if (prefs_get_mouse()) {
+    if (prefs_get_boolean(PREF_MOUSE)) {
         MEVENT mouse_event;
 
         if (*ch == KEY_MOUSE) {
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index b20d773b..62e05c2a 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -54,14 +54,14 @@ message_send(const char * const msg, const char * const recipient)
 {
     xmpp_conn_t * const conn = jabber_get_conn();
     xmpp_ctx_t * const ctx = jabber_get_ctx();
-    if (prefs_get_states()) {
+    if (prefs_get_boolean(PREF_STATES)) {
         if (!chat_session_exists(recipient)) {
             chat_session_start(recipient, TRUE);
         }
     }
 
     xmpp_stanza_t *message;
-    if (prefs_get_states() && chat_session_get_recipient_supports(recipient)) {
+    if (prefs_get_boolean(PREF_STATES) && chat_session_get_recipient_supports(recipient)) {
         chat_session_set_active(recipient);
         message = stanza_create_message(ctx, recipient, STANZA_TYPE_CHAT,
             msg, STANZA_NAME_ACTIVE);
@@ -273,7 +273,7 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
         // deal with chat states if recipient supports them
         if (recipient_supports && (!delayed)) {
             if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) {
-                if (prefs_get_notify_typing() || prefs_get_intype()) {
+                if (prefs_get_boolean(PREF_NOTIFY_TYPING) || prefs_get_boolean(PREF_INTYPE)) {
                     prof_handle_typing(jid->barejid);
                 }
             } else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {