about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/command/command.c67
-rw-r--r--src/common.c66
-rw-r--r--src/common.h30
-rw-r--r--src/config/accounts.c47
-rw-r--r--src/config/accounts.h6
-rw-r--r--src/profanity.c27
-rw-r--r--src/resource.h8
-rw-r--r--src/ui/titlebar.c38
-rw-r--r--src/ui/ui.h2
-rw-r--r--src/ui/windows.c24
-rw-r--r--src/xmpp/connection.h1
-rw-r--r--src/xmpp/iq.c4
-rw-r--r--src/xmpp/presence.c6
-rw-r--r--src/xmpp/stanza.c12
-rw-r--r--src/xmpp/stanza.h2
-rw-r--r--src/xmpp/xmpp.h2
17 files changed, 162 insertions, 182 deletions
diff --git a/configure.ac b/configure.ac
index a2a0ee91..f6c9ba3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,7 +87,7 @@ if test "x$enable_notifications" != xno; then
 fi
 
 # Default parameters
-AM_CFLAGS="-Wall"
+AM_CFLAGS="-Wall -Werror"
 LIBS="$LIBS $DEPS_LIBS $NOTIFY_LIBS"
 
 AM_CPPFLAGS="$DEPS_CFLAGS $NOTIFY_CFLAGS"
diff --git a/src/command/command.c b/src/command/command.c
index 3c8ea33c..ae3d51d6 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -68,7 +68,7 @@ struct cmd_t {
 };
 
 static struct cmd_t * _cmd_get_command(const char * const command);
-static void _update_presence(const presence_t presence,
+static void _update_presence(const resource_presence_t presence,
     const char * const show, gchar **args);
 static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
     const char * const display, preference_t pref);
@@ -85,7 +85,6 @@ static void _parameter_autocomplete_with_ac(char *input, int *size, char *comman
     Autocomplete ac);
 
 static int _strtoi(char *str, int *saveptr, int min, int max);
-static presence_t _presence_type_from_string(const char * const str);
 
 // command prototypes
 static gboolean _cmd_quit(gchar **args, struct cmd_help_t help);
@@ -1164,41 +1163,38 @@ _cmd_account(gchar **args, struct cmd_help_t help)
                     cons_show("Updated resource for account %s: %s", account_name, value);
                     cons_show("");
                 } else if (strcmp(property, "status") == 0) {
-                    if (!presence_valid_string(value) && (strcmp(value, "last") != 0)) {
+                    if (!valid_resource_presence_string(value) && (strcmp(value, "last") != 0)) {
                         cons_show("Invalud status: %s", value);
                     } else {
                         accounts_set_login_presence(account_name, value);
                         cons_show("Updated login status for account %s: %s", account_name, value);
                     }
                     cons_show("");
-                } else if (presence_valid_string(property)) {
+                } else if (valid_resource_presence_string(property)) {
                         int intval;
 
                         if (_strtoi(value, &intval, -128, 127) == 0) {
-                            presence_t presence_type = _presence_type_from_string(property);
+                            resource_presence_t presence_type = resource_presence_from_string(property);
                             switch (presence_type)
                             {
-                                case (PRESENCE_ONLINE):
+                                case (RESOURCE_ONLINE):
                                     accounts_set_priority_online(account_name, intval);
                                     break;
-                                case (PRESENCE_CHAT):
+                                case (RESOURCE_CHAT):
                                     accounts_set_priority_chat(account_name, intval);
                                     break;
-                                case (PRESENCE_AWAY):
+                                case (RESOURCE_AWAY):
                                     accounts_set_priority_away(account_name, intval);
                                     break;
-                                case (PRESENCE_XA):
+                                case (RESOURCE_XA):
                                     accounts_set_priority_xa(account_name, intval);
                                     break;
-                                case (PRESENCE_DND):
+                                case (RESOURCE_DND):
                                     accounts_set_priority_dnd(account_name, intval);
                                     break;
-                                default:
-                                    accounts_set_priority_online(account_name, intval);
-                                    break;
                             }
                             jabber_conn_status_t conn_status = jabber_get_connection_status();
-                            presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
+                            resource_presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
                             if (conn_status == JABBER_CONNECTED && presence_type == last_presence) {
                                 presence_update(last_presence, jabber_get_presence_message(), 0);
                             }
@@ -2239,7 +2235,7 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help)
 
     if (_strtoi(value, &intval, -128, 127) == 0) {
         accounts_set_priority_all(jabber_get_account_name(), intval);
-        presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
+        resource_presence_t last_presence = accounts_get_last_presence(jabber_get_account_name());
         presence_update(last_presence, jabber_get_presence_message(), 0);
         cons_show("Priority set to %d.", intval);
     }
@@ -2313,42 +2309,42 @@ _cmd_set_history(gchar **args, struct cmd_help_t help)
 static gboolean
 _cmd_away(gchar **args, struct cmd_help_t help)
 {
-    _update_presence(PRESENCE_AWAY, "away", args);
+    _update_presence(RESOURCE_AWAY, "away", args);
     return TRUE;
 }
 
 static gboolean
 _cmd_online(gchar **args, struct cmd_help_t help)
 {
-    _update_presence(PRESENCE_ONLINE, "online", args);
+    _update_presence(RESOURCE_ONLINE, "online", args);
     return TRUE;
 }
 
 static gboolean
 _cmd_dnd(gchar **args, struct cmd_help_t help)
 {
-    _update_presence(PRESENCE_DND, "dnd", args);
+    _update_presence(RESOURCE_DND, "dnd", args);
     return TRUE;
 }
 
 static gboolean
 _cmd_chat(gchar **args, struct cmd_help_t help)
 {
-    _update_presence(PRESENCE_CHAT, "chat", args);
+    _update_presence(RESOURCE_CHAT, "chat", args);
     return TRUE;
 }
 
 static gboolean
 _cmd_xa(gchar **args, struct cmd_help_t help)
 {
-    _update_presence(PRESENCE_XA, "xa", args);
+    _update_presence(RESOURCE_XA, "xa", args);
     return TRUE;
 }
 
 // helper function for status change commands
 
 static void
-_update_presence(const presence_t presence,
+_update_presence(const resource_presence_t resource_presence,
     const char * const show, gchar **args)
 {
     char *msg = NULL;
@@ -2362,9 +2358,12 @@ _update_presence(const presence_t presence,
     if (conn_status != JABBER_CONNECTED) {
         cons_show("You are not currently connected.");
     } else {
-        presence_update(presence, msg, 0);
-        title_bar_set_status(presence);
-        gint priority = accounts_get_priority_for_presence_type(jabber_get_account_name(), presence);
+        presence_update(resource_presence, msg, 0);
+
+        contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
+        title_bar_set_status(contact_presence);
+
+        gint priority = accounts_get_priority_for_presence_type(jabber_get_account_name(), resource_presence);
         if (msg != NULL) {
             cons_show("Status set to %s (priority %d), \"%s\".", show, priority, msg);
         } else {
@@ -2647,23 +2646,3 @@ _strtoi(char *str, int *saveptr, int min, int max)
 
     return 0;
 }
-
-static presence_t
-_presence_type_from_string(const char * const str)
-{
-    if (str == NULL) {
-        return PRESENCE_ONLINE;
-    } else if (!presence_valid_string(str)) {
-        return PRESENCE_ONLINE;
-    } else if (strcmp(str, "online") == 0) {
-        return PRESENCE_ONLINE;
-    } else if (strcmp(str, "chat") == 0) {
-        return PRESENCE_CHAT;
-    } else if (strcmp(str, "away") == 0) {
-        return PRESENCE_AWAY;
-    } else if (strcmp(str, "xa") == 0) {
-        return PRESENCE_XA;
-    } else {
-        return PRESENCE_DND;
-    }
-}
diff --git a/src/common.c b/src/common.c
index f2b0f550..641151db 100644
--- a/src/common.c
+++ b/src/common.c
@@ -261,7 +261,7 @@ release_get_latest()
 }
 
 gboolean
-presence_valid_string(const char * const str)
+valid_resource_presence_string(const char * const str)
 {
     assert(str != NULL);
     if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) ||
@@ -274,46 +274,58 @@ presence_valid_string(const char * const str)
 }
 
 const char *
-presence_display_string_from_type(presence_t presence)
+string_from_resource_presence(resource_presence_t presence)
 {
-    switch (presence)
+    switch(presence)
     {
-        case PRESENCE_ONLINE:
-            return "online";
-        case PRESENCE_CHAT:
+        case RESOURCE_CHAT:
             return "chat";
-        case PRESENCE_AWAY:
+        case RESOURCE_AWAY:
             return "away";
-        case PRESENCE_XA:
+        case RESOURCE_XA:
             return "xa";
-        case PRESENCE_DND:
+        case RESOURCE_DND:
             return "dnd";
-        case PRESENCE_OFFLINE:
-            return "offline";
         default:
-            return NULL;
+            return "online";
     }
 }
 
-const char *
-presence_stanza_show_from_type(presence_t presence)
+resource_presence_t
+resource_presence_from_string(const char * const str)
 {
-    assert(presence != PRESENCE_OFFLINE);
+    if (str == NULL) {
+        return RESOURCE_ONLINE;
+    } else if (strcmp(str, "online") == 0) {
+        return RESOURCE_ONLINE;
+    } else if (strcmp(str, "chat") == 0) {
+        return RESOURCE_CHAT;
+    } else if (strcmp(str, "away") == 0) {
+        return RESOURCE_AWAY;
+    } else if (strcmp(str, "xa") == 0) {
+        return RESOURCE_XA;
+    } else if (strcmp(str, "dnd") == 0) {
+        return RESOURCE_DND;
+    } else {
+        return RESOURCE_ONLINE;
+    }
+}
 
-    switch (presence)
+contact_presence_t
+contact_presence_from_resource_presence(resource_presence_t resource_presence)
+{
+    switch(resource_presence)
     {
-        case PRESENCE_ONLINE:
-            return NULL;
-        case PRESENCE_CHAT:
-            return "chat";
-        case PRESENCE_AWAY:
-            return "away";
-        case PRESENCE_XA:
-            return "xa";
-        case PRESENCE_DND:
-            return "dnd";
+        case RESOURCE_CHAT:
+            return CONTACT_CHAT;
+        case RESOURCE_AWAY:
+            return CONTACT_AWAY;
+        case RESOURCE_XA:
+            return CONTACT_XA;
+        case RESOURCE_DND:
+            return CONTACT_DND;
         default:
-            return NULL;
+            return CONTACT_ONLINE;
     }
 }
 
diff --git a/src/common.h b/src/common.h
index b2c8590a..59307b35 100644
--- a/src/common.h
+++ b/src/common.h
@@ -56,13 +56,21 @@
 }
 
 typedef enum {
-    PRESENCE_OFFLINE,
-    PRESENCE_ONLINE,
-    PRESENCE_AWAY,
-    PRESENCE_DND,
-    PRESENCE_CHAT,
-    PRESENCE_XA
-} presence_t;
+    CONTACT_OFFLINE,
+    CONTACT_ONLINE,
+    CONTACT_AWAY,
+    CONTACT_DND,
+    CONTACT_CHAT,
+    CONTACT_XA
+} contact_presence_t;
+
+typedef enum {
+    RESOURCE_ONLINE,
+    RESOURCE_AWAY,
+    RESOURCE_DND,
+    RESOURCE_CHAT,
+    RESOURCE_XA
+} resource_presence_t;
 
 gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos);
 void p_slist_free_full(GSList *items, GDestroyNotify free_func);
@@ -75,10 +83,12 @@ char* encode_xml(const char * const xml);
 char * prof_getline(FILE *stream);
 int octet_compare(unsigned char *str1, unsigned char *str2);
 char* release_get_latest(void);
-gboolean presence_valid_string(const char * const str);
-const char * presence_display_string_from_type(presence_t presence);
-const char * presence_stanza_show_from_type(presence_t presence);
 gchar * xdg_get_config_home(void);
 gchar * xdg_get_data_home(void);
 
+gboolean valid_resource_presence_string(const char * const str);
+const char * string_from_resource_presence(resource_presence_t presence);
+resource_presence_t resource_presence_from_string(const char * const str);
+contact_presence_t contact_presence_from_resource_presence(resource_presence_t resource_presence);
+
 #endif
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 6f3b07a0..b53f4fb0 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -189,7 +189,7 @@ accounts_get_account(const char * const name)
         }
 
         gchar *presence = g_key_file_get_string(accounts, name, "presence.last", NULL);
-        if (presence == NULL || (!presence_valid_string(presence))) {
+        if (presence == NULL || (!valid_resource_presence_string(presence))) {
             account->last_presence = strdup("online");
         } else {
             account->last_presence = strdup(presence);
@@ -200,7 +200,7 @@ accounts_get_account(const char * const name)
             account->login_presence = strdup("online");
         } else if (strcmp(presence, "last") == 0) {
             account->login_presence = strdup("last");
-        } else if (!presence_valid_string(presence)) {
+        } else if (!valid_resource_presence_string(presence)) {
             account->login_presence = strdup("online");
         } else {
             account->login_presence = strdup(presence);
@@ -403,29 +403,26 @@ accounts_set_priority_all(const char * const account_name, const gint value)
 
 gint
 accounts_get_priority_for_presence_type(const char * const account_name,
-    presence_t presence_type)
+    resource_presence_t presence_type)
 {
     gint result;
 
     switch (presence_type)
     {
-        case (PRESENCE_ONLINE):
+        case (RESOURCE_ONLINE):
             result = g_key_file_get_integer(accounts, account_name, "priority.online", NULL);
             break;
-        case (PRESENCE_CHAT):
+        case (RESOURCE_CHAT):
             result = g_key_file_get_integer(accounts, account_name, "priority.chat", NULL);
             break;
-        case (PRESENCE_AWAY):
+        case (RESOURCE_AWAY):
             result = g_key_file_get_integer(accounts, account_name, "priority.away", NULL);
             break;
-        case (PRESENCE_XA):
+        case (RESOURCE_XA):
             result = g_key_file_get_integer(accounts, account_name, "priority.xa", NULL);
             break;
-        case (PRESENCE_DND):
-            result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL);
-            break;
         default:
-            result = 0;
+            result = g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL);
             break;
     }
 
@@ -453,47 +450,47 @@ accounts_set_login_presence(const char * const account_name, const char * const
     }
 }
 
-presence_t
+resource_presence_t
 accounts_get_last_presence(const char * const account_name)
 {
     gchar *setting = g_key_file_get_string(accounts, account_name, "presence.last", NULL);
     if (setting == NULL || (strcmp(setting, "online") == 0)) {
-        return PRESENCE_ONLINE;
+        return RESOURCE_ONLINE;
     } else if (strcmp(setting, "chat") == 0) {
-        return PRESENCE_CHAT;
+        return RESOURCE_CHAT;
     } else if (strcmp(setting, "away") == 0) {
-        return PRESENCE_AWAY;
+        return RESOURCE_AWAY;
     } else if (strcmp(setting, "xa") == 0) {
-        return PRESENCE_XA;
+        return RESOURCE_XA;
     } else if (strcmp(setting, "dnd") == 0) {
-        return PRESENCE_DND;
+        return RESOURCE_DND;
     } else {
         log_warning("Error reading presence.last for account: '%s', value: '%s', defaulting to 'online'",
             account_name, setting);
-        return PRESENCE_ONLINE;
+        return RESOURCE_ONLINE;
     }
 }
 
-presence_t
+resource_presence_t
 accounts_get_login_presence(const char * const account_name)
 {
     gchar *setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
     if (setting == NULL || (strcmp(setting, "online") == 0)) {
-        return PRESENCE_ONLINE;
+        return RESOURCE_ONLINE;
     } else if (strcmp(setting, "chat") == 0) {
-        return PRESENCE_CHAT;
+        return RESOURCE_CHAT;
     } else if (strcmp(setting, "away") == 0) {
-        return PRESENCE_AWAY;
+        return RESOURCE_AWAY;
     } else if (strcmp(setting, "xa") == 0) {
-        return PRESENCE_XA;
+        return RESOURCE_XA;
     } else if (strcmp(setting, "dnd") == 0) {
-        return PRESENCE_DND;
+        return RESOURCE_DND;
     } else if (strcmp(setting, "last") == 0) {
         return accounts_get_last_presence(account_name);
     } else {
         log_warning("Error reading presence.login for account: '%s', value: '%s', defaulting to 'online'",
             account_name, setting);
-        return PRESENCE_ONLINE;
+        return RESOURCE_ONLINE;
     }
 }
 
diff --git a/src/config/accounts.h b/src/config/accounts.h
index f1b70aad..d1509d6f 100644
--- a/src/config/accounts.h
+++ b/src/config/accounts.h
@@ -61,8 +61,8 @@ void accounts_set_server(const char * const account_name, const char * const val
 void accounts_set_resource(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_login_presence(const char * const account_name, const char * const value);
-presence_t accounts_get_login_presence(const char * const account_name);
-presence_t accounts_get_last_presence(const char * const account_name);
+resource_presence_t accounts_get_login_presence(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);
 void accounts_set_priority_away(const char * const account_name, const gint value);
@@ -70,6 +70,6 @@ void accounts_set_priority_xa(const char * const account_name, const gint value)
 void accounts_set_priority_dnd(const char * const account_name, const gint value);
 void accounts_set_priority_all(const char * const account_name, const gint value);
 gint accounts_get_priority_for_presence_type(const char * const account_name,
-    presence_t presence_type);
+    resource_presence_t presence_type);
 
 #endif
diff --git a/src/profanity.c b/src/profanity.c
index 0de647b0..0ba0fb15 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -189,9 +189,10 @@ void
 prof_handle_login_account_success(char *account_name)
 {
     ProfAccount *account = accounts_get_account(account_name);
-    presence_t presence = accounts_get_login_presence(account->name);
+    resource_presence_t resource_presence = accounts_get_login_presence(account->name);
+    contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence);
     cons_show_login_success(account);
-    title_bar_set_status(presence);
+    title_bar_set_status(contact_presence);
     log_info("%s logged in successfully", account->jid);
     win_current_page_off();
     status_bar_print_message(account->jid);
@@ -439,28 +440,28 @@ _handle_idle_time()
 
             // handle away mode
             if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
-                presence_update(PRESENCE_AWAY, prefs_get_string(PREF_AUTOAWAY_MESSAGE), 0);
+                presence_update(CONTACT_AWAY, prefs_get_string(PREF_AUTOAWAY_MESSAGE), 0);
                 if (prefs_get_string(PREF_AUTOAWAY_MESSAGE) != NULL) {
                     int pri =
                         accounts_get_priority_for_presence_type(jabber_get_account_name(),
-                            PRESENCE_AWAY);
+                            CONTACT_AWAY);
                     cons_show("Idle for %d minutes, status set to away (priority %d), \"%s\".",
                         prefs_get_autoaway_time(), pri, prefs_get_string(PREF_AUTOAWAY_MESSAGE));
-                    title_bar_set_status(PRESENCE_AWAY);
+                    title_bar_set_status(RESOURCE_AWAY);
                     win_current_page_off();
                 } else {
                     int pri =
                         accounts_get_priority_for_presence_type(jabber_get_account_name(),
-                            PRESENCE_AWAY);
+                            CONTACT_AWAY);
                     cons_show("Idle for %d minutes, status set to away (priority %d).",
                         prefs_get_autoaway_time(), pri);
-                    title_bar_set_status(PRESENCE_AWAY);
+                    title_bar_set_status(RESOURCE_AWAY);
                     win_current_page_off();
                 }
 
             // handle idle mode
             } else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
-                presence_update(PRESENCE_ONLINE,
+                presence_update(CONTACT_ONLINE,
                     prefs_get_string(PREF_AUTOAWAY_MESSAGE), idle_ms / 1000);
             }
         }
@@ -472,16 +473,16 @@ _handle_idle_time()
             // handle check
             if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
                 if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "away") == 0) {
-                    presence_update(PRESENCE_ONLINE, NULL, 0);
+                    presence_update(CONTACT_ONLINE, NULL, 0);
                     int pri =
                         accounts_get_priority_for_presence_type(jabber_get_account_name(),
-                            PRESENCE_ONLINE);
+                            CONTACT_ONLINE);
                     cons_show("No longer idle, status set to online (priority %d).", pri);
-                    title_bar_set_status(PRESENCE_ONLINE);
+                    title_bar_set_status(RESOURCE_ONLINE);
                     win_current_page_off();
                 } else if (strcmp(prefs_get_string(PREF_AUTOAWAY_MODE), "idle") == 0) {
-                    presence_update(PRESENCE_ONLINE, NULL, 0);
-                    title_bar_set_status(PRESENCE_ONLINE);
+                    presence_update(CONTACT_ONLINE, NULL, 0);
+                    title_bar_set_status(RESOURCE_ONLINE);
                 }
             }
         }
diff --git a/src/resource.h b/src/resource.h
index 6a5a8f3e..491b33cc 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -23,14 +23,6 @@
 #ifndef RESOURCE_H
 #define RESOURCE_H
 
-typedef enum {
-    RESOURCE_ONLINE,
-    RESOURCE_CHAT,
-    RESOURCE_AWAY,
-    RESOURCE_XA,
-    RESOURCE_DND
-} resource_presence_t;
-
 typedef struct resource_t {
     char *name;
     char *show;
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index edeb79fd..5c8cee83 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -32,7 +32,7 @@ static char *current_title = NULL;
 static char *recipient = NULL;
 static GTimer *typing_elapsed;
 static int dirty;
-static presence_t current_status;
+static contact_presence_t current_status;
 
 static void _title_bar_draw_title(void);
 static void _title_bar_draw_status(void);
@@ -45,7 +45,7 @@ create_title_bar(void)
     title_bar = newwin(1, cols, 0, 0);
     wbkgd(title_bar, COLOUR_TITLE_TEXT);
     title_bar_title();
-    title_bar_set_status(PRESENCE_OFFLINE);
+    title_bar_set_status(CONTACT_OFFLINE);
     dirty = TRUE;
 }
 
@@ -119,7 +119,7 @@ title_bar_show(const char * const title)
 }
 
 void
-title_bar_set_status(presence_t status)
+title_bar_set_status(contact_presence_t status)
 {
     current_status = status;
     _title_bar_draw_status();
@@ -187,18 +187,26 @@ _title_bar_draw_status(void)
     mvwaddch(title_bar, 0, cols - 14, '[');
     wattroff(title_bar, COLOUR_TITLE_BRACKET);
 
-    if (current_status == PRESENCE_ONLINE) {
-        mvwprintw(title_bar, 0, cols - 13, " ...online ");
-    } else if (current_status == PRESENCE_AWAY) {
-        mvwprintw(title_bar, 0, cols - 13, " .....away ");
-    } else if (current_status == PRESENCE_DND) {
-        mvwprintw(title_bar, 0, cols - 13, " ......dnd ");
-    } else if (current_status == PRESENCE_CHAT) {
-        mvwprintw(title_bar, 0, cols - 13, " .....chat ");
-    } else if (current_status == PRESENCE_XA) {
-        mvwprintw(title_bar, 0, cols - 13, " .......xa ");
-    } else {
-        mvwprintw(title_bar, 0, cols - 13, " ..offline ");
+    switch (current_status)
+    {
+        case CONTACT_ONLINE:
+            mvwprintw(title_bar, 0, cols - 13, " ...online ");
+            break;
+        case CONTACT_AWAY:
+            mvwprintw(title_bar, 0, cols - 13, " .....away ");
+            break;
+        case CONTACT_DND:
+            mvwprintw(title_bar, 0, cols - 13, " ......dnd ");
+            break;
+        case CONTACT_CHAT:
+            mvwprintw(title_bar, 0, cols - 13, " .....chat ");
+            break;
+        case CONTACT_XA:
+            mvwprintw(title_bar, 0, cols - 13, " .......xa ");
+            break;
+        case CONTACT_OFFLINE:
+            mvwprintw(title_bar, 0, cols - 13, " ..offline ");
+            break;
     }
 
     wattron(title_bar, COLOUR_TITLE_BRACKET);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index d317ce41..6686acb7 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -92,7 +92,7 @@ void title_bar_refresh(void);
 void title_bar_resize(void);
 void title_bar_show(const char * const title);
 void title_bar_title(void);
-void title_bar_set_status(presence_t status);
+void title_bar_set_status(contact_presence_t status);
 void title_bar_set_recipient(char *from);
 void title_bar_set_typing(gboolean is_typing);
 void title_bar_draw(void);
diff --git a/src/ui/windows.c b/src/ui/windows.c
index a7fc6a24..d764755b 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -506,7 +506,7 @@ ui_disconnected(void)
         }
     }
 
-    title_bar_set_status(PRESENCE_OFFLINE);
+    title_bar_set_status(CONTACT_OFFLINE);
     status_bar_clear_message();
     status_bar_refresh();
 }
@@ -1094,26 +1094,8 @@ cons_show_login_success(ProfAccount *account)
     _win_show_time(console->win, '-');
     wprintw(console->win, "%s logged in successfully, ", account->jid);
 
-    presence_t presence = accounts_get_login_presence(account->name);
-    char *presence_str;
-    switch(presence)
-    {
-        case PRESENCE_CHAT:
-            presence_str = "chat";
-            break;
-        case PRESENCE_AWAY:
-            presence_str = "away";
-            break;
-        case PRESENCE_XA:
-            presence_str = "xa";
-            break;
-        case PRESENCE_DND:
-            presence_str = "dnd";
-            break;
-        default:
-            presence_str = "online";
-            break;
-    }
+    resource_presence_t presence = accounts_get_login_presence(account->name);
+    const char *presence_str = string_from_resource_presence(presence);
 
     _presence_colour_on(console->win, presence_str);
     wprintw(console->win, "%s", presence_str);
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index 3d27bf3e..b5e39953 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -29,7 +29,6 @@ void connection_free_resources(void);
 xmpp_conn_t *connection_get_conn(void);
 xmpp_ctx_t *connection_get_ctx(void);
 int connection_error_handler(xmpp_stanza_t * const stanza);
-void connection_set_presence_type(presence_t presence_type);
 void connection_set_priority(int priority);
 void connection_set_presence_message(const char * const message);
 
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index b32a6ef2..525c7cf3 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -153,8 +153,8 @@ _iq_handle_roster_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
             item = xmpp_stanza_get_next(item);
         }
 
-        presence_t connect_presence = accounts_get_login_presence(jabber_get_account_name());
-        presence_update(connect_presence, NULL, 0);
+        contact_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
+        presence_update(conn_presence, NULL, 0);
     }
 
     return 1;
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index ffc1cddf..f306712e 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -106,7 +106,7 @@ presence_free_sub_requests(void)
 }
 
 void
-presence_update(presence_t presence_type, const char * const msg,
+presence_update(resource_presence_t presence_type, const char * const msg,
     int idle)
 {
     xmpp_ctx_t *ctx = connection_get_ctx();
@@ -160,7 +160,7 @@ presence_join_room(Jid *jid)
 {
     xmpp_ctx_t *ctx = connection_get_ctx();
     xmpp_conn_t *conn = connection_get_conn();
-    presence_t presence_type = accounts_get_last_presence(jabber_get_account_name());
+    contact_presence_t presence_type = accounts_get_last_presence(jabber_get_account_name());
     const char *show = stanza_get_presence_string_from_type(presence_type);
     char *status = jabber_get_presence_message();
     int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(),
@@ -183,7 +183,7 @@ presence_change_room_nick(const char * const room, const char * const nick)
 {
     xmpp_ctx_t *ctx = connection_get_ctx();
     xmpp_conn_t *conn = connection_get_conn();
-    presence_t presence_type = accounts_get_last_presence(jabber_get_account_name());
+    contact_presence_t presence_type = accounts_get_last_presence(jabber_get_account_name());
     const char *show = stanza_get_presence_string_from_type(presence_type);
     char *status = jabber_get_presence_message();
     int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(),
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 69327552..c62ebdd4 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -664,19 +664,19 @@ stanza_attach_caps(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence)
 }
 
 const char *
-stanza_get_presence_string_from_type(presence_t presence_type)
+stanza_get_presence_string_from_type(resource_presence_t presence_type)
 {
     switch(presence_type)
     {
-        case PRESENCE_AWAY:
+        case RESOURCE_AWAY:
             return STANZA_TEXT_AWAY;
-        case PRESENCE_DND:
+        case RESOURCE_DND:
             return STANZA_TEXT_DND;
-        case PRESENCE_CHAT:
+        case RESOURCE_CHAT:
             return STANZA_TEXT_CHAT;
-        case PRESENCE_XA:
+        case RESOURCE_XA:
             return STANZA_TEXT_XA;
-        default: // PRESENCE_ONLINE
+        default:
             return NULL;
     }
 }
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 6c396de7..dd666eff 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -160,6 +160,6 @@ void stanza_attach_show(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence,
 void stanza_attach_status(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence,
     const char * const status);
 
-const char * stanza_get_presence_string_from_type(presence_t presence_type);
+const char * stanza_get_presence_string_from_type(resource_presence_t presence_type);
 
 #endif
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 4e857ad2..2b5cce92 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -84,7 +84,7 @@ GList* presence_get_subscription_requests(void);
 void presence_join_room(Jid *jid);
 void presence_change_room_nick(const char * const room, const char * const nick);
 void presence_leave_chat_room(const char * const room_jid);
-void presence_update(presence_t status, const char * const msg,
+void presence_update(resource_presence_t status, const char * const msg,
     int idle);
 
 // caps functions