about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-07-07 13:53:30 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-07 13:53:30 +0200
commita4cadf78faabc157e5db00e42302d495bba432c0 (patch)
tree6ff212e24fe750b04b37ca66c418fe366c5e5fd4 /src/xmpp
parent28fde3cd0129202d586cb4c24877a3e3f55ca582 (diff)
downloadprofani-tty-a4cadf78faabc157e5db00e42302d495bba432c0.tar.gz
Revert "Apply coding style"
This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2.

Sorting the includes creates some problems.
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/avatar.c95
-rw-r--r--src/xmpp/blocking.c94
-rw-r--r--src/xmpp/blocking.h2
-rw-r--r--src/xmpp/bookmark.c117
-rw-r--r--src/xmpp/capabilities.c138
-rw-r--r--src/xmpp/capabilities.h18
-rw-r--r--src/xmpp/chat_session.c58
-rw-r--r--src/xmpp/chat_session.h27
-rw-r--r--src/xmpp/chat_state.c47
-rw-r--r--src/xmpp/chat_state.h15
-rw-r--r--src/xmpp/connection.c210
-rw-r--r--src/xmpp/connection.h16
-rw-r--r--src/xmpp/contact.c86
-rw-r--r--src/xmpp/contact.h28
-rw-r--r--src/xmpp/form.c303
-rw-r--r--src/xmpp/form.h10
-rw-r--r--src/xmpp/iq.c1140
-rw-r--r--src/xmpp/iq.h22
-rw-r--r--src/xmpp/jid.c45
-rw-r--r--src/xmpp/jid.h29
-rw-r--r--src/xmpp/message.c556
-rw-r--r--src/xmpp/message.h10
-rw-r--r--src/xmpp/muc.c319
-rw-r--r--src/xmpp/muc.h121
-rw-r--r--src/xmpp/omemo.c234
-rw-r--r--src/xmpp/omemo.h10
-rw-r--r--src/xmpp/ox.c74
-rw-r--r--src/xmpp/ox.h3
-rw-r--r--src/xmpp/presence.c416
-rw-r--r--src/xmpp/resource.c62
-rw-r--r--src/xmpp/resource.h19
-rw-r--r--src/xmpp/roster.c150
-rw-r--r--src/xmpp/roster.h6
-rw-r--r--src/xmpp/roster_list.c173
-rw-r--r--src/xmpp/roster_list.h36
-rw-r--r--src/xmpp/session.c90
-rw-r--r--src/xmpp/stanza.c1028
-rw-r--r--src/xmpp/stanza.h523
-rw-r--r--src/xmpp/xmpp.h286
39 files changed, 3295 insertions, 3321 deletions
diff --git a/src/xmpp/avatar.c b/src/xmpp/avatar.c
index 83413e80..c5b44411 100644
--- a/src/xmpp/avatar.c
+++ b/src/xmpp/avatar.c
@@ -33,38 +33,37 @@
  *
  */
 
-#include <errno.h>
 #include <glib.h>
+#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+#include <errno.h>
 #include <sys/stat.h>
 
-#include "config/files.h"
-#include "config/preferences.h"
 #include "log.h"
-#include "ui/ui.h"
 #include "xmpp/connection.h"
 #include "xmpp/form.h"
 #include "xmpp/iq.h"
 #include "xmpp/message.h"
 #include "xmpp/stanza.h"
+#include "ui/ui.h"
+#include "config/files.h"
+#include "config/preferences.h"
 
-typedef struct avatar_metadata
-{
-    char* type;
-    char* id;
+typedef struct avatar_metadata {
+    char *type;
+    char *id;
 } avatar_metadata;
 
-static GHashTable* looking_for = NULL; // contains nicks/barejids from who we want to get the avatar
-static GHashTable* shall_open = NULL;  // contains a list of nicks that shall not just downloaded but also opened
+static GHashTable *looking_for = NULL; // contains nicks/barejids from who we want to get the avatar
+static GHashTable *shall_open = NULL; // contains a list of nicks that shall not just downloaded but also opened
 
-static void _avatar_request_item_by_id(const char* jid, avatar_metadata* data);
-static int _avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
+static void _avatar_request_item_by_id(const char *jid, avatar_metadata *data);
+static int _avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
 
 static void
-_free_avatar_data(avatar_metadata* data)
+_free_avatar_data(avatar_metadata *data)
 {
     if (data) {
         free(data->type);
@@ -111,21 +110,21 @@ avatar_get_by_nick(const char* nick, gboolean open)
 }
 
 static int
-_avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_avatar_metadata_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
     if (!g_hash_table_contains(looking_for, from)) {
         return 1;
     }
 
-    xmpp_stanza_t* root = NULL;
-    xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
+    xmpp_stanza_t *root = NULL;
+    xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
     if (event) {
         root = event;
     }
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
     if (pubsub) {
         root = pubsub;
     }
@@ -134,25 +133,25 @@ _avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 1;
     }
 
-    xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(root, "items");
+    xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items");
     if (!items) {
         return 1;
     }
 
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item");
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
     if (item) {
-        xmpp_stanza_t* metadata = xmpp_stanza_get_child_by_name(item, "metadata");
+        xmpp_stanza_t *metadata = xmpp_stanza_get_child_by_name(item, "metadata");
         if (!metadata)
             return 1;
 
-        xmpp_stanza_t* info = xmpp_stanza_get_child_by_name(metadata, "info");
+        xmpp_stanza_t *info = xmpp_stanza_get_child_by_name(metadata, "info");
 
-        const char* id = xmpp_stanza_get_id(info);
-        const char* type = xmpp_stanza_get_attribute(info, "type");
+        const char *id = xmpp_stanza_get_id(info);
+        const char *type = xmpp_stanza_get_attribute(info, "type");
 
         log_debug("Avatar ID for %s is: %s", from, id);
 
-        avatar_metadata* data = malloc(sizeof(avatar_metadata));
+        avatar_metadata *data = malloc(sizeof(avatar_metadata));
         data->type = strdup(type);
         data->id = strdup(id);
 
@@ -164,15 +163,15 @@ _avatar_metadata_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static void
-_avatar_request_item_by_id(const char* jid, avatar_metadata* data)
+_avatar_request_item_by_id(const char *jid, avatar_metadata *data)
 {
     caps_remove_feature(XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY);
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* uid = connection_create_stanza_id();
+    char *uid = connection_create_stanza_id();
 
-    xmpp_stanza_t* iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid);
+    xmpp_stanza_t *iq = stanza_create_avatar_retrieve_data_request(ctx, uid, data->id, jid);
     iq_id_handler_add(uid, _avatar_request_item_result_handler, (ProfIqFreeCallback)_free_avatar_data, data);
 
     free(uid);
@@ -182,9 +181,9 @@ _avatar_request_item_by_id(const char* jid, avatar_metadata* data)
 }
 
 static int
-_avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_avatar_request_item_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    const char *from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
     if (!from_attr) {
         return 1;
@@ -195,33 +194,33 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
     }
     g_hash_table_remove(looking_for, from_attr);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
     if (!pubsub) {
         return 1;
     }
 
-    xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(pubsub, "items");
+    xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(pubsub, "items");
     if (!items) {
         return 1;
     }
 
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item");
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
     if (!item) {
         return 1;
     }
 
-    xmpp_stanza_t* st_data = stanza_get_child_by_name_and_ns(item, "data", STANZA_NS_USER_AVATAR_DATA);
+    xmpp_stanza_t *st_data = stanza_get_child_by_name_and_ns(item, "data", STANZA_NS_USER_AVATAR_DATA);
     if (!st_data) {
         return 1;
     }
 
-    char* buf = xmpp_stanza_get_text(st_data);
+    char *buf = xmpp_stanza_get_text(st_data);
     gsize size;
-    gchar* de = (gchar*)g_base64_decode(buf, &size);
+    gchar *de = (gchar*)g_base64_decode(buf, &size);
     free(buf);
 
-    char* path = files_get_data_path("");
-    GString* filename = g_string_new(path);
+    char *path = files_get_data_path("");
+    GString *filename = g_string_new(path);
     free(path);
 
     g_string_append(filename, "avatars/");
@@ -229,7 +228,7 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
     errno = 0;
     int res = g_mkdir_with_parents(filename->str, S_IRWXU);
     if (res == -1) {
-        char* errmsg = strerror(errno);
+        char *errmsg = strerror(errno);
         if (errmsg) {
             log_error("Avatar: error creating directory: %s, %s", filename->str, errmsg);
         } else {
@@ -237,10 +236,10 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
         }
     }
 
-    gchar* from = str_replace(from_attr, "@", "_at_");
+    gchar *from = str_replace(from_attr, "@", "_at_");
     g_string_append(filename, from);
 
-    avatar_metadata* data = (avatar_metadata*)userdata;
+    avatar_metadata *data = (avatar_metadata*)userdata;
 
     // check a few image types ourselves
     // if none matches we won't add an extension but linux will
@@ -256,8 +255,8 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
 
     free(from);
 
-    GError* err = NULL;
-    if (g_file_set_contents(filename->str, de, size, &err) == FALSE) {
+    GError *err = NULL;
+    if (g_file_set_contents (filename->str, de, size, &err) == FALSE) {
         log_error("Unable to save picture: %s", err->message);
         cons_show("Unable to save picture %s", err->message);
         g_error_free(err);
@@ -267,9 +266,9 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
 
     // if we shall open it
     if (g_hash_table_contains(shall_open, from_attr)) {
-        gchar* argv[] = { prefs_get_string(PREF_AVATAR_CMD), filename->str, NULL };
+        gchar *argv[] = {prefs_get_string(PREF_AVATAR_CMD), filename->str, NULL};
         if (!call_external(argv, NULL, NULL)) {
-            cons_show_error("Unable to display avatar: check the logs for more information.");
+          cons_show_error("Unable to display avatar: check the logs for more information.");
         }
         g_hash_table_remove(shall_open, from_attr);
     }
diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c
index 27b360ae..302471a6 100644
--- a/src/xmpp/blocking.c
+++ b/src/xmpp/blocking.c
@@ -46,19 +46,19 @@
 
 #include <glib.h>
 
-#include "common.h"
 #include "log.h"
+#include "common.h"
 #include "ui/ui.h"
-#include "xmpp/connection.h"
-#include "xmpp/iq.h"
 #include "xmpp/session.h"
+#include "xmpp/connection.h"
 #include "xmpp/stanza.h"
+#include "xmpp/iq.h"
 
-static int _blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
+static int _blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
 
-static GList* blocked;
+static GList *blocked;
 static Autocomplete blocked_ac;
 
 void
@@ -74,11 +74,11 @@ blocking_request(void)
     }
     blocked_ac = autocomplete_new();
 
-    char* id = connection_create_stanza_id();
+    char *id = connection_create_stanza_id();
     iq_id_handler_add(id, _blocklist_result_handler, NULL, NULL);
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_blocked_list_request(ctx);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_blocked_list_request(ctx);
     xmpp_stanza_set_id(iq, id);
     free(id);
 
@@ -93,7 +93,7 @@ blocked_list(void)
 }
 
 char*
-blocked_ac_find(const char* const search_str, gboolean previous, void* context)
+blocked_ac_find(const char *const search_str, gboolean previous, void *context)
 {
     return autocomplete_complete(blocked_ac, search_str, TRUE, previous);
 }
@@ -107,23 +107,23 @@ blocked_ac_reset(void)
 }
 
 gboolean
-blocked_add(char* jid)
+blocked_add(char *jid)
 {
-    GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
+    GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
     if (found) {
         return FALSE;
     }
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
 
-    xmpp_stanza_t* block = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *block = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(block, STANZA_NAME_BLOCK);
     xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
 
@@ -143,23 +143,23 @@ blocked_add(char* jid)
 }
 
 gboolean
-blocked_remove(char* jid)
+blocked_remove(char *jid)
 {
-    GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
+    GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
     if (!found) {
         return FALSE;
     }
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
 
-    xmpp_stanza_t* block = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *block = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(block, STANZA_NAME_UNBLOCK);
     xmpp_stanza_set_ns(block, STANZA_NS_BLOCKING);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
 
@@ -179,27 +179,28 @@ blocked_remove(char* jid)
 }
 
 int
-blocked_set_handler(xmpp_stanza_t* stanza)
+blocked_set_handler(xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK);
+    xmpp_stanza_t *block = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCK);
     if (block) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(block);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(block);
         while (child) {
             if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
-                const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+                const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
                 if (jid) {
                     blocked = g_list_append(blocked, strdup(jid));
                     autocomplete_add(blocked_ac, jid);
                 }
+
             }
 
             child = xmpp_stanza_get_next(child);
         }
     }
 
-    xmpp_stanza_t* unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK);
+    xmpp_stanza_t *unblock = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_UNBLOCK);
     if (unblock) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(unblock);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(unblock);
         if (!child) {
             g_list_free_full(blocked, free);
             blocked = NULL;
@@ -207,15 +208,16 @@ blocked_set_handler(xmpp_stanza_t* stanza)
         } else {
             while (child) {
                 if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_ITEM) == 0) {
-                    const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+                    const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
                     if (jid) {
-                        GList* found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
+                        GList *found = g_list_find_custom(blocked, jid, (GCompareFunc)g_strcmp0);
                         if (found) {
                             blocked = g_list_remove_link(blocked, found);
                             g_list_free_full(found, free);
                             autocomplete_remove(blocked_ac, jid);
                         }
                     }
+
                 }
 
                 child = xmpp_stanza_get_next(child);
@@ -227,11 +229,11 @@ blocked_set_handler(xmpp_stanza_t* stanza)
 }
 
 static int
-_block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_block_add_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    char* jid = (char*)userdata;
+    char *jid = (char*)userdata;
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (!type) {
         log_info("Block response received for %s with no type attribute.", jid);
         return 0;
@@ -248,11 +250,11 @@ _block_add_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_block_remove_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    char* jid = (char*)userdata;
+    char *jid = (char*)userdata;
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (!type) {
         log_info("Unblock response received for %s with no type attribute.", jid);
         return 0;
@@ -269,17 +271,17 @@ _block_remove_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_blocklist_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
     log_debug("Blocked list result handler fired.");
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, "result") != 0) {
         log_info("Received blocklist without result type");
         return 0;
     }
 
-    xmpp_stanza_t* blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST);
+    xmpp_stanza_t *blocklist = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BLOCKLIST);
     if (!blocklist) {
         log_info("Received blocklist without blocklist element");
         return 0;
@@ -290,17 +292,17 @@ _blocklist_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
         blocked = NULL;
     }
 
-    xmpp_stanza_t* items = xmpp_stanza_get_children(blocklist);
+    xmpp_stanza_t *items = xmpp_stanza_get_children(blocklist);
     if (!items) {
         log_debug("No blocked users.");
         return 0;
     }
 
-    xmpp_stanza_t* curr = items;
+    xmpp_stanza_t *curr = items;
     while (curr) {
-        const char* name = xmpp_stanza_get_name(curr);
+        const char *name = xmpp_stanza_get_name(curr);
         if (g_strcmp0(name, "item") == 0) {
-            const char* jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID);
+            const char *jid = xmpp_stanza_get_attribute(curr, STANZA_ATTR_JID);
             if (jid) {
                 blocked = g_list_append(blocked, strdup(jid));
                 autocomplete_add(blocked_ac, jid);
diff --git a/src/xmpp/blocking.h b/src/xmpp/blocking.h
index ff09f21b..ee4eecae 100644
--- a/src/xmpp/blocking.h
+++ b/src/xmpp/blocking.h
@@ -37,6 +37,6 @@
 #define XMPP_BLOCKING_H
 
 void blocking_request(void);
-int blocked_set_handler(xmpp_stanza_t* stanza);
+int blocked_set_handler(xmpp_stanza_t *stanza);
 
 #endif
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index 72ae4763..a28b6107 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -36,10 +36,10 @@
 #include "config.h"
 
 #include <assert.h>
-#include <glib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <glib.h>
 
 #ifdef HAVE_LIBMESODE
 #include <mesode.h>
@@ -50,26 +50,26 @@
 #endif
 
 #include "common.h"
-#include "event/server_events.h"
 #include "log.h"
+#include "event/server_events.h"
 #include "plugins/plugins.h"
 #include "ui/ui.h"
-#include "xmpp/bookmark.h"
 #include "xmpp/connection.h"
 #include "xmpp/iq.h"
-#include "xmpp/muc.h"
 #include "xmpp/stanza.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/bookmark.h"
+#include "xmpp/muc.h"
 
 #define BOOKMARK_TIMEOUT 5000
 
 static Autocomplete bookmark_ac;
-static GHashTable* bookmarks;
+static GHashTable *bookmarks;
 
 // id handlers
-static int _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
+static int _bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
 
-static void _bookmark_destroy(Bookmark* bookmark);
+static void _bookmark_destroy(Bookmark *bookmark);
 static void _send_bookmarks(void);
 
 void
@@ -83,11 +83,11 @@ bookmark_request(void)
     autocomplete_free(bookmark_ac);
     bookmark_ac = autocomplete_new();
 
-    char* id = "bookmark_init_request";
+    char *id = "bookmark_init_request";
     iq_id_handler_add(id, _bookmark_result_id_handler, free, NULL);
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_bookmarks_storage_request(ctx);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_bookmarks_storage_request(ctx);
     xmpp_stanza_set_id(iq, id);
 
     iq_send_stanza(iq);
@@ -95,11 +95,11 @@ bookmark_request(void)
 }
 
 gboolean
-bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name)
+bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name)
 {
     assert(jid != NULL);
 
-    Jid* jidp = jid_create(jid);
+    Jid *jidp = jid_create(jid);
     if (jidp->domainpart) {
         muc_confserver_add(jidp->domainpart);
     }
@@ -109,7 +109,7 @@ bookmark_add(const char* jid, const char* nick, const char* password, const char
         return FALSE;
     }
 
-    Bookmark* bookmark = malloc(sizeof(Bookmark));
+    Bookmark *bookmark = malloc(sizeof(Bookmark));
     bookmark->barejid = strdup(jid);
     if (nick) {
         bookmark->nick = strdup(nick);
@@ -142,11 +142,11 @@ bookmark_add(const char* jid, const char* nick, const char* password, const char
 }
 
 gboolean
-bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name)
+bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name)
 {
     assert(jid != NULL);
 
-    Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid);
+    Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
     if (!bookmark) {
         return FALSE;
     }
@@ -176,19 +176,19 @@ bookmark_update(const char* jid, const char* nick, const char* password, const c
 }
 
 gboolean
-bookmark_join(const char* jid)
+bookmark_join(const char *jid)
 {
     assert(jid != NULL);
 
-    Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid);
+    Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
     if (!bookmark) {
         return FALSE;
     }
 
-    char* account_name = session_get_account_name();
-    ProfAccount* account = accounts_get_account(account_name);
+    char *account_name = session_get_account_name();
+    ProfAccount *account = accounts_get_account(account_name);
     if (!muc_active(bookmark->barejid)) {
-        char* nick = bookmark->nick;
+        char *nick = bookmark->nick;
         if (!nick) {
             nick = account->muc_nick;
         }
@@ -207,11 +207,11 @@ bookmark_join(const char* jid)
 }
 
 gboolean
-bookmark_remove(const char* jid)
+bookmark_remove(const char *jid)
 {
     assert(jid != NULL);
 
-    Bookmark* bookmark = g_hash_table_lookup(bookmarks, jid);
+    Bookmark *bookmark = g_hash_table_lookup(bookmarks, jid);
     if (!bookmark) {
         return FALSE;
     }
@@ -231,7 +231,7 @@ bookmark_get_list(void)
 }
 
 char*
-bookmark_find(const char* const search_str, gboolean previous, void* context)
+bookmark_find(const char *const search_str, gboolean previous, void *context)
 {
     return autocomplete_complete(bookmark_ac, search_str, TRUE, previous);
 }
@@ -245,24 +245,24 @@ bookmark_autocomplete_reset(void)
 }
 
 gboolean
-bookmark_exists(const char* const room)
+bookmark_exists(const char *const room)
 {
     return g_hash_table_contains(bookmarks, room);
 }
 
 static int
-_bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_bookmark_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* name = xmpp_stanza_get_name(stanza);
+    const char *name = xmpp_stanza_get_name(stanza);
     if (!name || strcmp(name, STANZA_NAME_IQ) != 0) {
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
     if (!query) {
         return 0;
     }
-    xmpp_stanza_t* storage = xmpp_stanza_get_child_by_name(query, STANZA_NAME_STORAGE);
+    xmpp_stanza_t *storage = xmpp_stanza_get_child_by_name(query, STANZA_NAME_STORAGE);
     if (!storage) {
         return 0;
     }
@@ -271,14 +271,14 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         bookmark_ac = autocomplete_new();
     }
 
-    xmpp_stanza_t* child = xmpp_stanza_get_children(storage);
+    xmpp_stanza_t *child = xmpp_stanza_get_children(storage);
     while (child) {
         name = xmpp_stanza_get_name(child);
         if (!name || strcmp(name, STANZA_NAME_CONFERENCE) != 0) {
             child = xmpp_stanza_get_next(child);
             continue;
         }
-        const char* barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+        const char *barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
         if (!barejid) {
             child = xmpp_stanza_get_next(child);
             continue;
@@ -286,21 +286,21 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
         log_debug("Handle bookmark for %s", barejid);
 
-        const char* room_name = xmpp_stanza_get_attribute(child, "name");
+        const char *room_name = xmpp_stanza_get_attribute(child, "name");
 
-        char* nick = NULL;
-        xmpp_stanza_t* nick_st = xmpp_stanza_get_child_by_name(child, "nick");
+        char *nick = NULL;
+        xmpp_stanza_t *nick_st = xmpp_stanza_get_child_by_name(child, "nick");
         if (nick_st) {
             nick = stanza_text_strdup(nick_st);
         }
 
-        char* password = NULL;
-        xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(child, "password");
+        char *password = NULL;
+        xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(child, "password");
         if (password_st) {
             password = stanza_text_strdup(password_st);
         }
 
-        const char* autojoin = xmpp_stanza_get_attribute(child, "autojoin");
+        const char *autojoin = xmpp_stanza_get_attribute(child, "autojoin");
         gboolean autojoin_val = FALSE;
         if (autojoin && (strcmp(autojoin, "1") == 0 || strcmp(autojoin, "true") == 0)) {
             autojoin_val = TRUE;
@@ -308,9 +308,9 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
         // we save minimize, which is not standard, so that we don't remove it if it was set by gajim
         int minimize = 0;
-        xmpp_stanza_t* minimize_st = stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS);
+        xmpp_stanza_t *minimize_st = stanza_get_child_by_name_and_ns(child, STANZA_NAME_MINIMIZE, STANZA_NS_EXT_GAJIM_BOOKMARKS);
         if (minimize_st) {
-            char* min_str = xmpp_stanza_get_text(minimize_st);
+            char *min_str = xmpp_stanza_get_text(minimize_st);
             if (strcmp(min_str, "true") == 0) {
                 minimize = 1;
             } else if (strcmp(min_str, "false") == 0) {
@@ -320,7 +320,7 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         }
 
         autocomplete_add(bookmark_ac, barejid);
-        Bookmark* bookmark = malloc(sizeof(Bookmark));
+        Bookmark *bookmark = malloc(sizeof(Bookmark));
         bookmark->barejid = strdup(barejid);
         bookmark->nick = nick;
         bookmark->password = password;
@@ -333,7 +333,7 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
             sv_ev_bookmark_autojoin(bookmark);
         }
 
-        Jid* jidp = jid_create(barejid);
+        Jid *jidp = jid_create(barejid);
         if (jidp->domainpart) {
             muc_confserver_add(jidp->domainpart);
         }
@@ -346,7 +346,7 @@ _bookmark_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static void
-_bookmark_destroy(Bookmark* bookmark)
+_bookmark_destroy(Bookmark *bookmark)
 {
     if (bookmark) {
         free(bookmark->barejid);
@@ -360,25 +360,25 @@ _bookmark_destroy(Bookmark* bookmark)
 static void
 _send_bookmarks(void)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, "jabber:iq:private");
 
-    xmpp_stanza_t* storage = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *storage = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(storage, STANZA_NAME_STORAGE);
     xmpp_stanza_set_ns(storage, "storage:bookmarks");
 
-    GList* bookmark_list = g_hash_table_get_values(bookmarks);
-    GList* curr = bookmark_list;
+    GList *bookmark_list = g_hash_table_get_values(bookmarks);
+    GList *curr = bookmark_list;
     while (curr) {
-        Bookmark* bookmark = curr->data;
-        xmpp_stanza_t* conference = xmpp_stanza_new(ctx);
+        Bookmark *bookmark = curr->data;
+        xmpp_stanza_t *conference = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(conference, STANZA_NAME_CONFERENCE);
         xmpp_stanza_set_attribute(conference, STANZA_ATTR_JID, bookmark->barejid);
 
@@ -387,7 +387,7 @@ _send_bookmarks(void)
             xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, bookmark->name);
         } else {
             // use localpart of JID by if no name is specified
-            Jid* jidp = jid_create(bookmark->barejid);
+            Jid *jidp = jid_create(bookmark->barejid);
             if (jidp->localpart) {
                 xmpp_stanza_set_attribute(conference, STANZA_ATTR_NAME, jidp->localpart);
             }
@@ -401,9 +401,9 @@ _send_bookmarks(void)
         }
 
         if (bookmark->nick) {
-            xmpp_stanza_t* nick_st = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *nick_st = xmpp_stanza_new(ctx);
             xmpp_stanza_set_name(nick_st, STANZA_NAME_NICK);
-            xmpp_stanza_t* nick_text = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *nick_text = xmpp_stanza_new(ctx);
             xmpp_stanza_set_text(nick_text, bookmark->nick);
             xmpp_stanza_add_child(nick_st, nick_text);
             xmpp_stanza_add_child(conference, nick_st);
@@ -413,9 +413,9 @@ _send_bookmarks(void)
         }
 
         if (bookmark->password) {
-            xmpp_stanza_t* password_st = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *password_st = xmpp_stanza_new(ctx);
             xmpp_stanza_set_name(password_st, STANZA_NAME_PASSWORD);
-            xmpp_stanza_t* password_text = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *password_text = xmpp_stanza_new(ctx);
             xmpp_stanza_set_text(password_text, bookmark->password);
             xmpp_stanza_add_child(password_st, password_text);
             xmpp_stanza_add_child(conference, password_st);
@@ -424,12 +424,13 @@ _send_bookmarks(void)
             xmpp_stanza_release(password_st);
         }
 
-        if (bookmark->ext_gajim_minimize == 1 || bookmark->ext_gajim_minimize == 2) {
-            xmpp_stanza_t* minimize_st = xmpp_stanza_new(ctx);
+        if (bookmark->ext_gajim_minimize == 1 ||
+                bookmark->ext_gajim_minimize == 2) {
+            xmpp_stanza_t *minimize_st = xmpp_stanza_new(ctx);
             xmpp_stanza_set_name(minimize_st, STANZA_NAME_MINIMIZE);
             xmpp_stanza_set_ns(minimize_st, STANZA_NS_EXT_GAJIM_BOOKMARKS);
 
-            xmpp_stanza_t* minimize_text = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *minimize_text = xmpp_stanza_new(ctx);
             if (bookmark->ext_gajim_minimize == 1) {
                 xmpp_stanza_set_text(minimize_text, "true");
             } else {
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index ef3bba54..a0fcecb0 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -54,29 +54,29 @@
 #endif
 
 #include "common.h"
-#include "config/files.h"
-#include "config/preferences.h"
-#include "event/client_events.h"
 #include "log.h"
+#include "event/client_events.h"
 #include "plugins/plugins.h"
-#include "xmpp/capabilities.h"
-#include "xmpp/form.h"
-#include "xmpp/stanza.h"
+#include "config/files.h"
+#include "config/preferences.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/stanza.h"
+#include "xmpp/form.h"
+#include "xmpp/capabilities.h"
 
-static char* cache_loc;
-static GKeyFile* cache;
+static char *cache_loc;
+static GKeyFile *cache;
 
-static GHashTable* jid_to_ver;
-static GHashTable* jid_to_caps;
+static GHashTable *jid_to_ver;
+static GHashTable *jid_to_caps;
 
-static GHashTable* prof_features;
-static char* my_sha1;
+static GHashTable *prof_features;
+static char *my_sha1;
 
 static void _save_cache(void);
-static EntityCapabilities* _caps_by_ver(const char* const ver);
-static EntityCapabilities* _caps_by_jid(const char* const jid);
-static EntityCapabilities* _caps_copy(EntityCapabilities* caps);
+static EntityCapabilities* _caps_by_ver(const char *const ver);
+static EntityCapabilities* _caps_by_jid(const char *const jid);
+static EntityCapabilities* _caps_copy(EntityCapabilities *caps);
 
 void
 caps_init(void)
@@ -121,7 +121,7 @@ caps_init(void)
 }
 
 void
-caps_add_feature(char* feature)
+caps_add_feature(char *feature)
 {
     if (g_hash_table_contains(prof_features, feature)) {
         return;
@@ -139,7 +139,7 @@ caps_add_feature(char* feature)
 }
 
 void
-caps_remove_feature(char* feature)
+caps_remove_feature(char *feature)
 {
     if (!g_hash_table_contains(prof_features, feature)) {
         return;
@@ -159,17 +159,17 @@ caps_remove_feature(char* feature)
 GList*
 caps_get_features(void)
 {
-    GList* result = NULL;
+    GList *result = NULL;
 
-    GList* features_as_list = g_hash_table_get_keys(prof_features);
-    GList* curr = features_as_list;
+    GList *features_as_list = g_hash_table_get_keys(prof_features);
+    GList *curr = features_as_list;
     while (curr) {
         result = g_list_append(result, strdup(curr->data));
         curr = g_list_next(curr);
     }
     g_list_free(features_as_list);
 
-    GList* plugin_features = plugins_get_disco_features();
+    GList *plugin_features = plugins_get_disco_features();
     curr = plugin_features;
     while (curr) {
         result = g_list_append(result, strdup(curr->data));
@@ -182,15 +182,15 @@ caps_get_features(void)
 }
 
 EntityCapabilities*
-caps_create(const char* const category, const char* const type, const char* const name,
-            const char* const software, const char* const software_version,
-            const char* const os, const char* const os_version,
-            GSList* features)
+caps_create(const char *const category, const char *const type, const char *const name,
+    const char *const software, const char *const software_version,
+    const char *const os, const char *const os_version,
+    GSList *features)
 {
-    EntityCapabilities* result = (EntityCapabilities*)malloc(sizeof(EntityCapabilities));
+    EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities));
 
     if (category || type || name) {
-        DiscoIdentity* identity = (DiscoIdentity*)malloc(sizeof(DiscoIdentity));
+        DiscoIdentity *identity = (DiscoIdentity*)malloc(sizeof(DiscoIdentity));
         identity->category = category ? strdup(category) : NULL;
         identity->type = type ? strdup(type) : NULL;
         identity->name = name ? strdup(name) : NULL;
@@ -200,7 +200,7 @@ caps_create(const char* const category, const char* const type, const char* cons
     }
 
     if (software || software_version || os || os_version) {
-        SoftwareVersion* software_versionp = (SoftwareVersion*)malloc(sizeof(SoftwareVersion));
+        SoftwareVersion *software_versionp = (SoftwareVersion*)malloc(sizeof(SoftwareVersion));
         software_versionp->software = software ? strdup(software) : NULL;
         software_versionp->software_version = software_version ? strdup(software_version) : NULL;
         software_versionp->os = os ? strdup(os) : NULL;
@@ -211,7 +211,7 @@ caps_create(const char* const category, const char* const type, const char* cons
     }
 
     result->features = NULL;
-    GSList* curr = features;
+    GSList *curr = features;
     while (curr) {
         result->features = g_slist_append(result->features, strdup(curr->data));
         curr = g_slist_next(curr);
@@ -221,7 +221,7 @@ caps_create(const char* const category, const char* const type, const char* cons
 }
 
 void
-caps_add_by_ver(const char* const ver, EntityCapabilities* caps)
+caps_add_by_ver(const char *const ver, EntityCapabilities *caps)
 {
     if (ver == NULL || caps == NULL) {
         return;
@@ -233,7 +233,7 @@ caps_add_by_ver(const char* const ver, EntityCapabilities* caps)
     }
 
     if (caps->identity) {
-        DiscoIdentity* identity = caps->identity;
+        DiscoIdentity *identity = caps->identity;
         if (identity->name) {
             g_key_file_set_string(cache, ver, "name", identity->name);
         }
@@ -246,7 +246,7 @@ caps_add_by_ver(const char* const ver, EntityCapabilities* caps)
     }
 
     if (caps->software_version) {
-        SoftwareVersion* software_version = caps->software_version;
+        SoftwareVersion *software_version = caps->software_version;
         if (software_version->software) {
             g_key_file_set_string(cache, ver, "software", software_version->software);
         }
@@ -262,7 +262,7 @@ caps_add_by_ver(const char* const ver, EntityCapabilities* caps)
     }
 
     if (caps->features) {
-        GSList* curr_feature = caps->features;
+        GSList *curr_feature = caps->features;
         int num = g_slist_length(caps->features);
         const gchar* features_list[num];
         int curr = 0;
@@ -277,35 +277,35 @@ caps_add_by_ver(const char* const ver, EntityCapabilities* caps)
 }
 
 void
-caps_add_by_jid(const char* const jid, EntityCapabilities* caps)
+caps_add_by_jid(const char *const jid, EntityCapabilities *caps)
 {
     g_hash_table_insert(jid_to_caps, strdup(jid), caps);
 }
 
 void
-caps_map_jid_to_ver(const char* const jid, const char* const ver)
+caps_map_jid_to_ver(const char *const jid, const char *const ver)
 {
     g_hash_table_insert(jid_to_ver, strdup(jid), strdup(ver));
 }
 
 gboolean
-caps_cache_contains(const char* const ver)
+caps_cache_contains(const char *const ver)
 {
     return (g_key_file_has_group(cache, ver));
 }
 
 EntityCapabilities*
-caps_lookup(const char* const jid)
+caps_lookup(const char *const jid)
 {
-    char* ver = g_hash_table_lookup(jid_to_ver, jid);
+    char *ver = g_hash_table_lookup(jid_to_ver, jid);
     if (ver) {
-        EntityCapabilities* caps = _caps_by_ver(ver);
+        EntityCapabilities *caps = _caps_by_ver(ver);
         if (caps) {
             log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver);
             return caps;
         }
     } else {
-        EntityCapabilities* caps = _caps_by_jid(jid);
+        EntityCapabilities *caps = _caps_by_jid(jid);
         if (caps) {
             log_debug("Capabilities lookup %s, found by JID.", jid);
             return _caps_copy(caps);
@@ -317,15 +317,15 @@ caps_lookup(const char* const jid)
 }
 
 gboolean
-caps_jid_has_feature(const char* const jid, const char* const feature)
+caps_jid_has_feature(const char *const jid, const char *const feature)
 {
-    EntityCapabilities* caps = caps_lookup(jid);
+    EntityCapabilities *caps = caps_lookup(jid);
 
     if (caps == NULL) {
         return FALSE;
     }
 
-    GSList* found = g_slist_find_custom(caps->features, feature, (GCompareFunc)g_strcmp0);
+    GSList *found = g_slist_find_custom(caps->features, feature, (GCompareFunc)g_strcmp0);
     gboolean result = found != NULL;
 
     caps_destroy(caps);
@@ -334,10 +334,10 @@ caps_jid_has_feature(const char* const jid, const char* const feature)
 }
 
 char*
-caps_get_my_sha1(xmpp_ctx_t* const ctx)
+caps_get_my_sha1(xmpp_ctx_t *const ctx)
 {
     if (my_sha1 == NULL) {
-        xmpp_stanza_t* query = stanza_create_caps_query_element(ctx);
+        xmpp_stanza_t *query = stanza_create_caps_query_element(ctx);
         my_sha1 = stanza_create_caps_sha1_from_query(query);
         xmpp_stanza_release(query);
     }
@@ -368,24 +368,24 @@ caps_close(void)
 }
 
 static EntityCapabilities*
-_caps_by_ver(const char* const ver)
+_caps_by_ver(const char *const ver)
 {
     if (!g_key_file_has_group(cache, ver)) {
         return NULL;
     }
 
-    char* category = g_key_file_get_string(cache, ver, "category", NULL);
-    char* type = g_key_file_get_string(cache, ver, "type", NULL);
-    char* name = g_key_file_get_string(cache, ver, "name", NULL);
+    char *category = g_key_file_get_string(cache, ver, "category", NULL);
+    char *type = g_key_file_get_string(cache, ver, "type", NULL);
+    char *name = g_key_file_get_string(cache, ver, "name", NULL);
 
-    char* software = g_key_file_get_string(cache, ver, "software", NULL);
-    char* software_version = g_key_file_get_string(cache, ver, "software_version", NULL);
-    char* os = g_key_file_get_string(cache, ver, "os", NULL);
-    char* os_version = g_key_file_get_string(cache, ver, "os_version", NULL);
+    char *software = g_key_file_get_string(cache, ver, "software", NULL);
+    char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL);
+    char *os = g_key_file_get_string(cache, ver, "os", NULL);
+    char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL);
 
     gsize features_len = 0;
-    gchar** features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
-    GSList* features = NULL;
+    gchar **features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
+    GSList *features = NULL;
     if (features_list && features_len > 0) {
         int i;
         for (i = 0; i < features_len; i++) {
@@ -393,7 +393,7 @@ _caps_by_ver(const char* const ver)
         }
     }
 
-    EntityCapabilities* result = caps_create(
+    EntityCapabilities *result = caps_create(
         category, type, name,
         software, software_version, os, os_version,
         features);
@@ -414,32 +414,32 @@ _caps_by_ver(const char* const ver)
 }
 
 static EntityCapabilities*
-_caps_by_jid(const char* const jid)
+_caps_by_jid(const char *const jid)
 {
     return g_hash_table_lookup(jid_to_caps, jid);
 }
 
 static EntityCapabilities*
-_caps_copy(EntityCapabilities* caps)
+_caps_copy(EntityCapabilities *caps)
 {
     if (!caps) {
         return NULL;
     }
 
-    const char* const categoty = caps->identity ? caps->identity->category : NULL;
-    const char* const type = caps->identity ? caps->identity->type : NULL;
-    const char* const name = caps->identity ? caps->identity->name : NULL;
+    const char *const categoty = caps->identity ? caps->identity->category : NULL;
+    const char *const type = caps->identity ? caps->identity->type : NULL;
+    const char *const name = caps->identity ? caps->identity->name : NULL;
 
-    const char* const software = caps->software_version ? caps->software_version->software : NULL;
-    const char* const software_version = caps->software_version ? caps->software_version->software_version : NULL;
-    const char* const os = caps->software_version ? caps->software_version->os : NULL;
-    const char* const os_version = caps->software_version ? caps->software_version->os_version : NULL;
+    const char *const software = caps->software_version ? caps->software_version->software : NULL;
+    const char *const software_version = caps->software_version ? caps->software_version->software_version : NULL;
+    const char *const os = caps->software_version ? caps->software_version->os : NULL;
+    const char *const os_version = caps->software_version ? caps->software_version->os_version : NULL;
 
     return caps_create(categoty, type, name, software, software_version, os, os_version, caps->features);
 }
 
 static void
-_disco_identity_destroy(DiscoIdentity* disco_identity)
+_disco_identity_destroy(DiscoIdentity *disco_identity)
 {
     if (disco_identity) {
         free(disco_identity->category);
@@ -450,7 +450,7 @@ _disco_identity_destroy(DiscoIdentity* disco_identity)
 }
 
 static void
-_software_version_destroy(SoftwareVersion* software_version)
+_software_version_destroy(SoftwareVersion *software_version)
 {
     if (software_version) {
         free(software_version->software);
@@ -462,7 +462,7 @@ _software_version_destroy(SoftwareVersion* software_version)
 }
 
 void
-caps_destroy(EntityCapabilities* caps)
+caps_destroy(EntityCapabilities *caps)
 {
     if (caps) {
         _disco_identity_destroy(caps->identity);
@@ -478,7 +478,7 @@ static void
 _save_cache(void)
 {
     gsize g_data_size;
-    gchar* g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL);
+    gchar *g_cache_data = g_key_file_to_data(cache, &g_data_size, NULL);
     g_file_set_contents(cache_loc, g_cache_data, g_data_size, NULL);
     g_chmod(cache_loc, S_IRUSR | S_IWUSR);
     g_free(g_cache_data);
diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h
index 0760f7d7..4cf3dd6c 100644
--- a/src/xmpp/capabilities.h
+++ b/src/xmpp/capabilities.h
@@ -50,15 +50,15 @@
 
 void caps_init(void);
 
-EntityCapabilities* caps_create(const char* const category, const char* const type, const char* const name,
-                                const char* const software, const char* const software_version,
-                                const char* const os, const char* const os_version,
-                                GSList* features);
-void caps_add_by_ver(const char* const ver, EntityCapabilities* caps);
-void caps_add_by_jid(const char* const jid, EntityCapabilities* caps);
-void caps_map_jid_to_ver(const char* const jid, const char* const ver);
-gboolean caps_cache_contains(const char* const ver);
+EntityCapabilities* caps_create(const char *const category, const char *const type, const char *const name,
+    const char *const software, const char *const software_version,
+    const char *const os, const char *const os_version,
+    GSList *features);
+void caps_add_by_ver(const char *const ver, EntityCapabilities *caps);
+void caps_add_by_jid(const char *const jid, EntityCapabilities *caps);
+void caps_map_jid_to_ver(const char *const jid, const char *const ver);
+gboolean caps_cache_contains(const char *const ver);
 GList* caps_get_features(void);
-char* caps_get_my_sha1(xmpp_ctx_t* const ctx);
+char* caps_get_my_sha1(xmpp_ctx_t *const ctx);
 
 #endif
diff --git a/src/xmpp/chat_session.c b/src/xmpp/chat_session.c
index 90411c03..3a018be8 100644
--- a/src/xmpp/chat_session.c
+++ b/src/xmpp/chat_session.c
@@ -33,28 +33,28 @@
  *
  */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <glib.h>
 
-#include "config/preferences.h"
 #include "log.h"
-#include "xmpp/chat_session.h"
-#include "xmpp/stanza.h"
+#include "config/preferences.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/stanza.h"
+#include "xmpp/chat_session.h"
 
-static GHashTable* sessions;
+static GHashTable *sessions;
 
 static void
-_chat_session_new(const char* const barejid, const char* const resource, gboolean resource_override,
-                  gboolean send_states)
+_chat_session_new(const char *const barejid, const char *const resource, gboolean resource_override,
+    gboolean send_states)
 {
     assert(barejid != NULL);
     assert(resource != NULL);
 
-    ChatSession* new_session = malloc(sizeof(struct chat_session_t));
+    ChatSession *new_session = malloc(sizeof(struct chat_session_t));
     new_session->barejid = strdup(barejid);
     new_session->resource = strdup(resource);
     new_session->resource_override = resource_override;
@@ -64,7 +64,7 @@ _chat_session_new(const char* const barejid, const char* const resource, gboolea
 }
 
 static void
-_chat_session_free(ChatSession* session)
+_chat_session_free(ChatSession *session)
 {
     if (session) {
         free(session->barejid);
@@ -91,24 +91,24 @@ chat_sessions_clear(void)
 }
 
 void
-chat_session_resource_override(const char* const barejid, const char* const resource)
+chat_session_resource_override(const char *const barejid, const char *const resource)
 {
     _chat_session_new(barejid, resource, TRUE, TRUE);
 }
 
 ChatSession*
-chat_session_get(const char* const barejid)
+chat_session_get(const char *const barejid)
 {
     return g_hash_table_lookup(sessions, barejid);
 }
 
 char*
-chat_session_get_jid(const char* const barejid)
+chat_session_get_jid(const char *const barejid)
 {
-    ChatSession* session = chat_session_get(barejid);
-    char* jid = NULL;
+    ChatSession *session = chat_session_get(barejid);
+    char *jid = NULL;
     if (session) {
-        Jid* jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
+        Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
         jid = strdup(jidp->fulljid);
         jid_destroy(jidp);
     } else {
@@ -119,10 +119,10 @@ chat_session_get_jid(const char* const barejid)
 }
 
 char*
-chat_session_get_state(const char* const barejid)
+chat_session_get_state(const char *const barejid)
 {
-    ChatSession* session = chat_session_get(barejid);
-    char* state = NULL;
+    ChatSession *session = chat_session_get(barejid);
+    char *state = NULL;
     if (session) {
         if (prefs_get_boolean(PREF_STATES) && session->send_states) {
             state = STANZA_NAME_ACTIVE;
@@ -137,12 +137,12 @@ chat_session_get_state(const char* const barejid)
 }
 
 void
-chat_session_recipient_gone(const char* const barejid, const char* const resource)
+chat_session_recipient_gone(const char *const barejid, const char *const resource)
 {
     assert(barejid != NULL);
     assert(resource != NULL);
 
-    ChatSession* session = g_hash_table_lookup(sessions, barejid);
+    ChatSession *session = g_hash_table_lookup(sessions, barejid);
     if (session && g_strcmp0(session->resource, resource) == 0) {
         if (!session->resource_override) {
             chat_session_remove(barejid);
@@ -151,48 +151,48 @@ chat_session_recipient_gone(const char* const barejid, const char* const resourc
 }
 
 void
-chat_session_recipient_typing(const char* const barejid, const char* const resource)
+chat_session_recipient_typing(const char *const barejid, const char *const resource)
 {
     chat_session_recipient_active(barejid, resource, TRUE);
 }
 
 void
-chat_session_recipient_paused(const char* const barejid, const char* const resource)
+chat_session_recipient_paused(const char *const barejid, const char *const resource)
 {
     chat_session_recipient_active(barejid, resource, TRUE);
 }
 
 void
-chat_session_recipient_inactive(const char* const barejid, const char* const resource)
+chat_session_recipient_inactive(const char *const barejid, const char *const resource)
 {
     chat_session_recipient_active(barejid, resource, TRUE);
 }
 
 void
-chat_session_recipient_active(const char* const barejid, const char* const resource,
-                              gboolean send_states)
+chat_session_recipient_active(const char *const barejid, const char *const resource,
+    gboolean send_states)
 {
     assert(barejid != NULL);
     assert(resource != NULL);
 
-    ChatSession* session = g_hash_table_lookup(sessions, barejid);
+    ChatSession *session = g_hash_table_lookup(sessions, barejid);
     if (session) {
         // session exists with resource, update chat_states
         if (g_strcmp0(session->resource, resource) == 0) {
             session->send_states = send_states;
-            // session exists with different resource and no override, replace
+        // session exists with different resource and no override, replace
         } else if (!session->resource_override) {
             _chat_session_new(barejid, resource, FALSE, send_states);
         }
 
-        // no session, create one
+    // no session, create one
     } else {
         _chat_session_new(barejid, resource, FALSE, send_states);
     }
 }
 
 void
-chat_session_remove(const char* const barejid)
+chat_session_remove(const char *const barejid)
 {
     g_hash_table_remove(sessions, barejid);
 }
diff --git a/src/xmpp/chat_session.h b/src/xmpp/chat_session.h
index e0144874..550858e7 100644
--- a/src/xmpp/chat_session.h
+++ b/src/xmpp/chat_session.h
@@ -38,10 +38,9 @@
 
 #include <glib.h>
 
-typedef struct chat_session_t
-{
-    char* barejid;
-    char* resource;
+typedef struct chat_session_t {
+    char *barejid;
+    char *resource;
     gboolean resource_override;
     gboolean send_states;
 
@@ -50,17 +49,17 @@ typedef struct chat_session_t
 void chat_sessions_init(void);
 void chat_sessions_clear(void);
 
-void chat_session_resource_override(const char* const barejid, const char* const resource);
-ChatSession* chat_session_get(const char* const barejid);
+void chat_session_resource_override(const char *const barejid, const char *const resource);
+ChatSession* chat_session_get(const char *const barejid);
 
-void chat_session_recipient_active(const char* const barejid, const char* const resource, gboolean send_states);
-void chat_session_recipient_typing(const char* const barejid, const char* const resource);
-void chat_session_recipient_paused(const char* const barejid, const char* const resource);
-void chat_session_recipient_gone(const char* const barejid, const char* const resource);
-void chat_session_recipient_inactive(const char* const barejid, const char* const resource);
-char* chat_session_get_jid(const char* const barejid);
-char* chat_session_get_state(const char* const barejid);
+void chat_session_recipient_active(const char *const barejid, const char *const resource, gboolean send_states);
+void chat_session_recipient_typing(const char *const barejid, const char *const resource);
+void chat_session_recipient_paused(const char *const barejid, const char *const resource);
+void chat_session_recipient_gone(const char *const barejid, const char *const resource);
+void chat_session_recipient_inactive(const char *const barejid, const char *const resource);
+char* chat_session_get_jid(const char *const barejid);
+char* chat_session_get_state(const char *const barejid);
 
-void chat_session_remove(const char* const barejid);
+void chat_session_remove(const char *const barejid);
 
 #endif
diff --git a/src/xmpp/chat_state.c b/src/xmpp/chat_state.c
index 6346b17f..77945a50 100644
--- a/src/xmpp/chat_state.c
+++ b/src/xmpp/chat_state.c
@@ -33,27 +33,27 @@
  *
  */
 
-#include <assert.h>
 #include <stdlib.h>
+#include <assert.h>
 
 #include <glib.h>
 
 #include "config/preferences.h"
-#include "ui/win_types.h"
 #include "ui/window_list.h"
-#include "xmpp/chat_session.h"
-#include "xmpp/chat_state.h"
+#include "ui/win_types.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/chat_state.h"
+#include "xmpp/chat_session.h"
 
-#define PAUSED_TIMEOUT   10.0
+#define PAUSED_TIMEOUT 10.0
 #define INACTIVE_TIMEOUT 30.0
 
-static void _send_if_supported(const char* const barejid, void (*send_func)(const char* const));
+static void _send_if_supported(const char *const barejid, void (*send_func)(const char *const));
 
 ChatState*
 chat_state_new(void)
 {
-    ChatState* new_state = malloc(sizeof(struct prof_chat_state_t));
+    ChatState *new_state = malloc(sizeof(struct prof_chat_state_t));
     new_state->type = CHAT_STATE_GONE;
     new_state->timer = g_timer_new();
 
@@ -61,16 +61,16 @@ chat_state_new(void)
 }
 
 void
-chat_state_free(ChatState* state)
+chat_state_free(ChatState *state)
 {
-    if (state && state->timer != NULL) {
+    if (state && state->timer!= NULL) {
         g_timer_destroy(state->timer);
     }
     free(state);
 }
 
 void
-chat_state_handle_idle(const char* const barejid, ChatState* state)
+chat_state_handle_idle(const char *const barejid, ChatState *state)
 {
     gdouble elapsed = g_timer_elapsed(state->timer, NULL);
 
@@ -92,12 +92,13 @@ chat_state_handle_idle(const char* const barejid, ChatState* state)
             _send_if_supported(barejid, message_send_inactive);
         }
         return;
+
     }
 
     // INACTIVE -> GONE
     if (state->type == CHAT_STATE_INACTIVE) {
         if (prefs_get_gone() != 0 && (elapsed > (prefs_get_gone() * 60.0))) {
-            ChatSession* session = chat_session_get(barejid);
+            ChatSession *session = chat_session_get(barejid);
             if (session) {
                 // never move to GONE when resource override
                 if (!session->resource_override) {
@@ -121,7 +122,7 @@ chat_state_handle_idle(const char* const barejid, ChatState* state)
 }
 
 void
-chat_state_handle_typing(const char* const barejid, ChatState* state)
+chat_state_handle_typing(const char *const barejid, ChatState *state)
 {
     // ACTIVE|INACTIVE|PAUSED|GONE -> COMPOSING
     if (state->type != CHAT_STATE_COMPOSING) {
@@ -134,14 +135,14 @@ chat_state_handle_typing(const char* const barejid, ChatState* state)
 }
 
 void
-chat_state_active(ChatState* state)
+chat_state_active(ChatState *state)
 {
     state->type = CHAT_STATE_ACTIVE;
     g_timer_start(state->timer);
 }
 
 void
-chat_state_gone(const char* const barejid, ChatState* state)
+chat_state_gone(const char *const barejid, ChatState *state)
 {
     if (state->type != CHAT_STATE_GONE) {
         if (prefs_get_boolean(PREF_STATES)) {
@@ -157,12 +158,12 @@ chat_state_idle(void)
 {
     jabber_conn_status_t status = connection_get_status();
     if (status == JABBER_CONNECTED) {
-        GSList* recipients = wins_get_chat_recipients();
-        GSList* curr = recipients;
+        GSList *recipients = wins_get_chat_recipients();
+        GSList *curr = recipients;
 
         while (curr) {
-            char* barejid = curr->data;
-            ProfChatWin* chatwin = wins_get_chat(barejid);
+            char *barejid = curr->data;
+            ProfChatWin *chatwin = wins_get_chat(barejid);
             chat_state_handle_idle(chatwin->barejid, chatwin->state);
             curr = g_slist_next(curr);
         }
@@ -177,21 +178,21 @@ void
 chat_state_activity(void)
 {
     jabber_conn_status_t status = connection_get_status();
-    ProfWin* current = wins_get_current();
+    ProfWin *current = wins_get_current();
 
     if ((status == JABBER_CONNECTED) && (current->type == WIN_CHAT)) {
-        ProfChatWin* chatwin = (ProfChatWin*)current;
+        ProfChatWin *chatwin = (ProfChatWin*)current;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
         chat_state_handle_typing(chatwin->barejid, chatwin->state);
     }
 }
 
 static void
-_send_if_supported(const char* const barejid, void (*send_func)(const char* const))
+_send_if_supported(const char *const barejid, void (*send_func)(const char *const))
 {
     gboolean send = TRUE;
-    GString* jid = g_string_new(barejid);
-    ChatSession* session = chat_session_get(barejid);
+    GString *jid = g_string_new(barejid);
+    ChatSession *session = chat_session_get(barejid);
     if (session) {
         if (session->send_states) {
             g_string_append(jid, "/");
diff --git a/src/xmpp/chat_state.h b/src/xmpp/chat_state.h
index 3b2e5829..e484b284 100644
--- a/src/xmpp/chat_state.h
+++ b/src/xmpp/chat_state.h
@@ -46,21 +46,20 @@ typedef enum {
     CHAT_STATE_GONE
 } chat_state_type_t;
 
-typedef struct prof_chat_state_t
-{
+typedef struct prof_chat_state_t {
     chat_state_type_t type;
-    GTimer* timer;
+    GTimer *timer;
 } ChatState;
 
 ChatState* chat_state_new(void);
-void chat_state_free(ChatState* state);
+void chat_state_free(ChatState *state);
 
 void chat_state_idle(void);
 void chat_state_activity(void);
 
-void chat_state_handle_idle(const char* const barejid, ChatState* state);
-void chat_state_handle_typing(const char* const barejid, ChatState* state);
-void chat_state_active(ChatState* state);
-void chat_state_gone(const char* const barejid, ChatState* state);
+void chat_state_handle_idle(const char *const barejid, ChatState *state);
+void chat_state_handle_typing(const char *const barejid, ChatState *state);
+void chat_state_active(ChatState *state);
+void chat_state_gone(const char *const barejid, ChatState *state);
 
 #endif
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index f9a8fe49..8c875e63 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -36,9 +36,9 @@
 
 #include "config.h"
 
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <glib.h>
 #include <glib/gstdio.h>
@@ -52,49 +52,48 @@
 #endif
 
 #include "common.h"
+#include "log.h"
 #include "config/files.h"
 #include "config/preferences.h"
 #include "event/server_events.h"
-#include "log.h"
-#include "ui/ui.h"
 #include "xmpp/connection.h"
-#include "xmpp/iq.h"
 #include "xmpp/session.h"
+#include "xmpp/iq.h"
+#include "ui/ui.h"
 
-typedef struct prof_conn_t
-{
-    xmpp_log_t* xmpp_log;
-    xmpp_ctx_t* xmpp_ctx;
-    xmpp_conn_t* xmpp_conn;
+typedef struct prof_conn_t {
+    xmpp_log_t *xmpp_log;
+    xmpp_ctx_t *xmpp_ctx;
+    xmpp_conn_t *xmpp_conn;
     gboolean xmpp_in_event_loop;
     jabber_conn_status_t conn_status;
     xmpp_conn_event_t conn_last_event;
-    char* presence_message;
+    char *presence_message;
     int priority;
-    char* domain;
-    GHashTable* available_resources;
-    GHashTable* features_by_jid;
-    GHashTable* requested_features;
+    char *domain;
+    GHashTable *available_resources;
+    GHashTable *features_by_jid;
+    GHashTable *requested_features;
 } ProfConnection;
 
 static ProfConnection conn;
-static gchar* profanity_instance_id = NULL;
-static gchar* prof_identifier = NULL;
+static gchar *profanity_instance_id = NULL;
+static gchar *prof_identifier = NULL;
 
 static xmpp_log_t* _xmpp_get_file_logger(void);
-static void _xmpp_file_logger(void* const userdata, const xmpp_log_level_t level, const char* const area, const char* const msg);
+static void _xmpp_file_logger(void *const userdata, const xmpp_log_level_t level, const char *const area, const char *const msg);
 
-static void _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error,
-                                xmpp_stream_error_t* const stream_error, void* const userdata);
+static void _connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status, const int error,
+    xmpp_stream_error_t *const stream_error, void *const userdata);
 
 #ifdef HAVE_LIBMESODE
-TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert);
-static int _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg);
+TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t *xmpptlscert);
+static int _connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg);
 #endif
 
 static void _random_bytes_init(void);
 static void _random_bytes_close(void);
-static void _compute_identifier(const char* barejid);
+static void _compute_identifier(const char *barejid);
 
 void
 connection_init(void)
@@ -111,7 +110,7 @@ connection_init(void)
     conn.available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy);
     conn.requested_features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
 
-    _random_bytes_init();
+	_random_bytes_init();
 }
 
 void
@@ -131,19 +130,19 @@ connection_shutdown(void)
     free(conn.xmpp_log);
     conn.xmpp_log = NULL;
 
-    _random_bytes_close();
+	_random_bytes_close();
 }
 
 jabber_conn_status_t
-connection_connect(const char* const jid, const char* const passwd, const char* const altdomain, int port,
-                   const char* const tls_policy, const char* const auth_policy)
+connection_connect(const char *const jid, const char *const passwd, const char *const altdomain, int port,
+    const char *const tls_policy, const char *const auth_policy)
 {
     long flags;
 
     assert(jid != NULL);
     assert(passwd != NULL);
 
-    Jid* jidp = jid_create(jid);
+    Jid *jidp = jid_create(jid);
     if (jidp == NULL) {
         log_error("Malformed JID not able to connect: %s", jid);
         conn.conn_status = JABBER_DISCONNECTED;
@@ -207,10 +206,7 @@ connection_connect(const char* const jid, const char* const passwd, const char*
     /* Print debug logs that can help when users share the logs */
     if (flags != 0) {
         log_debug("Connecting with flags (0x%lx):", flags);
-#define LOG_FLAG_IF_SET(name)  \
-    if (flags & name) {        \
-        log_debug("  " #name); \
-    }
+#define LOG_FLAG_IF_SET(name) if (flags & name) { log_debug("  " #name); }
         LOG_FLAG_IF_SET(XMPP_CONN_FLAG_MANDATORY_TLS);
         LOG_FLAG_IF_SET(XMPP_CONN_FLAG_TRUST_TLS);
         LOG_FLAG_IF_SET(XMPP_CONN_FLAG_DISABLE_TLS);
@@ -222,7 +218,7 @@ connection_connect(const char* const jid, const char* const passwd, const char*
     }
 
 #ifdef HAVE_LIBMESODE
-    char* cert_path = prefs_get_tls_certpath();
+    char *cert_path = prefs_get_tls_certpath();
     if (cert_path) {
         xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path);
         free(cert_path);
@@ -315,8 +311,8 @@ connection_clear_data(void)
 TLSCertificate*
 connection_get_tls_peer_cert(void)
 {
-    xmpp_tlscert_t* xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn);
-    TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert);
+    xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn);
+    TLSCertificate *cert = _xmppcert_to_profcert(xmpptlscert);
     xmpp_conn_free_tlscert(conn.xmpp_ctx, xmpptlscert);
 
     return cert;
@@ -334,7 +330,7 @@ connection_is_secured(void)
 }
 
 gboolean
-connection_send_stanza(const char* const stanza)
+connection_send_stanza(const char *const stanza)
 {
     if (conn.conn_status != JABBER_CONNECTED) {
         return FALSE;
@@ -345,15 +341,15 @@ connection_send_stanza(const char* const stanza)
 }
 
 gboolean
-connection_supports(const char* const feature)
+connection_supports(const char *const feature)
 {
     gboolean ret = FALSE;
-    GList* jids = g_hash_table_get_keys(conn.features_by_jid);
+    GList *jids = g_hash_table_get_keys(conn.features_by_jid);
 
-    GList* curr = jids;
+    GList *curr = jids;
     while (curr) {
-        char* jid = curr->data;
-        GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid);
+        char *jid = curr->data;
+        GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid);
         if (features && g_hash_table_lookup(features, feature)) {
             ret = TRUE;
             break;
@@ -368,18 +364,18 @@ connection_supports(const char* const feature)
 }
 
 char*
-connection_jid_for_feature(const char* const feature)
+connection_jid_for_feature(const char *const feature)
 {
     if (conn.features_by_jid == NULL) {
         return NULL;
     }
 
-    GList* jids = g_hash_table_get_keys(conn.features_by_jid);
+    GList *jids = g_hash_table_get_keys(conn.features_by_jid);
 
-    GList* curr = jids;
+    GList *curr = jids;
     while (curr) {
-        char* jid = curr->data;
-        GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid);
+        char *jid = curr->data;
+        GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid);
         if (features && g_hash_table_lookup(features, feature)) {
             g_list_free(jids);
             return jid;
@@ -402,14 +398,14 @@ connection_request_features(void)
 }
 
 void
-connection_set_disco_items(GSList* items)
+connection_set_disco_items(GSList *items)
 {
-    GSList* curr = items;
+    GSList *curr = items;
     while (curr) {
-        DiscoItem* item = curr->data;
+        DiscoItem *item = curr->data;
         g_hash_table_insert(conn.requested_features, strdup(item->jid), NULL);
         g_hash_table_insert(conn.features_by_jid, strdup(item->jid),
-                            g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL));
+            g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL));
 
         iq_disco_info_request_onconnect(item->jid);
 
@@ -438,7 +434,7 @@ connection_get_ctx(void)
 const char*
 connection_get_fulljid(void)
 {
-    const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
+    const char *jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
     if (jid) {
         return jid;
     } else {
@@ -447,12 +443,11 @@ connection_get_fulljid(void)
 }
 
 char*
-connection_get_barejid(void)
-{
-    const char* jid = connection_get_fulljid();
-    char* result;
+connection_get_barejid(void) {
+    const char *jid = connection_get_fulljid();
+    char *result;
 
-    Jid* jidp = jid_create(jid);
+    Jid *jidp = jid_create(jid);
     result = strdup(jidp->barejid);
     jid_destroy(jidp);
 
@@ -460,7 +455,7 @@ connection_get_barejid(void)
 }
 
 void
-connection_features_received(const char* const jid)
+connection_features_received(const char *const jid)
 {
     if (g_hash_table_remove(conn.requested_features, jid) && g_hash_table_size(conn.requested_features) == 0) {
         sv_ev_connection_features_received();
@@ -468,7 +463,7 @@ connection_features_received(const char* const jid)
 }
 
 GHashTable*
-connection_get_features(const char* const jid)
+connection_get_features(const char *const jid)
 {
     return g_hash_table_lookup(conn.features_by_jid, jid);
 }
@@ -480,13 +475,13 @@ connection_get_available_resources(void)
 }
 
 void
-connection_add_available_resource(Resource* resource)
+connection_add_available_resource(Resource *resource)
 {
     g_hash_table_replace(conn.available_resources, strdup(resource->name), resource);
 }
 
 void
-connection_remove_available_resource(const char* const resource)
+connection_remove_available_resource(const char *const resource)
 {
     g_hash_table_remove(conn.available_resources, resource);
 }
@@ -498,7 +493,7 @@ connection_create_uuid(void)
 }
 
 void
-connection_free_uuid(char* uuid)
+connection_free_uuid(char *uuid)
 {
     if (uuid) {
         xmpp_free(conn.xmpp_ctx, uuid);
@@ -508,21 +503,21 @@ connection_free_uuid(char* uuid)
 char*
 connection_create_stanza_id(void)
 {
-    char* uuid = connection_create_uuid();
+    char *uuid = connection_create_uuid();
 
     assert(uuid != NULL);
 
-    gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
-                                            (guchar*)prof_identifier, strlen(prof_identifier),
-                                            uuid, strlen(uuid));
+    gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
+            (guchar*)prof_identifier, strlen(prof_identifier),
+            uuid, strlen(uuid));
 
-    GString* signature = g_string_new("");
+    GString *signature = g_string_new("");
     g_string_printf(signature, "%s%s", uuid, hmac);
 
     free(uuid);
     g_free(hmac);
 
-    char* b64 = g_base64_encode((unsigned char*)signature->str, signature->len);
+    char *b64 = g_base64_encode((unsigned char*)signature->str, signature->len);
     g_string_free(signature, TRUE);
 
     assert(b64 != NULL);
@@ -543,7 +538,7 @@ connection_get_presence_msg(void)
 }
 
 void
-connection_set_presence_msg(const char* const message)
+connection_set_presence_msg(const char *const message)
 {
     FREE_SET_NULL(conn.presence_message);
     if (message) {
@@ -558,8 +553,8 @@ connection_set_priority(const int priority)
 }
 
 static void
-_connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error,
-                    xmpp_stream_error_t* const stream_error, void* const userdata)
+_connection_handler(xmpp_conn_t *const xmpp_conn, const xmpp_conn_event_t status, const int error,
+    xmpp_stream_error_t *const stream_error, void *const userdata)
 {
     conn.conn_last_event = status;
 
@@ -570,7 +565,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
         log_debug("Connection handler: XMPP_CONN_CONNECT");
         conn.conn_status = JABBER_CONNECTED;
 
-        Jid* my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn));
+        Jid *my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn));
         conn.domain = strdup(my_jid->domainpart);
         jid_destroy(my_jid);
 
@@ -590,7 +585,7 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
             log_debug("Connection handler: Lost connection for unknown reason");
             session_lost_connection();
 
-            // login attempt failed
+        // login attempt failed
         } else if (conn.conn_status != JABBER_DISCONNECTING) {
             log_debug("Connection handler: Login failed");
             session_login_failed();
@@ -615,9 +610,9 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status
 
 #ifdef HAVE_LIBMESODE
 static int
-_connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg)
+_connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg)
 {
-    TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert);
+    TLSCertificate *cert = _xmppcert_to_profcert(xmpptlscert);
 
     int res = sv_ev_certfail(errormsg, cert);
     tlscerts_free(cert);
@@ -626,7 +621,7 @@ _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg)
 }
 
 TLSCertificate*
-_xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert)
+_xmppcert_to_profcert(xmpp_tlscert_t *xmpptlscert)
 {
     return tlscerts_new(
         xmpp_conn_tlscert_fingerprint(xmpptlscert),
@@ -648,21 +643,13 @@ _xmpp_get_file_logger(void)
     xmpp_log_level_t xmpp_level = XMPP_LEVEL_ERROR;
 
     switch (prof_level) {
-    case PROF_LEVEL_DEBUG:
-        xmpp_level = XMPP_LEVEL_DEBUG;
-        break;
-    case PROF_LEVEL_INFO:
-        xmpp_level = XMPP_LEVEL_INFO;
-        break;
-    case PROF_LEVEL_WARN:
-        xmpp_level = XMPP_LEVEL_WARN;
-        break;
-    default:
-        xmpp_level = XMPP_LEVEL_ERROR;
-        break;
+    case PROF_LEVEL_DEBUG:  xmpp_level = XMPP_LEVEL_DEBUG; break;
+    case PROF_LEVEL_INFO:   xmpp_level = XMPP_LEVEL_INFO;  break;
+    case PROF_LEVEL_WARN:   xmpp_level = XMPP_LEVEL_WARN;  break;
+    default:                xmpp_level = XMPP_LEVEL_ERROR; break;
     }
 
-    xmpp_log_t* file_log = malloc(sizeof(xmpp_log_t));
+    xmpp_log_t *file_log = malloc(sizeof(xmpp_log_t));
     file_log->handler = _xmpp_file_logger;
     file_log->userdata = &xmpp_level;
 
@@ -670,23 +657,15 @@ _xmpp_get_file_logger(void)
 }
 
 static void
-_xmpp_file_logger(void* const userdata, const xmpp_log_level_t xmpp_level, const char* const area, const char* const msg)
+_xmpp_file_logger(void *const userdata, const xmpp_log_level_t xmpp_level, const char *const area, const char *const msg)
 {
     log_level_t prof_level = PROF_LEVEL_ERROR;
 
     switch (xmpp_level) {
-    case XMPP_LEVEL_DEBUG:
-        prof_level = PROF_LEVEL_DEBUG;
-        break;
-    case XMPP_LEVEL_INFO:
-        prof_level = PROF_LEVEL_INFO;
-        break;
-    case XMPP_LEVEL_WARN:
-        prof_level = PROF_LEVEL_WARN;
-        break;
-    default:
-        prof_level = PROF_LEVEL_ERROR;
-        break;
+    case XMPP_LEVEL_DEBUG:  prof_level = PROF_LEVEL_DEBUG; break;
+    case XMPP_LEVEL_INFO:   prof_level = PROF_LEVEL_INFO;  break;
+    case XMPP_LEVEL_WARN:   prof_level = PROF_LEVEL_WARN;  break;
+    default:                prof_level = PROF_LEVEL_ERROR; break;
     }
 
     log_msg(prof_level, area, msg);
@@ -696,11 +675,10 @@ _xmpp_file_logger(void* const userdata, const xmpp_log_level_t xmpp_level, const
     }
 }
 
-static void
-_random_bytes_init(void)
+static void _random_bytes_init(void)
 {
-    char* rndbytes_loc;
-    GKeyFile* rndbytes;
+    char *rndbytes_loc;
+    GKeyFile *rndbytes;
 
     rndbytes_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER);
 
@@ -718,10 +696,10 @@ _random_bytes_init(void)
         g_key_file_set_string(rndbytes, "identifier", "random_bytes", profanity_instance_id);
 
         gsize g_data_size;
-        gchar* g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);
+        gchar *g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);
 
-        gchar* base = g_path_get_dirname(rndbytes_loc);
-        gchar* true_loc = get_file_or_linked(rndbytes_loc, base);
+        gchar *base = g_path_get_dirname(rndbytes_loc);
+        gchar *true_loc = get_file_or_linked(rndbytes_loc, base);
         g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
 
         g_free(base);
@@ -733,20 +711,18 @@ _random_bytes_init(void)
     g_key_file_free(rndbytes);
 }
 
-static void
-_random_bytes_close(void)
+static void _random_bytes_close(void)
 {
     g_free(profanity_instance_id);
 }
 
-static void
-_compute_identifier(const char* barejid)
+static void _compute_identifier(const char *barejid)
 {
-    gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
-                                            (guchar*)profanity_instance_id, strlen(profanity_instance_id),
-                                            barejid, strlen(barejid));
+    gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
+            (guchar*)profanity_instance_id, strlen(profanity_instance_id),
+            barejid, strlen(barejid));
 
-    char* b64 = g_base64_encode((guchar*)hmac, XMPP_SHA1_DIGEST_SIZE);
+    char *b64 = g_base64_encode((guchar*)hmac, XMPP_SHA1_DIGEST_SIZE);
     assert(b64 != NULL);
     g_free(hmac);
 
@@ -756,8 +732,6 @@ _compute_identifier(const char* barejid)
     prof_identifier = b64;
 }
 
-const char*
-connection_get_profanity_identifier(void)
-{
+const char* connection_get_profanity_identifier(void) {
     return prof_identifier;
 }
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index d638d037..016a9d92 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -42,26 +42,26 @@ void connection_init(void);
 void connection_shutdown(void);
 void connection_check_events(void);
 
-jabber_conn_status_t connection_connect(const char* const fulljid, const char* const passwd, const char* const altdomain, int port,
-                                        const char* const tls_policy, const char* const auth_policy);
+jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
+    const char *const tls_policy, const char *const auth_policy);
 void connection_disconnect(void);
 void connection_set_disconnected(void);
 
 void connection_set_priority(const int priority);
 void connection_set_priority(int priority);
-void connection_set_disco_items(GSList* items);
+void connection_set_disco_items(GSList *items);
 
 xmpp_conn_t* connection_get_conn(void);
 xmpp_ctx_t* connection_get_ctx(void);
-char* connection_get_domain(void);
+char *connection_get_domain(void);
 void connection_request_features(void);
-void connection_features_received(const char* const jid);
-GHashTable* connection_get_features(const char* const jid);
+void connection_features_received(const char *const jid);
+GHashTable* connection_get_features(const char *const jid);
 
 void connection_clear_data(void);
 
-void connection_add_available_resource(Resource* resource);
-void connection_remove_available_resource(const char* const resource);
+void connection_add_available_resource(Resource *resource);
+void connection_remove_available_resource(const char *const resource);
 
 char* connection_create_stanza_id(void);
 
diff --git a/src/xmpp/contact.c b/src/xmpp/contact.c
index d5cee18b..31568237 100644
--- a/src/xmpp/contact.c
+++ b/src/xmpp/contact.c
@@ -41,28 +41,27 @@
 
 #include "common.h"
 #include "tools/autocomplete.h"
-#include "xmpp/contact.h"
 #include "xmpp/resource.h"
+#include "xmpp/contact.h"
 
-struct p_contact_t
-{
-    char* barejid;
-    gchar* barejid_collate_key;
-    char* name;
-    gchar* name_collate_key;
-    GSList* groups;
-    char* subscription;
-    char* offline_message;
+struct p_contact_t {
+    char *barejid;
+    gchar *barejid_collate_key;
+    char *name;
+    gchar *name_collate_key;
+    GSList *groups;
+    char *subscription;
+    char *offline_message;
     gboolean pending_out;
-    GDateTime* last_activity;
-    GHashTable* available_resources;
+    GDateTime *last_activity;
+    GHashTable *available_resources;
     Autocomplete resource_ac;
 };
 
 PContact
-p_contact_new(const char* const barejid, const char* const name,
-              GSList* groups, const char* const subscription,
-              const char* const offline_message, gboolean pending_out)
+p_contact_new(const char *const barejid, const char *const name,
+    GSList *groups, const char *const subscription,
+    const char *const offline_message, gboolean pending_out)
 {
     PContact contact = malloc(sizeof(struct p_contact_t));
     contact->barejid = strdup(barejid);
@@ -92,7 +91,7 @@ p_contact_new(const char* const barejid, const char* const name,
     contact->last_activity = NULL;
 
     contact->available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free,
-                                                         (GDestroyNotify)resource_destroy);
+        (GDestroyNotify)resource_destroy);
 
     contact->resource_ac = autocomplete_new();
 
@@ -100,7 +99,7 @@ p_contact_new(const char* const barejid, const char* const name,
 }
 
 void
-p_contact_set_name(const PContact contact, const char* const name)
+p_contact_set_name(const PContact contact, const char *const name)
 {
     FREE_SET_NULL(contact->name);
     FREE_SET_NULL(contact->name_collate_key);
@@ -111,7 +110,7 @@ p_contact_set_name(const PContact contact, const char* const name)
 }
 
 void
-p_contact_set_groups(const PContact contact, GSList* groups)
+p_contact_set_groups(const PContact contact, GSList *groups)
 {
     if (contact->groups) {
         g_slist_free_full(contact->groups, g_free);
@@ -122,9 +121,9 @@ p_contact_set_groups(const PContact contact, GSList* groups)
 }
 
 gboolean
-p_contact_in_group(const PContact contact, const char* const group)
+p_contact_in_group(const PContact contact, const char *const group)
 {
-    GSList* groups = contact->groups;
+    GSList *groups = contact->groups;
     while (groups) {
         if (strcmp(groups->data, group) == 0) {
             return TRUE;
@@ -142,7 +141,7 @@ p_contact_groups(const PContact contact)
 }
 
 gboolean
-p_contact_remove_resource(PContact contact, const char* const resource)
+p_contact_remove_resource(PContact contact, const char *const resource)
 {
     gboolean result = g_hash_table_remove(contact->available_resources, resource);
     autocomplete_remove(contact->resource_ac, resource);
@@ -210,12 +209,12 @@ p_contact_name_or_jid(const PContact contact)
 }
 
 char*
-p_contact_create_display_string(const PContact contact, const char* const resource)
+p_contact_create_display_string(const PContact contact, const char *const resource)
 {
-    GString* result_str = g_string_new("");
+    GString *result_str = g_string_new("");
 
     // use nickname if exists
-    const char* display_name = p_contact_name_or_jid(contact);
+    const char *display_name = p_contact_name_or_jid(contact);
     g_string_append(result_str, display_name);
 
     // add resource if not default provided by profanity
@@ -225,14 +224,14 @@ p_contact_create_display_string(const PContact contact, const char* const resour
         g_string_append(result_str, ")");
     }
 
-    char* result = result_str->str;
+    char *result = result_str->str;
     g_string_free(result_str, FALSE);
 
     return result;
 }
 
 static Resource*
-_highest_presence(Resource* first, Resource* second)
+_highest_presence(Resource *first, Resource *second)
 {
     if (first->presence == RESOURCE_CHAT) {
         return first;
@@ -265,10 +264,10 @@ _get_most_available_resource(PContact contact)
     //      away
     //      xa
     //      dnd
-    GList* resources = g_hash_table_get_values(contact->available_resources);
-    GList* curr = resources;
-    Resource* current = curr->data;
-    Resource* highest = current;
+    GList *resources = g_hash_table_get_values(contact->available_resources);
+    GList *curr = resources;
+    Resource *current = curr->data;
+    Resource *highest = current;
     curr = g_list_next(curr);
     while (curr) {
         current = curr->data;
@@ -277,7 +276,7 @@ _get_most_available_resource(PContact contact)
         if (current->priority == highest->priority) {
             highest = _highest_presence(highest, current);
 
-            // priority higher than current highest, set new presence
+        // priority higher than current highest, set new presence
         } else if (current->priority > highest->priority) {
             highest = current;
         }
@@ -299,7 +298,7 @@ p_contact_presence(const PContact contact)
         return "offline";
     }
 
-    Resource* resource = _get_most_available_resource(contact);
+    Resource *resource = _get_most_available_resource(contact);
 
     return string_from_resource_presence(resource->presence);
 }
@@ -314,7 +313,7 @@ p_contact_status(const PContact contact)
         return contact->offline_message;
     }
 
-    Resource* resource = _get_most_available_resource(contact);
+    Resource *resource = _get_most_available_resource(contact);
 
     return resource->status;
 }
@@ -340,7 +339,7 @@ p_contact_subscribed(const PContact contact)
 }
 
 Resource*
-p_contact_get_resource(const PContact contact, const char* const resource)
+p_contact_get_resource(const PContact contact, const char *const resource)
 {
     return g_hash_table_lookup(contact->available_resources, resource);
 }
@@ -361,12 +360,12 @@ GList*
 p_contact_get_available_resources(const PContact contact)
 {
     assert(contact != NULL);
-    GList* resources = g_hash_table_get_values(contact->available_resources);
-    GList* ordered = NULL;
+    GList *resources = g_hash_table_get_values(contact->available_resources);
+    GList *ordered = NULL;
 
-    GList* curr_resource = resources;
+    GList *curr_resource = resources;
     while (curr_resource) {
-        Resource* resource = curr_resource->data;
+        Resource *resource = curr_resource->data;
         ordered = g_list_insert_sorted(ordered, resource, (GCompareFunc)resource_compare_availability);
         curr_resource = g_list_next(curr_resource);
     }
@@ -385,8 +384,9 @@ p_contact_is_available(const PContact contact)
     }
 
     // if most available resource is CHAT or ONLINE, available
-    Resource* most_available = _get_most_available_resource(contact);
-    if ((most_available->presence == RESOURCE_ONLINE) || (most_available->presence == RESOURCE_CHAT)) {
+    Resource *most_available = _get_most_available_resource(contact);
+    if ((most_available->presence == RESOURCE_ONLINE) ||
+        (most_available->presence == RESOURCE_CHAT)) {
         return TRUE;
     } else {
         return FALSE;
@@ -400,14 +400,14 @@ p_contact_has_available_resource(const PContact contact)
 }
 
 void
-p_contact_set_presence(const PContact contact, Resource* resource)
+p_contact_set_presence(const PContact contact, Resource *resource)
 {
     g_hash_table_replace(contact->available_resources, strdup(resource->name), resource);
     autocomplete_add(contact->resource_ac, resource->name);
 }
 
 void
-p_contact_set_subscription(const PContact contact, const char* const subscription)
+p_contact_set_subscription(const PContact contact, const char *const subscription)
 {
     FREE_SET_NULL(contact->subscription);
     if (subscription) {
@@ -422,7 +422,7 @@ p_contact_set_pending_out(const PContact contact, gboolean pending_out)
 }
 
 void
-p_contact_set_last_activity(const PContact contact, GDateTime* last_activity)
+p_contact_set_last_activity(const PContact contact, GDateTime *last_activity)
 {
     if (contact->last_activity) {
         g_date_time_unref(contact->last_activity);
diff --git a/src/xmpp/contact.h b/src/xmpp/contact.h
index 26e73c1d..28b6e60c 100644
--- a/src/xmpp/contact.h
+++ b/src/xmpp/contact.h
@@ -39,12 +39,12 @@
 #include "tools/autocomplete.h"
 #include "xmpp/resource.h"
 
-typedef struct p_contact_t* PContact;
+typedef struct p_contact_t *PContact;
 
-PContact p_contact_new(const char* const barejid, const char* const name, GSList* groups,
-                       const char* const subscription, const char* const offline_message, gboolean pending_out);
-void p_contact_add_resource(PContact contact, Resource* resource);
-gboolean p_contact_remove_resource(PContact contact, const char* const resource);
+PContact p_contact_new(const char *const barejid, const char *const name, GSList *groups,
+    const char *const subscription, const char *const offline_message, gboolean pending_out);
+void p_contact_add_resource(PContact contact, Resource *resource);
+gboolean p_contact_remove_resource(PContact contact, const char *const resource);
 void p_contact_free(PContact contact);
 const char* p_contact_barejid(PContact contact);
 const char* p_contact_barejid_collate_key(PContact contact);
@@ -57,20 +57,20 @@ const char* p_contact_subscription(const PContact contact);
 GList* p_contact_get_available_resources(const PContact contact);
 GDateTime* p_contact_last_activity(const PContact contact);
 gboolean p_contact_pending_out(const PContact contact);
-void p_contact_set_presence(const PContact contact, Resource* resource);
-void p_contact_set_status(const PContact contact, const char* const status);
-void p_contact_set_name(const PContact contact, const char* const name);
-void p_contact_set_subscription(const PContact contact, const char* const subscription);
+void p_contact_set_presence(const PContact contact, Resource *resource);
+void p_contact_set_status(const PContact contact, const char *const status);
+void p_contact_set_name(const PContact contact, const char *const name);
+void p_contact_set_subscription(const PContact contact, const char *const subscription);
 void p_contact_set_pending_out(const PContact contact, gboolean pending_out);
-void p_contact_set_last_activity(const PContact contact, GDateTime* last_activity);
+void p_contact_set_last_activity(const PContact contact, GDateTime *last_activity);
 gboolean p_contact_is_available(const PContact contact);
 gboolean p_contact_has_available_resource(const PContact contact);
-Resource* p_contact_get_resource(const PContact contact, const char* const resource);
-void p_contact_set_groups(const PContact contact, GSList* groups);
+Resource* p_contact_get_resource(const PContact contact, const char *const resource);
+void p_contact_set_groups(const PContact contact, GSList *groups);
 GSList* p_contact_groups(const PContact contact);
-gboolean p_contact_in_group(const PContact contact, const char* const group);
+gboolean p_contact_in_group(const PContact contact, const char *const group);
 gboolean p_contact_subscribed(const PContact contact);
-char* p_contact_create_display_string(const PContact contact, const char* const resource);
+char* p_contact_create_display_string(const PContact contact, const char *const resource);
 Autocomplete p_contact_resource_ac(const PContact contact);
 void p_contact_resource_ac_reset(const PContact contact);
 
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index 6bc0d7c6..0e778ad3 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -35,8 +35,8 @@
 
 #include "config.h"
 
-#include <stdlib.h>
 #include <string.h>
+#include <stdlib.h>
 
 #ifdef HAVE_LIBMESODE
 #include <mesode.h>
@@ -49,27 +49,30 @@
 #include <glib.h>
 
 #include "log.h"
-#include "xmpp/connection.h"
-#include "xmpp/stanza.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/stanza.h"
+#include "xmpp/connection.h"
 
 static gboolean
-_is_valid_form_element(xmpp_stanza_t* stanza)
+_is_valid_form_element(xmpp_stanza_t *stanza)
 {
-    const char* name = xmpp_stanza_get_name(stanza);
+    const char *name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(name, STANZA_NAME_X) != 0) {
         log_error("Error parsing form, root element not <x/>.");
         return FALSE;
     }
 
-    const char* ns = xmpp_stanza_get_ns(stanza);
+    const char *ns = xmpp_stanza_get_ns(stanza);
     if (g_strcmp0(ns, STANZA_NS_DATA) != 0) {
         log_error("Error parsing form, namespace not %s.", STANZA_NS_DATA);
         return FALSE;
     }
 
-    const char* type = xmpp_stanza_get_type(stanza);
-    if ((g_strcmp0(type, "form") != 0) && (g_strcmp0(type, "submit") != 0) && (g_strcmp0(type, "cancel") != 0) && (g_strcmp0(type, "result") != 0)) {
+    const char *type = xmpp_stanza_get_type(stanza);
+    if ((g_strcmp0(type, "form") != 0) &&
+            (g_strcmp0(type, "submit") != 0) &&
+            (g_strcmp0(type, "cancel") != 0) &&
+            (g_strcmp0(type, "result") != 0)) {
         log_error("Error parsing form, unknown type.");
         return FALSE;
     }
@@ -80,7 +83,7 @@ _is_valid_form_element(xmpp_stanza_t* stanza)
 static DataForm*
 _form_new(void)
 {
-    DataForm* form = calloc(1, sizeof(DataForm));
+    DataForm *form = calloc(1, sizeof(DataForm));
 
     return form;
 }
@@ -88,20 +91,20 @@ _form_new(void)
 static FormField*
 _field_new(void)
 {
-    FormField* field = calloc(1, sizeof(FormField));
+    FormField *field = calloc(1, sizeof(FormField));
 
     return field;
 }
 
 static char*
-_get_property(xmpp_stanza_t* const stanza, const char* const property)
+_get_property(xmpp_stanza_t *const stanza, const char *const property)
 {
-    char* result = NULL;
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    char *result = NULL;
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    xmpp_stanza_t* child = xmpp_stanza_get_child_by_name(stanza, property);
+    xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, property);
     if (child) {
-        char* child_text = xmpp_stanza_get_text(child);
+        char *child_text = xmpp_stanza_get_text(child);
         if (child_text) {
             result = strdup(child_text);
             xmpp_free(ctx, child_text);
@@ -112,9 +115,9 @@ _get_property(xmpp_stanza_t* const stanza, const char* const property)
 }
 
 static char*
-_get_attr(xmpp_stanza_t* const stanza, const char* const attr)
+_get_attr(xmpp_stanza_t *const stanza, const char *const attr)
 {
-    const char* result = xmpp_stanza_get_attribute(stanza, attr);
+    const char *result = xmpp_stanza_get_attribute(stanza, attr);
     if (result) {
         return strdup(result);
     } else {
@@ -123,9 +126,9 @@ _get_attr(xmpp_stanza_t* const stanza, const char* const attr)
 }
 
 static gboolean
-_is_required(xmpp_stanza_t* const stanza)
+_is_required(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* child = xmpp_stanza_get_child_by_name(stanza, "required");
+    xmpp_stanza_t *child = xmpp_stanza_get_child_by_name(stanza, "required");
     if (child) {
         return TRUE;
     } else {
@@ -134,7 +137,7 @@ _is_required(xmpp_stanza_t* const stanza)
 }
 
 static form_field_type_t
-_get_field_type(const char* const type)
+_get_field_type(const char *const type)
 {
     if (g_strcmp0(type, "hidden") == 0) {
         return FIELD_HIDDEN;
@@ -170,15 +173,15 @@ _get_field_type(const char* const type)
 }
 
 DataForm*
-form_create(xmpp_stanza_t* const form_stanza)
+form_create(xmpp_stanza_t *const form_stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
     if (!_is_valid_form_element(form_stanza)) {
         return NULL;
     }
 
-    DataForm* form = _form_new();
+    DataForm *form = _form_new();
     form->type = _get_attr(form_stanza, "type");
     form->title = _get_property(form_stanza, "title");
     form->instructions = _get_property(form_stanza, "instructions");
@@ -190,13 +193,13 @@ form_create(xmpp_stanza_t* const form_stanza)
     int tag_num = 1;
 
     // get fields
-    xmpp_stanza_t* form_child = xmpp_stanza_get_children(form_stanza);
+    xmpp_stanza_t *form_child = xmpp_stanza_get_children(form_stanza);
     while (form_child) {
-        const char* child_name = xmpp_stanza_get_name(form_child);
+        const char *child_name = xmpp_stanza_get_name(form_child);
         if (g_strcmp0(child_name, "field") == 0) {
-            xmpp_stanza_t* field_stanza = form_child;
+            xmpp_stanza_t *field_stanza = form_child;
 
-            FormField* field = _field_new();
+            FormField *field = _field_new();
             field->label = _get_attr(field_stanza, "label");
             field->type = _get_attr(field_stanza, "type");
             field->type_t = _get_field_type(field->type);
@@ -205,7 +208,7 @@ form_create(xmpp_stanza_t* const form_stanza)
             field->var = _get_attr(field_stanza, "var");
 
             if (field->type_t != FIELD_HIDDEN && field->var) {
-                GString* tag = g_string_new("");
+                GString *tag = g_string_new("");
                 g_string_printf(tag, "field%d", tag_num++);
                 g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str));
                 g_hash_table_insert(form->tag_to_var, strdup(tag->str), strdup(field->var));
@@ -217,19 +220,19 @@ form_create(xmpp_stanza_t* const form_stanza)
             field->required = _is_required(field_stanza);
 
             // handle repeated field children
-            xmpp_stanza_t* field_child = xmpp_stanza_get_children(field_stanza);
+            xmpp_stanza_t *field_child = xmpp_stanza_get_children(field_stanza);
             int value_index = 1;
             while (field_child) {
                 child_name = xmpp_stanza_get_name(field_child);
 
                 // handle values
                 if (g_strcmp0(child_name, "value") == 0) {
-                    char* value = xmpp_stanza_get_text(field_child);
+                    char *value = xmpp_stanza_get_text(field_child);
                     if (value) {
                         field->values = g_slist_append(field->values, strdup(value));
 
                         if (field->type_t == FIELD_TEXT_MULTI) {
-                            GString* ac_val = g_string_new("");
+                            GString *ac_val = g_string_new("");
                             g_string_printf(ac_val, "val%d", value_index++);
                             autocomplete_add(field->value_ac, ac_val->str);
                             g_string_free(ac_val, TRUE);
@@ -241,9 +244,9 @@ form_create(xmpp_stanza_t* const form_stanza)
                         xmpp_free(ctx, value);
                     }
 
-                    // handle options
+                // handle options
                 } else if (g_strcmp0(child_name, "option") == 0) {
-                    FormOption* option = malloc(sizeof(FormOption));
+                    FormOption *option = malloc(sizeof(FormOption));
                     option->label = _get_attr(field_child, "label");
                     option->value = _get_property(field_child, "value");
 
@@ -267,74 +270,74 @@ form_create(xmpp_stanza_t* const form_stanza)
 }
 
 xmpp_stanza_t*
-form_create_submission(DataForm* form)
+form_create_submission(DataForm *form)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_DATA);
     xmpp_stanza_set_type(x, "submit");
 
-    GSList* curr_field = form->fields;
+    GSList *curr_field = form->fields;
     while (curr_field) {
-        FormField* field = curr_field->data;
+        FormField *field = curr_field->data;
 
         if (field->type_t != FIELD_FIXED) {
-            xmpp_stanza_t* field_stanza = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *field_stanza = xmpp_stanza_new(ctx);
             xmpp_stanza_set_name(field_stanza, "field");
             xmpp_stanza_set_attribute(field_stanza, "var", field->var);
 
-            xmpp_stanza_t* value_stanza = NULL;
-            GSList* curr_value = NULL;
+            xmpp_stanza_t *value_stanza = NULL;
+            GSList *curr_value = NULL;
 
             switch (field->type_t) {
-            case FIELD_HIDDEN:
-            case FIELD_TEXT_SINGLE:
-            case FIELD_TEXT_PRIVATE:
-            case FIELD_BOOLEAN:
-            case FIELD_LIST_SINGLE:
-            case FIELD_JID_SINGLE:
-                value_stanza = xmpp_stanza_new(ctx);
-                xmpp_stanza_set_name(value_stanza, "value");
-                if (field->values) {
-                    if (field->values->data) {
-                        xmpp_stanza_t* text_stanza = xmpp_stanza_new(ctx);
-                        xmpp_stanza_set_text(text_stanza, field->values->data);
-                        xmpp_stanza_add_child(value_stanza, text_stanza);
-                        xmpp_stanza_release(text_stanza);
-                    }
-                }
-                xmpp_stanza_add_child(field_stanza, value_stanza);
-                xmpp_stanza_release(value_stanza);
-
-                break;
-
-            case FIELD_TEXT_MULTI:
-            case FIELD_LIST_MULTI:
-            case FIELD_JID_MULTI:
-                curr_value = field->values;
-                while (curr_value) {
-                    char* value = curr_value->data;
-
+                case FIELD_HIDDEN:
+                case FIELD_TEXT_SINGLE:
+                case FIELD_TEXT_PRIVATE:
+                case FIELD_BOOLEAN:
+                case FIELD_LIST_SINGLE:
+                case FIELD_JID_SINGLE:
                     value_stanza = xmpp_stanza_new(ctx);
                     xmpp_stanza_set_name(value_stanza, "value");
-                    if (value) {
-                        xmpp_stanza_t* text_stanza = xmpp_stanza_new(ctx);
-                        xmpp_stanza_set_text(text_stanza, value);
-                        xmpp_stanza_add_child(value_stanza, text_stanza);
-                        xmpp_stanza_release(text_stanza);
+                    if (field->values) {
+                        if (field->values->data) {
+                            xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
+                            xmpp_stanza_set_text(text_stanza, field->values->data);
+                            xmpp_stanza_add_child(value_stanza, text_stanza);
+                            xmpp_stanza_release(text_stanza);
+                        }
                     }
-
                     xmpp_stanza_add_child(field_stanza, value_stanza);
                     xmpp_stanza_release(value_stanza);
 
-                    curr_value = g_slist_next(curr_value);
-                }
-                break;
-            case FIELD_FIXED:
-            default:
-                break;
+                    break;
+
+                case FIELD_TEXT_MULTI:
+                case FIELD_LIST_MULTI:
+                case FIELD_JID_MULTI:
+                    curr_value = field->values;
+                    while (curr_value) {
+                        char *value = curr_value->data;
+
+                        value_stanza = xmpp_stanza_new(ctx);
+                        xmpp_stanza_set_name(value_stanza, "value");
+                        if (value) {
+                            xmpp_stanza_t *text_stanza = xmpp_stanza_new(ctx);
+                            xmpp_stanza_set_text(text_stanza, value);
+                            xmpp_stanza_add_child(value_stanza, text_stanza);
+                            xmpp_stanza_release(text_stanza);
+                        }
+
+                        xmpp_stanza_add_child(field_stanza, value_stanza);
+                        xmpp_stanza_release(value_stanza);
+
+                        curr_value = g_slist_next(curr_value);
+                    }
+                    break;
+                case FIELD_FIXED:
+                default:
+                    break;
             }
 
             xmpp_stanza_add_child(x, field_stanza);
@@ -348,7 +351,7 @@ form_create_submission(DataForm* form)
 }
 
 static void
-_free_option(FormOption* option)
+_free_option(FormOption *option)
 {
     if (option) {
         free(option->label);
@@ -358,7 +361,7 @@ _free_option(FormOption* option)
 }
 
 static void
-_free_field(FormField* field)
+_free_field(FormField *field)
 {
     if (field) {
         free(field->label);
@@ -373,7 +376,7 @@ _free_field(FormField* field)
 }
 
 void
-form_destroy(DataForm* form)
+form_destroy(DataForm *form)
 {
     if (form) {
         free(form->type);
@@ -388,18 +391,18 @@ form_destroy(DataForm* form)
 }
 
 static int
-_field_compare_by_var(FormField* a, FormField* b)
+_field_compare_by_var(FormField *a, FormField *b)
 {
     return g_strcmp0(a->var, b->var);
 }
 
 GSList*
-form_get_non_form_type_fields_sorted(DataForm* form)
+form_get_non_form_type_fields_sorted(DataForm *form)
 {
-    GSList* sorted = NULL;
-    GSList* curr = form->fields;
+    GSList *sorted = NULL;
+    GSList *curr = form->fields;
     while (curr) {
-        FormField* field = curr->data;
+        FormField *field = curr->data;
         if (g_strcmp0(field->var, "FORM_TYPE") != 0) {
             sorted = g_slist_insert_sorted(sorted, field, (GCompareFunc)_field_compare_by_var);
         }
@@ -410,12 +413,12 @@ form_get_non_form_type_fields_sorted(DataForm* form)
 }
 
 GSList*
-form_get_field_values_sorted(FormField* field)
+form_get_field_values_sorted(FormField *field)
 {
-    GSList* sorted = NULL;
-    GSList* curr = field->values;
+    GSList *sorted = NULL;
+    GSList *curr = field->values;
     while (curr) {
-        char* value = curr->data;
+        char *value = curr->data;
         if (value) {
             sorted = g_slist_insert_sorted(sorted, value, (GCompareFunc)g_strcmp0);
         }
@@ -426,11 +429,11 @@ form_get_field_values_sorted(FormField* field)
 }
 
 char*
-form_get_form_type_field(DataForm* form)
+form_get_form_type_field(DataForm *form)
 {
-    GSList* curr = form->fields;
+    GSList *curr = form->fields;
     while (curr) {
-        FormField* field = curr->data;
+        FormField *field = curr->data;
         if (g_strcmp0(field->var, "FORM_TYPE") == 0) {
             return field->values->data;
         }
@@ -441,10 +444,10 @@ form_get_form_type_field(DataForm* form)
 }
 
 gboolean
-form_tag_exists(DataForm* form, const char* const tag)
+form_tag_exists(DataForm *form, const char *const tag)
 {
-    GList* tags = g_hash_table_get_keys(form->tag_to_var);
-    GList* curr = tags;
+    GList *tags = g_hash_table_get_keys(form->tag_to_var);
+    GList *curr = tags;
     while (curr) {
         if (g_strcmp0(curr->data, tag) == 0) {
             return TRUE;
@@ -457,13 +460,13 @@ form_tag_exists(DataForm* form, const char* const tag)
 }
 
 form_field_type_t
-form_get_field_type(DataForm* form, const char* const tag)
+form_get_field_type(DataForm *form, const char *const tag)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 return field->type_t;
             }
@@ -474,13 +477,13 @@ form_get_field_type(DataForm* form, const char* const tag)
 }
 
 void
-form_set_value(DataForm* form, const char* const tag, char* value)
+form_set_value(DataForm *form, const char *const tag, char *value)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 if (g_slist_length(field->values) == 0) {
                     field->values = g_slist_append(field->values, strdup(value));
@@ -499,18 +502,18 @@ form_set_value(DataForm* form, const char* const tag, char* value)
 }
 
 void
-form_add_value(DataForm* form, const char* const tag, char* value)
+form_add_value(DataForm *form, const char *const tag, char *value)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 field->values = g_slist_append(field->values, strdup(value));
                 if (field->type_t == FIELD_TEXT_MULTI) {
                     int total = g_slist_length(field->values);
-                    GString* value_index = g_string_new("");
+                    GString *value_index = g_string_new("");
                     g_string_printf(value_index, "val%d", total);
                     autocomplete_add(field->value_ac, value_index->str);
                     g_string_free(value_index, TRUE);
@@ -524,15 +527,15 @@ form_add_value(DataForm* form, const char* const tag, char* value)
 }
 
 gboolean
-form_add_unique_value(DataForm* form, const char* const tag, char* value)
+form_add_unique_value(DataForm *form, const char *const tag, char *value)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
-                GSList* curr_value = field->values;
+                GSList *curr_value = field->values;
                 while (curr_value) {
                     if (g_strcmp0(curr_value->data, value) == 0) {
                         return FALSE;
@@ -555,15 +558,15 @@ form_add_unique_value(DataForm* form, const char* const tag, char* value)
 }
 
 gboolean
-form_remove_value(DataForm* form, const char* const tag, char* value)
+form_remove_value(DataForm *form, const char *const tag, char *value)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
-                GSList* found = g_slist_find_custom(field->values, value, (GCompareFunc)g_strcmp0);
+                GSList *found = g_slist_find_custom(field->values, value, (GCompareFunc)g_strcmp0);
                 if (found) {
                     free(found->data);
                     found->data = NULL;
@@ -585,22 +588,22 @@ form_remove_value(DataForm* form, const char* const tag, char* value)
 }
 
 gboolean
-form_remove_text_multi_value(DataForm* form, const char* const tag, int index)
+form_remove_text_multi_value(DataForm *form, const char *const tag, int index)
 {
     index--;
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
-                GSList* item = g_slist_nth(field->values, index);
+                GSList *item = g_slist_nth(field->values, index);
                 if (item) {
                     free(item->data);
                     item->data = NULL;
                     field->values = g_slist_delete_link(field->values, item);
-                    GString* value_index = g_string_new("");
-                    g_string_printf(value_index, "val%d", index + 1);
+                    GString *value_index = g_string_new("");
+                    g_string_printf(value_index, "val%d", index+1);
                     autocomplete_remove(field->value_ac, value_index->str);
                     g_string_free(value_index, TRUE);
                     form->modified = TRUE;
@@ -617,13 +620,13 @@ form_remove_text_multi_value(DataForm* form, const char* const tag, int index)
 }
 
 int
-form_get_value_count(DataForm* form, const char* const tag)
+form_get_value_count(DataForm *form, const char *const tag)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 if ((g_slist_length(field->values) == 1) && (field->values->data == NULL)) {
                     return 0;
@@ -639,17 +642,17 @@ form_get_value_count(DataForm* form, const char* const tag)
 }
 
 gboolean
-form_field_contains_option(DataForm* form, const char* const tag, char* value)
+form_field_contains_option(DataForm *form, const char *const tag, char *value)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
-                GSList* curr_option = field->options;
+                GSList *curr_option = field->options;
                 while (curr_option) {
-                    FormOption* option = curr_option->data;
+                    FormOption *option = curr_option->data;
                     if (g_strcmp0(option->value, value) == 0) {
                         return TRUE;
                     }
@@ -664,13 +667,13 @@ form_field_contains_option(DataForm* form, const char* const tag, char* value)
 }
 
 FormField*
-form_get_field_by_tag(DataForm* form, const char* const tag)
+form_get_field_by_tag(DataForm *form, const char *const tag)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 return field;
             }
@@ -681,13 +684,13 @@ form_get_field_by_tag(DataForm* form, const char* const tag)
 }
 
 Autocomplete
-form_get_value_ac(DataForm* form, const char* const tag)
+form_get_value_ac(DataForm *form, const char *const tag)
 {
-    char* var = g_hash_table_lookup(form->tag_to_var, tag);
+    char *var = g_hash_table_lookup(form->tag_to_var, tag);
     if (var) {
-        GSList* curr = form->fields;
+        GSList *curr = form->fields;
         while (curr) {
-            FormField* field = curr->data;
+            FormField *field = curr->data;
             if (g_strcmp0(field->var, var) == 0) {
                 return field->value_ac;
             }
@@ -698,12 +701,12 @@ form_get_value_ac(DataForm* form, const char* const tag)
 }
 
 void
-form_reset_autocompleters(DataForm* form)
+form_reset_autocompleters(DataForm *form)
 {
     autocomplete_reset(form->tag_ac);
-    GSList* curr_field = form->fields;
+    GSList *curr_field = form->fields;
     while (curr_field) {
-        FormField* field = curr_field->data;
+        FormField *field = curr_field->data;
         autocomplete_reset(field->value_ac);
         curr_field = g_slist_next(curr_field);
     }
diff --git a/src/xmpp/form.h b/src/xmpp/form.h
index b305addf..4b61b4c2 100644
--- a/src/xmpp/form.h
+++ b/src/xmpp/form.h
@@ -46,10 +46,10 @@
 
 #include "xmpp/xmpp.h"
 
-DataForm* form_create(xmpp_stanza_t* const stanza);
-xmpp_stanza_t* form_create_submission(DataForm* form);
-char* form_get_form_type_field(DataForm* form);
-GSList* form_get_non_form_type_fields_sorted(DataForm* form);
-GSList* form_get_field_values_sorted(FormField* field);
+DataForm* form_create(xmpp_stanza_t *const stanza);
+xmpp_stanza_t* form_create_submission(DataForm *form);
+char* form_get_form_type_field(DataForm *form);
+GSList* form_get_non_form_type_fields_sorted(DataForm *form);
+GSList* form_get_field_values_sorted(FormField *field);
 
 #endif
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 13fcd9ad..75bd73a1 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -39,10 +39,10 @@
 #include "gitversion.h"
 #endif
 
-#include <glib.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
+#include <glib.h>
 
 #ifdef HAVE_LIBMESODE
 #include <mesode.h>
@@ -52,120 +52,116 @@
 #include <strophe.h>
 #endif
 
+#include "profanity.h"
+#include "log.h"
 #include "config/preferences.h"
 #include "event/server_events.h"
-#include "log.h"
 #include "plugins/plugins.h"
-#include "profanity.h"
 #include "tools/http_upload.h"
 #include "ui/ui.h"
 #include "ui/window_list.h"
-#include "xmpp/blocking.h"
-#include "xmpp/capabilities.h"
+#include "xmpp/xmpp.h"
 #include "xmpp/connection.h"
-#include "xmpp/form.h"
+#include "xmpp/session.h"
 #include "xmpp/iq.h"
-#include "xmpp/muc.h"
-#include "xmpp/roster.h"
-#include "xmpp/roster_list.h"
+#include "xmpp/capabilities.h"
+#include "xmpp/blocking.h"
 #include "xmpp/session.h"
 #include "xmpp/stanza.h"
-#include "xmpp/xmpp.h"
+#include "xmpp/form.h"
+#include "xmpp/roster_list.h"
+#include "xmpp/roster.h"
+#include "xmpp/muc.h"
 
 #ifdef HAVE_OMEMO
 #include "omemo/omemo.h"
 #endif
 
-typedef struct p_room_info_data_t
-{
-    char* room;
+typedef struct p_room_info_data_t {
+    char *room;
     gboolean display;
 } ProfRoomInfoData;
 
-typedef struct p_iq_handle_t
-{
+typedef struct p_iq_handle_t {
     ProfIqCallback func;
     ProfIqFreeCallback free_func;
-    void* userdata;
+    void *userdata;
 } ProfIqHandler;
 
-typedef struct privilege_set_t
-{
-    char* item;
-    char* privilege;
+typedef struct privilege_set_t {
+    char *item;
+    char *privilege;
 } ProfPrivilegeSet;
 
-typedef struct affiliation_list_t
-{
-    char* affiliation;
+typedef struct affiliation_list_t {
+    char *affiliation;
     bool show_ui_message;
 } ProfAffiliationList;
 
-typedef struct command_config_data_t
-{
-    char* sessionid;
-    char* command;
+typedef struct command_config_data_t {
+    char *sessionid;
+    char *command;
 } CommandConfigData;
 
-static int _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata);
-
-static void _error_handler(xmpp_stanza_t* const stanza);
-static void _disco_info_get_handler(xmpp_stanza_t* const stanza);
-static void _disco_items_get_handler(xmpp_stanza_t* const stanza);
-static void _disco_items_result_handler(xmpp_stanza_t* const stanza);
-static void _last_activity_get_handler(xmpp_stanza_t* const stanza);
-static void _version_get_handler(xmpp_stanza_t* const stanza);
-static void _ping_get_handler(xmpp_stanza_t* const stanza);
-
-static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata);
-static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx);
-static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata);
-
-static void _iq_free_room_data(ProfRoomInfoData* roominfo);
-static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set);
-static void _iq_free_affiliation_list(ProfAffiliationList* affiliation_list);
-static void _iq_id_handler_free(ProfIqHandler* handler);
+static int _iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
+
+static void _error_handler(xmpp_stanza_t *const stanza);
+static void _disco_info_get_handler(xmpp_stanza_t *const stanza);
+static void _disco_items_get_handler(xmpp_stanza_t *const stanza);
+static void _disco_items_result_handler(xmpp_stanza_t *const stanza);
+static void _last_activity_get_handler(xmpp_stanza_t *const stanza);
+static void _version_get_handler(xmpp_stanza_t *const stanza);
+static void _ping_get_handler(xmpp_stanza_t *const stanza);
+
+static int _version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata);
+static int _http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const upload_ctx);
+static int _last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _enable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata);
+
+static void _iq_free_room_data(ProfRoomInfoData *roominfo);
+static void _iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set);
+static void _iq_free_affiliation_list(ProfAffiliationList *affiliation_list);
+static void _iq_id_handler_free(ProfIqHandler *handler);
 
 // scheduled
-static int _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata);
+static int _autoping_timed_send(xmpp_conn_t *const conn, void *const userdata);
 
-static void _identity_destroy(DiscoIdentity* identity);
-static void _item_destroy(DiscoItem* item);
+static void _identity_destroy(DiscoIdentity *identity);
+static void _item_destroy(DiscoItem *item);
 
 static gboolean autoping_wait = FALSE;
-static GTimer* autoping_time = NULL;
-static GHashTable* id_handlers;
-static GHashTable* rooms_cache = NULL;
+static GTimer *autoping_time = NULL;
+static GHashTable *id_handlers;
+static GHashTable *rooms_cache = NULL;
 
 static int
-_iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata)
+_iq_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
 {
     log_debug("iq stanza handler fired");
 
     iq_autoping_timer_cancel(); // reset the autoping timer
 
-    char* text;
+    char *text;
     size_t text_size;
     xmpp_stanza_to_text(stanza, &text, &text_size);
     gboolean cont = plugins_on_iq_stanza_receive(text);
@@ -174,18 +170,18 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
         return 1;
     }
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
         _error_handler(stanza);
     }
 
-    xmpp_stanza_t* discoinfo = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_INFO);
+    xmpp_stanza_t *discoinfo = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_INFO);
     if (discoinfo && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) {
         _disco_info_get_handler(stanza);
     }
 
-    xmpp_stanza_t* discoitems = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS);
+    xmpp_stanza_t *discoitems = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS);
     if (discoitems && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) {
         _disco_items_get_handler(stanza);
     }
@@ -193,22 +189,22 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
         _disco_items_result_handler(stanza);
     }
 
-    xmpp_stanza_t* lastactivity = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LASTACTIVITY);
+    xmpp_stanza_t *lastactivity = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LASTACTIVITY);
     if (lastactivity && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) {
         _last_activity_get_handler(stanza);
     }
 
-    xmpp_stanza_t* version = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_VERSION);
+    xmpp_stanza_t *version = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_VERSION);
     if (version && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) {
         _version_get_handler(stanza);
     }
 
-    xmpp_stanza_t* ping = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PING);
+    xmpp_stanza_t *ping = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PING);
     if (ping && (g_strcmp0(type, STANZA_TYPE_GET) == 0)) {
         _ping_get_handler(stanza);
     }
 
-    xmpp_stanza_t* roster = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_ROSTER);
+    xmpp_stanza_t *roster = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_ROSTER);
     if (roster && (g_strcmp0(type, STANZA_TYPE_SET) == 0)) {
         roster_set_handler(stanza);
     }
@@ -216,14 +212,14 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
         roster_result_handler(stanza);
     }
 
-    xmpp_stanza_t* blocking = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_BLOCKING);
+    xmpp_stanza_t *blocking = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_BLOCKING);
     if (blocking && (g_strcmp0(type, STANZA_TYPE_SET) == 0)) {
         blocked_set_handler(stanza);
     }
 
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
     if (id) {
-        ProfIqHandler* handler = g_hash_table_lookup(id_handlers, id);
+        ProfIqHandler *handler = g_hash_table_lookup(id_handlers, id);
         if (handler) {
             int keep = handler->func(stanza, handler->userdata);
             if (!keep) {
@@ -238,8 +234,8 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
 void
 iq_handlers_init(void)
 {
-    xmpp_conn_t* const conn = connection_get_conn();
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_conn_t * const conn = connection_get_conn();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
     xmpp_handler_add(conn, _iq_handler, NULL, STANZA_NAME_IQ, NULL, ctx);
 
     if (prefs_get_autoping() != 0) {
@@ -264,7 +260,7 @@ iq_handlers_clear()
 }
 
 static void
-_iq_id_handler_free(ProfIqHandler* handler)
+_iq_id_handler_free(ProfIqHandler *handler)
 {
     if (handler == NULL) {
         return;
@@ -276,9 +272,9 @@ _iq_id_handler_free(ProfIqHandler* handler)
 }
 
 void
-iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
+iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata)
 {
-    ProfIqHandler* handler = malloc(sizeof(ProfIqHandler));
+    ProfIqHandler *handler = malloc(sizeof(ProfIqHandler));
     handler->func = func;
     handler->free_func = free_func;
     handler->userdata = userdata;
@@ -329,7 +325,7 @@ iq_set_autoping(const int seconds)
         return;
     }
 
-    xmpp_conn_t* const conn = connection_get_conn();
+    xmpp_conn_t * const conn = connection_get_conn();
     xmpp_timed_handler_delete(conn, _autoping_timed_send);
 
     if (seconds == 0) {
@@ -337,7 +333,7 @@ iq_set_autoping(const int seconds)
     }
 
     int millis = seconds * 1000;
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
     xmpp_timed_handler_add(conn, _autoping_timed_send, millis, ctx);
 }
 
@@ -352,7 +348,7 @@ iq_rooms_cache_clear(void)
 }
 
 void
-iq_room_list_request(gchar* conferencejid, gchar* filter)
+iq_room_list_request(gchar *conferencejid, gchar *filter)
 {
     if (g_hash_table_contains(rooms_cache, conferencejid)) {
         log_debug("Rooms request cached for: %s", conferencejid);
@@ -362,9 +358,9 @@ iq_room_list_request(gchar* conferencejid, gchar* filter)
 
     log_debug("Rooms request not cached for: %s", conferencejid);
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, id, conferencejid, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, id, conferencejid, NULL);
 
     iq_id_handler_add(id, _room_list_id_handler, NULL, filter);
 
@@ -375,9 +371,9 @@ iq_room_list_request(gchar* conferencejid, gchar* filter)
 void
 iq_enable_carbons(void)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_enable_carbons(ctx);
-    const char* id = xmpp_stanza_get_id(iq);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_enable_carbons(ctx);
+    const char *id = xmpp_stanza_get_id(iq);
 
     iq_id_handler_add(id, _enable_carbons_id_handler, NULL, NULL);
 
@@ -388,9 +384,9 @@ iq_enable_carbons(void)
 void
 iq_disable_carbons(void)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_disable_carbons(ctx);
-    const char* id = xmpp_stanza_get_id(iq);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_disable_carbons(ctx);
+    const char *id = xmpp_stanza_get_id(iq);
 
     iq_id_handler_add(id, _disable_carbons_id_handler, NULL, NULL);
 
@@ -399,17 +395,17 @@ iq_disable_carbons(void)
 }
 
 void
-iq_http_upload_request(HTTPUpload* upload)
+iq_http_upload_request(HTTPUpload *upload)
 {
-    char* jid = connection_jid_for_feature(STANZA_NS_HTTP_UPLOAD);
+    char *jid = connection_jid_for_feature(STANZA_NS_HTTP_UPLOAD);
     if (jid == NULL) {
         cons_show_error("XEP-0363 HTTP File Upload is not supported by the server");
         return;
     }
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_http_upload_request(ctx, id, jid, upload);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_http_upload_request(ctx, id, jid, upload);
     iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload);
     free(id);
 
@@ -420,11 +416,11 @@ iq_http_upload_request(HTTPUpload* upload)
 }
 
 void
-iq_disco_info_request(gchar* jid)
+iq_disco_info_request(gchar *jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
 
     iq_id_handler_add(id, _disco_info_response_id_handler, NULL, NULL);
 
@@ -435,11 +431,11 @@ iq_disco_info_request(gchar* jid)
 }
 
 void
-iq_disco_info_request_onconnect(gchar* jid)
+iq_disco_info_request_onconnect(gchar *jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, jid, NULL);
 
     iq_id_handler_add(id, _disco_info_response_id_handler_onconnect, NULL, NULL);
 
@@ -450,11 +446,11 @@ iq_disco_info_request_onconnect(gchar* jid)
 }
 
 void
-iq_last_activity_request(gchar* jid)
+iq_last_activity_request(gchar *jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_last_activity_iq(ctx, id, jid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_last_activity_iq(ctx, id, jid);
 
     iq_id_handler_add(id, _last_activity_response_id_handler, NULL, NULL);
 
@@ -465,13 +461,13 @@ iq_last_activity_request(gchar* jid)
 }
 
 void
-iq_room_info_request(const char* const room, gboolean display_result)
+iq_room_info_request(const char *const room, gboolean display_result)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
 
-    ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData));
+    ProfRoomInfoData *cb_data = malloc(sizeof(ProfRoomInfoData));
     cb_data->room = strdup(room);
     cb_data->display = display_result;
 
@@ -484,10 +480,10 @@ iq_room_info_request(const char* const room, gboolean display_result)
 }
 
 void
-iq_send_caps_request_for_jid(const char* const to, const char* const id,
-                             const char* const node, const char* const ver)
+iq_send_caps_request_for_jid(const char *const to, const char *const id,
+    const char *const node, const char *const ver)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
     if (!node) {
         log_error("Could not create caps request, no node");
@@ -498,9 +494,9 @@ iq_send_caps_request_for_jid(const char* const to, const char* const id,
         return;
     }
 
-    GString* node_str = g_string_new("");
+    GString *node_str = g_string_new("");
     g_string_printf(node_str, "%s#%s", node, ver);
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
     g_string_free(node_str, TRUE);
 
     iq_id_handler_add(id, _caps_response_for_jid_id_handler, free, strdup(to));
@@ -510,10 +506,10 @@ iq_send_caps_request_for_jid(const char* const to, const char* const id,
 }
 
 void
-iq_send_caps_request(const char* const to, const char* const id,
-                     const char* const node, const char* const ver)
+iq_send_caps_request(const char *const to, const char *const id,
+    const char *const node, const char *const ver)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
     if (!node) {
         log_error("Could not create caps request, no node");
@@ -524,9 +520,9 @@ iq_send_caps_request(const char* const to, const char* const id,
         return;
     }
 
-    GString* node_str = g_string_new("");
+    GString *node_str = g_string_new("");
     g_string_printf(node_str, "%s#%s", node, ver);
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
     g_string_free(node_str, TRUE);
 
     iq_id_handler_add(id, _caps_response_id_handler, NULL, NULL);
@@ -536,10 +532,10 @@ iq_send_caps_request(const char* const to, const char* const id,
 }
 
 void
-iq_send_caps_request_legacy(const char* const to, const char* const id,
-                            const char* const node, const char* const ver)
+iq_send_caps_request_legacy(const char *const to, const char *const id,
+    const char *const node, const char *const ver)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
     if (!node) {
         log_error("Could not create caps request, no node");
@@ -550,9 +546,9 @@ iq_send_caps_request_legacy(const char* const to, const char* const id,
         return;
     }
 
-    GString* node_str = g_string_new("");
+    GString *node_str = g_string_new("");
     g_string_printf(node_str, "%s#%s", node, ver);
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, to, node_str->str);
 
     iq_id_handler_add(id, _caps_response_legacy_id_handler, g_free, node_str->str);
     g_string_free(node_str, FALSE);
@@ -562,30 +558,30 @@ iq_send_caps_request_legacy(const char* const to, const char* const id,
 }
 
 void
-iq_disco_items_request(gchar* jid)
+iq_disco_items_request(gchar *jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, "discoitemsreq", jid, NULL);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-iq_disco_items_request_onconnect(gchar* jid)
+iq_disco_items_request_onconnect(gchar *jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, "discoitemsreq_onconnect", jid, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, "discoitemsreq_onconnect", jid, NULL);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-iq_send_software_version(const char* const fulljid)
+iq_send_software_version(const char *const fulljid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_software_version_iq(ctx, fulljid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_software_version_iq(ctx, fulljid);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _version_result_id_handler, free, strdup(fulljid));
 
     iq_send_stanza(iq);
@@ -593,21 +589,21 @@ iq_send_software_version(const char* const fulljid)
 }
 
 void
-iq_confirm_instant_room(const char* const room_jid)
+iq_confirm_instant_room(const char *const room_jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_instant_room_request_iq(ctx, room_jid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_instant_room_request_iq(ctx, room_jid);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-iq_destroy_room(const char* const room_jid)
+iq_destroy_room(const char *const room_jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_instant_room_destroy_iq(ctx, room_jid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_instant_room_destroy_iq(ctx, room_jid);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _destroy_room_result_id_handler, NULL, NULL);
 
     iq_send_stanza(iq);
@@ -615,12 +611,12 @@ iq_destroy_room(const char* const room_jid)
 }
 
 void
-iq_request_room_config_form(const char* const room_jid)
+iq_request_room_config_form(const char *const room_jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_config_request_iq(ctx, room_jid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_config_request_iq(ctx, room_jid);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _room_config_id_handler, NULL, NULL);
 
     iq_send_stanza(iq);
@@ -628,12 +624,12 @@ iq_request_room_config_form(const char* const room_jid)
 }
 
 void
-iq_submit_room_config(ProfConfWin* confwin)
+iq_submit_room_config(ProfConfWin *confwin)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_config_submit_iq(ctx, confwin->roomjid, confwin->form);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_config_submit_iq(ctx, confwin->roomjid, confwin->form);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _room_config_submit_id_handler, NULL, NULL);
 
     iq_send_stanza(iq);
@@ -641,23 +637,23 @@ iq_submit_room_config(ProfConfWin* confwin)
 }
 
 void
-iq_room_config_cancel(ProfConfWin* confwin)
+iq_room_config_cancel(ProfConfWin *confwin)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui_message)
+iq_room_affiliation_list(const char *const room, char *affiliation, bool show_ui_message)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_affiliation_list_iq(ctx, room, affiliation);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_affiliation_list_iq(ctx, room, affiliation);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
 
-    ProfAffiliationList* affiliation_list = malloc(sizeof(ProfAffiliationList));
+    ProfAffiliationList *affiliation_list = malloc(sizeof(ProfAffiliationList));
     affiliation_list->affiliation = strdup(affiliation);
     affiliation_list->show_ui_message = show_ui_message;
 
@@ -668,12 +664,12 @@ iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui
 }
 
 void
-iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason)
+iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_kick_iq(ctx, room, nick, reason);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_kick_iq(ctx, room, nick, reason);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _room_kick_result_id_handler, free, strdup(nick));
 
     iq_send_stanza(iq);
@@ -681,15 +677,15 @@ iq_room_kick_occupant(const char* const room, const char* const nick, const char
 }
 
 void
-iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation,
-                        const char* const reason)
+iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation,
+    const char *const reason)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_affiliation_set_iq(ctx, room, jid, affiliation, reason);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_affiliation_set_iq(ctx, room, jid, affiliation, reason);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
 
-    ProfPrivilegeSet* affiliation_set = malloc(sizeof(struct privilege_set_t));
+    ProfPrivilegeSet *affiliation_set = malloc(sizeof(struct privilege_set_t));
     affiliation_set->item = strdup(jid);
     affiliation_set->privilege = strdup(affiliation);
 
@@ -700,15 +696,15 @@ iq_room_affiliation_set(const char* const room, const char* const jid, char* aff
 }
 
 void
-iq_room_role_set(const char* const room, const char* const nick, char* role,
-                 const char* const reason)
+iq_room_role_set(const char *const room, const char *const nick, char *role,
+    const char *const reason)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_role_set_iq(ctx, room, nick, role, reason);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_role_set_iq(ctx, room, nick, role, reason);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
 
-    struct privilege_set_t* role_set = malloc(sizeof(ProfPrivilegeSet));
+    struct privilege_set_t *role_set = malloc(sizeof(ProfPrivilegeSet));
     role_set->item = strdup(nick);
     role_set->privilege = strdup(role);
 
@@ -719,12 +715,12 @@ iq_room_role_set(const char* const room, const char* const nick, char* role,
 }
 
 void
-iq_room_role_list(const char* const room, char* role)
+iq_room_role_list(const char *const room, char *role)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_room_role_list_iq(ctx, room, role);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_room_role_list_iq(ctx, room, role);
 
-    const char* id = xmpp_stanza_get_id(iq);
+    const char *id = xmpp_stanza_get_id(iq);
     iq_id_handler_add(id, _room_role_list_result_id_handler, free, strdup(role));
 
     iq_send_stanza(iq);
@@ -732,13 +728,13 @@ iq_room_role_list(const char* const room, char* role)
 }
 
 void
-iq_send_ping(const char* const target)
+iq_send_ping(const char *const target)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_ping_iq(ctx, target);
-    const char* id = xmpp_stanza_get_id(iq);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_ping_iq(ctx, target);
+    const char *id = xmpp_stanza_get_id(iq);
 
-    GDateTime* now = g_date_time_new_now_local();
+    GDateTime *now = g_date_time_new_now_local();
     iq_id_handler_add(id, _manual_pong_id_handler, (ProfIqFreeCallback)g_date_time_unref, now);
 
     iq_send_stanza(iq);
@@ -746,11 +742,11 @@ iq_send_ping(const char* const target)
 }
 
 void
-iq_command_list(const char* const target)
+iq_command_list(const char *const target)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    const char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_disco_items_iq(ctx, id, target, STANZA_NS_COMMAND);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    const char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_disco_items_iq(ctx, id, target, STANZA_NS_COMMAND);
 
     iq_id_handler_add(id, _command_list_result_handler, NULL, NULL);
 
@@ -759,11 +755,11 @@ iq_command_list(const char* const target)
 }
 
 void
-iq_command_exec(const char* const target, const char* const command)
+iq_command_exec(const char *const target, const char *const command)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_command_exec_iq(ctx, target, command);
-    const char* id = xmpp_stanza_get_id(iq);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_command_exec_iq(ctx, target, command);
+    const char *id = xmpp_stanza_get_id(iq);
 
     iq_id_handler_add(id, _command_exec_response_handler, free, strdup(command));
 
@@ -772,14 +768,14 @@ iq_command_exec(const char* const target, const char* const command)
 }
 
 void
-iq_submit_command_config(ProfConfWin* confwin)
+iq_submit_command_config(ProfConfWin *confwin)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    CommandConfigData* data = (CommandConfigData*)confwin->userdata;
-    xmpp_stanza_t* iq = stanza_create_command_config_submit_iq(ctx, confwin->roomjid, data->command, data->sessionid, confwin->form);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    CommandConfigData *data = (CommandConfigData *)confwin->userdata;
+    xmpp_stanza_t *iq = stanza_create_command_config_submit_iq(ctx, confwin->roomjid, data->command, data->sessionid, confwin->form);
 
-    const char* id = xmpp_stanza_get_id(iq);
-    iq_id_handler_add(id, _command_exec_response_handler, free, strdup(data->command));
+    const char *id = xmpp_stanza_get_id(iq);
+    iq_id_handler_add(id,  _command_exec_response_handler, free, strdup(data->command));
 
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
@@ -789,11 +785,11 @@ iq_submit_command_config(ProfConfWin* confwin)
 }
 
 void
-iq_cancel_command_config(ProfConfWin* confwin)
+iq_cancel_command_config(ProfConfWin *confwin)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    CommandConfigData* data = (CommandConfigData*)confwin->userdata;
-    xmpp_stanza_t* iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    CommandConfigData *data = (CommandConfigData *)confwin->userdata;
+    xmpp_stanza_t *iq = stanza_create_room_config_cancel_iq(ctx, confwin->roomjid);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
     free(data->sessionid);
@@ -802,10 +798,10 @@ iq_cancel_command_config(ProfConfWin* confwin)
 }
 
 static void
-_error_handler(xmpp_stanza_t* const stanza)
+_error_handler(xmpp_stanza_t *const stanza)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    char* error_msg = stanza_get_error_message(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
+    char *error_msg = stanza_get_error_message(stanza);
 
     if (id) {
         log_debug("IQ error handler fired, id: %s, error: %s", id, error_msg);
@@ -819,12 +815,12 @@ _error_handler(xmpp_stanza_t* const stanza)
 }
 
 static int
-_caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    const char *id = xmpp_stanza_get_id(stanza);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     // ignore non result
     if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) {
         return 1;
@@ -836,7 +832,7 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         log_debug("Capabilities response handler fired");
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_info("_caps_response_id_handler(): No from attribute");
         return 0;
@@ -844,7 +840,7 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_warning("Error received for capabilities response from %s: ", from, error_message);
         free(error_message);
         return 0;
@@ -855,16 +851,16 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 0;
     }
 
-    const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
+    const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
     if (node == NULL) {
         log_info("_caps_response_id_handler(): No node attribute found");
         return 0;
     }
 
     // validate sha1
-    gchar** split = g_strsplit(node, "#", -1);
-    char* given_sha1 = split[1];
-    char* generated_sha1 = stanza_create_caps_sha1_from_query(query);
+    gchar **split = g_strsplit(node, "#", -1);
+    char *given_sha1 = split[1];
+    char *generated_sha1 = stanza_create_caps_sha1_from_query(query);
 
     if (g_strcmp0(given_sha1, generated_sha1) != 0) {
         log_warning("Generated sha-1 does not match given:");
@@ -877,7 +873,7 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
             log_debug("Capabilties already cached: %s", given_sha1);
         } else {
             log_debug("Capabilities not cached: %s, storing", given_sha1);
-            EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
+            EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query);
             caps_add_by_ver(given_sha1, capabilities);
             caps_destroy(capabilities);
         }
@@ -892,13 +888,13 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    char* jid = (char*)userdata;
-    const char* id = xmpp_stanza_get_id(stanza);
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    char *jid = (char *)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     // ignore non result
     if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) {
         return 1;
@@ -910,7 +906,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userd
         log_debug("Capabilities response handler fired");
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         if (jid) {
             log_info("_caps_response_for_jid_id_handler(): No from attribute for %s", jid);
@@ -922,7 +918,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userd
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_warning("Error received for capabilities response from %s: ", from, error_message);
         free(error_message);
         return 0;
@@ -937,7 +933,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userd
         return 0;
     }
 
-    const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
+    const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
     if (node == NULL) {
         if (jid) {
             log_info("_caps_response_for_jid_id_handler(): No node attribute found for %s", jid);
@@ -948,20 +944,20 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t* const stanza, void* const userd
     }
 
     log_debug("Associating capabilities with: %s", jid);
-    EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
+    EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query);
     caps_add_by_jid(jid, capabilities);
 
     return 0;
 }
 
 static int
-_caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-    char* expected_node = (char*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    char *expected_node = (char *)userdata;
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     // ignore non result
     if ((g_strcmp0(type, "get") == 0) || (g_strcmp0(type, "set") == 0)) {
         return 1;
@@ -973,7 +969,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
         log_debug("Capabilities response handler fired");
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_info("_caps_response_legacy_id_handler(): No from attribute");
         return 0;
@@ -981,7 +977,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_warning("Error received for capabilities response from %s: ", from, error_message);
         free(error_message);
         return 0;
@@ -992,7 +988,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
         return 0;
     }
 
-    const char* node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
+    const char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
     if (node == NULL) {
         log_info("_caps_response_legacy_id_handler(): No node attribute found");
         return 0;
@@ -1005,14 +1001,14 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
             log_debug("Capabilties already cached: %s", node);
         } else {
             log_debug("Capabilities not cached: %s, storing", node);
-            EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
+            EntityCapabilities *capabilities = stanza_create_caps_from_query_element(query);
             caps_add_by_ver(node, capabilities);
             caps_destroy(capabilities);
         }
 
         caps_map_jid_to_ver(from, node);
 
-        // node match fail
+    // node match fail
     } else {
         log_info("Legacy Capabilities nodes do not match, expeceted %s, given %s.", expected_node, node);
     }
@@ -1021,11 +1017,11 @@ _caps_response_legacy_id_handler(xmpp_stanza_t* const stanza, void* const userda
 }
 
 static int
-_room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_list_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    gchar* filter = (gchar*)userdata;
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    gchar *filter = (gchar*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (prefs_get_boolean(PREF_ROOM_LIST_CACHE) && !g_hash_table_contains(rooms_cache, from)) {
         g_hash_table_insert(rooms_cache, strdup(from), xmpp_stanza_copy(stanza));
@@ -1033,7 +1029,7 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     log_debug("Response to query: %s", id);
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
     if (query == NULL) {
         return 0;
     }
@@ -1044,16 +1040,16 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
     } else {
         cons_show("Rooms list response received: %s", from);
     }
-    xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+    xmpp_stanza_t *child = xmpp_stanza_get_children(query);
     if (child == NULL) {
         cons_show("  No rooms found.");
         return 0;
     }
 
-    GPatternSpec* glob = NULL;
+    GPatternSpec *glob = NULL;
     if (filter != NULL) {
-        gchar* filter_lower = g_utf8_strdown(filter, -1);
-        GString* glob_str = g_string_new("*");
+        gchar *filter_lower = g_utf8_strdown(filter, -1);
+        GString *glob_str = g_string_new("*");
         g_string_append(glob_str, filter_lower);
         g_string_append(glob_str, "*");
         glob = g_pattern_spec_new(glob_str->str);
@@ -1062,28 +1058,30 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     gboolean matched = FALSE;
     while (child) {
-        const char* stanza_name = xmpp_stanza_get_name(child);
+        const char *stanza_name = xmpp_stanza_get_name(child);
         if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
-            const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
-            gchar* item_jid_lower = NULL;
+            const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+            gchar *item_jid_lower = NULL;
             if (item_jid) {
-                Jid* jidp = jid_create(item_jid);
+                Jid *jidp = jid_create(item_jid);
                 if (jidp && jidp->localpart) {
                     item_jid_lower = g_utf8_strdown(jidp->localpart, -1);
                 }
                 jid_destroy(jidp);
             }
-            const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
-            gchar* item_name_lower = NULL;
+            const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+            gchar *item_name_lower = NULL;
             if (item_name) {
                 item_name_lower = g_utf8_strdown(item_name, -1);
             }
-            if ((item_jid_lower) && ((glob == NULL) || ((g_pattern_match(glob, strlen(item_jid_lower), item_jid_lower, NULL)) || (item_name_lower && g_pattern_match(glob, strlen(item_name_lower), item_name_lower, NULL))))) {
+            if ((item_jid_lower) && ((glob == NULL) ||
+                ((g_pattern_match(glob, strlen(item_jid_lower), item_jid_lower, NULL)) ||
+                (item_name_lower && g_pattern_match(glob, strlen(item_name_lower), item_name_lower, NULL))))) {
 
                 if (glob) {
                     matched = TRUE;
                 }
-                GString* item = g_string_new(item_jid);
+                GString *item = g_string_new(item_jid);
                 if (item_name) {
                     g_string_append(item, " (");
                     g_string_append(item, item_name);
@@ -1110,11 +1108,11 @@ _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_command_list_result_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    char* from = strdup(xmpp_stanza_get_from(stanza));
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    char *from = strdup(xmpp_stanza_get_from(stanza));
 
     if (id) {
         log_debug("IQ command list result handler fired, id: %s.", id);
@@ -1124,9 +1122,9 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error retrieving command list for %s: %s", from, error_message);
-        ProfWin* win = wins_get_by_string(from);
+        ProfWin *win = wins_get_by_string(from);
         if (win) {
             win_command_list_error(win, error_message);
         }
@@ -1135,15 +1133,15 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 0;
     }
 
-    GSList* cmds = NULL;
+    GSList *cmds = NULL;
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, XMPP_NS_DISCO_ITEMS);
     if (query) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
         while (child) {
-            const char* name = xmpp_stanza_get_name(child);
+            const char *name = xmpp_stanza_get_name(child);
             if (g_strcmp0(name, "item") == 0) {
-                const char* node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
+                const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
                 if (node) {
                     cmds = g_slist_insert_sorted(cmds, (gpointer)node, (GCompareFunc)g_strcmp0);
                 }
@@ -1152,9 +1150,9 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
         }
     }
 
-    ProfWin* win = wins_get_by_string(from);
+    ProfWin *win = wins_get_by_string(from);
     if (win == NULL) {
-        win = wins_get_console();
+	    win = wins_get_console();
     }
 
     win_handle_command_list(win, cmds);
@@ -1165,12 +1163,12 @@ _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    char* command = userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    char *command = userdata;
 
     if (id) {
         log_debug("IQ command exec response handler fired, id: %s.", id);
@@ -1178,7 +1176,7 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
         log_debug("IQ command exec response handler fired.");
     }
 
-    ProfWin* win = wins_get_by_string(from);
+    ProfWin *win = wins_get_by_string(from);
     if (win == NULL) {
         /* No more window associated with this command.
          * Fallback to console. */
@@ -1187,44 +1185,45 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error executing command %s for %s: %s", command, from, error_message);
         win_command_exec_error(win, command, error_message);
         free(error_message);
         return 0;
     }
 
-    xmpp_stanza_t* cmd = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_COMMAND);
+    xmpp_stanza_t *cmd = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_COMMAND);
     if (!cmd) {
         log_error("No command element for command response");
         win_command_exec_error(win, command, "Malformed command response");
         return 0;
     }
 
-    const char* status = xmpp_stanza_get_attribute(cmd, STANZA_ATTR_STATUS);
+
+    const char *status = xmpp_stanza_get_attribute(cmd, STANZA_ATTR_STATUS);
     if (g_strcmp0(status, "completed") == 0) {
         win_handle_command_exec_status(win, command, "completed");
-        xmpp_stanza_t* note = xmpp_stanza_get_child_by_name(cmd, "note");
+        xmpp_stanza_t *note = xmpp_stanza_get_child_by_name(cmd, "note");
         if (note) {
-            const char* type = xmpp_stanza_get_attribute(note, "type");
-            const char* value = xmpp_stanza_get_text(note);
+            const char *type = xmpp_stanza_get_attribute(note, "type");
+            const char *value = xmpp_stanza_get_text(note);
             win_handle_command_exec_result_note(win, type, value);
         }
-        xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA);
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA);
         if (x) {
-            xmpp_stanza_t* roster = xmpp_stanza_get_child_by_ns(x, XMPP_NS_ROSTER);
+            xmpp_stanza_t *roster = xmpp_stanza_get_child_by_ns(x, XMPP_NS_ROSTER);
             if (roster) {
                 /* Special handling of xep-0133 roster in response */
-                GSList* list = NULL;
-                xmpp_stanza_t* child = xmpp_stanza_get_children(roster);
+                GSList *list = NULL;
+                xmpp_stanza_t *child = xmpp_stanza_get_children(roster);
                 while (child) {
-                    const char* barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
-                    gchar* barejid_lower = g_utf8_strdown(barejid, -1);
-                    const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
-                    const char* sub = xmpp_stanza_get_attribute(child, STANZA_ATTR_SUBSCRIPTION);
-                    const char* ask = xmpp_stanza_get_attribute(child, STANZA_ATTR_ASK);
+                    const char *barejid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+                    gchar *barejid_lower = g_utf8_strdown(barejid, -1);
+                    const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+                    const char *sub = xmpp_stanza_get_attribute(child, STANZA_ATTR_SUBSCRIPTION);
+                    const char *ask = xmpp_stanza_get_attribute(child, STANZA_ATTR_ASK);
 
-                    GSList* groups = NULL;
+                    GSList *groups = NULL;
                     groups = roster_get_groups_from_item(child);
 
                     gboolean pending_out = FALSE;
@@ -1240,8 +1239,8 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
                 cons_show_roster(list);
                 g_slist_free(list);
             } else {
-                DataForm* form = form_create(x);
-                ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, NULL, NULL, NULL);
+                DataForm *form = form_create(x);
+                ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, NULL, NULL, NULL);
                 confwin_handle_configuration(confwin, form);
             }
         }
@@ -1249,35 +1248,35 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
         win_handle_command_exec_status(win, command, "executing");
 
         /* Looking for a jabber:x:data type form */
-        xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA);
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(cmd, STANZA_NS_DATA);
         if (x == NULL) {
             return 0;
         }
 
-        const char* form_type = xmpp_stanza_get_type(x);
+        const char *form_type = xmpp_stanza_get_type(x);
         if (g_strcmp0(form_type, "form") != 0) {
             log_error("Unsupported payload in command response");
             win_command_exec_error(win, command, "Unsupported command response");
             return 0;
         }
-        const char* sessionid = xmpp_stanza_get_attribute(cmd, "sessionid");
+        const char *sessionid = xmpp_stanza_get_attribute(cmd, "sessionid");
 
-        DataForm* form = form_create(x);
-        CommandConfigData* data = malloc(sizeof(CommandConfigData));
+        DataForm *form = form_create(x);
+        CommandConfigData *data = malloc(sizeof(CommandConfigData));
         if (sessionid == NULL) {
             data->sessionid = NULL;
         } else {
             data->sessionid = strdup(sessionid);
         }
         data->command = strdup(command);
-        ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_command_config, iq_cancel_command_config, data);
+        ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_command_config, iq_cancel_command_config, data);
         confwin_handle_configuration(confwin, form);
     } else if (g_strcmp0(status, "canceled") == 0) {
         win_handle_command_exec_status(win, command, "canceled");
-        xmpp_stanza_t* note = xmpp_stanza_get_child_by_name(cmd, "note");
+        xmpp_stanza_t *note = xmpp_stanza_get_child_by_name(cmd, "note");
         if (note) {
-            const char* type = xmpp_stanza_get_attribute(note, "type");
-            const char* value = xmpp_stanza_get_text(note);
+            const char *type = xmpp_stanza_get_attribute(note, "type");
+            const char *value = xmpp_stanza_get_text(note);
             win_handle_command_exec_result_note(win, type, value);
         }
     } else {
@@ -1289,11 +1288,11 @@ _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata
 }
 
 static int
-_enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_enable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, "error") == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         cons_show_error("Server error enabling message carbons: %s", error_message);
         log_debug("Error enabling carbons: %s", error_message);
         free(error_message);
@@ -1305,11 +1304,11 @@ _enable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_disable_carbons_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, "error") == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         cons_show_error("Server error disabling message carbons: %s", error_message);
         log_debug("Error disabling carbons: %s", error_message);
         free(error_message);
@@ -1321,15 +1320,15 @@ _disable_carbons_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_manual_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    GDateTime* sent = (GDateTime*)userdata;
+    const char *from = xmpp_stanza_get_from(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    GDateTime *sent = (GDateTime *)userdata;
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         if (!error_message) {
             cons_show_error("Error returned from pinging %s.", from);
         } else {
@@ -1340,7 +1339,7 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 0;
     }
 
-    GDateTime* now = g_date_time_new_now_local();
+    GDateTime *now = g_date_time_new_now_local();
 
     GTimeSpan elapsed = g_date_time_difference(now, sent);
     int elapsed_millis = elapsed / 1000;
@@ -1357,7 +1356,7 @@ _manual_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
+_autoping_timed_send(xmpp_conn_t *const conn, void *const userdata)
 {
     if (connection_get_status() != JABBER_CONNECTED) {
         return 1;
@@ -1367,7 +1366,7 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
         log_warning("Server doesn't advertise %s feature, disabling autoping.", XMPP_FEATURE_PING);
         prefs_set_autoping(0);
         cons_show_error("Server ping not supported, autoping disabled.");
-        xmpp_conn_t* conn = connection_get_conn();
+        xmpp_conn_t *conn = connection_get_conn();
         xmpp_timed_handler_delete(conn, _autoping_timed_send);
         return 1;
     }
@@ -1377,9 +1376,9 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
         return 1;
     }
 
-    xmpp_ctx_t* ctx = (xmpp_ctx_t*)userdata;
-    xmpp_stanza_t* iq = stanza_create_ping_iq(ctx, NULL);
-    const char* id = xmpp_stanza_get_id(iq);
+    xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
+    xmpp_stanza_t *iq = stanza_create_ping_iq(ctx, NULL);
+    const char *id = xmpp_stanza_get_id(iq);
     log_debug("Autoping: Sending ping request: %s", id);
 
     // add pong handler
@@ -1397,11 +1396,11 @@ _autoping_timed_send(xmpp_conn_t* const conn, void* const userdata)
 }
 
 static int
-_auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_auto_pong_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
     iq_autoping_timer_cancel();
 
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
     if (id == NULL) {
         log_debug("Autoping: Pong handler fired.");
         return 0;
@@ -1409,7 +1408,7 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     log_debug("Autoping: Pong handler fired: %s.", id);
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (type == NULL) {
         return 0;
     }
@@ -1418,16 +1417,16 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
     }
 
     // show warning if error
-    char* error_msg = stanza_get_error_message(stanza);
+    char *error_msg = stanza_get_error_message(stanza);
     log_warning("Server ping (id=%s) responded with error: %s", id, error_msg);
     free(error_msg);
 
     // turn off autoping if error type is 'cancel'
-    xmpp_stanza_t* error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
     if (error == NULL) {
         return 0;
     }
-    const char* errtype = xmpp_stanza_get_type(error);
+    const char *errtype = xmpp_stanza_get_type(error);
     if (errtype == NULL) {
         return 0;
     }
@@ -1435,7 +1434,7 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         log_warning("Server ping (id=%s) error type 'cancel', disabling autoping.", id);
         prefs_set_autoping(0);
         cons_show_error("Server ping not supported, autoping disabled.");
-        xmpp_conn_t* conn = connection_get_conn();
+        xmpp_conn_t *conn = connection_get_conn();
         xmpp_timed_handler_delete(conn, _autoping_timed_send);
     }
 
@@ -1443,9 +1442,9 @@ _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_version_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
 
     if (id) {
         log_debug("IQ version result handler fired, id: %s.", id);
@@ -1453,12 +1452,12 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         log_debug("IQ version result handler fired.");
     }
 
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_RESULT) != 0) {
         if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-            char* error_message = stanza_get_error_message(stanza);
+            char *error_message = stanza_get_error_message(stanza);
             ui_handle_software_version_error(from, error_message);
             free(error_message);
         } else {
@@ -1469,26 +1468,26 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 0;
     }
 
-    const char* jid = xmpp_stanza_get_from(stanza);
+    const char *jid = xmpp_stanza_get_from(stanza);
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
     if (query == NULL) {
         log_error("Software version result received with no query element.");
         return 0;
     }
 
-    const char* ns = xmpp_stanza_get_ns(query);
+    const char *ns = xmpp_stanza_get_ns(query);
     if (g_strcmp0(ns, STANZA_NS_VERSION) != 0) {
         log_error("Software version result received without namespace.");
         return 0;
     }
 
-    char* name_str = NULL;
-    char* version_str = NULL;
-    char* os_str = NULL;
-    xmpp_stanza_t* name = xmpp_stanza_get_child_by_name(query, "name");
-    xmpp_stanza_t* version = xmpp_stanza_get_child_by_name(query, "version");
-    xmpp_stanza_t* os = xmpp_stanza_get_child_by_name(query, "os");
+    char *name_str = NULL;
+    char *version_str = NULL;
+    char *os_str = NULL;
+    xmpp_stanza_t *name = xmpp_stanza_get_child_by_name(query, "name");
+    xmpp_stanza_t *version = xmpp_stanza_get_child_by_name(query, "version");
+    xmpp_stanza_t *os = xmpp_stanza_get_child_by_name(query, "os");
 
     if (name) {
         name_str = xmpp_stanza_get_text(name);
@@ -1504,30 +1503,27 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         log_warning("From attribute specified different JID, using original JID.");
     }
 
-    xmpp_conn_t* conn = connection_get_conn();
-    xmpp_ctx_t* ctx = xmpp_conn_get_context(conn);
+    xmpp_conn_t *conn = connection_get_conn();
+    xmpp_ctx_t *ctx = xmpp_conn_get_context(conn);
 
-    Jid* jidp = jid_create((char*)userdata);
+    Jid *jidp = jid_create((char*)userdata);
 
-    const char* presence = NULL;
+    const char *presence = NULL;
 
     // if it has a fulljid it is a regular user (not server or component)
     if (jidp->fulljid) {
         if (muc_active(jidp->barejid)) {
-            Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
+            Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
             presence = string_from_resource_presence(occupant->presence);
         } else {
             PContact contact = roster_get_contact(jidp->barejid);
             if (contact) {
-                Resource* resource = p_contact_get_resource(contact, jidp->resourcepart);
+                Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
                 if (!resource) {
                     ui_handle_software_version_error(jidp->fulljid, "Unknown resource");
-                    if (name_str)
-                        xmpp_free(ctx, name_str);
-                    if (version_str)
-                        xmpp_free(ctx, version_str);
-                    if (os_str)
-                        xmpp_free(ctx, os_str);
+                    if (name_str) xmpp_free(ctx, name_str);
+                    if (version_str) xmpp_free(ctx, version_str);
+                    if (os_str) xmpp_free(ctx, os_str);
                     return 0;
                 }
                 presence = string_from_resource_presence(resource->presence);
@@ -1547,23 +1543,20 @@ _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     jid_destroy(jidp);
 
-    if (name_str)
-        xmpp_free(ctx, name_str);
-    if (version_str)
-        xmpp_free(ctx, version_str);
-    if (os_str)
-        xmpp_free(ctx, os_str);
+    if (name_str) xmpp_free(ctx, name_str);
+    if (version_str) xmpp_free(ctx, version_str);
+    if (os_str) xmpp_free(ctx, os_str);
 
     return 0;
 }
 
 static void
-_ping_get_handler(xmpp_stanza_t* const stanza)
+_ping_get_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* to = xmpp_stanza_get_to(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *to = xmpp_stanza_get_to(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (id) {
         log_debug("IQ ping get handler fired, id: %s.", id);
@@ -1575,7 +1568,7 @@ _ping_get_handler(xmpp_stanza_t* const stanza)
         return;
     }
 
-    xmpp_stanza_t* pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
+    xmpp_stanza_t *pong = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
     xmpp_stanza_set_to(pong, from);
     xmpp_stanza_set_from(pong, to);
 
@@ -1584,11 +1577,11 @@ _ping_get_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_version_get_handler(xmpp_stanza_t* const stanza)
+_version_get_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (id) {
         log_debug("IQ version get handler fired, id: %s.", id);
@@ -1601,23 +1594,23 @@ _version_get_handler(xmpp_stanza_t* const stanza)
             cons_show("Received IQ version request (XEP-0092) from %s", from);
         }
 
-        xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
+        xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, id);
         xmpp_stanza_set_to(response, from);
 
-        xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *query = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
         xmpp_stanza_set_ns(query, STANZA_NS_VERSION);
 
-        xmpp_stanza_t* name = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *name = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(name, "name");
-        xmpp_stanza_t* name_txt = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *name_txt = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(name_txt, "Profanity");
         xmpp_stanza_add_child(name, name_txt);
 
-        xmpp_stanza_t* version = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *version = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(version, "version");
-        xmpp_stanza_t* version_txt = xmpp_stanza_new(ctx);
-        GString* version_str = g_string_new(PACKAGE_VERSION);
+        xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx);
+        GString *version_str = g_string_new(PACKAGE_VERSION);
         if (strcmp(PACKAGE_STATUS, "development") == 0) {
 #ifdef HAVE_GIT_VERSION
             g_string_append(version_str, "dev.");
@@ -1631,8 +1624,8 @@ _version_get_handler(xmpp_stanza_t* const stanza)
         xmpp_stanza_set_text(version_txt, version_str->str);
         xmpp_stanza_add_child(version, version_txt);
 
-        xmpp_stanza_t* os;
-        xmpp_stanza_t* os_txt;
+        xmpp_stanza_t *os;
+        xmpp_stanza_t *os_txt;
 
         bool include_os = prefs_get_boolean(PREF_REVEAL_OS);
         if (include_os) {
@@ -1661,9 +1654,7 @@ _version_get_handler(xmpp_stanza_t* const stanza)
 
         xmpp_stanza_add_child(query, name);
         xmpp_stanza_add_child(query, version);
-        if (include_os) {
-            xmpp_stanza_add_child(query, os);
-        }
+        if (include_os) {xmpp_stanza_add_child(query, os);}
         xmpp_stanza_add_child(response, query);
 
         iq_send_stanza(response);
@@ -1671,25 +1662,21 @@ _version_get_handler(xmpp_stanza_t* const stanza)
         g_string_free(version_str, TRUE);
         xmpp_stanza_release(name_txt);
         xmpp_stanza_release(version_txt);
-        if (include_os) {
-            xmpp_stanza_release(os_txt);
-        }
+        if (include_os) {xmpp_stanza_release(os_txt);}
         xmpp_stanza_release(name);
         xmpp_stanza_release(version);
-        if (include_os) {
-            xmpp_stanza_release(os);
-        }
+        if (include_os) {xmpp_stanza_release(os);}
         xmpp_stanza_release(query);
         xmpp_stanza_release(response);
     }
 }
 
 static void
-_disco_items_get_handler(xmpp_stanza_t* const stanza)
+_disco_items_get_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (id) {
         log_debug("IQ disco items get handler fired, id: %s.", id);
@@ -1698,10 +1685,10 @@ _disco_items_get_handler(xmpp_stanza_t* const stanza)
     }
 
     if (from) {
-        xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
+        xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
         xmpp_stanza_set_to(response, from);
 
-        xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *query = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
         xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
         xmpp_stanza_add_child(response, query);
@@ -1713,10 +1700,10 @@ _disco_items_get_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_last_activity_get_handler(xmpp_stanza_t* const stanza)
+_last_activity_get_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (!from) {
         return;
@@ -1727,10 +1714,10 @@ _last_activity_get_handler(xmpp_stanza_t* const stanza)
         char str[50];
         sprintf(str, "%d", idls_secs);
 
-        xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
+        xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
         xmpp_stanza_set_to(response, from);
 
-        xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *query = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
         xmpp_stanza_set_attribute(query, STANZA_ATTR_XMLNS, STANZA_NS_LASTACTIVITY);
         xmpp_stanza_set_attribute(query, "seconds", str);
@@ -1742,14 +1729,14 @@ _last_activity_get_handler(xmpp_stanza_t* const stanza)
 
         xmpp_stanza_release(response);
     } else {
-        xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza));
+        xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_ERROR, xmpp_stanza_get_id(stanza));
         xmpp_stanza_set_to(response, from);
 
-        xmpp_stanza_t* error = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *error = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(error, STANZA_NAME_ERROR);
         xmpp_stanza_set_type(error, "cancel");
 
-        xmpp_stanza_t* service_unavailable = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *service_unavailable = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(service_unavailable, "service-unavailable");
         xmpp_stanza_set_ns(service_unavailable, "urn:ietf:params:xml:ns:xmpp-stanzas");
 
@@ -1766,15 +1753,15 @@ _last_activity_get_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_disco_info_get_handler(xmpp_stanza_t* const stanza)
+_disco_info_get_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    const char *from = xmpp_stanza_get_from(stanza);
 
-    xmpp_stanza_t* incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-    const char* node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE);
+    xmpp_stanza_t *incoming_query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    const char *node_str = xmpp_stanza_get_attribute(incoming_query, STANZA_ATTR_NODE);
 
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
 
     if (id) {
         log_debug("IQ disco info get handler fired, id: %s.", id);
@@ -1787,10 +1774,10 @@ _disco_info_get_handler(xmpp_stanza_t* const stanza)
             cons_show("Received IQ disco info request (XEP-0232) from %s", from);
         }
 
-        xmpp_stanza_t* response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
+        xmpp_stanza_t *response = xmpp_iq_new(ctx, STANZA_TYPE_RESULT, xmpp_stanza_get_id(stanza));
         xmpp_stanza_set_to(response, from);
 
-        xmpp_stanza_t* query = stanza_create_caps_query_element(ctx);
+        xmpp_stanza_t *query = stanza_create_caps_query_element(ctx);
         if (node_str) {
             xmpp_stanza_set_attribute(query, STANZA_ATTR_NODE, node_str);
         }
@@ -1803,9 +1790,9 @@ _disco_info_get_handler(xmpp_stanza_t* const stanza)
 }
 
 static int
-_destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_destroy_room_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
 
     if (id) {
         log_debug("IQ destroy room result handler fired, id: %s.", id);
@@ -1813,7 +1800,7 @@ _destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdat
         log_debug("IQ destroy room result handler fired.");
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (from == NULL) {
         log_error("No from attribute for IQ destroy room result");
     } else {
@@ -1824,11 +1811,11 @@ _destroy_room_result_id_handler(xmpp_stanza_t* const stanza, void* const userdat
 }
 
 static int
-_room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_config_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (id) {
         log_debug("IQ room config handler fired, id: %s.", id);
@@ -1838,7 +1825,7 @@ _room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         ui_handle_room_configuration_form_error(from, error_message);
         free(error_message);
         return 0;
@@ -1850,41 +1837,41 @@ _room_config_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
     if (query == NULL) {
         log_warning("No query element found parsing room config response");
         ui_handle_room_configuration_form_error(from, "No query element found parsing room config response");
         return 0;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
     if (x == NULL) {
         log_warning("No x element found with %s namespace parsing room config response", STANZA_NS_DATA);
         ui_handle_room_configuration_form_error(from, "No form configuration options available");
         return 0;
     }
 
-    const char* form_type = xmpp_stanza_get_type(x);
+    const char *form_type = xmpp_stanza_get_type(x);
     if (g_strcmp0(form_type, "form") != 0) {
         log_warning("x element not of type 'form' parsing room config response");
         ui_handle_room_configuration_form_error(from, "Form not of type 'form' parsing room config response.");
         return 0;
     }
 
-    DataForm* form = form_create(x);
-    ProfConfWin* confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_room_config, iq_room_config_cancel, NULL);
+    DataForm *form = form_create(x);
+    ProfConfWin *confwin = (ProfConfWin*)wins_new_config(from, form, iq_submit_room_config, iq_room_config_cancel, NULL);
     confwin_handle_configuration(confwin, form);
 
     return 0;
 }
 
 static int
-_room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_affiliation_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    ProfPrivilegeSet* affiliation_set = (ProfPrivilegeSet*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    ProfPrivilegeSet *affiliation_set = (ProfPrivilegeSet*)userdata;
 
     if (id) {
         log_debug("IQ affiliation set handler fired, id: %s.", id);
@@ -1894,9 +1881,9 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message);
-        ProfMucWin* mucwin = wins_get_muc(from);
+        ProfMucWin *mucwin = wins_get_muc(from);
         if (mucwin) {
             mucwin_affiliation_set_error(mucwin, affiliation_set->item, affiliation_set->privilege, error_message);
         }
@@ -1907,12 +1894,12 @@ _room_affiliation_set_result_id_handler(xmpp_stanza_t* const stanza, void* const
 }
 
 static int
-_room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_role_set_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    ProfPrivilegeSet* role_set = (ProfPrivilegeSet*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    ProfPrivilegeSet *role_set = (ProfPrivilegeSet*)userdata;
 
     if (id) {
         log_debug("IQ role set handler fired, id: %s.", id);
@@ -1922,9 +1909,9 @@ _room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userda
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error setting role %s list for room %s, user %s: %s", role_set->privilege, from, role_set->item, error_message);
-        ProfMucWin* mucwin = wins_get_muc(from);
+        ProfMucWin *mucwin = wins_get_muc(from);
         if (mucwin) {
             mucwin_role_set_error(mucwin, role_set->item, role_set->privilege, error_message);
         }
@@ -1935,12 +1922,12 @@ _room_role_set_result_id_handler(xmpp_stanza_t* const stanza, void* const userda
 }
 
 static int
-_room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_affiliation_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    ProfAffiliationList* affiliation_list = (ProfAffiliationList*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    ProfAffiliationList *affiliation_list = (ProfAffiliationList *)userdata;
 
     if (id) {
         log_debug("IQ affiliation list result handler fired, id: %s.", id);
@@ -1950,28 +1937,28 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* cons
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error retrieving %s list for room %s: %s", affiliation_list->affiliation, from, error_message);
-        ProfMucWin* mucwin = wins_get_muc(from);
+        ProfMucWin *mucwin = wins_get_muc(from);
         if (mucwin && affiliation_list->show_ui_message) {
             mucwin_affiliation_list_error(mucwin, affiliation_list->affiliation, error_message);
         }
         free(error_message);
         return 0;
     }
-    GSList* jids = NULL;
+    GSList *jids = NULL;
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN);
     if (query) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
         while (child) {
-            const char* name = xmpp_stanza_get_name(child);
+            const char *name = xmpp_stanza_get_name(child);
             if (g_strcmp0(name, "item") == 0) {
-                const char* jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+                const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
                 if (jid) {
                     if (g_strcmp0(affiliation_list->affiliation, "member") == 0
-                        || g_strcmp0(affiliation_list->affiliation, "owner") == 0
-                        || g_strcmp0(affiliation_list->affiliation, "admin") == 0) {
+                            || g_strcmp0(affiliation_list->affiliation, "owner") == 0
+                            || g_strcmp0(affiliation_list->affiliation, "admin") == 0) {
                         muc_members_add(from, jid);
                     }
                     jids = g_slist_insert_sorted(jids, (gpointer)jid, (GCompareFunc)g_strcmp0);
@@ -1982,7 +1969,7 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* cons
     }
 
     muc_jid_autocomplete_add_all(from, jids);
-    ProfMucWin* mucwin = wins_get_muc(from);
+    ProfMucWin *mucwin = wins_get_muc(from);
     if (mucwin && affiliation_list->show_ui_message) {
         mucwin_handle_affiliation_list(mucwin, affiliation_list->affiliation, jids);
     }
@@ -1992,12 +1979,12 @@ _room_affiliation_list_result_id_handler(xmpp_stanza_t* const stanza, void* cons
 }
 
 static int
-_room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_role_list_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    char* role = (char*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    char *role = (char *)userdata;
 
     if (id) {
         log_debug("IQ role list result handler fired, id: %s.", id);
@@ -2007,24 +1994,24 @@ _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userd
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         log_debug("Error retrieving %s list for room %s: %s", role, from, error_message);
-        ProfMucWin* mucwin = wins_get_muc(from);
+        ProfMucWin *mucwin = wins_get_muc(from);
         if (mucwin) {
             mucwin_role_list_error(mucwin, role, error_message);
         }
         free(error_message);
         return 0;
     }
-    GSList* nicks = NULL;
+    GSList *nicks = NULL;
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_ADMIN);
     if (query) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
         while (child) {
-            const char* name = xmpp_stanza_get_name(child);
+            const char *name = xmpp_stanza_get_name(child);
             if (g_strcmp0(name, "item") == 0) {
-                const char* nick = xmpp_stanza_get_attribute(child, STANZA_ATTR_NICK);
+                const char *nick = xmpp_stanza_get_attribute(child, STANZA_ATTR_NICK);
                 if (nick) {
                     nicks = g_slist_insert_sorted(nicks, (gpointer)nick, (GCompareFunc)g_strcmp0);
                 }
@@ -2033,7 +2020,7 @@ _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userd
         }
     }
 
-    ProfMucWin* mucwin = wins_get_muc(from);
+    ProfMucWin *mucwin = wins_get_muc(from);
     if (mucwin) {
         mucwin_handle_role_list(mucwin, role, nicks);
     }
@@ -2043,11 +2030,11 @@ _room_role_list_result_id_handler(xmpp_stanza_t* const stanza, void* const userd
 }
 
 static int
-_room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_config_submit_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (id) {
         log_debug("IQ room config submit handler fired, id: %s.", id);
@@ -2057,7 +2044,7 @@ _room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         ui_handle_room_config_submit_result_error(from, error_message);
         free(error_message);
         return 0;
@@ -2069,12 +2056,12 @@ _room_config_submit_id_handler(xmpp_stanza_t* const stanza, void* const userdata
 }
 
 static int
-_room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_kick_result_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    char* nick = (char*)userdata;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    char *nick = (char *)userdata;
 
     if (id) {
         log_debug("IQ kick result handler fired, id: %s.", id);
@@ -2083,9 +2070,9 @@ _room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
     }
 
     // handle error responses
-    ProfMucWin* mucwin = wins_get_muc(from);
+    ProfMucWin *mucwin = wins_get_muc(from);
     if (mucwin && (g_strcmp0(type, STANZA_TYPE_ERROR) == 0)) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         mucwin_kick_error(mucwin, nick, error_message);
         free(error_message);
     }
@@ -2094,7 +2081,7 @@ _room_kick_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static void
-_identity_destroy(DiscoIdentity* identity)
+_identity_destroy(DiscoIdentity *identity)
 {
     if (identity) {
         free(identity->name);
@@ -2105,7 +2092,7 @@ _identity_destroy(DiscoIdentity* identity)
 }
 
 static void
-_item_destroy(DiscoItem* item)
+_item_destroy(DiscoItem *item)
 {
     if (item) {
         free(item->jid);
@@ -2115,47 +2102,47 @@ _item_destroy(DiscoItem* item)
 }
 
 static int
-_room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_room_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* type = xmpp_stanza_get_type(stanza);
-    ProfRoomInfoData* cb_data = (ProfRoomInfoData*)userdata;
+    const char *type = xmpp_stanza_get_type(stanza);
+    ProfRoomInfoData *cb_data = (ProfRoomInfoData *)userdata;
     log_debug("Received disco#info response for room: %s", cb_data->room);
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        ProfMucWin* mucwin = wins_get_muc(cb_data->room);
+        ProfMucWin *mucwin = wins_get_muc(cb_data->room);
         if (mucwin && cb_data->display) {
-            char* error_message = stanza_get_error_message(stanza);
+            char *error_message = stanza_get_error_message(stanza);
             mucwin_room_info_error(mucwin, error_message);
             free(error_message);
         }
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
     if (query) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
-        GSList* identities = NULL;
-        GSList* features = NULL;
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
+        GSList *identities = NULL;
+        GSList *features = NULL;
         while (child) {
-            const char* stanza_name = xmpp_stanza_get_name(child);
+            const char *stanza_name = xmpp_stanza_get_name(child);
             if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
-                const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
+                const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
                 if (var) {
                     features = g_slist_append(features, strdup(var));
                 }
             } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
-                const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
-                const char* type = xmpp_stanza_get_type(child);
-                const char* category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
+                const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+                const char *type = xmpp_stanza_get_type(child);
+                const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
 
                 if (name || category || type) {
-                    DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
+                    DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t));
 
                     if (name) {
                         identity->name = strdup(name);
-                        ProfMucWin* mucwin = wins_get_muc(cb_data->room);
+                        ProfMucWin *mucwin = wins_get_muc(cb_data->room);
                         if (mucwin) {
                             mucwin->room_name = strdup(name);
                         }
@@ -2181,7 +2168,7 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
         }
 
         muc_set_features(cb_data->room, features);
-        ProfMucWin* mucwin = wins_get_muc(cb_data->room);
+        ProfMucWin *mucwin = wins_get_muc(cb_data->room);
         if (mucwin) {
 #ifdef HAVE_OMEMO
             if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS && omemo_automatic_start(cb_data->room)) {
@@ -2202,20 +2189,20 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
 }
 
 static int
-_last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_last_activity_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         cons_show_error("Invalid last activity response received.");
         log_info("Received last activity response with no from attribute.");
         return 0;
     }
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         if (from) {
             cons_show_error("Last activity request failed for %s: %s", from, error_message);
         } else {
@@ -2225,7 +2212,7 @@ _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const user
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
     if (!query) {
         cons_show_error("Invalid last activity response received.");
@@ -2233,7 +2220,7 @@ _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const user
         return 0;
     }
 
-    const char* seconds_str = xmpp_stanza_get_attribute(query, "seconds");
+    const char *seconds_str = xmpp_stanza_get_attribute(query, "seconds");
     if (!seconds_str) {
         cons_show_error("Invalid last activity response received.");
         log_info("Received last activity response with no seconds attribute.");
@@ -2247,7 +2234,7 @@ _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const user
         return 0;
     }
 
-    char* msg = xmpp_stanza_get_text(query);
+    char *msg = xmpp_stanza_get_text(query);
 
     sv_ev_lastactivity_response(from, seconds, msg);
 
@@ -2256,10 +2243,10 @@ _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const user
 }
 
 static int
-_disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_disco_info_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (from) {
         log_debug("Received disco#info response from: %s", from);
@@ -2269,7 +2256,7 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         if (from) {
             cons_show_error("Service discovery failed for %s: %s", from, error_message);
         } else {
@@ -2279,26 +2266,26 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
     if (query) {
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
-        GSList* identities = NULL;
-        GSList* features = NULL;
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
+        GSList *identities = NULL;
+        GSList *features = NULL;
         while (child) {
-            const char* stanza_name = xmpp_stanza_get_name(child);
+            const char *stanza_name = xmpp_stanza_get_name(child);
             if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
-                const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
+                const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
                 if (var) {
                     features = g_slist_append(features, strdup(var));
                 }
             } else if (g_strcmp0(stanza_name, STANZA_NAME_IDENTITY) == 0) {
-                const char* name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
-                const char* type = xmpp_stanza_get_type(child);
-                const char* category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
+                const char *name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+                const char *type = xmpp_stanza_get_type(child);
+                const char *category = xmpp_stanza_get_attribute(child, STANZA_ATTR_CATEGORY);
 
                 if (name || category || type) {
-                    DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
+                    DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t));
 
                     if (name) {
                         identity->name = strdup(name);
@@ -2333,10 +2320,10 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
 }
 
 static int
-_disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata)
+_disco_info_response_id_handler_onconnect(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (from) {
         log_debug("Received disco#info response from: %s", from);
@@ -2346,7 +2333,7 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         if (from) {
             log_error("Service discovery failed for %s: %s", from, error_message);
         } else {
@@ -2356,20 +2343,20 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
         return 0;
     }
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
     if (query) {
-        GHashTable* features = connection_get_features(from);
+        GHashTable *features = connection_get_features(from);
         if (features == NULL) {
             log_error("No matching disco item found for %s", from);
             return 1;
         }
 
-        xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+        xmpp_stanza_t *child = xmpp_stanza_get_children(query);
         while (child) {
-            const char* stanza_name = xmpp_stanza_get_name(child);
+            const char *stanza_name = xmpp_stanza_get_name(child);
             if (g_strcmp0(stanza_name, STANZA_NAME_FEATURE) == 0) {
-                const char* var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
+                const char *var = xmpp_stanza_get_attribute(child, STANZA_ATTR_VAR);
                 if (var) {
                     g_hash_table_add(features, strdup(var));
                 }
@@ -2384,11 +2371,11 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
 }
 
 static int
-_http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_http_upload_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    HTTPUpload* upload = (HTTPUpload*)userdata;
-    const char* from = xmpp_stanza_get_from(stanza);
-    const char* type = xmpp_stanza_get_type(stanza);
+    HTTPUpload *upload = (HTTPUpload *)userdata;
+    const char *from = xmpp_stanza_get_from(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (from) {
         log_info("Received http_upload response from: %s", from);
@@ -2398,7 +2385,7 @@ _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userda
 
     // handle error responses
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        char* error_message = stanza_get_error_message(stanza);
+        char *error_message = stanza_get_error_message(stanza);
         if (from) {
             cons_show_error("Uploading '%s' failed for %s: %s", upload->filename, from, error_message);
         } else {
@@ -2408,25 +2395,23 @@ _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userda
         return 0;
     }
 
-    xmpp_stanza_t* slot = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SLOT);
+    xmpp_stanza_t *slot = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SLOT);
 
     if (slot && g_strcmp0(xmpp_stanza_get_ns(slot), STANZA_NS_HTTP_UPLOAD) == 0) {
-        xmpp_stanza_t* put = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_PUT);
-        xmpp_stanza_t* get = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_GET);
+        xmpp_stanza_t *put = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_PUT);
+        xmpp_stanza_t *get = xmpp_stanza_get_child_by_name(slot, STANZA_NAME_GET);
 
         if (put && get) {
-            char* put_url = xmpp_stanza_get_text(put);
-            char* get_url = xmpp_stanza_get_text(get);
+            char *put_url = xmpp_stanza_get_text(put);
+            char *get_url = xmpp_stanza_get_text(get);
 
             upload->put_url = strdup(put_url);
             upload->get_url = strdup(get_url);
 
-            xmpp_conn_t* conn = connection_get_conn();
-            xmpp_ctx_t* ctx = xmpp_conn_get_context(conn);
-            if (put_url)
-                xmpp_free(ctx, put_url);
-            if (get_url)
-                xmpp_free(ctx, get_url);
+            xmpp_conn_t *conn = connection_get_conn();
+            xmpp_ctx_t *ctx = xmpp_conn_get_context(conn);
+            if (put_url) xmpp_free(ctx, put_url);
+            if (get_url) xmpp_free(ctx, get_url);
 
             pthread_create(&(upload->worker), NULL, &http_file_put, upload);
             http_upload_add_upload(upload);
@@ -2440,37 +2425,38 @@ _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const userda
 }
 
 static void
-_disco_items_result_handler(xmpp_stanza_t* const stanza)
+_disco_items_result_handler(xmpp_stanza_t *const stanza)
 {
     log_debug("Received disco#items response");
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* from = xmpp_stanza_get_from(stanza);
-    GSList* items = NULL;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
+    GSList *items = NULL;
 
-    if ((g_strcmp0(id, "discoitemsreq") != 0) && (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
+    if ((g_strcmp0(id, "discoitemsreq") != 0) &&
+            (g_strcmp0(id, "discoitemsreq_onconnect") != 0)) {
         return;
     }
 
     log_debug("Response to query: %s", id);
 
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
     if (query == NULL) {
         return;
     }
 
-    xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+    xmpp_stanza_t *child = xmpp_stanza_get_children(query);
     if (child == NULL) {
         return;
     }
 
     while (child) {
-        const char* stanza_name = xmpp_stanza_get_name(child);
+        const char *stanza_name = xmpp_stanza_get_name(child);
         if (stanza_name && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
-            const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
+            const char *item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
             if (item_jid) {
-                DiscoItem* item = malloc(sizeof(struct disco_item_t));
+                DiscoItem *item = malloc(sizeof(struct disco_item_t));
                 item->jid = strdup(item_jid);
-                const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
+                const char *item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
                 if (item_name) {
                     item->name = strdup(item_name);
                 } else {
@@ -2493,14 +2479,14 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
 }
 
 void
-iq_send_stanza(xmpp_stanza_t* const stanza)
+iq_send_stanza(xmpp_stanza_t *const stanza)
 {
-    char* text;
+    char *text;
     size_t text_size;
     xmpp_stanza_to_text(stanza, &text, &text_size);
 
-    xmpp_conn_t* conn = connection_get_conn();
-    char* plugin_text = plugins_on_iq_stanza_send(text);
+    xmpp_conn_t *conn = connection_get_conn();
+    char *plugin_text = plugins_on_iq_stanza_send(text);
     if (plugin_text) {
         xmpp_send_raw_string(conn, "%s", plugin_text);
         free(plugin_text);
@@ -2511,7 +2497,7 @@ iq_send_stanza(xmpp_stanza_t* const stanza)
 }
 
 static void
-_iq_free_room_data(ProfRoomInfoData* roominfo)
+_iq_free_room_data(ProfRoomInfoData *roominfo)
 {
     if (roominfo) {
         free(roominfo->room);
@@ -2520,7 +2506,7 @@ _iq_free_room_data(ProfRoomInfoData* roominfo)
 }
 
 static void
-_iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set)
+_iq_free_affiliation_set(ProfPrivilegeSet *affiliation_set)
 {
     if (affiliation_set) {
         free(affiliation_set->item);
@@ -2530,7 +2516,7 @@ _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set)
 }
 
 static void
-_iq_free_affiliation_list(ProfAffiliationList* affiliation_list)
+_iq_free_affiliation_list(ProfAffiliationList *affiliation_list)
 {
     if (affiliation_list) {
         free(affiliation_list->affiliation);
@@ -2539,26 +2525,26 @@ _iq_free_affiliation_list(ProfAffiliationList* affiliation_list)
 }
 
 void
-iq_mam_request(ProfChatWin* win)
+iq_mam_request(ProfChatWin *win)
 {
-    if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
+   if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
         log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_PING);
         cons_show_error("Server doesn't support MAM.");
         return;
-    }
+   }
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
 
-    GDateTime* now = g_date_time_new_now_local();
-    GDateTime* timestamp = g_date_time_add_days(now, -1);
+    GDateTime *now = g_date_time_new_now_local();
+    GDateTime *timestamp = g_date_time_add_days(now, -1);
     g_date_time_unref(now);
-    gchar* datestr = g_date_time_format(timestamp, "%FT%T%:::z");
-    xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr);
+    gchar *datestr = g_date_time_format(timestamp,"%FT%T%:::z");
+    xmpp_stanza_t *iq = stanza_create_mam_iq(ctx, win->barejid, datestr);
     g_free(datestr);
     g_date_time_unref(timestamp);
 
-    //    iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload);
+//    iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload);
     free(id);
 
     iq_send_stanza(iq);
diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h
index 887e832e..eba79034 100644
--- a/src/xmpp/iq.h
+++ b/src/xmpp/iq.h
@@ -36,18 +36,18 @@
 #ifndef XMPP_IQ_H
 #define XMPP_IQ_H
 
-typedef int (*ProfIqCallback)(xmpp_stanza_t* const stanza, void* const userdata);
-typedef void (*ProfIqFreeCallback)(void* userdata);
+typedef int(*ProfIqCallback)(xmpp_stanza_t *const stanza, void *const userdata);
+typedef void(*ProfIqFreeCallback)(void *userdata);
 
 void iq_handlers_init(void);
-void iq_send_stanza(xmpp_stanza_t* const stanza);
-void iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata);
-void iq_disco_info_request_onconnect(gchar* jid);
-void iq_disco_items_request_onconnect(gchar* jid);
-void iq_send_caps_request(const char* const to, const char* const id, const char* const node, const char* const ver);
-void iq_send_caps_request_for_jid(const char* const to, const char* const id, const char* const node,
-                                  const char* const ver);
-void iq_send_caps_request_legacy(const char* const to, const char* const id, const char* const node,
-                                 const char* const ver);
+void iq_send_stanza(xmpp_stanza_t *const stanza);
+void iq_id_handler_add(const char *const id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata);
+void iq_disco_info_request_onconnect(gchar *jid);
+void iq_disco_items_request_onconnect(gchar *jid);
+void iq_send_caps_request(const char *const to, const char *const id, const char *const node, const char *const ver);
+void iq_send_caps_request_for_jid(const char *const to, const char *const id, const char *const node,
+    const char *const ver);
+void iq_send_caps_request_legacy(const char *const to, const char *const id, const char *const node,
+    const char *const ver);
 
 #endif
diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c
index 32743cb4..a427a318 100644
--- a/src/xmpp/jid.c
+++ b/src/xmpp/jid.c
@@ -42,12 +42,12 @@
 #include "xmpp/jid.h"
 
 Jid*
-jid_create(const gchar* const str)
+jid_create(const gchar *const str)
 {
-    Jid* result = NULL;
+    Jid *result = NULL;
 
     /* if str is NULL g_strdup returns NULL */
-    gchar* trimmed = g_strdup(str);
+    gchar *trimmed = g_strdup(str);
     if (trimmed == NULL) {
         return NULL;
     }
@@ -75,9 +75,9 @@ jid_create(const gchar* const str)
     result->barejid = NULL;
     result->fulljid = NULL;
 
-    gchar* atp = g_utf8_strchr(trimmed, -1, '@');
-    gchar* slashp = g_utf8_strchr(trimmed, -1, '/');
-    gchar* domain_start = trimmed;
+    gchar *atp = g_utf8_strchr(trimmed, -1, '@');
+    gchar *slashp = g_utf8_strchr(trimmed, -1, '/');
+    gchar *domain_start = trimmed;
 
     if (atp) {
         result->localpart = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, atp));
@@ -87,7 +87,7 @@ jid_create(const gchar* const str)
     if (slashp) {
         result->resourcepart = g_strdup(slashp + 1);
         result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp));
-        char* barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
+        char *barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp));
         result->barejid = g_utf8_strdown(barejidraw, -1);
         result->fulljid = g_strdup(trimmed);
         g_free(barejidraw);
@@ -107,10 +107,10 @@ jid_create(const gchar* const str)
 }
 
 Jid*
-jid_create_from_bare_and_resource(const char* const barejid, const char* const resource)
+jid_create_from_bare_and_resource(const char *const barejid, const char *const resource)
 {
-    Jid* result;
-    char* jid = create_fulljid(barejid, resource);
+    Jid *result;
+    char *jid = create_fulljid(barejid, resource);
     result = jid_create(jid);
     free(jid);
 
@@ -118,7 +118,7 @@ jid_create_from_bare_and_resource(const char* const barejid, const char* const r
 }
 
 void
-jid_destroy(Jid* jid)
+jid_destroy(Jid *jid)
 {
     if (jid == NULL) {
         return;
@@ -134,7 +134,7 @@ jid_destroy(Jid* jid)
 }
 
 gboolean
-jid_is_valid_room_form(Jid* jid)
+jid_is_valid_room_form(Jid *jid)
 {
     return (jid->fulljid != NULL);
 }
@@ -145,15 +145,15 @@ jid_is_valid_room_form(Jid* jid)
  * Will return a newly created string that must be freed by the caller
  */
 char*
-create_fulljid(const char* const barejid, const char* const resource)
+create_fulljid(const char *const barejid, const char *const resource)
 {
-    gchar* barejidlower = g_utf8_strdown(barejid, -1);
-    GString* full_jid = g_string_new(barejidlower);
+    gchar *barejidlower = g_utf8_strdown(barejid, -1);
+    GString *full_jid = g_string_new(barejidlower);
     g_free(barejidlower);
     g_string_append(full_jid, "/");
     g_string_append(full_jid, resource);
 
-    char* result = strdup(full_jid->str);
+    char *result = strdup(full_jid->str);
 
     g_string_free(full_jid, TRUE);
 
@@ -166,10 +166,10 @@ create_fulljid(const char* const barejid, const char* const resource)
  * returns "person"
  */
 char*
-get_nick_from_full_jid(const char* const full_room_jid)
+get_nick_from_full_jid(const char *const full_room_jid)
 {
-    char** tokens = g_strsplit(full_room_jid, "/", 0);
-    char* nick_part = NULL;
+    char **tokens = g_strsplit(full_room_jid, "/", 0);
+    char *nick_part = NULL;
 
     if (tokens) {
         if (tokens[0] && tokens[1]) {
@@ -182,11 +182,12 @@ get_nick_from_full_jid(const char* const full_room_jid)
     return nick_part;
 }
 
+
 /*
  * get the fulljid, fall back to the barejid
  */
 char*
-jid_fulljid_or_barejid(Jid* jid)
+jid_fulljid_or_barejid(Jid *jid)
 {
     if (jid->fulljid) {
         return jid->fulljid;
@@ -198,9 +199,9 @@ jid_fulljid_or_barejid(Jid* jid)
 char*
 jid_random_resource(void)
 {
-    char* rand = get_random_string(4);
+    char *rand = get_random_string(4);
 
-    gchar* result = g_strdup_printf("profanity.%s", rand);
+    gchar *result = g_strdup_printf("profanity.%s", rand);
     free(rand);
 
     return result;
diff --git a/src/xmpp/jid.h b/src/xmpp/jid.h
index dae6cb2d..dd9361a2 100644
--- a/src/xmpp/jid.h
+++ b/src/xmpp/jid.h
@@ -38,27 +38,26 @@
 
 #include <glib.h>
 
-struct jid_t
-{
-    char* str;
-    char* localpart;
-    char* domainpart;
-    char* resourcepart;
-    char* barejid;
-    char* fulljid;
+struct jid_t {
+    char *str;
+    char *localpart;
+    char *domainpart;
+    char *resourcepart;
+    char *barejid;
+    char *fulljid;
 };
 
 typedef struct jid_t Jid;
 
-Jid* jid_create(const gchar* const str);
-Jid* jid_create_from_bare_and_resource(const char* const barejid, const char* const resource);
-void jid_destroy(Jid* jid);
+Jid* jid_create(const gchar *const str);
+Jid* jid_create_from_bare_and_resource(const char *const barejid, const char *const resource);
+void jid_destroy(Jid *jid);
 
-gboolean jid_is_valid_room_form(Jid* jid);
-char* create_fulljid(const char* const barejid, const char* const resource);
-char* get_nick_from_full_jid(const char* const full_room_jid);
+gboolean jid_is_valid_room_form(Jid *jid);
+char* create_fulljid(const char *const barejid, const char *const resource);
+char* get_nick_from_full_jid(const char *const full_room_jid);
 
-char* jid_fulljid_or_barejid(Jid* jid);
+char* jid_fulljid_or_barejid(Jid *jid);
 char* jid_random_resource(void);
 
 #endif
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index d331759a..a50b5518 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -47,61 +47,60 @@
 #include <strophe.h>
 #endif
 
+#include "profanity.h"
+#include "log.h"
 #include "config/preferences.h"
 #include "event/server_events.h"
-#include "log.h"
 #include "pgp/gpg.h"
 #include "plugins/plugins.h"
-#include "profanity.h"
 #include "ui/ui.h"
 #include "ui/window_list.h"
 #include "xmpp/chat_session.h"
-#include "xmpp/connection.h"
-#include "xmpp/message.h"
 #include "xmpp/muc.h"
+#include "xmpp/session.h"
+#include "xmpp/message.h"
 #include "xmpp/roster.h"
 #include "xmpp/roster_list.h"
-#include "xmpp/session.h"
 #include "xmpp/stanza.h"
+#include "xmpp/connection.h"
 #include "xmpp/xmpp.h"
 
 #ifdef HAVE_OMEMO
-#include "omemo/omemo.h"
 #include "xmpp/omemo.h"
+#include "omemo/omemo.h"
 #endif
 
-typedef struct p_message_handle_t
-{
+typedef struct p_message_handle_t {
     ProfMessageCallback func;
     ProfMessageFreeCallback free_func;
-    void* userdata;
+    void *userdata;
 } ProfMessageHandler;
 
-static int _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata);
-static void _handle_error(xmpp_stanza_t* const stanza);
-static void _handle_groupchat(xmpp_stanza_t* const stanza);
-static void _handle_muc_user(xmpp_stanza_t* const stanza);
-static void _handle_muc_private_message(xmpp_stanza_t* const stanza);
-static void _handle_conference(xmpp_stanza_t* const stanza);
-static void _handle_captcha(xmpp_stanza_t* const stanza);
-static void _handle_receipt_received(xmpp_stanza_t* const stanza);
-static void _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon);
-static void _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam);
-static xmpp_stanza_t* _handle_carbons(xmpp_stanza_t* const stanza);
-static void _send_message_stanza(xmpp_stanza_t* const stanza);
-static gboolean _handle_mam(xmpp_stanza_t* const stanza);
-static void _handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event);
+static int _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
+static void _handle_error(xmpp_stanza_t *const stanza);
+static void _handle_groupchat(xmpp_stanza_t *const stanza);
+static void _handle_muc_user(xmpp_stanza_t *const stanza);
+static void _handle_muc_private_message(xmpp_stanza_t *const stanza);
+static void _handle_conference(xmpp_stanza_t *const stanza);
+static void _handle_captcha(xmpp_stanza_t *const stanza);
+static void _handle_receipt_received(xmpp_stanza_t *const stanza);
+static void _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon);
+static void _handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam);
+static xmpp_stanza_t* _handle_carbons(xmpp_stanza_t *const stanza);
+static void _send_message_stanza(xmpp_stanza_t *const stanza);
+static gboolean _handle_mam(xmpp_stanza_t *const stanza);
+static void _handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event);
 
 #ifdef HAVE_LIBGPGME
 static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text);
 #endif // HAVE_LIBGPGME
 
-static GHashTable* pubsub_event_handlers;
+static GHashTable *pubsub_event_handlers;
 
 static gboolean
-_handled_by_plugin(xmpp_stanza_t* const stanza)
+_handled_by_plugin(xmpp_stanza_t *const stanza)
 {
-    char* text;
+    char *text;
     size_t text_size;
 
     xmpp_stanza_to_text(stanza, &text, &text_size);
@@ -112,11 +111,11 @@ _handled_by_plugin(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_headline(xmpp_stanza_t* const stanza)
+_handle_headline(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
     char* text = NULL;
-    xmpp_stanza_t* body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
+    xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
     if (body) {
         text = xmpp_stanza_get_text(body);
         if (text) {
@@ -127,7 +126,7 @@ _handle_headline(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_chat_states(xmpp_stanza_t* const stanza, Jid* const jid)
+_handle_chat_states(xmpp_stanza_t *const stanza, Jid *const jid)
 {
     gboolean gone = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL;
     gboolean typing = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL;
@@ -149,7 +148,7 @@ _handle_chat_states(xmpp_stanza_t* const stanza, Jid* const jid)
 }
 
 static int
-_message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata)
+_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
 {
     log_debug("Message stanza handler fired");
 
@@ -158,7 +157,7 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
     }
 
     // type according to RFC 6121
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
         _handle_error(stanza);
@@ -167,7 +166,7 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
         _handle_groupchat(stanza);
     } else if (g_strcmp0(type, STANZA_TYPE_HEADLINE) == 0) {
         _handle_headline(stanza);
-    } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0) {
+    } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) {
         // type: chat, normal (==NULL)
 
         // XEP-0313: Message Archive Management
@@ -176,48 +175,48 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
         }
 
         // XEP-0045: Multi-User Chat - invites - presence
-        xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+        xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
         if (mucuser) {
             _handle_muc_user(stanza);
         }
 
         // XEP-0249: Direct MUC Invitations
-        xmpp_stanza_t* conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
+        xmpp_stanza_t *conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
         if (conference) {
             _handle_conference(stanza);
             return 1;
         }
 
         // XEP-0158: CAPTCHA Forms
-        xmpp_stanza_t* captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA);
+        xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA);
         if (captcha) {
             _handle_captcha(stanza);
             return 1;
         }
 
         // XEP-0184: Message Delivery Receipts
-        xmpp_stanza_t* receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
+        xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
         if (receipts) {
             _handle_receipt_received(stanza);
         }
 
         // XEP-0060: Publish-Subscribe
-        xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
+        xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
         if (event) {
             _handle_pubsub(stanza, event);
             return 1;
         }
 
-        xmpp_stanza_t* msg_stanza = stanza;
+        xmpp_stanza_t *msg_stanza = stanza;
         gboolean is_carbon = FALSE;
 
         // XEP-0280: Message Carbons
-        xmpp_stanza_t* carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
+        xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
         if (carbons) {
 
             // carbon must come from ourselves
-            char* mybarejid = connection_get_barejid();
-            const char* const stanza_from = xmpp_stanza_get_from(stanza);
+            char *mybarejid = connection_get_barejid();
+            const char *const stanza_from = xmpp_stanza_get_from(stanza);
 
             if (g_strcmp0(mybarejid, stanza_from) != 0) {
                 log_warning("Invalid carbon received, from: %s", stanza_from);
@@ -236,7 +235,7 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
         }
     } else {
         // none of the allowed types
-        char* text;
+        char *text;
         size_t text_size;
 
         xmpp_stanza_to_text(stanza, &text, &text_size);
@@ -251,15 +250,15 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
 void
 message_handlers_init(void)
 {
-    xmpp_conn_t* const conn = connection_get_conn();
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_conn_t * const conn = connection_get_conn();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
     xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx);
 
     if (pubsub_event_handlers) {
-        GList* keys = g_hash_table_get_keys(pubsub_event_handlers);
-        GList* curr = keys;
+        GList *keys = g_hash_table_get_keys(pubsub_event_handlers);
+        GList *curr = keys;
         while (curr) {
-            ProfMessageHandler* handler = g_hash_table_lookup(pubsub_event_handlers, curr->data);
+            ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, curr->data);
             if (handler->free_func && handler->userdata) {
                 handler->free_func(handler->userdata);
             }
@@ -272,10 +271,10 @@ message_handlers_init(void)
     pubsub_event_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
 }
 
-ProfMessage*
+ProfMessage *
 message_init(void)
 {
-    ProfMessage* message = malloc(sizeof(ProfMessage));
+    ProfMessage *message = malloc(sizeof(ProfMessage));
 
     message->from_jid = NULL;
     message->to_jid = NULL;
@@ -294,9 +293,9 @@ message_init(void)
 }
 
 void
-message_free(ProfMessage* message)
+message_free(ProfMessage *message)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
     if (message->from_jid) {
         jid_destroy(message->from_jid);
     }
@@ -345,9 +344,9 @@ message_handlers_clear(void)
 }
 
 void
-message_pubsub_event_handler_add(const char* const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void* userdata)
+message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata)
 {
-    ProfMessageHandler* handler = malloc(sizeof(ProfMessageHandler));
+    ProfMessageHandler *handler = malloc(sizeof(ProfMessageHandler));
     handler->func = func;
     handler->free_func = free_func;
     handler->userdata = userdata;
@@ -356,15 +355,15 @@ message_pubsub_event_handler_add(const char* const node, ProfMessageCallback fun
 }
 
 char*
-message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id)
+message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* state = chat_session_get_state(barejid);
-    char* jid = chat_session_get_jid(barejid);
-    char* id = connection_create_stanza_id();
+    char *state = chat_session_get_state(barejid);
+    char *jid = chat_session_get_jid(barejid);
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
     xmpp_message_set_body(message, msg);
     free(jid);
 
@@ -391,28 +390,28 @@ message_send_chat(const char* const barejid, const char* const msg, const char*
 }
 
 char*
-message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
+message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* state = chat_session_get_state(barejid);
-    char* jid = chat_session_get_jid(barejid);
-    char* id = connection_create_stanza_id();
+    char *state = chat_session_get_state(barejid);
+    char *jid = chat_session_get_jid(barejid);
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = NULL;
+    xmpp_stanza_t *message = NULL;
 #ifdef HAVE_LIBGPGME
-    char* account_name = session_get_account_name();
-    ProfAccount* account = accounts_get_account(account_name);
+    char *account_name = session_get_account_name();
+    ProfAccount *account = accounts_get_account(account_name);
     if (account->pgp_keyid) {
-        Jid* jidp = jid_create(jid);
-        char* encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
+        Jid *jidp = jid_create(jid);
+        char *encrypted = p_gpg_encrypt(jidp->barejid, msg, account->pgp_keyid);
         if (encrypted) {
             message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
             xmpp_message_set_body(message, "This message is encrypted (XEP-0027).");
-            xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *x = xmpp_stanza_new(ctx);
             xmpp_stanza_set_name(x, STANZA_NAME_X);
             xmpp_stanza_set_ns(x, STANZA_NS_ENCRYPTED);
-            xmpp_stanza_t* enc_st = xmpp_stanza_new(ctx);
+            xmpp_stanza_t *enc_st = xmpp_stanza_new(ctx);
             xmpp_stanza_set_text(enc_st, encrypted);
             xmpp_stanza_add_child(x, enc_st);
             xmpp_stanza_release(enc_st);
@@ -456,44 +455,44 @@ message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean
 
 // XEP-0373: OpenPGP for XMPP
 char*
-message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
+message_send_chat_ox(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id)
 {
 #ifdef HAVE_LIBGPGME
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* state = chat_session_get_state(barejid);
-    char* jid = chat_session_get_jid(barejid);
-    char* id = connection_create_stanza_id();
+    char *state = chat_session_get_state(barejid);
+    char *jid = chat_session_get_jid(barejid);
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = NULL;
-    Jid* jidp = jid_create(jid);
+    xmpp_stanza_t *message = NULL;
+    Jid *jidp = jid_create(jid);
 
-    char* account_name = session_get_account_name();
-    ProfAccount* account = accounts_get_account(account_name);
+    char *account_name = session_get_account_name();
+    ProfAccount *account = accounts_get_account(account_name);
 
     message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
     xmpp_message_set_body(message, "This message is encrypted (XEP-0373: OpenPGP for XMPP).");
 
-    xmpp_stanza_t* openpgp = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *openpgp = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(openpgp, STANZA_NAME_OPENPGP);
     xmpp_stanza_set_ns(openpgp, STANZA_NS_OPENPGP_0);
 
-    xmpp_stanza_t* signcrypt = _openpgp_signcrypt(ctx, barejid, msg);
+    xmpp_stanza_t * signcrypt = _openpgp_signcrypt(ctx, barejid, msg);
     char* c;
     size_t s;
-    xmpp_stanza_to_text(signcrypt, &c, &s);
+    xmpp_stanza_to_text(signcrypt, &c,&s);
     char* signcrypt_e = p_ox_gpg_signcrypt(account->jid, barejid, c);
-    if (signcrypt_e == NULL) {
-        log_error("Message not signcrypted.");
-        return NULL;
+    if( signcrypt_e == NULL ) {
+      log_error("Message not signcrypted.");
+      return NULL;
     }
     // BASE64_OPENPGP_MESSAGE
     xmpp_stanza_t* base64_openpgp_message = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_text(base64_openpgp_message, signcrypt_e);
+    xmpp_stanza_set_text(base64_openpgp_message,signcrypt_e);
     xmpp_stanza_add_child(openpgp, base64_openpgp_message);
     xmpp_stanza_add_child(message, openpgp);
 
-    xmpp_stanza_to_text(message, &c, &s);
+    xmpp_stanza_to_text(message, &c,&s);
 
     account_free(account);
     jid_destroy(jidp);
@@ -520,15 +519,15 @@ message_send_chat_ox(const char* const barejid, const char* const msg, gboolean
 }
 
 char*
-message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
+message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* state = chat_session_get_state(barejid);
-    char* jid = chat_session_get_jid(barejid);
-    char* id = connection_create_stanza_id();
+    char *state = chat_session_get_state(barejid);
+    char *jid = chat_session_get_jid(barejid);
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, barejid, id);
     xmpp_message_set_body(message, msg);
 
     free(jid);
@@ -557,15 +556,15 @@ message_send_chat_otr(const char* const barejid, const char* const msg, gboolean
 
 #ifdef HAVE_OMEMO
 char*
-message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
-                        const unsigned char* const iv, size_t iv_len,
-                        const unsigned char* const ciphertext, size_t ciphertext_len,
-                        gboolean request_receipt, gboolean muc, const char* const replace_id)
+message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys,
+    const unsigned char *const iv, size_t iv_len,
+    const unsigned char *const ciphertext, size_t ciphertext_len,
+    gboolean request_receipt, gboolean muc, const char *const replace_id)
 {
-    char* state = chat_session_get_state(jid);
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id;
-    xmpp_stanza_t* message;
+    char *state = chat_session_get_state(jid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id;
+    xmpp_stanza_t *message;
     if (muc) {
         id = connection_create_stanza_id();
         message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, jid, id);
@@ -575,31 +574,31 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
         message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, jid, id);
     }
 
-    xmpp_stanza_t* encrypted = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *encrypted = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(encrypted, "encrypted");
     xmpp_stanza_set_ns(encrypted, STANZA_NS_OMEMO);
 
-    xmpp_stanza_t* header = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *header = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(header, "header");
-    char* sid_text = g_strdup_printf("%d", sid);
+    char *sid_text = g_strdup_printf("%d", sid);
     xmpp_stanza_set_attribute(header, "sid", sid_text);
     g_free(sid_text);
 
-    GList* key_iter;
+    GList *key_iter;
     for (key_iter = keys; key_iter != NULL; key_iter = key_iter->next) {
-        omemo_key_t* key = (omemo_key_t*)key_iter->data;
+        omemo_key_t *key = (omemo_key_t *)key_iter->data;
 
-        xmpp_stanza_t* key_stanza = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *key_stanza = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(key_stanza, "key");
-        char* rid = g_strdup_printf("%d", key->device_id);
+        char *rid = g_strdup_printf("%d", key->device_id);
         xmpp_stanza_set_attribute(key_stanza, "rid", rid);
         g_free(rid);
         if (key->prekey) {
             xmpp_stanza_set_attribute(key_stanza, "prekey", "true");
         }
 
-        gchar* key_raw = g_base64_encode(key->data, key->length);
-        xmpp_stanza_t* key_text = xmpp_stanza_new(ctx);
+        gchar *key_raw = g_base64_encode(key->data, key->length);
+        xmpp_stanza_t *key_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(key_text, key_raw);
         g_free(key_raw);
 
@@ -609,11 +608,11 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
         xmpp_stanza_release(key_stanza);
     }
 
-    xmpp_stanza_t* iv_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *iv_stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(iv_stanza, "iv");
 
-    gchar* iv_raw = g_base64_encode(iv, iv_len);
-    xmpp_stanza_t* iv_text = xmpp_stanza_new(ctx);
+    gchar *iv_raw = g_base64_encode(iv, iv_len);
+    xmpp_stanza_t *iv_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(iv_text, iv_raw);
     g_free(iv_raw);
 
@@ -625,11 +624,11 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
     xmpp_stanza_add_child(encrypted, header);
     xmpp_stanza_release(header);
 
-    xmpp_stanza_t* payload = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *payload = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(payload, "payload");
 
-    gchar* ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len);
-    xmpp_stanza_t* payload_text = xmpp_stanza_new(ctx);
+    gchar *ciphertext_raw = g_base64_encode(ciphertext, ciphertext_len);
+    xmpp_stanza_t *payload_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(payload_text, ciphertext_raw);
     g_free(ciphertext_raw);
 
@@ -641,9 +640,9 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
     xmpp_stanza_add_child(message, encrypted);
     xmpp_stanza_release(encrypted);
 
-    xmpp_stanza_t* body = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *body = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(body, "body");
-    xmpp_stanza_t* body_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *body_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(body_text, "You received a message encrypted with OMEMO but your client doesn't support OMEMO.");
     xmpp_stanza_add_child(body, body_text);
     xmpp_stanza_release(body_text);
@@ -672,12 +671,12 @@ message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys,
 #endif
 
 char*
-message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url)
+message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
     xmpp_message_set_body(message, msg);
 
     if (oob_url) {
@@ -691,12 +690,12 @@ message_send_private(const char* const fulljid, const char* const msg, const cha
 }
 
 char*
-message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id)
+message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, roomjid, id);
     stanza_attach_origin_id(ctx, message, id);
     xmpp_message_set_body(message, msg);
 
@@ -715,26 +714,26 @@ message_send_groupchat(const char* const roomjid, const char* const msg, const c
 }
 
 void
-message_send_groupchat_subject(const char* const roomjid, const char* const subject)
+message_send_groupchat_subject(const char *const roomjid, const char *const subject)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* message = stanza_create_room_subject_message(ctx, roomjid, subject);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *message = stanza_create_room_subject_message(ctx, roomjid, subject);
 
     _send_message_stanza(message);
     xmpp_stanza_release(message);
 }
 
 void
-message_send_invite(const char* const roomjid, const char* const contact,
-                    const char* const reason)
+message_send_invite(const char *const roomjid, const char *const contact,
+    const char *const reason)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* stanza;
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *stanza;
 
     muc_member_type_t member_type = muc_member_type(roomjid);
     if (member_type == MUC_MEMBER_TYPE_PUBLIC) {
         log_debug("Sending direct invite to %s, for %s", contact, roomjid);
-        char* password = muc_password(roomjid);
+        char *password = muc_password(roomjid);
         stanza = stanza_create_invite(ctx, roomjid, contact, reason, password);
     } else {
         log_debug("Sending mediated invite to %s, for %s", contact, roomjid);
@@ -746,58 +745,59 @@ message_send_invite(const char* const roomjid, const char* const contact,
 }
 
 void
-message_send_composing(const char* const jid)
+message_send_composing(const char *const jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_COMPOSING);
+    xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_COMPOSING);
     _send_message_stanza(stanza);
     xmpp_stanza_release(stanza);
+
 }
 
 void
-message_send_paused(const char* const jid)
+message_send_paused(const char *const jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_PAUSED);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_PAUSED);
     _send_message_stanza(stanza);
     xmpp_stanza_release(stanza);
 }
 
 void
-message_send_inactive(const char* const jid)
+message_send_inactive(const char *const jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_INACTIVE);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_INACTIVE);
 
     _send_message_stanza(stanza);
     xmpp_stanza_release(stanza);
 }
 
 void
-message_send_gone(const char* const jid)
+message_send_gone(const char *const jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_GONE);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, jid, STANZA_NAME_GONE);
     _send_message_stanza(stanza);
     xmpp_stanza_release(stanza);
 }
 
 static void
-_handle_error(xmpp_stanza_t* const stanza)
+_handle_error(xmpp_stanza_t *const stanza)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
-    const char* jid = xmpp_stanza_get_from(stanza);
-    xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
-    const char* type = NULL;
+    const char *id = xmpp_stanza_get_id(stanza);
+    const char *jid = xmpp_stanza_get_from(stanza);
+    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    const char *type = NULL;
     if (error_stanza) {
         type = xmpp_stanza_get_type(error_stanza);
     }
 
     // stanza_get_error never returns NULL
-    char* err_msg = stanza_get_error_message(stanza);
+    char *err_msg = stanza_get_error_message(stanza);
 
-    GString* log_msg = g_string_new("message stanza error received");
+    GString *log_msg = g_string_new("message stanza error received");
     if (id) {
         g_string_append(log_msg, " id=");
         g_string_append(log_msg, id);
@@ -821,7 +821,7 @@ _handle_error(xmpp_stanza_t* const stanza)
         ui_handle_error(err_msg);
     } else if (type && (strcmp(type, "cancel") == 0)) {
         log_info("Recipient %s not found: %s", jid, err_msg);
-        Jid* jidp = jid_create(jid);
+        Jid *jidp = jid_create(jid);
         chat_session_remove(jidp->barejid);
         jid_destroy(jidp);
     } else {
@@ -832,11 +832,11 @@ _handle_error(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_muc_user(xmpp_stanza_t* const stanza)
+_handle_muc_user(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
-    const char* room = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    const char *room = xmpp_stanza_get_from(stanza);
 
     if (!room) {
         log_warning("Message received with no from attribute, ignoring");
@@ -844,31 +844,31 @@ _handle_muc_user(xmpp_stanza_t* const stanza)
     }
 
     // XEP-0045
-    xmpp_stanza_t* invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE);
+    xmpp_stanza_t *invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE);
     if (!invite) {
         return;
     }
 
-    const char* invitor_jid = xmpp_stanza_get_from(invite);
+    const char *invitor_jid = xmpp_stanza_get_from(invite);
     if (!invitor_jid) {
         log_warning("Chat room invite received with no from attribute");
         return;
     }
 
-    Jid* jidp = jid_create(invitor_jid);
+    Jid *jidp = jid_create(invitor_jid);
     if (!jidp) {
         return;
     }
-    char* invitor = jidp->barejid;
+    char *invitor = jidp->barejid;
 
-    char* reason = NULL;
-    xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);
+    char *reason = NULL;
+    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);
     if (reason_st) {
         reason = xmpp_stanza_get_text(reason_st);
     }
 
-    char* password = NULL;
-    xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD);
+    char *password = NULL;
+    xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD);
     if (password_st) {
         password = xmpp_stanza_get_text(password_st);
     }
@@ -884,40 +884,40 @@ _handle_muc_user(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_conference(xmpp_stanza_t* const stanza)
+_handle_conference(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
+    xmpp_stanza_t *xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("Message received with no from attribute, ignoring");
         return;
     }
 
-    Jid* jidp = jid_create(from);
+    Jid *jidp = jid_create(from);
     if (!jidp) {
         return;
     }
 
     // XEP-0249
-    const char* room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID);
+    const char *room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID);
     if (!room) {
         jid_destroy(jidp);
         return;
     }
 
-    const char* reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON);
-    const char* password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD);
+    const char *reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON);
+    const char *password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD);
 
     sv_ev_room_invite(INVITE_DIRECT, jidp->barejid, room, reason, password);
     jid_destroy(jidp);
 }
 
 static void
-_handle_captcha(xmpp_stanza_t* const stanza)
+_handle_captcha(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    const char *from = xmpp_stanza_get_from(stanza);
 
     if (!from) {
         log_warning("Message received with no from attribute, ignoring");
@@ -925,7 +925,7 @@ _handle_captcha(xmpp_stanza_t* const stanza)
     }
 
     // XEP-0158
-    char* message = xmpp_message_get_body(stanza);
+    char *message = xmpp_message_get_body(stanza);
     if (!message) {
         return;
     }
@@ -935,25 +935,25 @@ _handle_captcha(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_groupchat(xmpp_stanza_t* const stanza)
+_handle_groupchat(xmpp_stanza_t *const stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    const char* id = xmpp_stanza_get_id(stanza);
-    char* originid = NULL;
+    const char *id = xmpp_stanza_get_id(stanza);
+    char *originid = NULL;
 
-    xmpp_stanza_t* origin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_ORIGIN_ID, STANZA_NS_STABLE_ID);
+    xmpp_stanza_t *origin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_ORIGIN_ID, STANZA_NS_STABLE_ID);
     if (origin) {
         originid = (char*)xmpp_stanza_get_attribute(origin, STANZA_ATTR_ID);
     }
 
-    const char* room_jid = xmpp_stanza_get_from(stanza);
-    Jid* from_jid = jid_create(room_jid);
+    const char *room_jid = xmpp_stanza_get_from(stanza);
+    Jid *from_jid = jid_create(room_jid);
 
     // handle room subject
-    xmpp_stanza_t* subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
+    xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
     if (subject) {
-        char* subject_text;
+        char *subject_text;
         subject_text = xmpp_stanza_get_text(subject);
         sv_ev_room_subject(from_jid->barejid, from_jid->resourcepart, subject_text);
         xmpp_free(ctx, subject_text);
@@ -964,7 +964,7 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
 
     // handle room broadcasts
     if (!from_jid->resourcepart) {
-        char* broadcast;
+        char *broadcast;
         broadcast = xmpp_message_get_body(stanza);
         if (!broadcast) {
             jid_destroy(from_jid);
@@ -991,7 +991,7 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
         return;
     }
 
-    ProfMessage* message = message_init();
+    ProfMessage *message = message_init();
     message->from_jid = from_jid;
     message->type = PROF_MSG_TYPE_MUC;
 
@@ -1003,9 +1003,9 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
         message->originid = strdup(originid);
     }
 
-    xmpp_stanza_t* replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
+    xmpp_stanza_t *replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
     if (replace_id_stanza) {
-        const char* replace_id = xmpp_stanza_get_id(replace_id_stanza);
+        const char *replace_id = xmpp_stanza_get_id(replace_id_stanza);
         if (replace_id) {
             message->replace_id = strdup(replace_id);
         }
@@ -1063,15 +1063,15 @@ out:
 }
 
 static void
-_message_send_receipt(const char* const fulljid, const char* const message_id)
+_message_send_receipt(const char *const fulljid, const char *const message_id)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, fulljid, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, fulljid, id);
     free(id);
 
-    xmpp_stanza_t* receipt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *receipt = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(receipt, "received");
     xmpp_stanza_set_ns(receipt, STANZA_NS_RECEIPTS);
     xmpp_stanza_set_id(receipt, message_id);
@@ -1084,69 +1084,69 @@ _message_send_receipt(const char* const fulljid, const char* const message_id)
 }
 
 static void
-_handle_receipt_received(xmpp_stanza_t* const stanza)
+_handle_receipt_received(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
-    const char* name = xmpp_stanza_get_name(receipt);
+    xmpp_stanza_t *receipt = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
+    const char *name = xmpp_stanza_get_name(receipt);
     if (g_strcmp0(name, "received") != 0) {
         return;
     }
 
-    const char* id = xmpp_stanza_get_id(receipt);
+    const char *id = xmpp_stanza_get_id(receipt);
     if (!id) {
         return;
     }
 
-    const char* fulljid = xmpp_stanza_get_from(stanza);
+    const char *fulljid = xmpp_stanza_get_from(stanza);
     if (!fulljid) {
         return;
     }
 
-    Jid* jidp = jid_create(fulljid);
+    Jid *jidp = jid_create(fulljid);
     sv_ev_message_receipt(jidp->barejid, id);
     jid_destroy(jidp);
 }
 
 static void
-_receipt_request_handler(xmpp_stanza_t* const stanza)
+_receipt_request_handler(xmpp_stanza_t *const stanza)
 {
     if (!prefs_get_boolean(PREF_RECEIPTS_SEND)) {
         return;
     }
 
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
     if (!id) {
         return;
     }
 
-    xmpp_stanza_t* receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
+    xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
     if (!receipts) {
         return;
     }
 
-    const char* receipts_name = xmpp_stanza_get_name(receipts);
+    const char *receipts_name = xmpp_stanza_get_name(receipts);
     if (g_strcmp0(receipts_name, "request") != 0) {
         return;
     }
 
-    const gchar* from = xmpp_stanza_get_from(stanza);
-    Jid* jid = jid_create(from);
+    const gchar *from = xmpp_stanza_get_from(stanza);
+    Jid *jid = jid_create(from);
     _message_send_receipt(jid->fulljid, id);
     jid_destroy(jid);
 }
 
 static void
-_handle_muc_private_message(xmpp_stanza_t* const stanza)
+_handle_muc_private_message(xmpp_stanza_t *const stanza)
 {
     // standard chat message, use jid without resource
-    ProfMessage* message = message_init();
+    ProfMessage *message = message_init();
     message->type = PROF_MSG_TYPE_MUCPM;
 
-    const gchar* from = xmpp_stanza_get_from(stanza);
+    const gchar *from = xmpp_stanza_get_from(stanza);
     message->from_jid = jid_create(from);
 
     // message stanza id
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
     if (id) {
         message->id = strdup(id);
     }
@@ -1182,9 +1182,9 @@ out:
 }
 
 static xmpp_stanza_t*
-_handle_carbons(xmpp_stanza_t* const stanza)
+_handle_carbons(xmpp_stanza_t *const stanza)
 {
-    const char* name = xmpp_stanza_get_name(stanza);
+    const char *name = xmpp_stanza_get_name(stanza);
     if (!name) {
         log_error("Unable to retrieve stanza name for Carbon");
         return NULL;
@@ -1201,13 +1201,13 @@ _handle_carbons(xmpp_stanza_t* const stanza)
         return NULL;
     }
 
-    xmpp_stanza_t* forwarded = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_FORWARD);
+    xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_FORWARD);
     if (!forwarded) {
         log_warning("Carbon received with no forwarded element");
         return NULL;
     }
 
-    xmpp_stanza_t* message_stanza = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
+    xmpp_stanza_t *message_stanza = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
     if (!message_stanza) {
         log_warning("Carbon received with no message element");
         return NULL;
@@ -1217,25 +1217,25 @@ _handle_carbons(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
+_handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam, gboolean is_carbon)
 {
     // some clients send the mucuser namespace with private messages
     // if the namespace exists, and the stanza contains a body element, assume its a private message
     // otherwise exit the handler
-    xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
-    xmpp_stanza_t* body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
+    xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
     if (mucuser && body == NULL) {
         return;
     }
 
-    const gchar* from = xmpp_stanza_get_from(stanza);
+    const gchar *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         return;
     }
-    Jid* jid = jid_create(from);
+    Jid *jid = jid_create(from);
 
-    Jid* to_jid = NULL;
-    const gchar* to = xmpp_stanza_get_to(stanza);
+    Jid *to_jid = NULL;
+    const gchar *to = xmpp_stanza_get_to(stanza);
     if (to) {
         to_jid = jid_create(to);
     }
@@ -1249,7 +1249,7 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
     }
 
     // standard chat message, use jid without resource
-    ProfMessage* message = message_init();
+    ProfMessage *message = message_init();
     message->is_mam = is_mam;
     message->from_jid = jid;
     if (to_jid) {
@@ -1258,7 +1258,7 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
         if (is_carbon) {
             // happens when receive a carbon of a self sent message
             // really? maybe some servers do this, but it's not required.
-            Jid* from_jid = jid_create(from);
+            Jid *from_jid = jid_create(from);
             message->to_jid = from_jid;
         }
     }
@@ -1269,21 +1269,21 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
         message->type = PROF_MSG_TYPE_CHAT;
     }
 
-    const gchar* to_text = xmpp_stanza_get_to(stanza);
+    const gchar *to_text = xmpp_stanza_get_to(stanza);
     if (to_text) {
         message->to_jid = jid_create(to_text);
     }
 
     // message stanza id
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
     if (id) {
         message->id = strdup(id);
     }
 
     // replace id for XEP-0308: Last Message Correction
-    xmpp_stanza_t* replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
+    xmpp_stanza_t *replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
     if (replace_id_stanza) {
-        const char* replace_id = xmpp_stanza_get_id(replace_id_stanza);
+        const char *replace_id = xmpp_stanza_get_id(replace_id_stanza);
         if (replace_id) {
             message->replace_id = strdup(replace_id);
         }
@@ -1307,19 +1307,19 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
     }
 #endif
 
-    xmpp_stanza_t* encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_ENCRYPTED);
+    xmpp_stanza_t *encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_ENCRYPTED);
     if (encrypted) {
         message->encrypted = xmpp_stanza_get_text(encrypted);
     }
 
-    xmpp_stanza_t* ox = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OPENPGP_0);
+    xmpp_stanza_t *ox = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OPENPGP_0);
     if (ox) {
-        _handle_ox_chat(stanza, message, FALSE);
+        _handle_ox_chat(stanza,message, FALSE);
     }
 
     if (message->plain || message->body || message->encrypted) {
         if (is_carbon) {
-            char* mybarejid = connection_get_barejid();
+            char *mybarejid = connection_get_barejid();
 
             // if we are the recipient, treat as standard incoming message
             if (g_strcmp0(mybarejid, message->to_jid->barejid) == 0) {
@@ -1345,17 +1345,18 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon)
     message_free(message);
 }
 
+
 /*!
  * @brief Handle incoming XMMP-OX chat message.
  */
 static void
-_handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam)
+_handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam)
 {
-    message->enc = PROF_MSG_ENC_OX;
+    message->enc=PROF_MSG_ENC_OX;
 
 #ifdef HAVE_LIBGPGME
-    xmpp_stanza_t* ox = stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
-    message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
+	xmpp_stanza_t *ox = stanza_get_child_by_name_and_ns(stanza, "openpgp", STANZA_NS_OPENPGP_0);
+	message->plain = p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));
 
     // Implementation for libstrophe 0.10.
     /*
@@ -1369,41 +1370,40 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
 	message->encrypted = xmpp_stanza_get_text(ox);
     */
 
-    if (message->plain == NULL) {
+    if(message->plain == NULL ) {
         message->plain = xmpp_stanza_get_text(stanza);
     }
-    message->encrypted = xmpp_stanza_get_text(ox);
+	message->encrypted = xmpp_stanza_get_text(ox);
 #endif // HAVE_LIBGPGME
 }
 
 static gboolean
-_handle_mam(xmpp_stanza_t* const stanza)
+_handle_mam(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* result = stanza_get_child_by_name_and_ns(stanza, "result", STANZA_NS_MAM2);
+    xmpp_stanza_t *result = stanza_get_child_by_name_and_ns(stanza, "result", STANZA_NS_MAM2);
     if (!result) {
         return FALSE;
     }
 
-    xmpp_stanza_t* forwarded = xmpp_stanza_get_child_by_ns(result, STANZA_NS_FORWARD);
+    xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(result, STANZA_NS_FORWARD);
     if (!forwarded) {
         log_warning("MAM received with no forwarded element");
         return FALSE;
     }
 
-    xmpp_stanza_t* message_stanza = xmpp_stanza_get_child_by_ns(forwarded, "jabber:client");
+    xmpp_stanza_t *message_stanza = xmpp_stanza_get_child_by_ns(forwarded, "jabber:client");
     _handle_chat(message_stanza, TRUE, FALSE);
 
     return TRUE;
 }
 
 static void
-_handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event)
-{
-    xmpp_stanza_t* child = xmpp_stanza_get_children(event);
+_handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event) {
+    xmpp_stanza_t *child = xmpp_stanza_get_children(event);
     if (child) {
-        const char* node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
+        const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
         if (node) {
-            ProfMessageHandler* handler = g_hash_table_lookup(pubsub_event_handlers, node);
+            ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, node);
             if (handler) {
                 int keep = handler->func(stanza, handler->userdata);
                 if (!keep) {
@@ -1415,14 +1415,14 @@ _handle_pubsub(xmpp_stanza_t* const stanza, xmpp_stanza_t* const event)
 }
 
 static void
-_send_message_stanza(xmpp_stanza_t* const stanza)
+_send_message_stanza(xmpp_stanza_t *const stanza)
 {
-    char* text;
+    char *text;
     size_t text_size;
     xmpp_stanza_to_text(stanza, &text, &text_size);
 
-    xmpp_conn_t* conn = connection_get_conn();
-    char* plugin_text = plugins_on_message_stanza_send(text);
+    xmpp_conn_t *conn = connection_get_conn();
+    char *plugin_text = plugins_on_message_stanza_send(text);
     if (plugin_text) {
         xmpp_send_raw_string(conn, "%s", plugin_text);
         free(plugin_text);
@@ -1436,14 +1436,13 @@ _send_message_stanza(xmpp_stanza_t* const stanza)
  * checkOID = false: check regular id
  */
 bool
-message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
-{
+message_is_sent_by_us(const ProfMessage *const message, bool checkOID) {
     bool ret = FALSE;
 
     // we check the </origin-id> for this we calculate a hash into it so we can detect
     // whether this client sent it. See connection_create_stanza_id()
     if (message) {
-        char* tmp_id = NULL;
+        char *tmp_id = NULL;
 
         if (checkOID && message->originid != NULL) {
             tmp_id = message->originid;
@@ -1453,16 +1452,16 @@ message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
 
         if (tmp_id != NULL) {
             gsize tmp_len;
-            char* tmp = (char*)g_base64_decode(tmp_id, &tmp_len);
+            char *tmp = (char*)g_base64_decode(tmp_id, &tmp_len);
 
             // our client sents at least 36 (uuid) + identifier
             if (tmp_len > 36) {
-                char* uuid = g_strndup(tmp, 36);
-                const char* prof_identifier = connection_get_profanity_identifier();
+                char *uuid = g_strndup(tmp, 36);
+                const char *prof_identifier = connection_get_profanity_identifier();
 
-                gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
-                                                        (guchar*)prof_identifier, strlen(prof_identifier),
-                                                        uuid, strlen(uuid));
+                gchar *hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
+                        (guchar*)prof_identifier, strlen(prof_identifier),
+                        uuid, strlen(uuid));
 
                 if (g_strcmp0(&tmp[36], hmac) == 0) {
                     ret = TRUE;
@@ -1475,7 +1474,7 @@ message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
         }
     }
 
-    return ret;
+    return  ret;
 }
 
 #ifdef HAVE_LIBGPGME
@@ -1489,44 +1488,44 @@ _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text
     int randnr = rand() % 5;
     char rpad_data[randnr];
 
-    for (int i = 0; i < randnr - 1; i++) {
+    for(int i = 0; i < randnr-1; i++) {
         rpad_data[i] = 'c';
     }
-    rpad_data[randnr - 1] = '\0';
+    rpad_data[randnr-1] = '\0';
 
     // signcrypt
-    xmpp_stanza_t* signcrypt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *signcrypt = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(signcrypt, "signcrypt");
     xmpp_stanza_set_ns(signcrypt, "urn:xmpp:openpgp:0");
     // to
-    xmpp_stanza_t* s_to = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *s_to = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(s_to, "to");
     xmpp_stanza_set_attribute(s_to, "jid", to);
     // time
-    xmpp_stanza_t* time = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *time = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(time, "time");
     xmpp_stanza_set_attribute(time, "stamp", buf);
     xmpp_stanza_set_name(time, "time");
     // rpad
-    xmpp_stanza_t* rpad = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *rpad = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(rpad, "rpad");
-    xmpp_stanza_t* rpad_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *rpad_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(rpad_text, rpad_data);
     // payload
-    xmpp_stanza_t* payload = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *payload= xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(payload, "payload");
     // body
-    xmpp_stanza_t* body = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *body = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(body, "body");
     xmpp_stanza_set_ns(body, "jabber:client");
     // text
-    xmpp_stanza_t* body_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *body_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(body_text, text);
-    xmpp_stanza_add_child(signcrypt, s_to);
-    xmpp_stanza_add_child(signcrypt, time);
-    xmpp_stanza_add_child(signcrypt, rpad);
-    xmpp_stanza_add_child(rpad, rpad_text);
-    xmpp_stanza_add_child(signcrypt, payload);
+    xmpp_stanza_add_child(signcrypt,s_to);
+    xmpp_stanza_add_child(signcrypt,time);
+    xmpp_stanza_add_child(signcrypt,rpad);
+    xmpp_stanza_add_child(rpad,rpad_text);
+    xmpp_stanza_add_child(signcrypt,payload);
     xmpp_stanza_add_child(payload, body);
     xmpp_stanza_add_child(body, body_text);
 
@@ -1540,3 +1539,4 @@ _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text
     return signcrypt;
 }
 #endif // HAVE_LIBGPGME
+
diff --git a/src/xmpp/message.h b/src/xmpp/message.h
index fec5662a..aa82b2cf 100644
--- a/src/xmpp/message.h
+++ b/src/xmpp/message.h
@@ -38,13 +38,13 @@
 
 #include "xmpp/xmpp.h"
 
-typedef int (*ProfMessageCallback)(xmpp_stanza_t* const stanza, void* const userdata);
-typedef void (*ProfMessageFreeCallback)(void* userdata);
+typedef int(*ProfMessageCallback)(xmpp_stanza_t *const stanza, void *const userdata);
+typedef void(*ProfMessageFreeCallback)(void *userdata);
 
-ProfMessage* message_init(void);
-void message_free(ProfMessage* message);
+ProfMessage *message_init(void);
+void message_free(ProfMessage *message);
 void message_handlers_init(void);
 void message_handlers_clear(void);
-void message_pubsub_event_handler_add(const char* const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void* userdata);
+void message_pubsub_event_handler_add(const char *const node, ProfMessageCallback func, ProfMessageFreeCallback free_func, void *userdata);
 
 #endif
diff --git a/src/xmpp/muc.c b/src/xmpp/muc.c
index e9175590..85f90ae6 100644
--- a/src/xmpp/muc.c
+++ b/src/xmpp/muc.c
@@ -33,9 +33,9 @@
  *
  */
 
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <glib.h>
 
@@ -43,51 +43,50 @@
 #include "tools/autocomplete.h"
 #include "ui/ui.h"
 #include "ui/window_list.h"
-#include "xmpp/contact.h"
 #include "xmpp/jid.h"
 #include "xmpp/muc.h"
+#include "xmpp/contact.h"
 
 #ifdef HAVE_OMEMO
 #include "omemo/omemo.h"
 #endif
 
-typedef struct _muc_room_t
-{
-    char* room; // e.g. test@conference.server
-    char* nick; // e.g. Some User
+typedef struct _muc_room_t {
+    char *room; // e.g. test@conference.server
+    char *nick; // e.g. Some User
     muc_role_t role;
     muc_affiliation_t affiliation;
-    char* password;
-    char* subject;
-    char* autocomplete_prefix;
+    char *password;
+    char *subject;
+    char *autocomplete_prefix;
     gboolean pending_config;
-    GList* pending_broadcasts;
+    GList *pending_broadcasts;
     gboolean autojoin;
     gboolean pending_nick_change;
-    GHashTable* roster;
-    GHashTable* members;
+    GHashTable *roster;
+    GHashTable *members;
     Autocomplete nick_ac;
     Autocomplete jid_ac;
-    GHashTable* nick_changes;
+    GHashTable *nick_changes;
     gboolean roster_received;
     muc_member_type_t member_type;
     muc_anonymity_type_t anonymity_type;
 } ChatRoom;
 
-GHashTable* rooms = NULL;
-GHashTable* invite_passwords = NULL;
+GHashTable *rooms = NULL;
+GHashTable *invite_passwords = NULL;
 Autocomplete invite_ac = NULL;
 Autocomplete confservers_ac = NULL;
 
-static void _free_room(ChatRoom* room);
-static gint _compare_occupants(Occupant* a, Occupant* b);
-static muc_role_t _role_from_string(const char* const role);
-static muc_affiliation_t _affiliation_from_string(const char* const affiliation);
+static void _free_room(ChatRoom *room);
+static gint _compare_occupants(Occupant *a, Occupant *b);
+static muc_role_t _role_from_string(const char *const role);
+static muc_affiliation_t _affiliation_from_string(const char *const affiliation);
 static char* _role_to_string(muc_role_t role);
 static char* _affiliation_to_string(muc_affiliation_t affiliation);
-static Occupant* _muc_occupant_new(const char* const nick, const char* const jid, muc_role_t role,
-                                   muc_affiliation_t affiliation, resource_presence_t presence, const char* const status);
-static void _occupant_free(Occupant* occupant);
+static Occupant* _muc_occupant_new(const char *const nick, const char *const jid, muc_role_t role,
+    muc_affiliation_t affiliation, resource_presence_t presence, const char *const status);
+static void _occupant_free(Occupant *occupant);
 
 void
 muc_init(void)
@@ -112,13 +111,13 @@ muc_close(void)
 }
 
 void
-muc_confserver_add(const char* const server)
+muc_confserver_add(const char *const server)
 {
     autocomplete_add(confservers_ac, server);
 }
 
 void
-muc_invites_add(const char* const room, const char* const password)
+muc_invites_add(const char *const room, const char *const password)
 {
     autocomplete_add(invite_ac, room);
     if (password) {
@@ -127,7 +126,7 @@ muc_invites_add(const char* const room, const char* const password)
 }
 
 void
-muc_invites_remove(const char* const room)
+muc_invites_remove(const char *const room)
 {
     autocomplete_remove(invite_ac, room);
     g_hash_table_remove(invite_passwords, room);
@@ -146,16 +145,16 @@ muc_invites(void)
 }
 
 char*
-muc_invite_password(const char* const room)
+muc_invite_password(const char *const room)
 {
     return g_hash_table_lookup(invite_passwords, room);
 }
 
 gboolean
-muc_invites_contain(const char* const room)
+muc_invites_contain(const char *const room)
 {
-    GList* invites = autocomplete_create_list(invite_ac);
-    GList* curr = invites;
+    GList *invites = autocomplete_create_list(invite_ac);
+    GList *curr = invites;
     while (curr) {
         if (strcmp(curr->data, room) == 0) {
             g_list_free_full(invites, g_free);
@@ -182,13 +181,13 @@ muc_confserver_reset_ac(void)
 }
 
 char*
-muc_invites_find(const char* const search_str, gboolean previous, void* context)
+muc_invites_find(const char *const search_str, gboolean previous, void *context)
 {
     return autocomplete_complete(invite_ac, search_str, TRUE, previous);
 }
 
 char*
-muc_confserver_find(const char* const search_str, gboolean previous, void* context)
+muc_confserver_find(const char *const search_str, gboolean previous, void *context)
 {
     return autocomplete_complete(confservers_ac, search_str, TRUE, previous);
 }
@@ -209,9 +208,9 @@ muc_confserver_clear(void)
 }
 
 void
-muc_join(const char* const room, const char* const nick, const char* const password, gboolean autojoin)
+muc_join(const char *const room, const char *const nick, const char *const password, gboolean autojoin)
 {
-    ChatRoom* new_room = malloc(sizeof(ChatRoom));
+    ChatRoom *new_room = malloc(sizeof(ChatRoom));
     new_room->room = strdup(room);
     new_room->nick = strdup(nick);
     new_room->role = MUC_ROLE_NONE;
@@ -240,35 +239,36 @@ muc_join(const char* const room, const char* const nick, const char* const passw
 }
 
 void
-muc_leave(const char* const room)
+muc_leave(const char *const room)
 {
     g_hash_table_remove(rooms, room);
 }
 
 gboolean
-muc_requires_config(const char* const room)
+muc_requires_config(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->pending_config;
     } else {
         return FALSE;
     }
+
 }
 
 void
-muc_set_requires_config(const char* const room, gboolean val)
+muc_set_requires_config(const char *const room, gboolean val)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->pending_config = val;
     }
 }
 
 void
-muc_set_features(const char* const room, GSList* features)
+muc_set_features(const char *const room, GSList *features)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room && features) {
         if (g_slist_find_custom(features, "muc_membersonly", (GCompareFunc)g_strcmp0)) {
             chat_room->member_type = MUC_MEMBER_TYPE_MEMBERS_ONLY;
@@ -289,16 +289,16 @@ muc_set_features(const char* const room, GSList* features)
  * Returns TRUE if the user is currently in the room
  */
 gboolean
-muc_active(const char* const room)
+muc_active(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     return (chat_room != NULL);
 }
 
 gboolean
-muc_autojoin(const char* const room)
+muc_autojoin(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->autojoin;
     } else {
@@ -307,9 +307,9 @@ muc_autojoin(const char* const room)
 }
 
 void
-muc_set_subject(const char* const room, const char* const subject)
+muc_set_subject(const char *const room, const char *const subject)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         free(chat_room->subject);
         if (subject) {
@@ -321,9 +321,9 @@ muc_set_subject(const char* const room, const char* const subject)
 }
 
 char*
-muc_subject(const char* const room)
+muc_subject(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->subject;
     } else {
@@ -332,18 +332,18 @@ muc_subject(const char* const room)
 }
 
 void
-muc_pending_broadcasts_add(const char* const room, const char* const message)
+muc_pending_broadcasts_add(const char *const room, const char *const message)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->pending_broadcasts = g_list_append(chat_room->pending_broadcasts, strdup(message));
     }
 }
 
 GList*
-muc_pending_broadcasts(const char* const room)
+muc_pending_broadcasts(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->pending_broadcasts;
     } else {
@@ -352,9 +352,9 @@ muc_pending_broadcasts(const char* const room)
 }
 
 char*
-muc_old_nick(const char* const room, const char* const new_nick)
+muc_old_nick(const char *const room, const char *const new_nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room && chat_room->pending_nick_change) {
         return g_hash_table_lookup(chat_room->nick_changes, new_nick);
     } else {
@@ -367,9 +367,9 @@ muc_old_nick(const char* const room, const char* const new_nick)
  * and is awaiting the response
  */
 void
-muc_nick_change_start(const char* const room, const char* const new_nick)
+muc_nick_change_start(const char *const room, const char *const new_nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->pending_nick_change = TRUE;
         g_hash_table_insert(chat_room->nick_changes, strdup(new_nick), strdup(chat_room->nick));
@@ -381,9 +381,9 @@ muc_nick_change_start(const char* const room, const char* const new_nick)
  * nick change
  */
 gboolean
-muc_nick_change_pending(const char* const room)
+muc_nick_change_pending(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->pending_nick_change;
     } else {
@@ -396,9 +396,9 @@ muc_nick_change_pending(const char* const room)
  * the service has responded
  */
 void
-muc_nick_change_complete(const char* const room, const char* const nick)
+muc_nick_change_complete(const char *const room, const char *const nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         g_hash_table_remove(chat_room->roster, chat_room->nick);
         autocomplete_remove(chat_room->nick_ac, chat_room->nick);
@@ -425,9 +425,9 @@ muc_rooms(void)
  * The nickname is owned by the chat room and should not be modified or freed
  */
 char*
-muc_nick(const char* const room)
+muc_nick(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->nick;
     } else {
@@ -440,9 +440,9 @@ muc_nick(const char* const room)
  * The password is owned by the chat room and should not be modified or freed
  */
 char*
-muc_password(const char* const room)
+muc_password(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->password;
     } else {
@@ -454,11 +454,11 @@ muc_password(const char* const room)
  * Returns TRUE if the specified nick exists in the room's roster
  */
 gboolean
-muc_roster_contains_nick(const char* const room, const char* const nick)
+muc_roster_contains_nick(const char *const room, const char *const nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        Occupant* occupant = g_hash_table_lookup(chat_room->roster, nick);
+        Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick);
         return (occupant != NULL);
     } else {
         return FALSE;
@@ -469,31 +469,32 @@ muc_roster_contains_nick(const char* const room, const char* const nick)
  * Add a new chat room member to the room's roster
  */
 gboolean
-muc_roster_add(const char* const room, const char* const nick, const char* const jid, const char* const role,
-               const char* const affiliation, const char* const show, const char* const status)
+muc_roster_add(const char *const room, const char *const nick, const char *const jid, const char *const role,
+    const char *const affiliation, const char *const show, const char *const status)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     gboolean updated = FALSE;
     resource_presence_t new_presence = resource_presence_from_string(show);
 
     if (chat_room) {
-        Occupant* old = g_hash_table_lookup(chat_room->roster, nick);
+        Occupant *old = g_hash_table_lookup(chat_room->roster, nick);
 
         if (!old) {
             updated = TRUE;
             autocomplete_add(chat_room->nick_ac, nick);
-        } else if (old->presence != new_presence || (g_strcmp0(old->status, status) != 0)) {
+        } else if (old->presence != new_presence ||
+                    (g_strcmp0(old->status, status) != 0)) {
             updated = TRUE;
         }
 
         resource_presence_t presence = resource_presence_from_string(show);
         muc_role_t role_t = _role_from_string(role);
         muc_affiliation_t affiliation_t = _affiliation_from_string(affiliation);
-        Occupant* occupant = _muc_occupant_new(nick, jid, role_t, affiliation_t, presence, status);
+        Occupant *occupant = _muc_occupant_new(nick, jid, role_t, affiliation_t, presence, status);
         g_hash_table_replace(chat_room->roster, strdup(nick), occupant);
 
         if (jid) {
-            Jid* jidp = jid_create(jid);
+            Jid *jidp = jid_create(jid);
             if (jidp->barejid) {
                 autocomplete_add(chat_room->jid_ac, jidp->barejid);
             }
@@ -508,9 +509,9 @@ muc_roster_add(const char* const room, const char* const nick, const char* const
  * Remove a room member from the room's roster
  */
 void
-muc_roster_remove(const char* const room, const char* const nick)
+muc_roster_remove(const char *const room, const char *const nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         g_hash_table_remove(chat_room->roster, nick);
         autocomplete_remove(chat_room->nick_ac, nick);
@@ -518,11 +519,11 @@ muc_roster_remove(const char* const room, const char* const nick)
 }
 
 Occupant*
-muc_roster_item(const char* const room, const char* const nick)
+muc_roster_item(const char *const room, const char *const nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        Occupant* occupant = g_hash_table_lookup(chat_room->roster, nick);
+        Occupant *occupant = g_hash_table_lookup(chat_room->roster, nick);
         return occupant;
     } else {
         return NULL;
@@ -533,14 +534,14 @@ muc_roster_item(const char* const room, const char* const nick)
  * Return a list of PContacts representing the room members in the room's roster
  */
 GList*
-muc_roster(const char* const room)
+muc_roster(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        GList* result = NULL;
-        GList* occupants = g_hash_table_get_values(chat_room->roster);
+        GList *result = NULL;
+        GList *occupants = g_hash_table_get_values(chat_room->roster);
 
-        GList* curr = occupants;
+        GList *curr = occupants;
         while (curr) {
             result = g_list_insert_sorted(result, curr->data, (GCompareFunc)_compare_occupants);
             curr = g_list_next(curr);
@@ -558,9 +559,9 @@ muc_roster(const char* const room)
  * Return a Autocomplete representing the room member's in the roster
  */
 Autocomplete
-muc_roster_ac(const char* const room)
+muc_roster_ac(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->nick_ac;
     } else {
@@ -569,9 +570,9 @@ muc_roster_ac(const char* const room)
 }
 
 Autocomplete
-muc_roster_jid_ac(const char* const room)
+muc_roster_jid_ac(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->jid_ac;
     } else {
@@ -583,9 +584,9 @@ muc_roster_jid_ac(const char* const room)
  * Set to TRUE when the rooms roster has been fully received
  */
 void
-muc_roster_set_complete(const char* const room)
+muc_roster_set_complete(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->roster_received = TRUE;
     }
@@ -595,9 +596,9 @@ muc_roster_set_complete(const char* const room)
  * Returns TRUE id the rooms roster has been fully received
  */
 gboolean
-muc_roster_complete(const char* const room)
+muc_roster_complete(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->roster_received;
     } else {
@@ -606,36 +607,36 @@ muc_roster_complete(const char* const room)
 }
 
 gboolean
-muc_occupant_available(Occupant* occupant)
+muc_occupant_available(Occupant *occupant)
 {
     return (occupant->presence == RESOURCE_ONLINE || occupant->presence == RESOURCE_CHAT);
 }
 
 const char*
-muc_occupant_affiliation_str(Occupant* occupant)
+muc_occupant_affiliation_str(Occupant *occupant)
 {
     return _affiliation_to_string(occupant->affiliation);
 }
 
 const char*
-muc_occupant_role_str(Occupant* occupant)
+muc_occupant_role_str(Occupant *occupant)
 {
     return _role_to_string(occupant->role);
 }
 
 GSList*
-muc_occupants_by_role(const char* const room, muc_role_t role)
+muc_occupants_by_role(const char *const room, muc_role_t role)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        GSList* result = NULL;
+        GSList *result = NULL;
         GHashTableIter iter;
         gpointer key;
         gpointer value;
 
         g_hash_table_iter_init(&iter, chat_room->roster);
         while (g_hash_table_iter_next(&iter, &key, &value)) {
-            Occupant* occupant = (Occupant*)value;
+            Occupant *occupant = (Occupant *)value;
             if (occupant->role == role) {
                 result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_occupants);
             }
@@ -647,18 +648,18 @@ muc_occupants_by_role(const char* const room, muc_role_t role)
 }
 
 GSList*
-muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliation)
+muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliation)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        GSList* result = NULL;
+        GSList *result = NULL;
         GHashTableIter iter;
         gpointer key;
         gpointer value;
 
         g_hash_table_iter_init(&iter, chat_room->roster);
         while (g_hash_table_iter_next(&iter, &key, &value)) {
-            Occupant* occupant = (Occupant*)value;
+            Occupant *occupant = (Occupant *)value;
             if (occupant->affiliation == affiliation) {
                 result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_occupants);
             }
@@ -674,9 +675,9 @@ muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliati
  * is in progress
  */
 void
-muc_occupant_nick_change_start(const char* const room, const char* const new_nick, const char* const old_nick)
+muc_occupant_nick_change_start(const char *const room, const char *const new_nick, const char *const old_nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         g_hash_table_insert(chat_room->nick_changes, strdup(new_nick), strdup(old_nick));
         muc_roster_remove(room, old_nick);
@@ -690,13 +691,13 @@ muc_occupant_nick_change_start(const char* const room, const char* const new_nic
  * the caller
  */
 char*
-muc_roster_nick_change_complete(const char* const room, const char* const nick)
+muc_roster_nick_change_complete(const char *const room, const char *const nick)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
-        char* old_nick = g_hash_table_lookup(chat_room->nick_changes, nick);
+        char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick);
         if (old_nick) {
-            char* old_nick_cpy = strdup(old_nick);
+            char *old_nick_cpy = strdup(old_nick);
             g_hash_table_remove(chat_room->nick_changes, nick);
 
             return old_nick_cpy;
@@ -707,40 +708,40 @@ muc_roster_nick_change_complete(const char* const room, const char* const nick)
 }
 
 char*
-muc_autocomplete(ProfWin* window, const char* const input, gboolean previous)
+muc_autocomplete(ProfWin *window, const char *const input, gboolean previous)
 {
     if (window->type != WIN_MUC) {
         return NULL;
     }
 
-    ProfMucWin* mucwin = (ProfMucWin*)window;
+    ProfMucWin *mucwin = (ProfMucWin*)window;
     assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, mucwin->roomjid);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, mucwin->roomjid);
     if (chat_room == NULL || chat_room->nick_ac == NULL) {
         return NULL;
     }
 
-    const char* search_str = NULL;
+    const char * search_str = NULL;
 
-    gchar* last_space = g_strrstr(input, " ");
+    gchar *last_space = g_strrstr(input, " ");
     if (!last_space) {
         search_str = input;
         if (!chat_room->autocomplete_prefix) {
             chat_room->autocomplete_prefix = strdup("");
         }
     } else {
-        search_str = last_space + 1;
+        search_str = last_space+1;
         if (!chat_room->autocomplete_prefix) {
             chat_room->autocomplete_prefix = g_strndup(input, search_str - input);
         }
     }
 
-    char* result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
+    char *result = autocomplete_complete(chat_room->nick_ac, search_str, FALSE, previous);
     if (result == NULL) {
         return NULL;
     }
 
-    GString* replace_with = g_string_new(chat_room->autocomplete_prefix);
+    GString *replace_with = g_string_new(chat_room->autocomplete_prefix);
     g_string_append(replace_with, result);
 
     if (strlen(chat_room->autocomplete_prefix) == 0) {
@@ -753,9 +754,9 @@ muc_autocomplete(ProfWin* window, const char* const input, gboolean previous)
 }
 
 void
-muc_jid_autocomplete_reset(const char* const room)
+muc_jid_autocomplete_reset(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         if (chat_room->jid_ac) {
             autocomplete_reset(chat_room->jid_ac);
@@ -764,15 +765,15 @@ muc_jid_autocomplete_reset(const char* const room)
 }
 
 void
-muc_jid_autocomplete_add_all(const char* const room, GSList* jids)
+muc_jid_autocomplete_add_all(const char *const room, GSList *jids)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         if (chat_room->jid_ac) {
-            GSList* curr_jid = jids;
+            GSList *curr_jid = jids;
             while (curr_jid) {
-                const char* jid = curr_jid->data;
-                Jid* jidp = jid_create(jid);
+                const char *jid = curr_jid->data;
+                Jid *jidp = jid_create(jid);
                 if (jidp) {
                     if (jidp->barejid) {
                         autocomplete_add(chat_room->jid_ac, jidp->barejid);
@@ -786,9 +787,9 @@ muc_jid_autocomplete_add_all(const char* const room, GSList* jids)
 }
 
 void
-muc_autocomplete_reset(const char* const room)
+muc_autocomplete_reset(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         if (chat_room->nick_ac) {
             autocomplete_reset(chat_room->nick_ac);
@@ -802,9 +803,9 @@ muc_autocomplete_reset(const char* const room)
 }
 
 char*
-muc_role_str(const char* const room)
+muc_role_str(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return _role_to_string(chat_room->role);
     } else {
@@ -813,18 +814,18 @@ muc_role_str(const char* const room)
 }
 
 void
-muc_set_role(const char* const room, const char* const role)
+muc_set_role(const char *const room, const char *const role)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->role = _role_from_string(role);
     }
 }
 
 char*
-muc_affiliation_str(const char* const room)
+muc_affiliation_str(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return _affiliation_to_string(chat_room->affiliation);
     } else {
@@ -833,18 +834,18 @@ muc_affiliation_str(const char* const room)
 }
 
 void
-muc_set_affiliation(const char* const room, const char* const affiliation)
+muc_set_affiliation(const char *const room, const char *const affiliation)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         chat_room->affiliation = _affiliation_from_string(affiliation);
     }
 }
 
 muc_member_type_t
-muc_member_type(const char* const room)
+muc_member_type(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->member_type;
     } else {
@@ -853,9 +854,9 @@ muc_member_type(const char* const room)
 }
 
 muc_anonymity_type_t
-muc_anonymity_type(const char* const room)
+muc_anonymity_type(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return chat_room->anonymity_type;
     } else {
@@ -867,9 +868,9 @@ muc_anonymity_type(const char* const room)
  * Return the list of jid affiliated as member in the room
  */
 GList*
-muc_members(const char* const room)
+muc_members(const char *const room)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         return g_hash_table_get_keys(chat_room->members);
     } else {
@@ -878,14 +879,14 @@ muc_members(const char* const room)
 }
 
 void
-muc_members_add(const char* const room, const char* const jid)
+muc_members_add(const char *const room, const char *const jid)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         if (g_hash_table_insert(chat_room->members, strdup(jid), NULL)) {
 #ifdef HAVE_OMEMO
-            if (chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
-                char* our_barejid = connection_get_barejid();
+            if(chat_room->anonymity_type == MUC_ANONYMITY_TYPE_NONANONYMOUS ) {
+                char *our_barejid = connection_get_barejid();
                 if (strcmp(jid, our_barejid) != 0) {
                     omemo_start_session(jid);
                 }
@@ -897,16 +898,16 @@ muc_members_add(const char* const room, const char* const jid)
 }
 
 void
-muc_members_remove(const char* const room, const char* const jid)
+muc_members_remove(const char *const room, const char *const jid)
 {
-    ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
     if (chat_room) {
         g_hash_table_remove(chat_room->members, jid);
     }
 }
 
 void
-muc_members_update(const char* const room, const char* const jid, const char* const affiliation)
+muc_members_update(const char *const room, const char *const jid, const char *const affiliation)
 {
     if (strcmp(affiliation, "outcast") == 0 || strcmp(affiliation, "none") == 0) {
         muc_members_remove(room, jid);
@@ -916,7 +917,7 @@ muc_members_update(const char* const room, const char* const jid, const char* co
 }
 
 static void
-_free_room(ChatRoom* room)
+_free_room(ChatRoom *room)
 {
     if (room) {
         free(room->room);
@@ -943,10 +944,10 @@ _free_room(ChatRoom* room)
 }
 
 static gint
-_compare_occupants(Occupant* a, Occupant* b)
+_compare_occupants(Occupant *a, Occupant *b)
 {
-    const char* utf8_str_a = a->nick_collate_key;
-    const char* utf8_str_b = b->nick_collate_key;
+    const char * utf8_str_a = a->nick_collate_key;
+    const char * utf8_str_b = b->nick_collate_key;
 
     gint result = g_strcmp0(utf8_str_a, utf8_str_b);
 
@@ -954,7 +955,7 @@ _compare_occupants(Occupant* a, Occupant* b)
 }
 
 static muc_role_t
-_role_from_string(const char* const role)
+_role_from_string(const char *const role)
 {
     if (role) {
         if (g_strcmp0(role, "visitor") == 0) {
@@ -974,7 +975,7 @@ _role_from_string(const char* const role)
 static char*
 _role_to_string(muc_role_t role)
 {
-    char* result = NULL;
+    char *result = NULL;
 
     switch (role) {
     case MUC_ROLE_NONE:
@@ -998,7 +999,7 @@ _role_to_string(muc_role_t role)
 }
 
 static muc_affiliation_t
-_affiliation_from_string(const char* const affiliation)
+_affiliation_from_string(const char *const affiliation)
 {
     if (affiliation) {
         if (g_strcmp0(affiliation, "outcast") == 0) {
@@ -1020,7 +1021,7 @@ _affiliation_from_string(const char* const affiliation)
 static char*
 _affiliation_to_string(muc_affiliation_t affiliation)
 {
-    char* result = NULL;
+    char *result = NULL;
 
     switch (affiliation) {
     case MUC_AFFILIATION_NONE:
@@ -1047,10 +1048,10 @@ _affiliation_to_string(muc_affiliation_t affiliation)
 }
 
 static Occupant*
-_muc_occupant_new(const char* const nick, const char* const jid, muc_role_t role, muc_affiliation_t affiliation,
-                  resource_presence_t presence, const char* const status)
+_muc_occupant_new(const char *const nick, const char *const jid, muc_role_t role, muc_affiliation_t affiliation,
+    resource_presence_t presence, const char *const status)
 {
-    Occupant* occupant = malloc(sizeof(Occupant));
+    Occupant *occupant = malloc(sizeof(Occupant));
 
     if (nick) {
         occupant->nick = strdup(nick);
@@ -1081,7 +1082,7 @@ _muc_occupant_new(const char* const nick, const char* const jid, muc_role_t role
 }
 
 static void
-_occupant_free(Occupant* occupant)
+_occupant_free(Occupant *occupant)
 {
     if (occupant) {
         free(occupant->nick);
diff --git a/src/xmpp/muc.h b/src/xmpp/muc.h
index 27fa0d4f..1c5506ab 100644
--- a/src/xmpp/muc.h
+++ b/src/xmpp/muc.h
@@ -70,99 +70,98 @@ typedef enum {
     MUC_ANONYMITY_TYPE_SEMIANONYMOUS
 } muc_anonymity_type_t;
 
-typedef struct _muc_occupant_t
-{
-    char* nick;
-    gchar* nick_collate_key;
-    char* jid;
+typedef struct _muc_occupant_t {
+    char *nick;
+    gchar *nick_collate_key;
+    char *jid;
     muc_role_t role;
     muc_affiliation_t affiliation;
     resource_presence_t presence;
-    char* status;
+    char *status;
 } Occupant;
 
 void muc_init(void);
 void muc_close(void);
 
-void muc_join(const char* const room, const char* const nick, const char* const password, gboolean autojoin);
-void muc_leave(const char* const room);
+void muc_join(const char *const room, const char *const nick, const char *const password, gboolean autojoin);
+void muc_leave(const char *const room);
 
-gboolean muc_active(const char* const room);
-gboolean muc_autojoin(const char* const room);
+gboolean muc_active(const char *const room);
+gboolean muc_autojoin(const char *const room);
 
 GList* muc_rooms(void);
 
-void muc_set_features(const char* const room, GSList* features);
+void muc_set_features(const char *const room, GSList *features);
 
-char* muc_nick(const char* const room);
-char* muc_password(const char* const room);
+char* muc_nick(const char *const room);
+char* muc_password(const char *const room);
 
-void muc_nick_change_start(const char* const room, const char* const new_nick);
-void muc_nick_change_complete(const char* const room, const char* const nick);
-gboolean muc_nick_change_pending(const char* const room);
-char* muc_old_nick(const char* const room, const char* const new_nick);
+void muc_nick_change_start(const char *const room, const char *const new_nick);
+void muc_nick_change_complete(const char *const room, const char *const nick);
+gboolean muc_nick_change_pending(const char *const room);
+char* muc_old_nick(const char *const room, const char *const new_nick);
 
-gboolean muc_roster_contains_nick(const char* const room, const char* const nick);
-gboolean muc_roster_complete(const char* const room);
-gboolean muc_roster_add(const char* const room, const char* const nick, const char* const jid, const char* const role,
-                        const char* const affiliation, const char* const show, const char* const status);
-void muc_roster_remove(const char* const room, const char* const nick);
-void muc_roster_set_complete(const char* const room);
-GList* muc_roster(const char* const room);
-Autocomplete muc_roster_ac(const char* const room);
-Autocomplete muc_roster_jid_ac(const char* const room);
-void muc_jid_autocomplete_reset(const char* const room);
-void muc_jid_autocomplete_add_all(const char* const room, GSList* jids);
+gboolean muc_roster_contains_nick(const char *const room, const char *const nick);
+gboolean muc_roster_complete(const char *const room);
+gboolean muc_roster_add(const char *const room, const char *const nick, const char *const jid, const char *const role,
+    const char *const affiliation, const char *const show, const char *const status);
+void muc_roster_remove(const char *const room, const char *const nick);
+void muc_roster_set_complete(const char *const room);
+GList* muc_roster(const char *const room);
+Autocomplete muc_roster_ac(const char *const room);
+Autocomplete muc_roster_jid_ac(const char *const room);
+void muc_jid_autocomplete_reset(const char *const room);
+void muc_jid_autocomplete_add_all(const char *const room, GSList *jids);
 
-Occupant* muc_roster_item(const char* const room, const char* const nick);
+Occupant* muc_roster_item(const char *const room, const char *const nick);
 
-gboolean muc_occupant_available(Occupant* occupant);
-const char* muc_occupant_affiliation_str(Occupant* occupant);
-const char* muc_occupant_role_str(Occupant* occupant);
-GSList* muc_occupants_by_role(const char* const room, muc_role_t role);
-GSList* muc_occupants_by_affiliation(const char* const room, muc_affiliation_t affiliation);
+gboolean muc_occupant_available(Occupant *occupant);
+const char* muc_occupant_affiliation_str(Occupant *occupant);
+const char* muc_occupant_role_str(Occupant *occupant);
+GSList* muc_occupants_by_role(const char *const room, muc_role_t role);
+GSList* muc_occupants_by_affiliation(const char *const room, muc_affiliation_t affiliation);
 
-void muc_occupant_nick_change_start(const char* const room, const char* const new_nick, const char* const old_nick);
-char* muc_roster_nick_change_complete(const char* const room, const char* const nick);
+void muc_occupant_nick_change_start(const char *const room, const char *const new_nick, const char *const old_nick);
+char* muc_roster_nick_change_complete(const char *const room, const char *const nick);
 
-void muc_confserver_add(const char* const server);
+void muc_confserver_add(const char *const server);
 void muc_confserver_reset_ac(void);
-char* muc_confserver_find(const char* const search_str, gboolean previous, void* context);
+char* muc_confserver_find(const char *const search_str, gboolean previous, void *context);
 void muc_confserver_clear(void);
 
-void muc_invites_add(const char* const room, const char* const password);
-void muc_invites_remove(const char* const room);
+void muc_invites_add(const char *const room, const char *const password);
+void muc_invites_remove(const char *const room);
 gint muc_invites_count(void);
 GList* muc_invites(void);
-gboolean muc_invites_contain(const char* const room);
+gboolean muc_invites_contain(const char *const room);
 void muc_invites_reset_ac(void);
-char* muc_invites_find(const char* const search_str, gboolean previous, void* context);
+char* muc_invites_find(const char *const search_str, gboolean previous, void *context);
 void muc_invites_clear(void);
-char* muc_invite_password(const char* const room);
+char* muc_invite_password(const char *const room);
 
-void muc_set_subject(const char* const room, const char* const subject);
-char* muc_subject(const char* const room);
+void muc_set_subject(const char *const room, const char *const subject);
+char* muc_subject(const char *const room);
 
-void muc_pending_broadcasts_add(const char* const room, const char* const message);
-GList* muc_pending_broadcasts(const char* const room);
+void muc_pending_broadcasts_add(const char *const room, const char *const message);
+GList* muc_pending_broadcasts(const char *const room);
 
-char* muc_autocomplete(ProfWin* window, const char* const input, gboolean previous);
-void muc_autocomplete_reset(const char* const room);
+char* muc_autocomplete(ProfWin *window, const char *const input, gboolean previous);
+void muc_autocomplete_reset(const char *const room);
 
-gboolean muc_requires_config(const char* const room);
-void muc_set_requires_config(const char* const room, gboolean val);
+gboolean muc_requires_config(const char *const room);
+void muc_set_requires_config(const char *const room, gboolean val);
 
-void muc_set_role(const char* const room, const char* const role);
-void muc_set_affiliation(const char* const room, const char* const affiliation);
-char* muc_role_str(const char* const room);
-char* muc_affiliation_str(const char* const room);
+void muc_set_role(const char *const room, const char *const role);
+void muc_set_affiliation(const char *const room, const char *const affiliation);
+char* muc_role_str(const char *const room);
+char* muc_affiliation_str(const char *const room);
 
-muc_member_type_t muc_member_type(const char* const room);
-muc_anonymity_type_t muc_anonymity_type(const char* const room);
+muc_member_type_t muc_member_type(const char *const room);
+muc_anonymity_type_t muc_anonymity_type(const char *const room);
 
-GList* muc_members(const char* const room);
-void muc_members_add(const char* const room, const char* const jid);
-void muc_members_remove(const char* const room, const char* const jid);
-void muc_members_update(const char* const room, const char* const jid, const char* const affiliation);
+GList* muc_members(const char *const room);
+void muc_members_add(const char *const room, const char *const jid);
+void muc_members_remove(const char *const room, const char *const jid);
+void muc_members_update(const char *const room, const char *const jid, const char *const affiliation);
 
 #endif
diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c
index e527d4c7..2021816a 100644
--- a/src/xmpp/omemo.c
+++ b/src/xmpp/omemo.c
@@ -44,10 +44,10 @@
 
 #include "omemo/omemo.h"
 
-static int _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata);
-static int _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata);
-static int _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdata);
-static int _omemo_bundle_publish_configure_result(xmpp_stanza_t* const stanza, void* const userdata);
+static int _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata);
+static int _omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata);
+static int _omemo_bundle_publish_configure(xmpp_stanza_t *const stanza, void *const userdata);
+static int _omemo_bundle_publish_configure_result(xmpp_stanza_t *const stanza, void *const userdata);
 
 void
 omemo_devicelist_subscribe(void)
@@ -58,10 +58,10 @@ omemo_devicelist_subscribe(void)
 }
 
 void
-omemo_devicelist_publish(GList* device_list)
+omemo_devicelist_publish(GList *device_list)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_omemo_devicelist_publish(ctx, device_list);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_omemo_devicelist_publish(ctx, device_list);
 
     if (connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) {
         stanza_attach_publish_options(ctx, iq, "pubsub#access_model", "open");
@@ -72,12 +72,12 @@ omemo_devicelist_publish(GList* device_list)
 }
 
 void
-omemo_devicelist_request(const char* const jid)
+omemo_devicelist_request(const char * const jid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* iq = stanza_create_omemo_devicelist_request(ctx, id, jid);
+    xmpp_stanza_t *iq = stanza_create_omemo_devicelist_request(ctx, id, jid);
     iq_id_handler_add(id, _omemo_receive_devicelist, NULL, NULL);
 
     iq_send_stanza(iq);
@@ -89,12 +89,12 @@ omemo_devicelist_request(const char* const jid)
 void
 omemo_bundle_publish(gboolean first)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    unsigned char* identity_key = NULL;
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    unsigned char *identity_key = NULL;
     size_t identity_key_length;
-    unsigned char* signed_prekey = NULL;
+    unsigned char *signed_prekey = NULL;
     size_t signed_prekey_length;
-    unsigned char* signed_prekey_signature = NULL;
+    unsigned char *signed_prekey_signature = NULL;
     size_t signed_prekey_signature_length;
     GList *prekeys = NULL, *ids = NULL, *lengths = NULL;
 
@@ -103,11 +103,11 @@ omemo_bundle_publish(gboolean first)
     omemo_signed_prekey_signature(&signed_prekey_signature, &signed_prekey_signature_length);
     omemo_prekeys(&prekeys, &ids, &lengths);
 
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_omemo_bundle_publish(ctx, id,
-                                                           omemo_device_id(), identity_key, identity_key_length, signed_prekey,
-                                                           signed_prekey_length, signed_prekey_signature,
-                                                           signed_prekey_signature_length, prekeys, ids, lengths);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_omemo_bundle_publish(ctx, id,
+        omemo_device_id(), identity_key, identity_key_length, signed_prekey,
+        signed_prekey_length, signed_prekey_signature,
+        signed_prekey_signature_length, prekeys, ids, lengths);
 
     g_list_free_full(prekeys, free);
     g_list_free(lengths);
@@ -129,12 +129,12 @@ omemo_bundle_publish(gboolean first)
 }
 
 void
-omemo_bundle_request(const char* const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
+omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
 
-    xmpp_stanza_t* iq = stanza_create_omemo_bundle_request(ctx, id, jid, device_id);
+    xmpp_stanza_t *iq = stanza_create_omemo_bundle_request(ctx, id, jid, device_id);
     iq_id_handler_add(id, func, free_func, userdata);
 
     iq_send_stanza(iq);
@@ -144,17 +144,17 @@ omemo_bundle_request(const char* const jid, uint32_t device_id, ProfIqCallback f
 }
 
 int
-omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* const userdata)
+omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    GList* prekeys_list = NULL;
-    unsigned char* signed_prekey_raw = NULL;
-    unsigned char* signed_prekey_signature_raw = NULL;
-    char* from = NULL;
+    GList *prekeys_list = NULL;
+    unsigned char *signed_prekey_raw = NULL;
+    unsigned char *signed_prekey_signature_raw = NULL;
+    char *from = NULL;
 
-    const char* from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    const char *from_attr = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
     if (!from_attr) {
-        Jid* jid = jid_create(connection_get_fulljid());
+        Jid *jid = jid_create(connection_get_fulljid());
         from = strdup(jid->barejid);
         jid_destroy(jid);
     } else {
@@ -165,62 +165,62 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* cons
         goto out;
     }
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
     if (!pubsub) {
         goto out;
     }
 
-    xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(pubsub, "items");
+    xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(pubsub, "items");
     if (!items) {
         goto out;
     }
-    const char* node = xmpp_stanza_get_attribute(items, "node");
-    char* device_id_str = strstr(node, ":");
+    const char *node = xmpp_stanza_get_attribute(items, "node");
+    char *device_id_str = strstr(node, ":");
     if (!device_id_str) {
         goto out;
     }
 
     uint32_t device_id = strtoul(++device_id_str, NULL, 10);
 
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(items, "item");
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
     if (!item) {
         goto out;
     }
 
-    xmpp_stanza_t* bundle = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
+    xmpp_stanza_t *bundle = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
     if (!bundle) {
         goto out;
     }
 
-    xmpp_stanza_t* prekeys = xmpp_stanza_get_child_by_name(bundle, "prekeys");
+    xmpp_stanza_t *prekeys = xmpp_stanza_get_child_by_name(bundle, "prekeys");
     if (!prekeys) {
         goto out;
     }
 
-    xmpp_stanza_t* prekey;
+    xmpp_stanza_t *prekey;
     for (prekey = xmpp_stanza_get_children(prekeys); prekey != NULL; prekey = xmpp_stanza_get_next(prekey)) {
         if (g_strcmp0(xmpp_stanza_get_name(prekey), "preKeyPublic") != 0) {
             continue;
         }
 
-        omemo_key_t* key = malloc(sizeof(omemo_key_t));
+        omemo_key_t *key = malloc(sizeof(omemo_key_t));
         key->data = NULL;
 
-        const char* prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId");
+        const char *prekey_id_text = xmpp_stanza_get_attribute(prekey, "preKeyId");
         if (!prekey_id_text) {
             omemo_key_free(key);
             continue;
         }
 
         key->id = strtoul(prekey_id_text, NULL, 10);
-        xmpp_stanza_t* prekey_text = xmpp_stanza_get_children(prekey);
+        xmpp_stanza_t *prekey_text = xmpp_stanza_get_children(prekey);
 
         if (!prekey_text) {
             omemo_key_free(key);
             continue;
         }
 
-        char* prekey_b64 = xmpp_stanza_get_text(prekey_text);
+        char *prekey_b64 = xmpp_stanza_get_text(prekey_text);
         key->data = g_base64_decode(prekey_b64, &key->length);
         free(prekey_b64);
         if (!key->data) {
@@ -233,64 +233,64 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* cons
         prekeys_list = g_list_append(prekeys_list, key);
     }
 
-    xmpp_stanza_t* signed_prekey = xmpp_stanza_get_child_by_name(bundle, "signedPreKeyPublic");
+    xmpp_stanza_t *signed_prekey = xmpp_stanza_get_child_by_name(bundle, "signedPreKeyPublic");
     if (!signed_prekey) {
         goto out;
     }
-    const char* signed_prekey_id_text = xmpp_stanza_get_attribute(signed_prekey, "signedPreKeyId");
+    const char *signed_prekey_id_text = xmpp_stanza_get_attribute(signed_prekey, "signedPreKeyId");
     if (!signed_prekey_id_text) {
         goto out;
     }
 
     uint32_t signed_prekey_id = strtoul(signed_prekey_id_text, NULL, 10);
-    xmpp_stanza_t* signed_prekey_text = xmpp_stanza_get_children(signed_prekey);
+    xmpp_stanza_t *signed_prekey_text = xmpp_stanza_get_children(signed_prekey);
     if (!signed_prekey_text) {
         goto out;
     }
 
     size_t signed_prekey_len;
-    char* signed_prekey_b64 = xmpp_stanza_get_text(signed_prekey_text);
+    char *signed_prekey_b64 = xmpp_stanza_get_text(signed_prekey_text);
     signed_prekey_raw = g_base64_decode(signed_prekey_b64, &signed_prekey_len);
     free(signed_prekey_b64);
     if (!signed_prekey_raw) {
         goto out;
     }
 
-    xmpp_stanza_t* signed_prekey_signature = xmpp_stanza_get_child_by_name(bundle, "signedPreKeySignature");
+    xmpp_stanza_t *signed_prekey_signature = xmpp_stanza_get_child_by_name(bundle, "signedPreKeySignature");
     if (!signed_prekey_signature) {
         goto out;
     }
-    xmpp_stanza_t* signed_prekey_signature_text = xmpp_stanza_get_children(signed_prekey_signature);
+    xmpp_stanza_t *signed_prekey_signature_text = xmpp_stanza_get_children(signed_prekey_signature);
     if (!signed_prekey_signature_text) {
         goto out;
     }
     size_t signed_prekey_signature_len;
-    char* signed_prekey_signature_b64 = xmpp_stanza_get_text(signed_prekey_signature_text);
+    char *signed_prekey_signature_b64 = xmpp_stanza_get_text(signed_prekey_signature_text);
     signed_prekey_signature_raw = g_base64_decode(signed_prekey_signature_b64, &signed_prekey_signature_len);
     free(signed_prekey_signature_b64);
     if (!signed_prekey_signature_raw) {
         goto out;
     }
 
-    xmpp_stanza_t* identity_key = xmpp_stanza_get_child_by_name(bundle, "identityKey");
+    xmpp_stanza_t *identity_key = xmpp_stanza_get_child_by_name(bundle, "identityKey");
     if (!identity_key) {
         goto out;
     }
-    xmpp_stanza_t* identity_key_text = xmpp_stanza_get_children(identity_key);
+    xmpp_stanza_t *identity_key_text = xmpp_stanza_get_children(identity_key);
     if (!identity_key_text) {
         goto out;
     }
     size_t identity_key_len;
-    char* identity_key_b64 = xmpp_stanza_get_text(identity_key_text);
-    unsigned char* identity_key_raw = g_base64_decode(identity_key_b64, &identity_key_len);
+    char *identity_key_b64 = xmpp_stanza_get_text(identity_key_text);
+    unsigned char *identity_key_raw = g_base64_decode(identity_key_b64, &identity_key_len);
     free(identity_key_b64);
     if (!identity_key_raw) {
         goto out;
     }
 
     omemo_start_device_session(from, device_id, prekeys_list, signed_prekey_id,
-                               signed_prekey_raw, signed_prekey_len, signed_prekey_signature_raw,
-                               signed_prekey_signature_len, identity_key_raw, identity_key_len);
+        signed_prekey_raw, signed_prekey_len, signed_prekey_signature_raw,
+        signed_prekey_signature_len, identity_key_raw, identity_key_len);
 
     g_free(identity_key_raw);
 
@@ -308,34 +308,34 @@ out:
     return 1;
 }
 
-char*
-omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
+char *
+omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted)
 {
-    char* plaintext = NULL;
-    const char* type = xmpp_stanza_get_type(stanza);
-    GList* keys = NULL;
-    unsigned char* iv_raw = NULL;
-    unsigned char* payload_raw = NULL;
-    char* iv_text = NULL;
-    char* payload_text = NULL;
-
-    xmpp_stanza_t* encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OMEMO);
+    char *plaintext = NULL;
+    const char *type = xmpp_stanza_get_type(stanza);
+    GList *keys = NULL;
+    unsigned char *iv_raw = NULL;
+    unsigned char *payload_raw = NULL;
+    char *iv_text = NULL;
+    char *payload_text = NULL;
+
+    xmpp_stanza_t *encrypted = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_OMEMO);
     if (!encrypted) {
         return NULL;
     }
 
-    xmpp_stanza_t* header = xmpp_stanza_get_child_by_name(encrypted, "header");
+    xmpp_stanza_t *header = xmpp_stanza_get_child_by_name(encrypted, "header");
     if (!header) {
         return NULL;
     }
 
-    const char* sid_text = xmpp_stanza_get_attribute(header, "sid");
+    const char *sid_text = xmpp_stanza_get_attribute(header, "sid");
     if (!sid_text) {
         return NULL;
     }
     uint32_t sid = strtoul(sid_text, NULL, 10);
 
-    xmpp_stanza_t* iv = xmpp_stanza_get_child_by_name(header, "iv");
+    xmpp_stanza_t *iv = xmpp_stanza_get_child_by_name(header, "iv");
     if (!iv) {
         return NULL;
     }
@@ -349,7 +349,7 @@ omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
         goto out;
     }
 
-    xmpp_stanza_t* payload = xmpp_stanza_get_child_by_name(encrypted, "payload");
+    xmpp_stanza_t *payload = xmpp_stanza_get_child_by_name(encrypted, "payload");
     if (!payload) {
         goto out;
     }
@@ -363,19 +363,19 @@ omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
         goto out;
     }
 
-    xmpp_stanza_t* key_stanza;
+    xmpp_stanza_t *key_stanza;
     for (key_stanza = xmpp_stanza_get_children(header); key_stanza != NULL; key_stanza = xmpp_stanza_get_next(key_stanza)) {
         if (g_strcmp0(xmpp_stanza_get_name(key_stanza), "key") != 0) {
             continue;
         }
 
-        omemo_key_t* key = malloc(sizeof(omemo_key_t));
-        char* key_text = xmpp_stanza_get_text(key_stanza);
+        omemo_key_t *key = malloc(sizeof(omemo_key_t));
+        char *key_text = xmpp_stanza_get_text(key_stanza);
         if (!key_text) {
             goto skip;
         }
 
-        const char* rid_text = xmpp_stanza_get_attribute(key_stanza, "rid");
+        const char *rid_text = xmpp_stanza_get_attribute(key_stanza, "rid");
         key->device_id = strtoul(rid_text, NULL, 10);
         if (!key->device_id) {
             goto skip;
@@ -386,20 +386,21 @@ omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted)
         if (!key->data) {
             goto skip;
         }
-        key->prekey = g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "true") == 0
-                      || g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "1") == 0;
+        key->prekey = 
+            g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "true") == 0
+            || g_strcmp0(xmpp_stanza_get_attribute(key_stanza, "prekey"), "1") == 0;
         keys = g_list_append(keys, key);
         continue;
 
-    skip:
+skip:
         free(key);
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
 
     plaintext = omemo_on_message_recv(from, sid, iv_raw, iv_len,
-                                      keys, payload_raw, payload_len,
-                                      g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0, trusted);
+        keys, payload_raw, payload_len,
+        g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0, trusted);
 
 out:
     if (keys) {
@@ -415,18 +416,18 @@ out:
 }
 
 static int
-_omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
+_omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    GList* device_list = NULL;
-    const char* from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    GList *device_list = NULL;
+    const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
-    xmpp_stanza_t* root = NULL;
-    xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
+    xmpp_stanza_t *root = NULL;
+    xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
     if (event) {
         root = event;
     }
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
     if (pubsub) {
         root = pubsub;
     }
@@ -435,20 +436,21 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
         return 1;
     }
 
-    xmpp_stanza_t* items = xmpp_stanza_get_child_by_name(root, "items");
+    xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items");
     if (!items) {
         return 1;
     }
 
+
     // Looking for "current" item - if there is no current, take the first item.
     xmpp_stanza_t* first = NULL;
     xmpp_stanza_t* current = NULL;
-
-    xmpp_stanza_t* item = xmpp_stanza_get_children(items);
-    while (item) {
+    
+    xmpp_stanza_t *item = xmpp_stanza_get_children(items);
+    while ( item ) {
         if (g_strcmp0(xmpp_stanza_get_name(item), "item") == 0) {
             first = item;
-            if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0) {
+            if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) {
                 current = item;
                 break;
             }
@@ -456,27 +458,27 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
         item = xmpp_stanza_get_next(item);
     }
 
-    if (current) {
+    if(current) {
         item = current;
-    } else if (first) {
+    } else if( first ) {
         log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(first));
         item = first;
     } else {
         return 1;
     }
 
-    xmpp_stanza_t* list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
+    xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
     if (!list) {
         return 1;
     }
 
-    xmpp_stanza_t* device;
+    xmpp_stanza_t *device;
     for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
         if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
             continue;
         }
 
-        const char* id = xmpp_stanza_get_id(device);
+        const char *id = xmpp_stanza_get_id(device);
         if (id != NULL) {
             device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
         } else {
@@ -490,9 +492,9 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
+_omemo_bundle_publish_result(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_ERROR) != 0) {
         return 0;
@@ -504,11 +506,11 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
     }
 
     log_info("OMEMO: cannot publish bundle with open access model, trying to configure node");
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    Jid* jid = jid_create(connection_get_fulljid());
-    char* id = connection_create_stanza_id();
-    char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
-    xmpp_stanza_t* iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    Jid *jid = jid_create(connection_get_fulljid());
+    char *id = connection_create_stanza_id();
+    char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
+    xmpp_stanza_t *iq = stanza_create_pubsub_configure_request(ctx, id, jid->barejid, node);
     g_free(node);
 
     iq_id_handler_add(id, _omemo_bundle_publish_configure, NULL, userdata);
@@ -522,26 +524,26 @@ _omemo_bundle_publish_result(xmpp_stanza_t* const stanza, void* const userdata)
 }
 
 static int
-_omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdata)
+_omemo_bundle_publish_configure(xmpp_stanza_t *const stanza, void *const userdata)
 {
     /* TODO handle error */
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_name(stanza, "pubsub");
-    xmpp_stanza_t* configure = xmpp_stanza_get_child_by_name(pubsub, STANZA_NAME_CONFIGURE);
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(configure, "x");
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_name(stanza, "pubsub");
+    xmpp_stanza_t *configure = xmpp_stanza_get_child_by_name(pubsub, STANZA_NAME_CONFIGURE);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(configure, "x");
 
     DataForm* form = form_create(x);
-    char* tag = g_hash_table_lookup(form->var_to_tag, "pubsub#access_model");
+    char *tag = g_hash_table_lookup(form->var_to_tag, "pubsub#access_model");
     if (!tag) {
         log_info("OMEMO: cannot configure bundle to an open access model");
         return 0;
     }
     form_set_value(form, tag, "open");
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    Jid* jid = jid_create(connection_get_fulljid());
-    char* id = connection_create_stanza_id();
-    char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
-    xmpp_stanza_t* iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    Jid *jid = jid_create(connection_get_fulljid());
+    char *id = connection_create_stanza_id();
+    char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, omemo_device_id());
+    xmpp_stanza_t *iq = stanza_create_pubsub_configure_submit(ctx, id, jid->barejid, node, form);
     g_free(node);
 
     iq_id_handler_add(id, _omemo_bundle_publish_configure_result, NULL, userdata);
@@ -555,9 +557,9 @@ _omemo_bundle_publish_configure(xmpp_stanza_t* const stanza, void* const userdat
 }
 
 static int
-_omemo_bundle_publish_configure_result(xmpp_stanza_t* const stanza, void* const userdata)
+_omemo_bundle_publish_configure_result(xmpp_stanza_t *const stanza, void *const userdata)
 {
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
         log_error("OMEMO: cannot configure bundle to an open access model");
diff --git a/src/xmpp/omemo.h b/src/xmpp/omemo.h
index 31021ab4..bc025519 100644
--- a/src/xmpp/omemo.h
+++ b/src/xmpp/omemo.h
@@ -38,9 +38,9 @@
 #include "xmpp/iq.h"
 
 void omemo_devicelist_subscribe(void);
-void omemo_devicelist_publish(GList* device_list);
-void omemo_devicelist_request(const char* const jid);
+void omemo_devicelist_publish(GList *device_list);
+void omemo_devicelist_request(const char * const jid);
 void omemo_bundle_publish(gboolean first);
-void omemo_bundle_request(const char* const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata);
-int omemo_start_device_session_handle_bundle(xmpp_stanza_t* const stanza, void* const userdata);
-char* omemo_receive_message(xmpp_stanza_t* const stanza, gboolean* trusted);
+void omemo_bundle_request(const char * const jid, uint32_t device_id, ProfIqCallback func, ProfIqFreeCallback free_func, void *userdata);
+int omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *const userdata);
+char * omemo_receive_message(xmpp_stanza_t *const stanza, gboolean *trusted);
diff --git a/src/xmpp/ox.c b/src/xmpp/ox.c
index 83458dde..c1901085 100644
--- a/src/xmpp/ox.c
+++ b/src/xmpp/ox.c
@@ -33,14 +33,15 @@
  *
  */
 
-#include <assert.h>
 #include <glib.h>
+#include <assert.h>
 
 #include "log.h"
-#include "pgp/gpg.h"
 #include "ui/ui.h"
 #include "xmpp/connection.h"
 #include "xmpp/stanza.h"
+#include "pgp/gpg.h"
+
 
 static void _ox_metadata_node__public_key(const char* const fingerprint);
 
@@ -76,9 +77,8 @@ static char* _gettimestamp();
  *
  */
 
-gboolean
-ox_announce_public_key(const char* const filename)
-{
+gboolean 
+ox_announce_public_key(const char* const filename) {
     assert(filename);
 
     cons_show("Annonuce OpenPGP Key for OX %s ...", filename);
@@ -89,13 +89,13 @@ ox_announce_public_key(const char* const filename)
     char* fp = NULL;
     p_ox_gpg_readkey(filename, &key, &fp);
 
-    if (!(key && fp)) {
+    if( !(key && fp) ) {
         cons_show("Error during OpenPGP OX announce. See log file for more information");
         return FALSE;
     } else {
         log_info("Annonuce OpenPGP Key for Fingerprint: %s", fp);
-        xmpp_ctx_t* const ctx = connection_get_ctx();
-        char* id = xmpp_uuid_gen(ctx);
+        xmpp_ctx_t * const ctx = connection_get_ctx();
+        char *id = xmpp_uuid_gen(ctx);
         xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
         xmpp_stanza_set_from(iq, xmpp_conn_get_jid(connection_get_conn()));
 
@@ -108,21 +108,22 @@ ox_announce_public_key(const char* const filename)
         g_string_append(node_name, fp);
 
         xmpp_stanza_t* publish = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH);
-        xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node_name->str);
+        xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); 
+        xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node_name->str) ;
 
         xmpp_stanza_t* item = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
-        xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, _gettimestamp());
-
+        xmpp_stanza_set_name(item, STANZA_NAME_ITEM); 
+        xmpp_stanza_set_attribute(item, STANZA_ATTR_ID, _gettimestamp()) ;
+        
         xmpp_stanza_t* pubkey = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY);
+        xmpp_stanza_set_name(pubkey, STANZA_NAME_PUPKEY); 
         xmpp_stanza_set_ns(pubkey, STANZA_NS_OPENPGP_0);
-
+        
         xmpp_stanza_t* data = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_name(data, STANZA_NAME_DATA);
-        xmpp_stanza_t* keydata = xmpp_stanza_new(ctx);
-        xmpp_stanza_set_text(keydata, key);
+        xmpp_stanza_set_name(data, STANZA_NAME_DATA); 
+        xmpp_stanza_t* keydata =  xmpp_stanza_new(ctx);
+        xmpp_stanza_set_text(keydata,key);
+        
 
         xmpp_stanza_add_child(data, keydata);
         xmpp_stanza_add_child(pubkey, data);
@@ -130,9 +131,10 @@ ox_announce_public_key(const char* const filename)
         xmpp_stanza_add_child(publish, item);
         xmpp_stanza_add_child(pubsub, publish);
         xmpp_stanza_add_child(iq, pubsub);
-        xmpp_send(connection_get_conn(), iq);
+        xmpp_send (connection_get_conn(), iq);
 
         _ox_metadata_node__public_key(fp);
+         
     }
     return TRUE;
 }
@@ -164,15 +166,14 @@ ox_announce_public_key(const char* const filename)
  *
  */
 
-void
-_ox_metadata_node__public_key(const char* const fingerprint)
-{
+void 
+_ox_metadata_node__public_key(const char* const fingerprint) {
     log_info("Annonuce OpenPGP metadata: %s", fingerprint);
     assert(fingerprint);
     assert(strlen(fingerprint) == 40);
     // iq
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = xmpp_uuid_gen(ctx);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = xmpp_uuid_gen(ctx);
     xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     xmpp_stanza_set_from(iq, xmpp_conn_get_jid(connection_get_conn()));
     // pubsub
@@ -181,33 +182,31 @@ _ox_metadata_node__public_key(const char* const fingerprint)
     xmpp_stanza_set_ns(pubsub, XMPP_FEATURE_PUBSUB);
     // publish
     xmpp_stanza_t* publish = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH);
-    xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OPENPGP_0_PUBLIC_KEYS);
+    xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH); 
+    xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OPENPGP_0_PUBLIC_KEYS) ;
     // item
     xmpp_stanza_t* item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
-    // public-keys-list
+    // public-keys-list        
     xmpp_stanza_t* publickeyslist = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(publickeyslist, STANZA_NAME_PUBLIC_KEYS_LIST);
+    xmpp_stanza_set_name(publickeyslist, STANZA_NAME_PUBLIC_KEYS_LIST); 
     xmpp_stanza_set_ns(publickeyslist, STANZA_NS_OPENPGP_0);
     // pubkey-metadata
     xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA);
+    xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA); 
     xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint);
     xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, _gettimestamp());
 
-    xmpp_stanza_add_child(publickeyslist, pubkeymetadata);
-    xmpp_stanza_add_child(item, publickeyslist);
-    xmpp_stanza_add_child(publish, item);
+    xmpp_stanza_add_child(publickeyslist,pubkeymetadata );
+    xmpp_stanza_add_child(item, publickeyslist );
+    xmpp_stanza_add_child(publish,item );
     xmpp_stanza_add_child(pubsub, publish);
     xmpp_stanza_add_child(iq, pubsub);
-    xmpp_send(connection_get_conn(), iq);
-}
+    xmpp_send (connection_get_conn(), iq);
+} 
 
 // Date and Time (XEP-0082)
-char*
-_gettimestamp()
-{
+char* _gettimestamp() {
     time_t now = time(NULL);
     struct tm* tm = localtime(&now);
     char buf[255];
@@ -216,3 +215,4 @@ _gettimestamp()
     g_string_append(d, "Z");
     return strdup(d->str);
 }
+
diff --git a/src/xmpp/ox.h b/src/xmpp/ox.h
index 51435bb5..8d959eb1 100644
--- a/src/xmpp/ox.h
+++ b/src/xmpp/ox.h
@@ -43,6 +43,7 @@
  * https://xmpp.org/extensions/xep-0373.html
  */
 
+
 /*!
  * \brief Announcing OpenPGP public key from file to PEP.
  *
@@ -56,3 +57,5 @@
  */
 
 gboolean ox_announce_public_key(const char* const filename);
+
+
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index acd412f9..e6f236cd 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -50,36 +50,36 @@
 #include <strophe.h>
 #endif
 
+#include "profanity.h"
+#include "log.h"
 #include "common.h"
 #include "config/preferences.h"
 #include "event/server_events.h"
-#include "log.h"
 #include "plugins/plugins.h"
-#include "profanity.h"
 #include "ui/ui.h"
-#include "xmpp/capabilities.h"
 #include "xmpp/connection.h"
-#include "xmpp/iq.h"
-#include "xmpp/muc.h"
+#include "xmpp/capabilities.h"
 #include "xmpp/session.h"
 #include "xmpp/stanza.h"
+#include "xmpp/iq.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/muc.h"
 
 static Autocomplete sub_requests_ac;
 
-static int _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata);
+static int _presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata);
 
-static void _presence_error_handler(xmpp_stanza_t* const stanza);
-static void _unavailable_handler(xmpp_stanza_t* const stanza);
-static void _subscribe_handler(xmpp_stanza_t* const stanza);
-static void _subscribed_handler(xmpp_stanza_t* const stanza);
-static void _unsubscribed_handler(xmpp_stanza_t* const stanza);
-static void _muc_user_handler(xmpp_stanza_t* const stanza);
-static void _available_handler(xmpp_stanza_t* const stanza);
+static void _presence_error_handler(xmpp_stanza_t *const stanza);
+static void _unavailable_handler(xmpp_stanza_t *const stanza);
+static void _subscribe_handler(xmpp_stanza_t *const stanza);
+static void _subscribed_handler(xmpp_stanza_t *const stanza);
+static void _unsubscribed_handler(xmpp_stanza_t *const stanza);
+static void _muc_user_handler(xmpp_stanza_t *const stanza);
+static void _available_handler(xmpp_stanza_t *const stanza);
 
-void _send_caps_request(char* node, char* caps_key, char* id, char* from);
-static void _send_room_presence(xmpp_stanza_t* presence);
-static void _send_presence_stanza(xmpp_stanza_t* const stanza);
+void _send_caps_request(char *node, char *caps_key, char *id, char *from);
+static void _send_room_presence(xmpp_stanza_t *presence);
+static void _send_presence_stanza(xmpp_stanza_t *const stanza);
 
 void
 presence_sub_requests_init(void)
@@ -90,45 +90,46 @@ presence_sub_requests_init(void)
 void
 presence_handlers_init(void)
 {
-    xmpp_conn_t* const conn = connection_get_conn();
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_conn_t * const conn = connection_get_conn();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
     xmpp_handler_add(conn, _presence_handler, NULL, STANZA_NAME_PRESENCE, NULL, ctx);
 }
 
 void
-presence_subscription(const char* const jid, const jabber_subscr_t action)
+presence_subscription(const char *const jid, const jabber_subscr_t action)
 {
     assert(jid != NULL);
 
-    Jid* jidp = jid_create(jid);
+    Jid *jidp = jid_create(jid);
     autocomplete_remove(sub_requests_ac, jidp->barejid);
 
-    const char* type = NULL;
-    switch (action) {
-    case PRESENCE_SUBSCRIBE:
-        log_debug("Sending presence subscribe: %s", jid);
-        type = STANZA_TYPE_SUBSCRIBE;
-        break;
-    case PRESENCE_SUBSCRIBED:
-        log_debug("Sending presence subscribed: %s", jid);
-        type = STANZA_TYPE_SUBSCRIBED;
-        break;
-    case PRESENCE_UNSUBSCRIBED:
-        log_debug("Sending presence usubscribed: %s", jid);
-        type = STANZA_TYPE_UNSUBSCRIBED;
-        break;
-    default:
-        break;
+    const char *type = NULL;
+    switch (action)
+    {
+        case PRESENCE_SUBSCRIBE:
+            log_debug("Sending presence subscribe: %s", jid);
+            type = STANZA_TYPE_SUBSCRIBE;
+            break;
+        case PRESENCE_SUBSCRIBED:
+            log_debug("Sending presence subscribed: %s", jid);
+            type = STANZA_TYPE_SUBSCRIBED;
+            break;
+        case PRESENCE_UNSUBSCRIBED:
+            log_debug("Sending presence usubscribed: %s", jid);
+            type = STANZA_TYPE_UNSUBSCRIBED;
+            break;
+        default:
+            break;
     }
     if (!type) {
         log_error("Attempt to send unknown subscription action: %s", jid);
         return;
     }
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* presence = xmpp_presence_new(ctx);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *presence = xmpp_presence_new(ctx);
 
-    char* id = connection_create_stanza_id();
+    char *id = connection_create_stanza_id();
     xmpp_stanza_set_id(presence, id);
     free(id);
 
@@ -160,18 +161,18 @@ presence_clear_sub_requests(void)
 }
 
 char*
-presence_sub_request_find(const char* const search_str, gboolean previous, void* context)
+presence_sub_request_find(const char *const search_str, gboolean previous, void *context)
 {
     return autocomplete_complete(sub_requests_ac, search_str, TRUE, previous);
 }
 
 gboolean
-presence_sub_request_exists(const char* const bare_jid)
+presence_sub_request_exists(const char *const bare_jid)
 {
     gboolean result = FALSE;
 
-    GList* requests = autocomplete_create_list(sub_requests_ac);
-    GList* curr = requests;
+    GList *requests = autocomplete_create_list(sub_requests_ac);
+    GList *curr = requests;
     while (curr) {
         if (strcmp(curr->data, bare_jid) == 0) {
             result = TRUE;
@@ -191,14 +192,14 @@ presence_reset_sub_request_search(void)
 }
 
 void
-presence_send(const resource_presence_t presence_type, const int idle, char* signed_status)
+presence_send(const resource_presence_t presence_type, const int idle, char *signed_status)
 {
     if (connection_get_status() != JABBER_CONNECTED) {
         log_warning("Error setting presence, not connected.");
         return;
     }
 
-    char* msg = connection_get_presence_msg();
+    char *msg = connection_get_presence_msg();
     if (msg) {
         log_debug("Updating presence: %s, \"%s\"", string_from_resource_presence(presence_type), msg);
     } else {
@@ -208,24 +209,24 @@ presence_send(const resource_presence_t presence_type, const int idle, char* sig
     const int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type);
     connection_set_priority(pri);
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* presence = xmpp_presence_new(ctx);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *presence = xmpp_presence_new(ctx);
 
-    char* id = connection_create_stanza_id();
+    char *id = connection_create_stanza_id();
     xmpp_stanza_set_id(presence, id);
     free(id);
 
-    const char* show = stanza_get_presence_string_from_type(presence_type);
+    const char *show = stanza_get_presence_string_from_type(presence_type);
     stanza_attach_show(ctx, presence, show);
 
     stanza_attach_status(ctx, presence, msg);
 
     if (signed_status) {
-        xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *x = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(x, STANZA_NAME_X);
         xmpp_stanza_set_ns(x, STANZA_NS_SIGNED);
 
-        xmpp_stanza_t* signed_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *signed_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(signed_text, signed_status);
 
         xmpp_stanza_add_child(x, signed_text);
@@ -249,27 +250,27 @@ presence_send(const resource_presence_t presence_type, const int idle, char* sig
     xmpp_stanza_release(presence);
 
     // set last presence for account
-    const char* last = show;
+    const char *last = show;
     if (last == NULL) {
         last = STANZA_TEXT_ONLINE;
     }
 
-    char* account = session_get_account_name();
+    char *account = session_get_account_name();
     accounts_set_last_presence(account, last);
     accounts_set_last_status(account, msg);
 }
 
 static void
-_send_room_presence(xmpp_stanza_t* presence)
+_send_room_presence(xmpp_stanza_t *presence)
 {
-    GList* rooms = muc_rooms();
-    GList* curr = rooms;
+    GList *rooms = muc_rooms();
+    GList *curr = rooms;
     while (curr) {
-        const char* room = curr->data;
-        const char* nick = muc_nick(room);
+        const char *room = curr->data;
+        const char *nick = muc_nick(room);
 
         if (nick) {
-            char* full_room_jid = create_fulljid(room, nick);
+            char *full_room_jid = create_fulljid(room, nick);
             xmpp_stanza_set_to(presence, full_room_jid);
             log_debug("Sending presence to room: %s", full_room_jid);
             free(full_room_jid);
@@ -283,18 +284,18 @@ _send_room_presence(xmpp_stanza_t* presence)
 }
 
 void
-presence_join_room(const char* const room, const char* const nick, const char* const passwd)
+presence_join_room(const char *const room, const char *const nick, const char *const passwd)
 {
-    Jid* jid = jid_create_from_bare_and_resource(room, nick);
+    Jid *jid = jid_create_from_bare_and_resource(room, nick);
     log_debug("Sending room join presence to: %s", jid->fulljid);
 
     resource_presence_t presence_type = accounts_get_last_presence(session_get_account_name());
-    const char* show = stanza_get_presence_string_from_type(presence_type);
-    char* status = connection_get_presence_msg();
+    const char *show = stanza_get_presence_string_from_type(presence_type);
+    char *status = connection_get_presence_msg();
     int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type);
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* presence = stanza_create_room_join_presence(ctx, jid->fulljid, passwd);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *presence = stanza_create_room_join_presence(ctx, jid->fulljid, passwd);
     stanza_attach_show(ctx, presence, show);
     stanza_attach_status(ctx, presence, status);
     stanza_attach_priority(ctx, presence, pri);
@@ -307,20 +308,20 @@ presence_join_room(const char* const room, const char* const nick, const char* c
 }
 
 void
-presence_change_room_nick(const char* const room, const char* const nick)
+presence_change_room_nick(const char *const room, const char *const nick)
 {
     assert(room != NULL);
     assert(nick != NULL);
 
     log_debug("Sending room nickname change to: %s, nick: %s", room, nick);
     resource_presence_t presence_type = accounts_get_last_presence(session_get_account_name());
-    const char* show = stanza_get_presence_string_from_type(presence_type);
-    char* status = connection_get_presence_msg();
+    const char *show = stanza_get_presence_string_from_type(presence_type);
+    char *status = connection_get_presence_msg();
     int pri = accounts_get_priority_for_presence_type(session_get_account_name(), presence_type);
-    char* full_room_jid = create_fulljid(room, nick);
+    char *full_room_jid = create_fulljid(room, nick);
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* presence = stanza_create_room_newnick_presence(ctx, full_room_jid);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *presence = stanza_create_room_newnick_presence(ctx, full_room_jid);
     stanza_attach_show(ctx, presence, show);
     stanza_attach_status(ctx, presence, status);
     stanza_attach_priority(ctx, presence, pri);
@@ -333,11 +334,11 @@ presence_change_room_nick(const char* const room, const char* const nick)
 }
 
 void
-presence_leave_chat_room(const char* const room_jid)
+presence_leave_chat_room(const char *const room_jid)
 {
     assert(room_jid != NULL);
 
-    char* nick = muc_nick(room_jid);
+    char *nick = muc_nick(room_jid);
     if (!nick) {
         log_error("Could not get nickname for room: %s", room_jid);
         return;
@@ -345,8 +346,8 @@ presence_leave_chat_room(const char* const room_jid)
 
     log_debug("Sending room leave presence to: %s", room_jid);
 
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* presence = stanza_create_room_leave_presence(ctx, room_jid, nick);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *presence = stanza_create_room_leave_presence(ctx, room_jid, nick);
 
     _send_presence_stanza(presence);
 
@@ -354,11 +355,11 @@ presence_leave_chat_room(const char* const room_jid)
 }
 
 static int
-_presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata)
+_presence_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
 {
     log_debug("Presence stanza handler fired");
 
-    char* text = NULL;
+    char *text = NULL;
     size_t text_size;
     xmpp_stanza_to_text(stanza, &text, &text_size);
 
@@ -368,7 +369,7 @@ _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* co
         return 1;
     }
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
 
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
         _presence_error_handler(stanza);
@@ -390,7 +391,7 @@ _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* co
         _unsubscribed_handler(stanza);
     }
 
-    xmpp_stanza_t* mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (mucuser) {
         _muc_user_handler(stanza);
     }
@@ -401,21 +402,21 @@ _presence_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* co
 }
 
 static void
-_presence_error_handler(xmpp_stanza_t* const stanza)
+_presence_error_handler(xmpp_stanza_t *const stanza)
 {
-    const char* xmlns = NULL;
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
+    const char *xmlns = NULL;
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
     if (x) {
         xmlns = xmpp_stanza_get_ns(x);
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
-    xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    const char *from = xmpp_stanza_get_from(stanza);
+    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
 
     // handle MUC join errors
     if (g_strcmp0(xmlns, STANZA_NS_MUC) == 0) {
-        const char* error_cond = NULL;
-        xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS);
+        const char *error_cond = NULL;
+        xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS);
         if (reason_st) {
             error_cond = xmpp_stanza_get_name(reason_st);
         }
@@ -423,7 +424,7 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
             error_cond = "unknown";
         }
 
-        Jid* fulljid = jid_create(from);
+        Jid *fulljid = jid_create(from);
         log_info("Error joining room: %s, reason: %s", fulljid->barejid, error_cond);
         if (muc_active(fulljid->barejid)) {
             muc_leave(fulljid->barejid);
@@ -434,8 +435,8 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
         return;
     }
 
-    GString* log_msg = g_string_new("presence stanza error received");
-    const char* id = xmpp_stanza_get_id(stanza);
+    GString *log_msg = g_string_new("presence stanza error received");
+    const char *id = xmpp_stanza_get_id(stanza);
     if (id) {
         g_string_append(log_msg, " id=");
         g_string_append(log_msg, id);
@@ -445,7 +446,7 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
         g_string_append(log_msg, from);
     }
 
-    const char* type = NULL;
+    const char *type = NULL;
     if (error_stanza) {
         type = xmpp_stanza_get_type(error_stanza);
     }
@@ -455,7 +456,7 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
     }
 
     // stanza_get_error never returns NULL
-    char* err_msg = stanza_get_error_message(stanza);
+    char *err_msg = stanza_get_error_message(stanza);
     g_string_append(log_msg, " error=");
     g_string_append(log_msg, err_msg);
 
@@ -473,16 +474,16 @@ _presence_error_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_unsubscribed_handler(xmpp_stanza_t* const stanza)
+_unsubscribed_handler(xmpp_stanza_t *const stanza)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("Unsubscribed presence handler received with no from attribute");
         return;
     }
     log_debug("Unsubscribed presence handler fired for %s", from);
 
-    Jid* from_jid = jid_create(from);
+    Jid *from_jid = jid_create(from);
     sv_ev_subscription(from_jid->barejid, PRESENCE_UNSUBSCRIBED);
     autocomplete_remove(sub_requests_ac, from_jid->barejid);
 
@@ -490,16 +491,16 @@ _unsubscribed_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_subscribed_handler(xmpp_stanza_t* const stanza)
+_subscribed_handler(xmpp_stanza_t *const stanza)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("Subscribed presence handler received with no from attribute");
         return;
     }
     log_debug("Subscribed presence handler fired for %s", from);
 
-    Jid* from_jid = jid_create(from);
+    Jid *from_jid = jid_create(from);
     sv_ev_subscription(from_jid->barejid, PRESENCE_SUBSCRIBED);
     autocomplete_remove(sub_requests_ac, from_jid->barejid);
 
@@ -507,15 +508,15 @@ _subscribed_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_subscribe_handler(xmpp_stanza_t* const stanza)
+_subscribe_handler(xmpp_stanza_t *const stanza)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("Subscribe presence handler received with no from attribute", from);
     }
     log_debug("Subscribe presence handler fired for %s", from);
 
-    Jid* from_jid = jid_create(from);
+    Jid *from_jid = jid_create(from);
     if (from_jid == NULL) {
         return;
     }
@@ -527,32 +528,32 @@ _subscribe_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_unavailable_handler(xmpp_stanza_t* const stanza)
+_unavailable_handler(xmpp_stanza_t *const stanza)
 {
     inp_nonblocking(TRUE);
 
-    xmpp_conn_t* conn = connection_get_conn();
-    const char* jid = xmpp_conn_get_jid(conn);
-    const char* from = xmpp_stanza_get_from(stanza);
+    xmpp_conn_t *conn = connection_get_conn();
+    const char *jid = xmpp_conn_get_jid(conn);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("Unavailable presence received with no from attribute");
     }
     log_debug("Unavailable presence handler fired for %s", from);
 
-    Jid* my_jid = jid_create(jid);
-    Jid* from_jid = jid_create(from);
+    Jid *my_jid = jid_create(jid);
+    Jid *from_jid = jid_create(from);
     if (my_jid == NULL || from_jid == NULL) {
         jid_destroy(my_jid);
         jid_destroy(from_jid);
         return;
     }
 
-    if (strcmp(my_jid->barejid, from_jid->barejid) != 0) {
-        char* status_str = stanza_get_status(stanza, NULL);
+    if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
+        char *status_str = stanza_get_status(stanza, NULL);
         if (from_jid->resourcepart) {
             sv_ev_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str);
 
-            // hack for servers that do not send full jid with unavailable presence
+        // hack for servers that do not send full jid with unavailable presence
         } else {
             sv_ev_contact_offline(from_jid->barejid, "__prof_default", status_str);
         }
@@ -568,7 +569,7 @@ _unavailable_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_handle_caps(const char* const jid, XMPPCaps* caps)
+_handle_caps(const char *const jid, XMPPCaps *caps)
 {
     // hash supported, xep-0115, cache against ver
     if (g_strcmp0(caps->hash, "sha-1") == 0) {
@@ -579,23 +580,23 @@ _handle_caps(const char* const jid, XMPPCaps* caps)
                 caps_map_jid_to_ver(jid, caps->ver);
             } else {
                 log_debug("Capabilities cache miss: %s, for %s, sending service discovery request", caps->ver, jid);
-                char* id = connection_create_stanza_id();
+                char *id = connection_create_stanza_id();
                 iq_send_caps_request(jid, id, caps->node, caps->ver);
                 free(id);
             }
         }
 
-        // unsupported hash, xep-0115, associate with JID, no cache
+    // unsupported hash, xep-0115, associate with JID, no cache
     } else if (caps->hash) {
         log_info("Hash %s not supported: %s, sending service discovery request", caps->hash, jid);
-        char* id = connection_create_stanza_id();
+        char *id = connection_create_stanza_id();
         iq_send_caps_request_for_jid(jid, id, caps->node, caps->ver);
         free(id);
 
-        // no hash, legacy caps, cache against node#ver
-    } else if (caps->node && caps->ver) {
+   // no hash, legacy caps, cache against node#ver
+   } else if (caps->node && caps->ver) {
         log_info("No hash specified: %s, legacy request made for %s#%s", jid, caps->node, caps->ver);
-        char* id = connection_create_stanza_id();
+        char *id = connection_create_stanza_id();
         iq_send_caps_request_legacy(jid, id, caps->node, caps->ver);
         free(id);
     } else {
@@ -604,7 +605,7 @@ _handle_caps(const char* const jid, XMPPCaps* caps)
 }
 
 static void
-_available_handler(xmpp_stanza_t* const stanza)
+_available_handler(xmpp_stanza_t *const stanza)
 {
     inp_nonblocking(TRUE);
 
@@ -614,7 +615,10 @@ _available_handler(xmpp_stanza_t* const stanza)
     }
 
     // handler still fires if other types
-    if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) || (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) {
+    if ((g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNAVAILABLE) == 0) ||
+            (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) ||
+            (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) ||
+            (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) {
         return;
     }
 
@@ -624,52 +628,52 @@ _available_handler(xmpp_stanza_t* const stanza)
     }
 
     int err = 0;
-    XMPPPresence* xmpp_presence = stanza_parse_presence(stanza, &err);
+    XMPPPresence *xmpp_presence = stanza_parse_presence(stanza, &err);
 
     if (!xmpp_presence) {
-        const char* from = NULL;
-        switch (err) {
-        case STANZA_PARSE_ERROR_NO_FROM:
-            log_warning("Available presence handler fired with no from attribute.");
-            break;
-        case STANZA_PARSE_ERROR_INVALID_FROM:
-            from = xmpp_stanza_get_from(stanza);
-            log_warning("Available presence handler fired with invalid from attribute: %s", from);
-            break;
-        default:
-            log_warning("Available presence handler fired, could not parse stanza.");
-            break;
+        const char *from = NULL;
+        switch(err) {
+            case STANZA_PARSE_ERROR_NO_FROM:
+                log_warning("Available presence handler fired with no from attribute.");
+                break;
+            case STANZA_PARSE_ERROR_INVALID_FROM:
+                from = xmpp_stanza_get_from(stanza);
+                log_warning("Available presence handler fired with invalid from attribute: %s", from);
+                break;
+            default:
+                log_warning("Available presence handler fired, could not parse stanza.");
+                break;
         }
         return;
     } else {
-        char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
+        char *jid = jid_fulljid_or_barejid(xmpp_presence->jid);
         log_debug("Presence available handler fired for: %s", jid);
     }
 
-    xmpp_conn_t* conn = connection_get_conn();
-    const char* my_jid_str = xmpp_conn_get_jid(conn);
-    Jid* my_jid = jid_create(my_jid_str);
+    xmpp_conn_t *conn = connection_get_conn();
+    const char *my_jid_str = xmpp_conn_get_jid(conn);
+    Jid *my_jid = jid_create(my_jid_str);
 
-    XMPPCaps* caps = stanza_parse_caps(stanza);
+    XMPPCaps *caps = stanza_parse_caps(stanza);
     if ((g_strcmp0(my_jid->fulljid, xmpp_presence->jid->fulljid) != 0) && caps) {
         log_debug("Presence contains capabilities.");
-        char* jid = jid_fulljid_or_barejid(xmpp_presence->jid);
+        char *jid = jid_fulljid_or_barejid(xmpp_presence->jid);
         _handle_caps(jid, caps);
     }
     stanza_free_caps(caps);
 
-    Resource* resource = stanza_resource_from_presence(xmpp_presence);
+    Resource *resource = stanza_resource_from_presence(xmpp_presence);
 
     if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) {
         connection_add_available_resource(resource);
     } else {
-        char* pgpsig = NULL;
-        xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED);
+        char *pgpsig = NULL;
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED);
         if (x) {
             pgpsig = xmpp_stanza_get_text(x);
         }
         sv_ev_contact_online(xmpp_presence->jid->barejid, resource, xmpp_presence->last_activity, pgpsig);
-        xmpp_ctx_t* ctx = connection_get_ctx();
+        xmpp_ctx_t *ctx = connection_get_ctx();
         xmpp_free(ctx, pgpsig);
     }
 
@@ -678,7 +682,7 @@ _available_handler(xmpp_stanza_t* const stanza)
 }
 
 void
-_send_caps_request(char* node, char* caps_key, char* id, char* from)
+_send_caps_request(char *node, char *caps_key, char *id, char *from)
 {
     if (!node) {
         log_debug("No node string, not sending discovery IQ.");
@@ -692,8 +696,8 @@ _send_caps_request(char* node, char* caps_key, char* id, char* from)
     }
 
     log_debug("Capabilities not cached for '%s', sending discovery IQ.", from);
-    xmpp_ctx_t* ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, from, node);
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, from, node);
 
     iq_send_stanza(iq);
 
@@ -701,51 +705,51 @@ _send_caps_request(char* node, char* caps_key, char* id, char* from)
 }
 
 static void
-_muc_user_self_handler(xmpp_stanza_t* stanza)
+_muc_user_self_handler(xmpp_stanza_t *stanza)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
-    Jid* from_jid = jid_create(from);
+    const char *from = xmpp_stanza_get_from(stanza);
+    Jid *from_jid = jid_create(from);
 
     log_debug("Room self presence received from %s", from_jid->fulljid);
 
-    char* room = from_jid->barejid;
+    char *room = from_jid->barejid;
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, STANZA_TYPE_UNAVAILABLE) == 0) {
 
         // handle nickname change
-        const char* new_nick = stanza_get_new_nick(stanza);
+        const char *new_nick = stanza_get_new_nick(stanza);
         if (new_nick) {
             muc_nick_change_start(room, new_nick);
 
-            // handle left room
+        // handle left room
         } else {
-            GSList* status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER);
+            GSList *status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER);
 
             // room destroyed
             if (stanza_room_destroyed(stanza)) {
-                const char* new_jid = stanza_get_muc_destroy_alternative_room(stanza);
-                char* password = stanza_get_muc_destroy_alternative_password(stanza);
-                char* reason = stanza_get_muc_destroy_reason(stanza);
+                const char *new_jid = stanza_get_muc_destroy_alternative_room(stanza);
+                char *password = stanza_get_muc_destroy_alternative_password(stanza);
+                char *reason = stanza_get_muc_destroy_reason(stanza);
                 sv_ev_room_destroyed(room, new_jid, password, reason);
                 free(password);
                 free(reason);
 
-                // kicked from room
+            // kicked from room
             } else if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
-                const char* actor = stanza_get_actor(stanza);
-                char* reason = stanza_get_reason(stanza);
+                const char *actor = stanza_get_actor(stanza);
+                char *reason = stanza_get_reason(stanza);
                 sv_ev_room_kicked(room, actor, reason);
                 free(reason);
 
-                // banned from room
+            // banned from room
             } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
-                const char* actor = stanza_get_actor(stanza);
-                char* reason = stanza_get_reason(stanza);
+                const char *actor = stanza_get_actor(stanza);
+                char *reason = stanza_get_reason(stanza);
                 sv_ev_room_banned(room, actor, reason);
                 free(reason);
 
-                // normal exit
+            // normal exit
             } else {
                 sv_ev_leave_room(room);
             }
@@ -754,17 +758,17 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
         }
     } else {
         gboolean config_required = stanza_muc_requires_config(stanza);
-        const char* actor = stanza_get_actor(stanza);
-        char* reason = stanza_get_reason(stanza);
-        char* nick = from_jid->resourcepart;
-        char* show_str = stanza_get_show(stanza, "online");
-        char* status_str = stanza_get_status(stanza, NULL);
-        const char* jid = NULL;
-        const char* role = NULL;
-        const char* affiliation = NULL;
-        xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+        const char *actor = stanza_get_actor(stanza);
+        char *reason = stanza_get_reason(stanza);
+        char *nick = from_jid->resourcepart;
+        char *show_str = stanza_get_show(stanza, "online");
+        char *status_str = stanza_get_status(stanza, NULL);
+        const char *jid = NULL;
+        const char *role = NULL;
+        const char *affiliation = NULL;
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
         if (x) {
-            xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
+            xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
             if (item) {
                 jid = xmpp_stanza_get_attribute(item, "jid");
                 role = xmpp_stanza_get_attribute(item, "role");
@@ -781,44 +785,44 @@ _muc_user_self_handler(xmpp_stanza_t* stanza)
 }
 
 static void
-_muc_user_occupant_handler(xmpp_stanza_t* stanza)
+_muc_user_occupant_handler(xmpp_stanza_t *stanza)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
-    Jid* from_jid = jid_create(from);
+    const char *from = xmpp_stanza_get_from(stanza);
+    Jid *from_jid = jid_create(from);
 
     log_debug("Room presence received from %s", from_jid->fulljid);
 
-    char* room = from_jid->barejid;
-    char* nick = from_jid->resourcepart;
-    char* status_str = stanza_get_status(stanza, NULL);
+    char *room = from_jid->barejid;
+    char *nick = from_jid->resourcepart;
+    char *status_str = stanza_get_status(stanza, NULL);
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, STANZA_TYPE_UNAVAILABLE) == 0) {
 
         // handle nickname change
-        const char* new_nick = stanza_get_new_nick(stanza);
+        const char *new_nick = stanza_get_new_nick(stanza);
         if (new_nick) {
             muc_occupant_nick_change_start(room, new_nick, nick);
 
-            // handle left room
+        // handle left room
         } else {
-            GSList* status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER);
+            GSList *status_codes = stanza_get_status_codes_by_ns(stanza, STANZA_NS_MUC_USER);
 
             // kicked from room
             if (g_slist_find_custom(status_codes, "307", (GCompareFunc)g_strcmp0)) {
-                const char* actor = stanza_get_actor(stanza);
-                char* reason = stanza_get_reason(stanza);
+                const char *actor = stanza_get_actor(stanza);
+                char *reason = stanza_get_reason(stanza);
                 sv_ev_room_occupent_kicked(room, nick, actor, reason);
                 free(reason);
 
-                // banned from room
+            // banned from room
             } else if (g_slist_find_custom(status_codes, "301", (GCompareFunc)g_strcmp0)) {
-                const char* actor = stanza_get_actor(stanza);
-                char* reason = stanza_get_reason(stanza);
+                const char *actor = stanza_get_actor(stanza);
+                char *reason = stanza_get_reason(stanza);
                 sv_ev_room_occupent_banned(room, nick, actor, reason);
                 free(reason);
 
-                // normal exit
+            // normal exit
             } else {
                 sv_ev_room_occupant_offline(room, nick, "offline", status_str);
             }
@@ -826,24 +830,24 @@ _muc_user_occupant_handler(xmpp_stanza_t* stanza)
             g_slist_free_full(status_codes, free);
         }
 
-        // room occupant online
+    // room occupant online
     } else {
         // send disco info for capabilities, if not cached
-        XMPPCaps* caps = stanza_parse_caps(stanza);
+        XMPPCaps *caps = stanza_parse_caps(stanza);
         if (caps) {
             _handle_caps(from, caps);
         }
         stanza_free_caps(caps);
 
-        const char* actor = stanza_get_actor(stanza);
-        char* show_str = stanza_get_show(stanza, "online");
-        char* reason = stanza_get_reason(stanza);
-        const char* jid = NULL;
-        const char* role = NULL;
-        const char* affiliation = NULL;
-        xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+        const char *actor = stanza_get_actor(stanza);
+        char *show_str = stanza_get_show(stanza, "online");
+        char *reason = stanza_get_reason(stanza);
+        const char *jid = NULL;
+        const char *role = NULL;
+        const char *affiliation = NULL;
+        xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
         if (x) {
-            xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
+            xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
             if (item) {
                 jid = xmpp_stanza_get_attribute(item, "jid");
                 role = xmpp_stanza_get_attribute(item, "role");
@@ -860,23 +864,23 @@ _muc_user_occupant_handler(xmpp_stanza_t* stanza)
 }
 
 static void
-_muc_user_handler(xmpp_stanza_t* const stanza)
+_muc_user_handler(xmpp_stanza_t *const stanza)
 {
     inp_nonblocking(TRUE);
 
-    const char* type = xmpp_stanza_get_type(stanza);
+    const char *type = xmpp_stanza_get_type(stanza);
     // handler still fires if error
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
         return;
     }
 
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         log_warning("MUC User stanza received with no from attribute");
         return;
     }
 
-    Jid* from_jid = jid_create(from);
+    Jid *from_jid = jid_create(from);
     if (from_jid == NULL || from_jid->resourcepart == NULL) {
         log_warning("MUC User stanza received with invalid from attribute: %s", from);
         jid_destroy(from_jid);
@@ -892,14 +896,14 @@ _muc_user_handler(xmpp_stanza_t* const stanza)
 }
 
 static void
-_send_presence_stanza(xmpp_stanza_t* const stanza)
+_send_presence_stanza(xmpp_stanza_t *const stanza)
 {
-    char* text;
+    char *text;
     size_t text_size;
     xmpp_stanza_to_text(stanza, &text, &text_size);
 
-    xmpp_conn_t* conn = connection_get_conn();
-    char* plugin_text = plugins_on_presence_stanza_send(text);
+    xmpp_conn_t *conn = connection_get_conn();
+    char *plugin_text = plugins_on_presence_stanza_send(text);
     if (plugin_text) {
         xmpp_send_raw_string(conn, "%s", plugin_text);
         free(plugin_text);
diff --git a/src/xmpp/resource.c b/src/xmpp/resource.c
index 9e8e1a8b..774c8e23 100644
--- a/src/xmpp/resource.c
+++ b/src/xmpp/resource.c
@@ -41,10 +41,10 @@
 #include "xmpp/resource.h"
 
 Resource*
-resource_new(const char* const name, resource_presence_t presence, const char* const status, const int priority)
+resource_new(const char *const name, resource_presence_t presence, const char *const status, const int priority)
 {
     assert(name != NULL);
-    Resource* new_resource = malloc(sizeof(struct resource_t));
+    Resource *new_resource = malloc(sizeof(struct resource_t));
     new_resource->name = strdup(name);
     new_resource->presence = presence;
     if (status) {
@@ -58,7 +58,7 @@ resource_new(const char* const name, resource_presence_t presence, const char* c
 }
 
 int
-resource_compare_availability(Resource* first, Resource* second)
+resource_compare_availability(Resource *first, Resource *second)
 {
     if (first->priority > second->priority) {
         return -1;
@@ -88,7 +88,7 @@ resource_compare_availability(Resource* first, Resource* second)
 }
 
 void
-resource_destroy(Resource* resource)
+resource_destroy(Resource *resource)
 {
     if (resource) {
         free(resource->name);
@@ -98,10 +98,12 @@ resource_destroy(Resource* resource)
 }
 
 gboolean
-valid_resource_presence_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) || (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) || (strcmp(str, "dnd") == 0)) {
+    if ((strcmp(str, "online") == 0) || (strcmp(str, "chat") == 0) ||
+            (strcmp(str, "away") == 0) || (strcmp(str, "xa") == 0) ||
+            (strcmp(str, "dnd") == 0)) {
         return TRUE;
     } else {
         return FALSE;
@@ -111,22 +113,23 @@ valid_resource_presence_string(const char* const str)
 const char*
 string_from_resource_presence(resource_presence_t presence)
 {
-    switch (presence) {
-    case RESOURCE_CHAT:
-        return "chat";
-    case RESOURCE_AWAY:
-        return "away";
-    case RESOURCE_XA:
-        return "xa";
-    case RESOURCE_DND:
-        return "dnd";
-    default:
-        return "online";
+    switch(presence)
+    {
+        case RESOURCE_CHAT:
+            return "chat";
+        case RESOURCE_AWAY:
+            return "away";
+        case RESOURCE_XA:
+            return "xa";
+        case RESOURCE_DND:
+            return "dnd";
+        default:
+            return "online";
     }
 }
 
 resource_presence_t
-resource_presence_from_string(const char* const str)
+resource_presence_from_string(const char *const str)
 {
     if (str == NULL) {
         return RESOURCE_ONLINE;
@@ -148,16 +151,17 @@ resource_presence_from_string(const char* const str)
 contact_presence_t
 contact_presence_from_resource_presence(resource_presence_t resource_presence)
 {
-    switch (resource_presence) {
-    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 CONTACT_ONLINE;
+    switch(resource_presence)
+    {
+        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 CONTACT_ONLINE;
     }
 }
diff --git a/src/xmpp/resource.h b/src/xmpp/resource.h
index 41d20511..ce01203f 100644
--- a/src/xmpp/resource.h
+++ b/src/xmpp/resource.h
@@ -38,22 +38,21 @@
 
 #include "common.h"
 
-typedef struct resource_t
-{
-    char* name;
+typedef struct resource_t {
+    char *name;
     resource_presence_t presence;
-    char* status;
+    char *status;
     int priority;
 } Resource;
 
-Resource* resource_new(const char* const name, resource_presence_t presence, const char* const status,
-                       const int priority);
-void resource_destroy(Resource* resource);
-int resource_compare_availability(Resource* first, Resource* second);
+Resource* resource_new(const char *const name, resource_presence_t presence, const char *const status,
+    const int priority);
+void resource_destroy(Resource *resource);
+int resource_compare_availability(Resource *first, Resource *second);
 
-gboolean valid_resource_presence_string(const char* const str);
+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);
+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/xmpp/roster.c b/src/xmpp/roster.c
index df728903..64099335 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -49,79 +49,78 @@
 #include <strophe.h>
 #endif
 
-#include "config/preferences.h"
-#include "event/client_events.h"
-#include "event/server_events.h"
+#include "profanity.h"
 #include "log.h"
+#include "config/preferences.h"
 #include "plugins/plugins.h"
-#include "profanity.h"
+#include "event/server_events.h"
+#include "event/client_events.h"
 #include "tools/autocomplete.h"
 #include "ui/ui.h"
-#include "xmpp/connection.h"
+#include "xmpp/session.h"
 #include "xmpp/iq.h"
+#include "xmpp/connection.h"
 #include "xmpp/roster.h"
 #include "xmpp/roster_list.h"
-#include "xmpp/session.h"
 #include "xmpp/stanza.h"
 #include "xmpp/xmpp.h"
 
 // callback data for group commands
-typedef struct _group_data
-{
-    char* name;
-    char* group;
+typedef struct _group_data {
+    char *name;
+    char *group;
 } GroupData;
 
 // id handlers
-static int _group_add_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static int _group_remove_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
-static void _free_group_data(GroupData* data);
+static int _group_add_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static int _group_remove_id_handler(xmpp_stanza_t *const stanza, void *const userdata);
+static void _free_group_data(GroupData *data);
 
 void
 roster_request(void)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_roster_iq(ctx);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_roster_iq(ctx);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-roster_send_add_new(const char* const barejid, const char* const name)
+roster_send_add_new(const char *const barejid, const char *const name)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, name, NULL);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_roster_set(ctx, id, barejid, name, NULL);
     free(id);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-roster_send_remove(const char* const barejid)
+roster_send_remove(const char *const barejid)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    xmpp_stanza_t* iq = stanza_create_roster_remove_set(ctx, barejid);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    xmpp_stanza_t *iq = stanza_create_roster_remove_set(ctx, barejid);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups)
+roster_send_name_change(const char *const barejid, const char *const new_name, GSList *groups)
 {
-    xmpp_ctx_t* const ctx = connection_get_ctx();
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups);
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = stanza_create_roster_set(ctx, id, barejid, new_name, groups);
     free(id);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
 }
 
 void
-roster_send_add_to_group(const char* const group, PContact contact)
+roster_send_add_to_group(const char *const group, PContact contact)
 {
-    GSList* groups = p_contact_groups(contact);
-    GSList* new_groups = NULL;
+    GSList *groups = p_contact_groups(contact);
+    GSList *new_groups = NULL;
     while (groups) {
         new_groups = g_slist_append(new_groups, strdup(groups->data));
         groups = g_slist_next(groups);
@@ -129,8 +128,8 @@ roster_send_add_to_group(const char* const group, PContact contact)
 
     new_groups = g_slist_append(new_groups, strdup(group));
     // add an id handler to handle the response
-    char* unique_id = connection_create_stanza_id();
-    GroupData* data = malloc(sizeof(GroupData));
+    char *unique_id = connection_create_stanza_id();
+    GroupData *data = malloc(sizeof(GroupData));
     data->group = strdup(group);
     if (p_contact_name(contact)) {
         data->name = strdup(p_contact_name(contact));
@@ -138,30 +137,30 @@ roster_send_add_to_group(const char* const group, PContact contact)
         data->name = strdup(p_contact_barejid(contact));
     }
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
     iq_id_handler_add(unique_id, _group_add_id_handler, (ProfIqFreeCallback)_free_group_data, data);
-    xmpp_stanza_t* iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact),
-                                                 p_contact_name(contact), new_groups);
+    xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact),
+        p_contact_name(contact), new_groups);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
     free(unique_id);
 }
 
 static int
-_group_add_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_group_add_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
     if (userdata) {
-        GroupData* data = userdata;
+        GroupData *data = userdata;
         ui_group_added(data->name, data->group);
     }
     return 0;
 }
 
 void
-roster_send_remove_from_group(const char* const group, PContact contact)
+roster_send_remove_from_group(const char *const group, PContact contact)
 {
-    GSList* groups = p_contact_groups(contact);
-    GSList* new_groups = NULL;
+    GSList *groups = p_contact_groups(contact);
+    GSList *new_groups = NULL;
     while (groups) {
         if (strcmp(groups->data, group) != 0) {
             new_groups = g_slist_append(new_groups, strdup(groups->data));
@@ -169,11 +168,11 @@ roster_send_remove_from_group(const char* const group, PContact contact)
         groups = g_slist_next(groups);
     }
 
-    xmpp_ctx_t* const ctx = connection_get_ctx();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
 
     // add an id handler to handle the response
-    char* unique_id = connection_create_stanza_id();
-    GroupData* data = malloc(sizeof(GroupData));
+    char *unique_id = connection_create_stanza_id();
+    GroupData *data = malloc(sizeof(GroupData));
     data->group = strdup(group);
     if (p_contact_name(contact)) {
         data->name = strdup(p_contact_name(contact));
@@ -182,36 +181,38 @@ roster_send_remove_from_group(const char* const group, PContact contact)
     }
 
     iq_id_handler_add(unique_id, _group_remove_id_handler, (ProfIqFreeCallback)_free_group_data, data);
-    xmpp_stanza_t* iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact),
-                                                 p_contact_name(contact), new_groups);
+    xmpp_stanza_t *iq = stanza_create_roster_set(ctx, unique_id, p_contact_barejid(contact),
+        p_contact_name(contact), new_groups);
     iq_send_stanza(iq);
     xmpp_stanza_release(iq);
     free(unique_id);
 }
 
 static int
-_group_remove_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+_group_remove_id_handler(xmpp_stanza_t *const stanza, void *const userdata)
 {
     if (userdata) {
-        GroupData* data = userdata;
+        GroupData *data = userdata;
         ui_group_removed(data->name, data->group);
     }
     return 0;
 }
 
 void
-roster_set_handler(xmpp_stanza_t* const stanza)
+roster_set_handler(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(query, STANZA_NAME_ITEM);
+    xmpp_stanza_t *query =
+        xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *item =
+        xmpp_stanza_get_child_by_name(query, STANZA_NAME_ITEM);
 
     if (item == NULL) {
         return;
     }
 
     // if from attribute exists and it is not current users barejid, ignore push
-    char* mybarejid = connection_get_barejid();
-    const char* from = xmpp_stanza_get_from(stanza);
+    char *mybarejid = connection_get_barejid();
+    const char *from = xmpp_stanza_get_from(stanza);
     if (from && (strcmp(from, mybarejid) != 0)) {
         log_warning("Received alleged roster push from: %s", from);
         free(mybarejid);
@@ -219,11 +220,11 @@ roster_set_handler(xmpp_stanza_t* const stanza)
     }
     free(mybarejid);
 
-    const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
-    gchar* barejid_lower = g_utf8_strdown(barejid, -1);
-    const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
-    const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
-    const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
+    const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+    gchar *barejid_lower = g_utf8_strdown(barejid, -1);
+    const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
+    const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
+    const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
 
     // do not set nickname to empty string, set to NULL instead
     if (name && (strlen(name) == 0)) {
@@ -239,7 +240,7 @@ roster_set_handler(xmpp_stanza_t* const stanza)
         roster_remove(name, barejid_lower);
         ui_roster_remove(barejid_lower);
 
-        // otherwise update local roster
+    // otherwise update local roster
     } else {
 
         // check for pending out subscriptions
@@ -248,7 +249,7 @@ roster_set_handler(xmpp_stanza_t* const stanza)
             pending_out = TRUE;
         }
 
-        GSList* groups = roster_get_groups_from_item(item);
+        GSList *groups = roster_get_groups_from_item(item);
 
         // update the local roster
         PContact contact = roster_get_contact(barejid_lower);
@@ -268,35 +269,34 @@ roster_set_handler(xmpp_stanza_t* const stanza)
 }
 
 void
-roster_result_handler(xmpp_stanza_t* const stanza)
+roster_result_handler(xmpp_stanza_t *const stanza)
 {
-    const char* id = xmpp_stanza_get_id(stanza);
+    const char *id = xmpp_stanza_get_id(stanza);
 
     if (g_strcmp0(id, "roster") != 0) {
         return;
     }
 
     // handle initial roster response
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
-    xmpp_stanza_t* item = xmpp_stanza_get_children(query);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *item = xmpp_stanza_get_children(query);
 
     while (item) {
-        const char* barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
-        gchar* barejid_lower = g_utf8_strdown(barejid, -1);
-        const char* name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
-        const char* sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
+        const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+        gchar *barejid_lower = g_utf8_strdown(barejid, -1);
+        const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
+        const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
 
         // do not set nickname to empty string, set to NULL instead
-        if (name && (strlen(name) == 0))
-            name = NULL;
+        if (name && (strlen(name) == 0)) name = NULL;
 
         gboolean pending_out = FALSE;
-        const char* ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
+        const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
         if (g_strcmp0(ask, "subscribe") == 0) {
             pending_out = TRUE;
         }
 
-        GSList* groups = roster_get_groups_from_item(item);
+        GSList *groups = roster_get_groups_from_item(item);
 
         gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
         if (!added) {
@@ -313,14 +313,14 @@ roster_result_handler(xmpp_stanza_t* const stanza)
 }
 
 GSList*
-roster_get_groups_from_item(xmpp_stanza_t* item)
+roster_get_groups_from_item(xmpp_stanza_t *item)
 {
-    GSList* groups = NULL;
-    xmpp_stanza_t* group_element = xmpp_stanza_get_children(item);
+    GSList *groups = NULL;
+    xmpp_stanza_t *group_element = xmpp_stanza_get_children(item);
 
     while (group_element) {
         if (strcmp(xmpp_stanza_get_name(group_element), STANZA_NAME_GROUP) == 0) {
-            char* groupname = xmpp_stanza_get_text(group_element);
+            char *groupname = xmpp_stanza_get_text(group_element);
             if (groupname) {
                 groups = g_slist_append(groups, groupname);
             }
@@ -332,7 +332,7 @@ roster_get_groups_from_item(xmpp_stanza_t* item)
 }
 
 static void
-_free_group_data(GroupData* data)
+_free_group_data(GroupData *data)
 {
     if (data) {
         free(data->group);
diff --git a/src/xmpp/roster.h b/src/xmpp/roster.h
index 253e088d..d516fa97 100644
--- a/src/xmpp/roster.h
+++ b/src/xmpp/roster.h
@@ -37,8 +37,8 @@
 #define XMPP_ROSTER_H
 
 void roster_request(void);
-void roster_set_handler(xmpp_stanza_t* const stanza);
-void roster_result_handler(xmpp_stanza_t* const stanza);
-GSList* roster_get_groups_from_item(xmpp_stanza_t* const item);
+void roster_set_handler(xmpp_stanza_t *const stanza);
+void roster_result_handler(xmpp_stanza_t *const stanza);
+GSList* roster_get_groups_from_item(xmpp_stanza_t *const item);
 
 #endif
diff --git a/src/xmpp/roster_list.c b/src/xmpp/roster_list.c
index d5acfc78..49f067d6 100644
--- a/src/xmpp/roster_list.c
+++ b/src/xmpp/roster_list.c
@@ -33,22 +33,23 @@
  *
  */
 
+
+#include <string.h>
+#include <stdlib.h>
 #include <assert.h>
 #include <glib.h>
-#include <stdlib.h>
-#include <string.h>
+#include <assert.h>
 
 #include "config/preferences.h"
 #include "tools/autocomplete.h"
+#include "xmpp/roster_list.h"
+#include "xmpp/resource.h"
 #include "xmpp/contact.h"
 #include "xmpp/jid.h"
-#include "xmpp/resource.h"
-#include "xmpp/roster_list.h"
 
-typedef struct prof_roster_t
-{
+typedef struct prof_roster_t {
     // contacts, indexed on barejid
-    GHashTable* contacts;
+    GHashTable *contacts;
 
     // nicknames
     Autocomplete name_ac;
@@ -60,28 +61,27 @@ typedef struct prof_roster_t
     Autocomplete fulljid_ac;
 
     // nickname to barejid map
-    GHashTable* name_to_barejid;
+    GHashTable *name_to_barejid;
 
     // groups
     Autocomplete groups_ac;
-    GHashTable* group_count;
+    GHashTable *group_count;
 } ProfRoster;
 
-typedef struct pending_presence
-{
-    char* barejid;
-    Resource* resource;
-    GDateTime* last_activity;
+typedef struct pending_presence {
+    char *barejid;
+    Resource *resource;
+    GDateTime *last_activity;
 } ProfPendingPresence;
 
-static ProfRoster* roster = NULL;
+static ProfRoster *roster = NULL;
 static gboolean roster_received = FALSE;
-static GSList* roster_pending_presence = NULL;
+static GSList *roster_pending_presence = NULL;
 
-static gboolean _key_equals(void* key1, void* key2);
-static gboolean _datetimes_equal(GDateTime* dt1, GDateTime* dt2);
-static void _replace_name(const char* const current_name, const char* const new_name, const char* const barejid);
-static void _add_name_and_barejid(const char* const name, const char* const barejid);
+static gboolean _key_equals(void *key1, void *key2);
+static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2);
+static void _replace_name(const char *const current_name, const char *const new_name, const char *const barejid);
+static void _add_name_and_barejid(const char *const name, const char *const barejid);
 
 void
 roster_create(void)
@@ -119,7 +119,7 @@ roster_destroy(void)
 }
 
 gboolean
-roster_update_presence(const char* const barejid, Resource* resource, GDateTime* last_activity)
+roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity)
 {
     assert(roster != NULL);
 
@@ -127,7 +127,7 @@ roster_update_presence(const char* const barejid, Resource* resource, GDateTime*
     assert(resource != NULL);
 
     if (!roster_received) {
-        ProfPendingPresence* presence = malloc(sizeof(ProfPendingPresence));
+        ProfPendingPresence *presence = malloc(sizeof(ProfPendingPresence));
         presence->barejid = strdup(barejid);
         presence->resource = resource;
         presence->last_activity = last_activity;
@@ -148,7 +148,7 @@ roster_update_presence(const char* const barejid, Resource* resource, GDateTime*
         p_contact_set_last_activity(contact, last_activity);
     }
     p_contact_set_presence(contact, resource);
-    Jid* jid = jid_create_from_bare_and_resource(barejid, resource->name);
+    Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
     autocomplete_add(roster->fulljid_ac, jid->fulljid);
     jid_destroy(jid);
 
@@ -156,11 +156,11 @@ roster_update_presence(const char* const barejid, Resource* resource, GDateTime*
 }
 
 PContact
-roster_get_contact(const char* const barejid)
+roster_get_contact(const char *const barejid)
 {
     assert(roster != NULL);
 
-    gchar* barejidlower = g_utf8_strdown(barejid, -1);
+    gchar *barejidlower = g_utf8_strdown(barejid, -1);
     PContact contact = g_hash_table_lookup(roster->contacts, barejidlower);
     g_free(barejidlower);
 
@@ -168,11 +168,11 @@ roster_get_contact(const char* const barejid)
 }
 
 char*
-roster_get_msg_display_name(const char* const barejid, const char* const resource)
+roster_get_msg_display_name(const char *const barejid, const char *const resource)
 {
     assert(roster != NULL);
 
-    GString* result = g_string_new("");
+    GString *result = g_string_new("");
 
     PContact contact = roster_get_contact(barejid);
     if (contact) {
@@ -190,14 +190,14 @@ roster_get_msg_display_name(const char* const barejid, const char* const resourc
         g_string_append(result, resource);
     }
 
-    char* result_str = result->str;
+    char *result_str = result->str;
     g_string_free(result, FALSE);
 
     return result_str;
 }
 
 gboolean
-roster_contact_offline(const char* const barejid, const char* const resource, const char* const status)
+roster_contact_offline(const char *const barejid, const char *const resource, const char *const status)
 {
     assert(roster != NULL);
 
@@ -211,7 +211,7 @@ roster_contact_offline(const char* const barejid, const char* const resource, co
     } else {
         gboolean result = p_contact_remove_resource(contact, resource);
         if (result == TRUE) {
-            Jid* jid = jid_create_from_bare_and_resource(barejid, resource);
+            Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
             autocomplete_remove(roster->fulljid_ac, jid->fulljid);
             jid_destroy(jid);
         }
@@ -232,13 +232,13 @@ roster_reset_search_attempts(void)
 }
 
 void
-roster_change_name(PContact contact, const char* const new_name)
+roster_change_name(PContact contact, const char *const new_name)
 {
     assert(roster != NULL);
     assert(contact != NULL);
 
-    char* current_name = NULL;
-    const char* barejid = p_contact_barejid(contact);
+    char *current_name = NULL;
+    const char *barejid = p_contact_barejid(contact);
 
     if (p_contact_name(contact)) {
         current_name = strdup(p_contact_name(contact));
@@ -250,7 +250,7 @@ roster_change_name(PContact contact, const char* const new_name)
 }
 
 void
-roster_remove(const char* const name, const char* const barejid)
+roster_remove(const char *const name, const char *const barejid)
 {
     assert(roster != NULL);
 
@@ -261,9 +261,9 @@ roster_remove(const char* const name, const char* const barejid)
     // remove each fulljid
     PContact contact = roster_get_contact(barejid);
     if (contact) {
-        GList* resources = p_contact_get_available_resources(contact);
+        GList *resources = p_contact_get_available_resources(contact);
         while (resources) {
-            GString* fulljid = g_string_new(barejid);
+            GString *fulljid = g_string_new(barejid);
             g_string_append(fulljid, "/");
             g_string_append(fulljid, resources->data);
             autocomplete_remove(roster->fulljid_ac, fulljid->str);
@@ -272,10 +272,10 @@ roster_remove(const char* const name, const char* const barejid)
         }
         g_list_free(resources);
 
-        GSList* groups = p_contact_groups(contact);
-        GSList* curr = groups;
+        GSList *groups = p_contact_groups(contact);
+        GSList *curr = groups;
         while (curr) {
-            gchar* group = curr->data;
+            gchar *group = curr->data;
             if (g_hash_table_contains(roster->group_count, group)) {
                 int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, group));
                 count--;
@@ -295,8 +295,8 @@ roster_remove(const char* const name, const char* const barejid)
 }
 
 void
-roster_update(const char* const barejid, const char* const name, GSList* groups, const char* const subscription,
-              gboolean pending_out)
+roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
+    gboolean pending_out)
 {
     assert(roster != NULL);
 
@@ -308,9 +308,9 @@ roster_update(const char* const barejid, const char* const name, GSList* groups,
 
     roster_change_name(contact, name);
 
-    GSList* curr_new_group = groups;
+    GSList *curr_new_group = groups;
     while (curr_new_group) {
-        char* new_group = curr_new_group->data;
+        char *new_group = curr_new_group->data;
 
         // contact added to group
         if (!p_contact_in_group(contact, new_group)) {
@@ -320,7 +320,7 @@ roster_update(const char* const barejid, const char* const name, GSList* groups,
                 g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(1));
                 autocomplete_add(roster->groups_ac, curr_new_group->data);
 
-                // increment count
+            // increment count
             } else {
                 int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group));
                 g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
@@ -329,10 +329,10 @@ roster_update(const char* const barejid, const char* const name, GSList* groups,
         curr_new_group = g_slist_next(curr_new_group);
     }
 
-    GSList* old_groups = p_contact_groups(contact);
-    GSList* curr_old_group = old_groups;
+    GSList *old_groups = p_contact_groups(contact);
+    GSList *curr_old_group = old_groups;
     while (curr_old_group) {
-        char* old_group = curr_old_group->data;
+        char *old_group = curr_old_group->data;
         // removed from group
         if (!g_slist_find_custom(groups, old_group, (GCompareFunc)g_strcmp0)) {
             if (g_hash_table_contains(roster->group_count, old_group)) {
@@ -354,8 +354,8 @@ roster_update(const char* const barejid, const char* const name, GSList* groups,
 }
 
 gboolean
-roster_add(const char* const barejid, const char* const name, GSList* groups, const char* const subscription,
-           gboolean pending_out)
+roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
+    gboolean pending_out)
 {
     assert(roster != NULL);
 
@@ -367,9 +367,9 @@ roster_add(const char* const barejid, const char* const name, GSList* groups, co
     contact = p_contact_new(barejid, name, groups, subscription, NULL, pending_out);
 
     // add groups
-    GSList* curr_new_group = groups;
+    GSList *curr_new_group = groups;
     while (curr_new_group) {
-        char* new_group = curr_new_group->data;
+        char *new_group = curr_new_group->data;
         if (g_hash_table_contains(roster->group_count, new_group)) {
             int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group));
             g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
@@ -389,7 +389,7 @@ roster_add(const char* const barejid, const char* const name, GSList* groups, co
 }
 
 char*
-roster_barejid_from_name(const char* const name)
+roster_barejid_from_name(const char *const name)
 {
     assert(roster != NULL);
 
@@ -401,11 +401,11 @@ roster_barejid_from_name(const char* const name)
 }
 
 GSList*
-roster_get_contacts_by_presence(const char* const presence)
+roster_get_contacts_by_presence(const char *const presence)
 {
     assert(roster != NULL);
 
-    GSList* result = NULL;
+    GSList *result = NULL;
     GHashTableIter iter;
     gpointer key;
     gpointer value;
@@ -427,16 +427,16 @@ roster_get_contacts(roster_ord_t order)
 {
     assert(roster != NULL);
 
-    GSList* result = NULL;
+    GSList *result = NULL;
     GHashTableIter iter;
     gpointer key;
     gpointer value;
 
     GCompareFunc cmp_func;
     if (order == ROSTER_ORD_PRESENCE) {
-        cmp_func = (GCompareFunc)roster_compare_presence;
+        cmp_func = (GCompareFunc) roster_compare_presence;
     } else {
-        cmp_func = (GCompareFunc)roster_compare_name;
+        cmp_func = (GCompareFunc) roster_compare_name;
     }
 
     g_hash_table_iter_init(&iter, roster->contacts);
@@ -453,14 +453,14 @@ roster_get_contacts_online(void)
 {
     assert(roster != NULL);
 
-    GSList* result = NULL;
+    GSList *result = NULL;
     GHashTableIter iter;
     gpointer key;
     gpointer value;
 
     g_hash_table_iter_init(&iter, roster->contacts);
     while (g_hash_table_iter_next(&iter, &key, &value)) {
-        if (strcmp(p_contact_presence(value), "offline"))
+        if(strcmp(p_contact_presence(value), "offline"))
             result = g_slist_insert_sorted(result, value, (GCompareFunc)roster_compare_name);
     }
 
@@ -479,7 +479,7 @@ roster_has_pending_subscriptions(void)
 
     g_hash_table_iter_init(&iter, roster->contacts);
     while (g_hash_table_iter_next(&iter, &key, &value)) {
-        PContact contact = (PContact)value;
+        PContact contact = (PContact) value;
         if (p_contact_pending_out(contact)) {
             return TRUE;
         }
@@ -489,7 +489,7 @@ roster_has_pending_subscriptions(void)
 }
 
 char*
-roster_contact_autocomplete(const char* const search_str, gboolean previous, void* context)
+roster_contact_autocomplete(const char *const search_str, gboolean previous, void *context)
 {
     assert(roster != NULL);
 
@@ -497,7 +497,7 @@ roster_contact_autocomplete(const char* const search_str, gboolean previous, voi
 }
 
 char*
-roster_fulljid_autocomplete(const char* const search_str, gboolean previous, void* context)
+roster_fulljid_autocomplete(const char *const search_str, gboolean previous, void *context)
 {
     assert(roster != NULL);
 
@@ -505,25 +505,25 @@ roster_fulljid_autocomplete(const char* const search_str, gboolean previous, voi
 }
 
 GSList*
-roster_get_group(const char* const group, roster_ord_t order)
+roster_get_group(const char *const group, roster_ord_t order)
 {
     assert(roster != NULL);
 
-    GSList* result = NULL;
+    GSList *result = NULL;
     GHashTableIter iter;
     gpointer key;
     gpointer value;
 
     GCompareFunc cmp_func;
     if (order == ROSTER_ORD_PRESENCE) {
-        cmp_func = (GCompareFunc)roster_compare_presence;
+        cmp_func = (GCompareFunc) roster_compare_presence;
     } else {
-        cmp_func = (GCompareFunc)roster_compare_name;
+        cmp_func = (GCompareFunc) roster_compare_name;
     }
 
     g_hash_table_iter_init(&iter, roster->contacts);
     while (g_hash_table_iter_next(&iter, &key, &value)) {
-        GSList* groups = p_contact_groups(value);
+        GSList *groups = p_contact_groups(value);
         if (group == NULL) {
             if (groups == NULL) {
                 result = g_slist_insert_sorted(result, value, cmp_func);
@@ -552,7 +552,7 @@ roster_get_groups(void)
 }
 
 char*
-roster_group_autocomplete(const char* const search_str, gboolean previous, void* context)
+roster_group_autocomplete(const char *const search_str, gboolean previous, void *context)
 {
     assert(roster != NULL);
 
@@ -560,7 +560,7 @@ roster_group_autocomplete(const char* const search_str, gboolean previous, void*
 }
 
 char*
-roster_barejid_autocomplete(const char* const search_str, gboolean previous, void* context)
+roster_barejid_autocomplete(const char *const search_str, gboolean previous, void *context)
 {
     assert(roster != NULL);
 
@@ -568,16 +568,16 @@ roster_barejid_autocomplete(const char* const search_str, gboolean previous, voi
 }
 
 static gboolean
-_key_equals(void* key1, void* key2)
+_key_equals(void *key1, void *key2)
 {
-    gchar* str1 = (gchar*)key1;
-    gchar* str2 = (gchar*)key2;
+    gchar *str1 = (gchar *) key1;
+    gchar *str2 = (gchar *) key2;
 
     return (g_strcmp0(str1, str2) == 0);
 }
 
 static gboolean
-_datetimes_equal(GDateTime* dt1, GDateTime* dt2)
+_datetimes_equal(GDateTime *dt1, GDateTime *dt2)
 {
     if ((dt1 == NULL) && (dt2 == NULL)) {
         return TRUE;
@@ -591,7 +591,7 @@ _datetimes_equal(GDateTime* dt1, GDateTime* dt2)
 }
 
 static void
-_replace_name(const char* const current_name, const char* const new_name, const char* const barejid)
+_replace_name(const char *const current_name, const char *const new_name, const char *const barejid)
 {
     assert(roster != NULL);
 
@@ -600,7 +600,7 @@ _replace_name(const char* const current_name, const char* const new_name, const
         autocomplete_remove(roster->name_ac, current_name);
         g_hash_table_remove(roster->name_to_barejid, current_name);
         _add_name_and_barejid(new_name, barejid);
-        // no current handle
+    // no current handle
     } else if (new_name) {
         autocomplete_remove(roster->name_ac, barejid);
         g_hash_table_remove(roster->name_to_barejid, barejid);
@@ -609,7 +609,7 @@ _replace_name(const char* const current_name, const char* const new_name, const
 }
 
 static void
-_add_name_and_barejid(const char* const name, const char* const barejid)
+_add_name_and_barejid(const char *const name, const char *const barejid)
 {
     assert(roster != NULL);
 
@@ -625,8 +625,8 @@ _add_name_and_barejid(const char* const name, const char* const barejid)
 gint
 roster_compare_name(PContact a, PContact b)
 {
-    const char* utf8_str_a = NULL;
-    const char* utf8_str_b = NULL;
+    const char * utf8_str_a = NULL;
+    const char * utf8_str_b = NULL;
 
     if (p_contact_name_collate_key(a)) {
         utf8_str_a = p_contact_name_collate_key(a);
@@ -645,7 +645,7 @@ roster_compare_name(PContact a, PContact b)
 }
 
 static gint
-_get_presence_weight(const char* presence)
+_get_presence_weight(const char *presence)
 {
     if (g_strcmp0(presence, "chat") == 0) {
         return 0;
@@ -665,8 +665,8 @@ _get_presence_weight(const char* presence)
 gint
 roster_compare_presence(PContact a, PContact b)
 {
-    const char* presence_a = p_contact_presence(a);
-    const char* presence_b = p_contact_presence(b);
+    const char *presence_a = p_contact_presence(a);
+    const char *presence_b = p_contact_presence(b);
 
     // if presence different, order by presence
     if (g_strcmp0(presence_a, presence_b) != 0) {
@@ -678,14 +678,14 @@ roster_compare_presence(PContact a, PContact b)
             return 1;
         }
 
-        // otherwise order by name
+    // otherwise order by name
     } else {
         return roster_compare_name(a, b);
     }
 }
 
 static void
-_pendingPresence_free(ProfPendingPresence* presence)
+_pendingPresence_free(ProfPendingPresence *presence)
 {
     if (!presence)
         return;
@@ -698,9 +698,9 @@ roster_process_pending_presence(void)
 {
     roster_received = TRUE;
 
-    GSList* iter;
+    GSList *iter;
     for (iter = roster_pending_presence; iter != NULL; iter = iter->next) {
-        ProfPendingPresence* presence = iter->data;
+        ProfPendingPresence *presence = iter->data;
         roster_update_presence(presence->barejid, presence->resource, presence->last_activity);
         /* seems like resource isn't free on the calling side */
         if (presence->last_activity) {
@@ -713,8 +713,7 @@ roster_process_pending_presence(void)
 }
 
 gboolean
-roster_exists(void)
-{
+roster_exists(void) {
     if (roster != NULL) {
         return TRUE;
     }
diff --git a/src/xmpp/roster_list.h b/src/xmpp/roster_list.h
index 7c9abab3..d5d3c572 100644
--- a/src/xmpp/roster_list.h
+++ b/src/xmpp/roster_list.h
@@ -38,8 +38,8 @@
 
 #include <glib.h>
 
-#include "xmpp/contact.h"
 #include "xmpp/resource.h"
+#include "xmpp/contact.h"
 
 typedef enum {
     ROSTER_ORD_NAME,
@@ -47,30 +47,30 @@ typedef enum {
 } roster_ord_t;
 
 void roster_clear(void);
-gboolean roster_update_presence(const char* const barejid, Resource* resource, GDateTime* last_activity);
-PContact roster_get_contact(const char* const barejid);
-gboolean roster_contact_offline(const char* const barejid, const char* const resource, const char* const status);
+gboolean roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity);
+PContact roster_get_contact(const char *const barejid);
+gboolean roster_contact_offline(const char *const barejid, const char *const resource, const char *const status);
 void roster_reset_search_attempts(void);
 void roster_create(void);
 void roster_destroy(void);
-void roster_change_name(PContact contact, const char* const new_name);
-void roster_remove(const char* const name, const char* const barejid);
-void roster_update(const char* const barejid, const char* const name, GSList* groups, const char* const subscription,
-                   gboolean pending_out);
-gboolean roster_add(const char* const barejid, const char* const name, GSList* groups, const char* const subscription,
-                    gboolean pending_out);
-char* roster_barejid_from_name(const char* const name);
+void roster_change_name(PContact contact, const char *const new_name);
+void roster_remove(const char *const name, const char *const barejid);
+void roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
+    gboolean pending_out);
+gboolean roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
+    gboolean pending_out);
+char* roster_barejid_from_name(const char *const name);
 GSList* roster_get_contacts(roster_ord_t order);
 GSList* roster_get_contacts_online(void);
 gboolean roster_has_pending_subscriptions(void);
-char* roster_contact_autocomplete(const char* const search_str, gboolean previous, void* context);
-char* roster_fulljid_autocomplete(const char* const search_str, gboolean previous, void* context);
-GSList* roster_get_group(const char* const group, roster_ord_t order);
+char* roster_contact_autocomplete(const char *const search_str, gboolean previous, void *context);
+char* roster_fulljid_autocomplete(const char *const search_str, gboolean previous, void *context);
+GSList* roster_get_group(const char *const group, roster_ord_t order);
 GList* roster_get_groups(void);
-char* roster_group_autocomplete(const char* const search_str, gboolean previous, void* context);
-char* roster_barejid_autocomplete(const char* const search_str, gboolean previous, void* context);
-GSList* roster_get_contacts_by_presence(const char* const presence);
-char* roster_get_msg_display_name(const char* const barejid, const char* const resource);
+char* roster_group_autocomplete(const char *const search_str, gboolean previous, void *context);
+char* roster_barejid_autocomplete(const char *const search_str, gboolean previous, void *context);
+GSList* roster_get_contacts_by_presence(const char *const presence);
+char* roster_get_msg_display_name(const char *const barejid, const char *const resource);
 gint roster_compare_name(PContact a, PContact b);
 gint roster_compare_presence(PContact a, PContact b);
 void roster_process_pending_presence(void);
diff --git a/src/xmpp/session.c b/src/xmpp/session.c
index 1e2a3b11..21517305 100644
--- a/src/xmpp/session.c
+++ b/src/xmpp/session.c
@@ -36,30 +36,30 @@
 #include "config.h"
 
 #include <assert.h>
-#include <stdlib.h>
 #include <string.h>
+#include <stdlib.h>
 
+#include "profanity.h"
+#include "log.h"
 #include "common.h"
 #include "config/preferences.h"
-#include "event/client_events.h"
-#include "event/server_events.h"
-#include "log.h"
 #include "plugins/plugins.h"
-#include "profanity.h"
-#include "xmpp/blocking.h"
+#include "event/server_events.h"
+#include "event/client_events.h"
 #include "xmpp/bookmark.h"
-#include "xmpp/capabilities.h"
-#include "xmpp/chat_session.h"
+#include "xmpp/blocking.h"
 #include "xmpp/connection.h"
+#include "xmpp/capabilities.h"
+#include "xmpp/session.h"
 #include "xmpp/iq.h"
-#include "xmpp/jid.h"
 #include "xmpp/message.h"
-#include "xmpp/muc.h"
 #include "xmpp/presence.h"
 #include "xmpp/roster.h"
-#include "xmpp/session.h"
 #include "xmpp/stanza.h"
 #include "xmpp/xmpp.h"
+#include "xmpp/muc.h"
+#include "xmpp/chat_session.h"
+#include "xmpp/jid.h"
 
 #ifdef HAVE_OMEMO
 #include "omemo/omemo.h"
@@ -67,21 +67,19 @@
 #endif
 
 // for auto reconnect
-static struct
-{
-    char* name;
-    char* passwd;
+static struct {
+    char *name;
+    char *passwd;
 } saved_account;
 
-static struct
-{
-    char* name;
-    char* jid;
-    char* passwd;
-    char* altdomain;
+static struct {
+    char *name;
+    char *jid;
+    char *passwd;
+    char *altdomain;
     int port;
-    char* tls_policy;
-    char* auth_policy;
+    char *tls_policy;
+    char *auth_policy;
 } saved_details;
 
 typedef enum {
@@ -91,10 +89,10 @@ typedef enum {
     ACTIVITY_ST_XA,
 } activity_state_t;
 
-static GTimer* reconnect_timer;
+static GTimer *reconnect_timer;
 static activity_state_t activity_state;
 static resource_presence_t saved_presence;
-static char* saved_status;
+static char *saved_status;
 
 static void _session_reconnect(void);
 
@@ -111,7 +109,7 @@ session_init(void)
 }
 
 jabber_conn_status_t
-session_connect_with_account(const ProfAccount* const account)
+session_connect_with_account(const ProfAccount *const account)
 {
     assert(account != NULL);
 
@@ -124,9 +122,9 @@ session_connect_with_account(const ProfAccount* const account)
     saved_account.name = strdup(account->name);
     saved_account.passwd = strdup(account->password);
 
-    char* jid = NULL;
+    char *jid = NULL;
     if (account->resource) {
-        Jid* jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
+        Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
         jid = strdup(jidp->fulljid);
         jid_destroy(jidp);
     } else {
@@ -146,8 +144,8 @@ session_connect_with_account(const ProfAccount* const account)
 }
 
 jabber_conn_status_t
-session_connect_with_details(const char* const jid, const char* const passwd, const char* const altdomain,
-                             const int port, const char* const tls_policy, const char* const auth_policy)
+session_connect_with_details(const char *const jid, const char *const passwd, const char *const altdomain,
+    const int port, const char *const tls_policy, const char *const auth_policy)
 {
     assert(jid != NULL);
     assert(passwd != NULL);
@@ -180,10 +178,10 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
     }
 
     // use 'profanity' when no resourcepart in provided jid
-    Jid* jidp = jid_create(jid);
+    Jid *jidp = jid_create(jid);
     if (jidp->resourcepart == NULL) {
         jid_destroy(jidp);
-        char* resource = jid_random_resource();
+        char *resource = jid_random_resource();
         jidp = jid_create_from_bare_and_resource(jid, resource);
         free(resource);
         saved_details.jid = strdup(jidp->fulljid);
@@ -217,8 +215,8 @@ session_disconnect(void)
     if (connection_get_status() == JABBER_CONNECTED) {
         log_info("Closing connection");
 
-        char* account_name = session_get_account_name();
-        const char* fulljid = connection_get_fulljid();
+        char *account_name = session_get_account_name();
+        const char *fulljid = connection_get_fulljid();
         plugins_on_disconnect(account_name, fulljid);
 
         accounts_set_last_activity(session_get_account_name());
@@ -258,7 +256,8 @@ session_process_events(void)
     int reconnect_sec;
 
     jabber_conn_status_t conn_status = connection_get_status();
-    switch (conn_status) {
+    switch (conn_status)
+    {
     case JABBER_CONNECTED:
     case JABBER_CONNECTING:
     case JABBER_DISCONNECTING:
@@ -298,7 +297,7 @@ session_login_success(gboolean secured)
         log_debug("Connection handler: logged in with account name: %s", saved_account.name);
         sv_ev_login_account_success(saved_account.name, secured);
 
-        // logged in without account, use details to create new account
+    // logged in without account, use details to create new account
     } else {
         log_debug("Connection handler: logged in with jid: %s", saved_details.name);
         accounts_add(saved_details.name, saved_details.altdomain, saved_details.port, saved_details.tls_policy, saved_details.auth_policy);
@@ -317,10 +316,10 @@ session_login_success(gboolean secured)
 
     // items discovery
     connection_request_features();
-    char* domain = connection_get_domain();
+    char *domain = connection_get_domain();
     iq_disco_items_request_onconnect(domain);
 
-    if (prefs_get_boolean(PREF_CARBONS)) {
+    if (prefs_get_boolean(PREF_CARBONS)){
         iq_enable_carbons();
     }
 
@@ -379,16 +378,16 @@ session_check_autoaway(void)
         return;
     }
 
-    char* mode = prefs_get_string(PREF_AUTOAWAY_MODE);
+    char *mode = prefs_get_string(PREF_AUTOAWAY_MODE);
     gboolean check = prefs_get_boolean(PREF_AUTOAWAY_CHECK);
     gint away_time = prefs_get_autoaway_time();
     gint xa_time = prefs_get_autoxa_time();
     int away_time_ms = away_time * 60000;
     int xa_time_ms = xa_time * 60000;
 
-    char* account = session_get_account_name();
+    char *account = session_get_account_name();
     resource_presence_t curr_presence = accounts_get_last_presence(account);
-    char* curr_status = accounts_get_last_status(account);
+    char *curr_status = accounts_get_last_status(account);
 
     unsigned long idle_ms = ui_get_idle_time();
 
@@ -411,7 +410,7 @@ session_check_autoaway(void)
                     }
 
                     // send away presence with last activity
-                    char* message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
+                    char *message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
                     connection_set_presence_msg(message);
                     if (prefs_get_boolean(PREF_LASTACTIVITY)) {
                         cl_ev_presence_send(RESOURCE_AWAY, idle_ms / 1000);
@@ -454,7 +453,7 @@ session_check_autoaway(void)
             activity_state = ACTIVITY_ST_XA;
 
             // send extended away presence with last activity
-            char* message = prefs_get_string(PREF_AUTOXA_MESSAGE);
+            char *message = prefs_get_string(PREF_AUTOXA_MESSAGE);
             connection_set_presence_msg(message);
             if (prefs_get_boolean(PREF_LASTACTIVITY)) {
                 cl_ev_presence_send(RESOURCE_XA, idle_ms / 1000);
@@ -506,13 +505,13 @@ static void
 _session_reconnect(void)
 {
     // reconnect with account.
-    ProfAccount* account = accounts_get_account(saved_account.name);
+    ProfAccount *account = accounts_get_account(saved_account.name);
     if (account == NULL) {
         log_error("Unable to reconnect, account no longer exists: %s", saved_account.name);
         return;
     }
 
-    char* jid = NULL;
+    char *jid = NULL;
     if (account->resource) {
         jid = create_fulljid(account->jid, account->resource);
     } else {
@@ -543,3 +542,4 @@ _session_free_saved_details(void)
     FREE_SET_NULL(saved_details.tls_policy);
     FREE_SET_NULL(saved_details.auth_policy);
 }
+
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 5990690f..3a7e39c8 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -41,12 +41,12 @@
 #include "gitversion.h"
 #endif
 
-#include <assert.h>
-#include <inttypes.h>
-#include <libgen.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
+#include <libgen.h>
+#include <inttypes.h>
+#include <assert.h>
 
 #include <glib.h>
 
@@ -60,15 +60,15 @@
 
 #include "common.h"
 #include "log.h"
+#include "xmpp/session.h"
+#include "xmpp/stanza.h"
 #include "xmpp/capabilities.h"
 #include "xmpp/connection.h"
 #include "xmpp/form.h"
 #include "xmpp/muc.h"
-#include "xmpp/session.h"
-#include "xmpp/stanza.h"
 
-static void _stanza_add_unique_id(xmpp_stanza_t* stanza);
-static char* _stanza_create_sha1_hash(char* str);
+static void _stanza_add_unique_id(xmpp_stanza_t *stanza);
+static char* _stanza_create_sha1_hash(char *str);
 
 #if 0
 xmpp_stanza_t*
@@ -94,16 +94,16 @@ stanza_create_bookmarks_pubsub_request(xmpp_ctx_t *ctx)
 #endif
 
 xmpp_stanza_t*
-stanza_create_bookmarks_storage_request(xmpp_ctx_t* ctx)
+stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
     xmpp_stanza_set_ns(iq, "jabber:client");
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, "jabber:iq:private");
 
-    xmpp_stanza_t* storage = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *storage = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(storage, STANZA_NAME_STORAGE);
     xmpp_stanza_set_ns(storage, "storage:bookmarks");
 
@@ -116,11 +116,11 @@ stanza_create_bookmarks_storage_request(xmpp_ctx_t* ctx)
 }
 
 xmpp_stanza_t*
-stanza_create_blocked_list_request(xmpp_ctx_t* ctx)
+stanza_create_blocked_list_request(xmpp_ctx_t *ctx)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, NULL);
 
-    xmpp_stanza_t* blocklist = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *blocklist = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(blocklist, STANZA_NAME_BLOCKLIST);
     xmpp_stanza_set_ns(blocklist, STANZA_NS_BLOCKING);
 
@@ -222,23 +222,23 @@ stanza_create_bookmarks_pubsub_add(xmpp_ctx_t *ctx, const char *const jid,
 #endif
 
 xmpp_stanza_t*
-stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
-                                  const char* const jid, HTTPUpload* upload)
+stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id,
+    const char *const jid, HTTPUpload *upload)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* request = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *request = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(request, STANZA_NAME_REQUEST);
     xmpp_stanza_set_ns(request, STANZA_NS_HTTP_UPLOAD);
 
-    xmpp_stanza_t* filename = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *filename = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(filename, STANZA_NAME_FILENAME);
-    xmpp_stanza_t* filename_txt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *filename_txt = xmpp_stanza_new(ctx);
     char* filename_cpy = strdup(upload->filename);
     // strip spaces from filename (servers don't spaces)
     int i;
-    for (i = 0; i < strlen(filename_cpy); i++) {
+    for (i=0; i<strlen(filename_cpy); i++) {
         if (filename_cpy[i] == ' ') {
             filename_cpy[i] = '_';
         }
@@ -250,9 +250,9 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
     xmpp_stanza_release(filename_txt);
     xmpp_stanza_release(filename);
 
-    xmpp_stanza_t* size = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *size = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(size, STANZA_NAME_SIZE);
-    xmpp_stanza_t* size_txt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *size_txt = xmpp_stanza_new(ctx);
     char* filesize = NULL;
     if (asprintf(&filesize, "%jd", (intmax_t)(upload->filesize)) != -1) {
         xmpp_stanza_set_text(size_txt, filesize);
@@ -263,9 +263,9 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
     xmpp_stanza_release(size_txt);
     xmpp_stanza_release(size);
 
-    xmpp_stanza_t* content_type = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *content_type = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(content_type, STANZA_NAME_CONTENT_TYPE);
-    xmpp_stanza_t* content_type_txt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *content_type_txt = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(content_type_txt, upload->mime_type);
     xmpp_stanza_add_child(content_type, content_type_txt);
     xmpp_stanza_add_child(request, content_type);
@@ -279,13 +279,13 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
 }
 
 xmpp_stanza_t*
-stanza_enable_carbons(xmpp_ctx_t* ctx)
+stanza_enable_carbons(xmpp_ctx_t *ctx)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* carbons_enable = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *carbons_enable = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(carbons_enable, STANZA_NAME_ENABLE);
     xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS);
 
@@ -296,13 +296,13 @@ stanza_enable_carbons(xmpp_ctx_t* ctx)
 }
 
 xmpp_stanza_t*
-stanza_disable_carbons(xmpp_ctx_t* ctx)
+stanza_disable_carbons(xmpp_ctx_t *ctx)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* carbons_disable = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *carbons_disable = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(carbons_disable, STANZA_NAME_DISABLE);
     xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS);
 
@@ -313,13 +313,13 @@ stanza_disable_carbons(xmpp_ctx_t* ctx)
 }
 
 xmpp_stanza_t*
-stanza_create_chat_state(xmpp_ctx_t* ctx, const char* const fulljid, const char* const state)
+stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char *const state)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
     free(id);
 
-    xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(chat_state, state);
     xmpp_stanza_set_ns(chat_state, STANZA_NS_CHATSTATES);
     xmpp_stanza_add_child(msg, chat_state);
@@ -329,14 +329,14 @@ stanza_create_chat_state(xmpp_ctx_t* ctx, const char* const fulljid, const char*
 }
 
 xmpp_stanza_t*
-stanza_create_room_subject_message(xmpp_ctx_t* ctx, const char* const room, const char* const subject)
+stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject)
 {
-    xmpp_stanza_t* msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL);
+    xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL);
 
-    xmpp_stanza_t* subject_st = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT);
     if (subject) {
-        xmpp_stanza_t* subject_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *subject_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(subject_text, subject);
         xmpp_stanza_add_child(subject_st, subject_text);
         xmpp_stanza_release(subject_text);
@@ -349,9 +349,9 @@ stanza_create_room_subject_message(xmpp_ctx_t* ctx, const char* const room, cons
 }
 
 xmpp_stanza_t*
-stanza_attach_state(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const state)
+stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const state)
 {
-    xmpp_stanza_t* chat_state = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(chat_state, state);
     xmpp_stanza_set_ns(chat_state, STANZA_NS_CHATSTATES);
     xmpp_stanza_add_child(stanza, chat_state);
@@ -361,9 +361,9 @@ stanza_attach_state(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const st
 }
 
 xmpp_stanza_t*
-stanza_attach_carbons_private(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
+stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* private_carbon = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *private_carbon = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(private_carbon, "private");
     xmpp_stanza_set_ns(private_carbon, STANZA_NS_CARBONS);
     xmpp_stanza_add_child(stanza, private_carbon);
@@ -373,9 +373,9 @@ stanza_attach_carbons_private(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
 }
 
 xmpp_stanza_t*
-stanza_attach_hints_no_copy(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
+stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* no_copy = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *no_copy = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(no_copy, "no-copy");
     xmpp_stanza_set_ns(no_copy, STANZA_NS_HINTS);
     xmpp_stanza_add_child(stanza, no_copy);
@@ -385,9 +385,9 @@ stanza_attach_hints_no_copy(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
 }
 
 xmpp_stanza_t*
-stanza_attach_hints_no_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
+stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* no_store = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *no_store = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(no_store, "no-store");
     xmpp_stanza_set_ns(no_store, STANZA_NS_HINTS);
     xmpp_stanza_add_child(stanza, no_store);
@@ -397,9 +397,9 @@ stanza_attach_hints_no_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
 }
 
 xmpp_stanza_t*
-stanza_attach_hints_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
+stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* store = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *store = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(store, "store");
     xmpp_stanza_set_ns(store, STANZA_NS_HINTS);
     xmpp_stanza_add_child(stanza, store);
@@ -409,9 +409,9 @@ stanza_attach_hints_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
 }
 
 xmpp_stanza_t*
-stanza_attach_receipt_request(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
+stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* receipet_request = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *receipet_request = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(receipet_request, "request");
     xmpp_stanza_set_ns(receipet_request, STANZA_NS_RECEIPTS);
     xmpp_stanza_add_child(stanza, receipet_request);
@@ -421,16 +421,16 @@ stanza_attach_receipt_request(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza)
 }
 
 xmpp_stanza_t*
-stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const url)
+stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url)
 {
-    xmpp_stanza_t* x_oob = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x_oob = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x_oob, STANZA_NAME_X);
     xmpp_stanza_set_ns(x_oob, STANZA_NS_X_OOB);
 
-    xmpp_stanza_t* surl = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *surl = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(surl, STANZA_NAME_URL);
 
-    xmpp_stanza_t* surl_txt = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *surl_txt = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(surl_txt, url);
     xmpp_stanza_add_child(surl, surl_txt);
     xmpp_stanza_release(surl_txt);
@@ -445,17 +445,17 @@ stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* cons
 }
 
 xmpp_stanza_t*
-stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid)
+stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, barejid);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_SUBSCRIPTION, "remove");
@@ -466,19 +466,20 @@ stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid)
     xmpp_stanza_release(query);
 
     return iq;
+
 }
 
 xmpp_stanza_t*
-stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id,
-                         const char* const jid, const char* const handle, GSList* groups)
+stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id,
+    const char *const jid, const char *const handle, GSList *groups)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
 
@@ -489,8 +490,8 @@ stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id,
     }
 
     while (groups) {
-        xmpp_stanza_t* group = xmpp_stanza_new(ctx);
-        xmpp_stanza_t* groupname = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *group = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *groupname = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(group, STANZA_NAME_GROUP);
         xmpp_stanza_set_text(groupname, groups->data);
         xmpp_stanza_add_child(group, groupname);
@@ -509,14 +510,14 @@ stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id,
 }
 
 xmpp_stanza_t*
-stanza_create_invite(xmpp_ctx_t* ctx, const char* const room,
-                     const char* const contact, const char* const reason, const char* const password)
+stanza_create_invite(xmpp_ctx_t *ctx, const char *const room,
+    const char *const contact, const char *const reason, const char *const password)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, contact, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, contact, id);
     free(id);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_CONFERENCE);
 
@@ -535,25 +536,25 @@ stanza_create_invite(xmpp_ctx_t* ctx, const char* const room,
 }
 
 xmpp_stanza_t*
-stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room,
-                              const char* const contact, const char* const reason)
+stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
+    const char *const contact, const char *const reason)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* message = xmpp_message_new(ctx, NULL, room, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, room, id);
     free(id);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_MUC_USER);
 
-    xmpp_stanza_t* invite = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *invite = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(invite, STANZA_NAME_INVITE);
     xmpp_stanza_set_to(invite, contact);
 
     if (reason) {
-        xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
-        xmpp_stanza_t* reason_txt = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_txt = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(reason_txt, reason);
         xmpp_stanza_add_child(reason_st, reason_txt);
         xmpp_stanza_release(reason_txt);
@@ -570,21 +571,21 @@ stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room,
 }
 
 xmpp_stanza_t*
-stanza_create_room_join_presence(xmpp_ctx_t* const ctx,
-                                 const char* const full_room_jid, const char* const passwd)
+stanza_create_room_join_presence(xmpp_ctx_t *const ctx,
+    const char *const full_room_jid, const char *const passwd)
 {
-    xmpp_stanza_t* presence = xmpp_presence_new(ctx);
+    xmpp_stanza_t *presence = xmpp_presence_new(ctx);
     xmpp_stanza_set_to(presence, full_room_jid);
     _stanza_add_unique_id(presence);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_MUC);
 
     if (passwd) {
-        xmpp_stanza_t* pass = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *pass = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(pass, "password");
-        xmpp_stanza_t* text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(text, passwd);
         xmpp_stanza_add_child(pass, text);
         xmpp_stanza_add_child(x, pass);
@@ -599,10 +600,10 @@ stanza_create_room_join_presence(xmpp_ctx_t* const ctx,
 }
 
 xmpp_stanza_t*
-stanza_create_room_newnick_presence(xmpp_ctx_t* ctx,
-                                    const char* const full_room_jid)
+stanza_create_room_newnick_presence(xmpp_ctx_t *ctx,
+    const char *const full_room_jid)
 {
-    xmpp_stanza_t* presence = xmpp_presence_new(ctx);
+    xmpp_stanza_t *presence = xmpp_presence_new(ctx);
     _stanza_add_unique_id(presence);
     xmpp_stanza_set_to(presence, full_room_jid);
 
@@ -610,14 +611,14 @@ stanza_create_room_newnick_presence(xmpp_ctx_t* ctx,
 }
 
 xmpp_stanza_t*
-stanza_create_room_leave_presence(xmpp_ctx_t* ctx, const char* const room,
-                                  const char* const nick)
+stanza_create_room_leave_presence(xmpp_ctx_t *ctx, const char *const room,
+    const char *const nick)
 {
-    GString* full_jid = g_string_new(room);
+    GString *full_jid = g_string_new(room);
     g_string_append(full_jid, "/");
     g_string_append(full_jid, nick);
 
-    xmpp_stanza_t* presence = xmpp_presence_new(ctx);
+    xmpp_stanza_t *presence = xmpp_presence_new(ctx);
     xmpp_stanza_set_type(presence, STANZA_TYPE_UNAVAILABLE);
     xmpp_stanza_set_to(presence, full_jid->str);
     _stanza_add_unique_id(presence);
@@ -628,18 +629,18 @@ stanza_create_room_leave_presence(xmpp_ctx_t* ctx, const char* const room,
 }
 
 xmpp_stanza_t*
-stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid)
+stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room_jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_type(x, "submit");
     xmpp_stanza_set_ns(x, STANZA_NS_DATA);
@@ -654,18 +655,18 @@ stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_ji
 }
 
 xmpp_stanza_t*
-stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid)
+stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room_jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
 
-    xmpp_stanza_t* destroy = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *destroy = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(destroy, STANZA_NAME_DESTROY);
 
     xmpp_stanza_add_child(query, destroy);
@@ -678,14 +679,14 @@ stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_ji
 }
 
 xmpp_stanza_t*
-stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid)
+stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     free(id);
     xmpp_stanza_set_to(iq, room_jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
 
@@ -696,18 +697,18 @@ stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid
 }
 
 xmpp_stanza_t*
-stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid)
+stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room_jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_type(x, "cancel");
     xmpp_stanza_set_ns(x, STANZA_NS_DATA);
@@ -722,18 +723,18 @@ stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid)
 }
 
 xmpp_stanza_t*
-stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const affiliation)
+stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const affiliation)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "affiliation", affiliation);
 
@@ -746,18 +747,18 @@ stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room,
 }
 
 xmpp_stanza_t*
-stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role)
+stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "role", role);
 
@@ -770,27 +771,27 @@ stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const c
 }
 
 xmpp_stanza_t*
-stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid,
-                                      const char* const affiliation, const char* const reason)
+stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid,
+    const char *const affiliation, const char *const reason)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "affiliation", affiliation);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
 
     if (reason) {
-        xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
-        xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(reason_text, reason);
         xmpp_stanza_add_child(reason_st, reason_text);
         xmpp_stanza_release(reason_text);
@@ -808,27 +809,27 @@ stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, c
 }
 
 xmpp_stanza_t*
-stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick,
-                               const char* const role, const char* const reason)
+stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick,
+    const char *const role, const char *const reason)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "role", role);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_NICK, nick);
 
     if (reason) {
-        xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
-        xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(reason_text, reason);
         xmpp_stanza_add_child(reason_st, reason_text);
         xmpp_stanza_release(reason_text);
@@ -846,27 +847,27 @@ stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, co
 }
 
 xmpp_stanza_t*
-stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick,
-                           const char* const reason)
+stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick,
+    const char *const reason)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_ADMIN);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, STANZA_ATTR_NICK, nick);
     xmpp_stanza_set_attribute(item, "role", "none");
 
     if (reason) {
-        xmpp_stanza_t* reason_st = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
-        xmpp_stanza_t* reason_text = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *reason_text = xmpp_stanza_new(ctx);
         xmpp_stanza_set_text(reason_text, reason);
         xmpp_stanza_add_child(reason_st, reason_text);
         xmpp_stanza_release(reason_text);
@@ -884,14 +885,14 @@ stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const
 }
 
 xmpp_stanza_t*
-stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid)
+stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     free(id);
     xmpp_stanza_set_to(iq, fulljid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_VERSION);
 
@@ -902,11 +903,11 @@ stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid)
 }
 
 xmpp_stanza_t*
-stanza_create_roster_iq(xmpp_ctx_t* ctx)
+stanza_create_roster_iq(xmpp_ctx_t *ctx)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "roster");
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, "roster");
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
 
@@ -917,13 +918,13 @@ stanza_create_roster_iq(xmpp_ctx_t* ctx)
 }
 
 xmpp_stanza_t*
-stanza_create_disco_info_iq(xmpp_ctx_t* ctx, const char* const id, const char* const to,
-                            const char* const node)
+stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to,
+    const char *const node)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, to);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
     if (node) {
@@ -937,13 +938,13 @@ stanza_create_disco_info_iq(xmpp_ctx_t* ctx, const char* const id, const char* c
 }
 
 xmpp_stanza_t*
-stanza_create_disco_items_iq(xmpp_ctx_t* ctx, const char* const id,
-                             const char* const jid, const char* const node)
+stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id,
+    const char *const jid, const char *const node)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
     if (node) {
@@ -957,12 +958,12 @@ stanza_create_disco_items_iq(xmpp_ctx_t* ctx, const char* const id,
 }
 
 xmpp_stanza_t*
-stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id, const char* const to)
+stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id, const char *const to)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, to);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_LASTACTIVITY);
 
@@ -973,18 +974,18 @@ stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id, const char
 }
 
 xmpp_stanza_t*
-stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form)
+stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MUC_OWNER);
 
-    xmpp_stanza_t* x = form_create_submission(form);
+    xmpp_stanza_t *x = form_create_submission(form);
     xmpp_stanza_add_child(query, x);
     xmpp_stanza_release(x);
 
@@ -995,18 +996,18 @@ stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, Dat
 }
 
 xmpp_stanza_t*
-stanza_create_caps_query_element(xmpp_ctx_t* ctx)
+stanza_create_caps_query_element(xmpp_ctx_t *ctx)
 {
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
 
-    xmpp_stanza_t* identity = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *identity = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(identity, "identity");
     xmpp_stanza_set_attribute(identity, "category", "client");
     xmpp_stanza_set_type(identity, "console");
 
-    GString* name_str = g_string_new("Profanity ");
+    GString *name_str = g_string_new("Profanity ");
     g_string_append(name_str, PACKAGE_VERSION);
     if (strcmp(PACKAGE_STATUS, "development") == 0) {
 #ifdef HAVE_GIT_VERSION
@@ -1023,10 +1024,10 @@ stanza_create_caps_query_element(xmpp_ctx_t* ctx)
     xmpp_stanza_add_child(query, identity);
     xmpp_stanza_release(identity);
 
-    GList* features = caps_get_features();
-    GList* curr = features;
+    GList *features = caps_get_features();
+    GList *curr = features;
     while (curr) {
-        xmpp_stanza_t* feature = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *feature = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(feature, STANZA_NAME_FEATURE);
         xmpp_stanza_set_attribute(feature, STANZA_ATTR_VAR, curr->data);
         xmpp_stanza_add_child(query, feature);
@@ -1040,22 +1041,26 @@ stanza_create_caps_query_element(xmpp_ctx_t* ctx)
 }
 
 gboolean
-stanza_contains_chat_state(xmpp_stanza_t* stanza)
+stanza_contains_chat_state(xmpp_stanza_t *stanza)
 {
-    return ((xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ACTIVE) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) || (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL));
+    return ((xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ACTIVE) != NULL) ||
+            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) ||
+            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) ||
+            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) ||
+            (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL));
 }
 
 xmpp_stanza_t*
-stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target)
+stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     free(id);
     if (target) {
         xmpp_stanza_set_to(iq, target);
     }
 
-    xmpp_stanza_t* ping = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *ping = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(ping, STANZA_NAME_PING);
 
     xmpp_stanza_set_ns(ping, STANZA_NS_PING);
@@ -1067,22 +1072,22 @@ stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target)
 }
 
 char*
-stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
+stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query)
 {
-    GSList* identities = NULL;
-    GSList* features = NULL;
-    GSList* form_names = NULL;
-    GHashTable* forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)form_destroy);
+    GSList *identities = NULL;
+    GSList *features = NULL;
+    GSList *form_names = NULL;
+    GHashTable *forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)form_destroy);
 
-    xmpp_stanza_t* child = xmpp_stanza_get_children(query);
+    xmpp_stanza_t *child = xmpp_stanza_get_children(query);
     while (child) {
         if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) {
-            const char* category = xmpp_stanza_get_attribute(child, "category");
-            const char* type = xmpp_stanza_get_type(child);
-            const char* lang = xmpp_stanza_get_attribute(child, "xml:lang");
-            const char* name = xmpp_stanza_get_attribute(child, "name");
+            const char *category = xmpp_stanza_get_attribute(child, "category");
+            const char *type = xmpp_stanza_get_type(child);
+            const char *lang = xmpp_stanza_get_attribute(child, "xml:lang");
+            const char *name = xmpp_stanza_get_attribute(child, "name");
 
-            GString* identity_str = g_string_new(category);
+            GString *identity_str = g_string_new(category);
             g_string_append(identity_str, "/");
             if (type) {
                 g_string_append(identity_str, type);
@@ -1099,12 +1104,12 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
             identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp);
             g_string_free(identity_str, TRUE);
         } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) {
-            const char* feature_str = xmpp_stanza_get_attribute(child, "var");
+            const char *feature_str = xmpp_stanza_get_attribute(child, "var");
             features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp);
         } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) {
             if (g_strcmp0(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) {
-                DataForm* form = form_create(child);
-                char* form_type = form_get_form_type_field(form);
+                DataForm *form = form_create(child);
+                char *form_type = form_get_form_type_field(form);
                 form_names = g_slist_insert_sorted(form_names, g_strdup(form_type), (GCompareFunc)strcmp);
                 g_hash_table_insert(forms, g_strdup(form_type), form);
             }
@@ -1112,9 +1117,9 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
         child = xmpp_stanza_get_next(child);
     }
 
-    GString* s = g_string_new("");
+    GString *s = g_string_new("");
 
-    GSList* curr = identities;
+    GSList *curr = identities;
     while (curr) {
         g_string_append(s, curr->data);
         curr = g_slist_next(curr);
@@ -1129,20 +1134,20 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
 
     curr = form_names;
     while (curr) {
-        DataForm* form = g_hash_table_lookup(forms, curr->data);
-        char* form_type = form_get_form_type_field(form);
+        DataForm *form = g_hash_table_lookup(forms, curr->data);
+        char *form_type = form_get_form_type_field(form);
         g_string_append(s, form_type);
         g_string_append(s, "<");
 
-        GSList* sorted_fields = form_get_non_form_type_fields_sorted(form);
-        GSList* curr_field = sorted_fields;
+        GSList *sorted_fields = form_get_non_form_type_fields_sorted(form);
+        GSList *curr_field = sorted_fields;
         while (curr_field) {
-            FormField* field = curr_field->data;
+            FormField *field = curr_field->data;
             g_string_append(s, field->var);
             g_string_append(s, "<");
 
-            GSList* sorted_values = form_get_field_values_sorted(field);
-            GSList* curr_value = sorted_values;
+            GSList *sorted_values = form_get_field_values_sorted(field);
+            GSList *curr_value = sorted_values;
             while (curr_value) {
                 g_string_append(s, curr_value->data);
                 g_string_append(s, "<");
@@ -1156,7 +1161,7 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
         curr = g_slist_next(curr);
     }
 
-    char* result = _stanza_create_sha1_hash(s->str);
+    char *result = _stanza_create_sha1_hash(s->str);
 
     g_string_free(s, TRUE);
     g_slist_free_full(identities, g_free);
@@ -1168,11 +1173,11 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query)
 }
 
 xmpp_stanza_t*
-stanza_get_child_by_name_and_from(xmpp_stanza_t* const stanza, const char* const name, const char* const from)
+stanza_get_child_by_name_and_from(xmpp_stanza_t * const stanza, const char * const name, const char * const from)
 {
-    xmpp_stanza_t* child;
-    const char* child_from;
-    const char* child_name;
+    xmpp_stanza_t *child;
+    const char *child_from;
+    const char *child_name;
 
     for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) {
         child_name = xmpp_stanza_get_name(child);
@@ -1188,24 +1193,24 @@ stanza_get_child_by_name_and_from(xmpp_stanza_t* const stanza, const char* const
 }
 
 GDateTime*
-stanza_get_delay(xmpp_stanza_t* const stanza)
+stanza_get_delay(xmpp_stanza_t *const stanza)
 {
     return stanza_get_delay_from(stanza, NULL);
 }
 
 static GDateTime*
-_stanza_get_delay_timestamp_xep0203(xmpp_stanza_t* const delay_stanza)
+_stanza_get_delay_timestamp_xep0203(xmpp_stanza_t *const delay_stanza)
 {
     GTimeVal utc_stamp;
-    const char* xmlns = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_XMLNS);
+    const char *xmlns = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_XMLNS);
 
     if (xmlns && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {
-        const char* stamp = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_STAMP);
+        const char *stamp = xmpp_stanza_get_attribute(delay_stanza, STANZA_ATTR_STAMP);
 
         if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) {
 
-            GDateTime* utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
-            GDateTime* local_datetime = g_date_time_to_local(utc_datetime);
+            GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
+            GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
             g_date_time_unref(utc_datetime);
 
             return local_datetime;
@@ -1216,17 +1221,17 @@ _stanza_get_delay_timestamp_xep0203(xmpp_stanza_t* const delay_stanza)
 }
 
 static GDateTime*
-_stanza_get_delay_timestamp_xep0091(xmpp_stanza_t* const x_stanza)
+_stanza_get_delay_timestamp_xep0091(xmpp_stanza_t *const x_stanza)
 {
     GTimeVal utc_stamp;
-    const char* xmlns = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_XMLNS);
+    const char *xmlns = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_XMLNS);
 
     if (xmlns && (strcmp(xmlns, "jabber:x:delay") == 0)) {
-        const char* stamp = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_STAMP);
+        const char *stamp = xmpp_stanza_get_attribute(x_stanza, STANZA_ATTR_STAMP);
         if (stamp && (g_time_val_from_iso8601(stamp, &utc_stamp))) {
 
-            GDateTime* utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
-            GDateTime* local_datetime = g_date_time_to_local(utc_datetime);
+            GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
+            GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
             g_date_time_unref(utc_datetime);
 
             return local_datetime;
@@ -1237,9 +1242,9 @@ _stanza_get_delay_timestamp_xep0091(xmpp_stanza_t* const x_stanza)
 }
 
 GDateTime*
-stanza_get_delay_from(xmpp_stanza_t* const stanza, gchar* from)
+stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from)
 {
-    xmpp_stanza_t* delay = NULL;
+    xmpp_stanza_t *delay = NULL;
 
     // first check for XEP-0203 delayed delivery
     if (from) {
@@ -1268,10 +1273,10 @@ stanza_get_delay_from(xmpp_stanza_t* const stanza, gchar* from)
 }
 
 GDateTime*
-stanza_get_oldest_delay(xmpp_stanza_t* const stanza)
+stanza_get_oldest_delay(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* child;
-    const char* child_name;
+    xmpp_stanza_t *child;
+    const char *child_name;
     GDateTime* oldest = NULL;
 
     for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) {
@@ -1279,7 +1284,7 @@ stanza_get_oldest_delay(xmpp_stanza_t* const stanza)
         child_name = xmpp_stanza_get_name(child);
 
         if (child_name && strcmp(child_name, STANZA_NAME_DELAY) == 0) {
-            GDateTime* tmp = _stanza_get_delay_timestamp_xep0203(child);
+            GDateTime *tmp = _stanza_get_delay_timestamp_xep0203(child);
 
             if (oldest == NULL) {
                 oldest = tmp;
@@ -1292,7 +1297,7 @@ stanza_get_oldest_delay(xmpp_stanza_t* const stanza)
         }
 
         if (child_name && strcmp(child_name, STANZA_NAME_X) == 0) {
-            GDateTime* tmp = _stanza_get_delay_timestamp_xep0091(child);
+            GDateTime *tmp = _stanza_get_delay_timestamp_xep0091(child);
 
             if (oldest == NULL) {
                 oldest = tmp;
@@ -1309,9 +1314,9 @@ stanza_get_oldest_delay(xmpp_stanza_t* const stanza)
 }
 
 char*
-stanza_get_status(xmpp_stanza_t* stanza, char* def)
+stanza_get_status(xmpp_stanza_t *stanza, char *def)
 {
-    xmpp_stanza_t* status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
+    xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
 
     if (status) {
         return stanza_text_strdup(status);
@@ -1323,9 +1328,9 @@ stanza_get_status(xmpp_stanza_t* stanza, char* def)
 }
 
 char*
-stanza_get_show(xmpp_stanza_t* stanza, char* def)
+stanza_get_show(xmpp_stanza_t *stanza, char *def)
 {
-    xmpp_stanza_t* show = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SHOW);
+    xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SHOW);
 
     if (show) {
         return stanza_text_strdup(show);
@@ -1337,7 +1342,7 @@ stanza_get_show(xmpp_stanza_t* stanza, char* def)
 }
 
 gboolean
-stanza_is_muc_presence(xmpp_stanza_t* const stanza)
+stanza_is_muc_presence(xmpp_stanza_t *const stanza)
 {
     if (stanza == NULL) {
         return FALSE;
@@ -1346,7 +1351,7 @@ stanza_is_muc_presence(xmpp_stanza_t* const stanza)
         return FALSE;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
 
     if (x) {
         return TRUE;
@@ -1356,7 +1361,7 @@ stanza_is_muc_presence(xmpp_stanza_t* const stanza)
 }
 
 gboolean
-stanza_muc_requires_config(xmpp_stanza_t* const stanza)
+stanza_muc_requires_config(xmpp_stanza_t *const stanza)
 {
     // no stanza, or not presence stanza
     if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) {
@@ -1364,26 +1369,26 @@ stanza_muc_requires_config(xmpp_stanza_t* const stanza)
     }
 
     // muc user namespaced x element
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return FALSE;
     }
 
     // check for item element with owner affiliation
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, "item");
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, "item");
     if (item == NULL) {
         return FALSE;
     }
-    const char* affiliation = xmpp_stanza_get_attribute(item, "affiliation");
+    const char *affiliation = xmpp_stanza_get_attribute(item, "affiliation");
     if (g_strcmp0(affiliation, "owner") != 0) {
         return FALSE;
     }
 
     // check for status code 201
-    xmpp_stanza_t* x_children = xmpp_stanza_get_children(x);
+    xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
     while (x_children) {
         if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
-            const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
+            const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
             if (g_strcmp0(code, "201") == 0) {
                 return TRUE;
             }
@@ -1395,8 +1400,8 @@ stanza_muc_requires_config(xmpp_stanza_t* const stanza)
 }
 
 gboolean
-stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
-                            const char* const self_jid)
+stanza_is_muc_self_presence(xmpp_stanza_t *const stanza,
+    const char *const self_jid)
 {
     // no stanza, or not presence stanza
     if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) {
@@ -1404,17 +1409,17 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
     }
 
     // muc user namespaced x element
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
 
     if (x == NULL) {
         return FALSE;
     }
 
     // check for status child element with 110 code
-    xmpp_stanza_t* x_children = xmpp_stanza_get_children(x);
+    xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
     while (x_children) {
         if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
-            const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
+            const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
             if (g_strcmp0(code, "110") == 0) {
                 return TRUE;
             }
@@ -1423,9 +1428,9 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
     }
 
     // check for item child element with jid property
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
     if (item) {
-        const char* jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+        const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
         if (jid) {
             if (g_str_has_prefix(self_jid, jid)) {
                 return TRUE;
@@ -1434,11 +1439,11 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
     }
 
     // check if 'from' attribute identifies this user
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (from) {
-        Jid* from_jid = jid_create(from);
+        Jid *from_jid = jid_create(from);
         if (muc_active(from_jid->barejid)) {
-            char* nick = muc_nick(from_jid->barejid);
+            char *nick = muc_nick(from_jid->barejid);
             if (g_strcmp0(from_jid->resourcepart, nick) == 0) {
                 jid_destroy(from_jid);
                 return TRUE;
@@ -1447,10 +1452,10 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
 
         // check if a new nickname maps to a pending nick change for this user
         if (muc_nick_change_pending(from_jid->barejid)) {
-            char* new_nick = from_jid->resourcepart;
+            char *new_nick = from_jid->resourcepart;
             if (new_nick) {
-                char* nick = muc_nick(from_jid->barejid);
-                char* old_nick = muc_old_nick(from_jid->barejid, new_nick);
+                char *nick = muc_nick(from_jid->barejid);
+                char *old_nick = muc_old_nick(from_jid->barejid, new_nick);
                 if (g_strcmp0(old_nick, nick) == 0) {
                     jid_destroy(from_jid);
                     return TRUE;
@@ -1466,19 +1471,19 @@ stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
 }
 
 GSList*
-stanza_get_status_codes_by_ns(xmpp_stanza_t* const stanza, char* ns)
+stanza_get_status_codes_by_ns(xmpp_stanza_t *const stanza, char *ns)
 {
-    xmpp_stanza_t* ns_child = xmpp_stanza_get_child_by_ns(stanza, ns);
+    xmpp_stanza_t *ns_child = xmpp_stanza_get_child_by_ns(stanza, ns);
     if (ns_child == NULL) {
         return NULL;
     }
 
-    GSList* codes = NULL;
-    xmpp_stanza_t* child = xmpp_stanza_get_children(ns_child);
+    GSList *codes = NULL;
+    xmpp_stanza_t *child = xmpp_stanza_get_children(ns_child);
     while (child) {
-        const char* name = xmpp_stanza_get_name(child);
+        const char *name = xmpp_stanza_get_name(child);
         if (g_strcmp0(name, STANZA_NAME_STATUS) == 0) {
-            const char* code = xmpp_stanza_get_attribute(child, STANZA_ATTR_CODE);
+            const char *code = xmpp_stanza_get_attribute(child, STANZA_ATTR_CODE);
             if (code) {
                 codes = g_slist_append(codes, strdup(code));
             }
@@ -1490,19 +1495,19 @@ stanza_get_status_codes_by_ns(xmpp_stanza_t* const stanza, char* ns)
 }
 
 gboolean
-stanza_room_destroyed(xmpp_stanza_t* stanza)
+stanza_room_destroyed(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return FALSE;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return FALSE;
     }
 
-    xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
+    xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
     if (destroy) {
         return TRUE;
     }
@@ -1511,24 +1516,24 @@ stanza_room_destroyed(xmpp_stanza_t* stanza)
 }
 
 const char*
-stanza_get_muc_destroy_alternative_room(xmpp_stanza_t* stanza)
+stanza_get_muc_destroy_alternative_room(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
+    xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
     if (destroy == NULL) {
         return NULL;
     }
 
-    const char* jid = xmpp_stanza_get_attribute(destroy, STANZA_ATTR_JID);
+    const char *jid = xmpp_stanza_get_attribute(destroy, STANZA_ATTR_JID);
     if (jid) {
         return jid;
     }
@@ -1537,24 +1542,24 @@ stanza_get_muc_destroy_alternative_room(xmpp_stanza_t* stanza)
 }
 
 char*
-stanza_get_muc_destroy_alternative_password(xmpp_stanza_t* stanza)
+stanza_get_muc_destroy_alternative_password(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
+    xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
     if (destroy == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* password_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_PASSWORD);
+    xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_PASSWORD);
     if (password_st == NULL) {
         return NULL;
     }
@@ -1563,24 +1568,24 @@ stanza_get_muc_destroy_alternative_password(xmpp_stanza_t* stanza)
 }
 
 char*
-stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza)
+stanza_get_muc_destroy_reason(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
+    xmpp_stanza_t *destroy = xmpp_stanza_get_child_by_name(x, STANZA_NAME_DESTROY);
     if (destroy == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_REASON);
+    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(destroy, STANZA_NAME_REASON);
     if (reason_st == NULL) {
         return NULL;
     }
@@ -1589,34 +1594,34 @@ stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza)
 }
 
 const char*
-stanza_get_actor(xmpp_stanza_t* stanza)
+stanza_get_actor(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
     if (item == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* actor = xmpp_stanza_get_child_by_name(item, STANZA_NAME_ACTOR);
+    xmpp_stanza_t *actor = xmpp_stanza_get_child_by_name(item, STANZA_NAME_ACTOR);
     if (actor == NULL) {
         return NULL;
     }
 
-    const char* nick = xmpp_stanza_get_attribute(actor, STANZA_ATTR_NICK);
+    const char *nick = xmpp_stanza_get_attribute(actor, STANZA_ATTR_NICK);
     if (nick) {
         return nick;
     }
 
-    const char* jid = xmpp_stanza_get_attribute(actor, STANZA_ATTR_JID);
+    const char *jid = xmpp_stanza_get_attribute(actor, STANZA_ATTR_JID);
     if (jid) {
         return jid;
     }
@@ -1625,24 +1630,24 @@ stanza_get_actor(xmpp_stanza_t* stanza)
 }
 
 char*
-stanza_get_reason(xmpp_stanza_t* stanza)
+stanza_get_reason(xmpp_stanza_t *stanza)
 {
-    const char* stanza_name = xmpp_stanza_get_name(stanza);
+    const char *stanza_name = xmpp_stanza_get_name(stanza);
     if (g_strcmp0(stanza_name, STANZA_NAME_PRESENCE) != 0) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
+    xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(x, STANZA_NAME_ITEM);
     if (item == NULL) {
         return NULL;
     }
 
-    xmpp_stanza_t* reason_st = xmpp_stanza_get_child_by_name(item, STANZA_NAME_REASON);
+    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(item, STANZA_NAME_REASON);
     if (reason_st == NULL) {
         return NULL;
     }
@@ -1651,7 +1656,7 @@ stanza_get_reason(xmpp_stanza_t* stanza)
 }
 
 gboolean
-stanza_is_room_nick_change(xmpp_stanza_t* const stanza)
+stanza_is_room_nick_change(xmpp_stanza_t *const stanza)
 {
     // no stanza, or not presence stanza
     if ((stanza == NULL) || (g_strcmp0(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0)) {
@@ -1659,16 +1664,16 @@ stanza_is_room_nick_change(xmpp_stanza_t* const stanza)
     }
 
     // muc user namespaced x element
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
     if (x == NULL) {
         return FALSE;
     }
 
     // check for status child element with 303 code
-    xmpp_stanza_t* x_children = xmpp_stanza_get_children(x);
+    xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
     while (x_children) {
         if (g_strcmp0(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
-            const char* code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
+            const char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
             if (g_strcmp0(code, "303") == 0) {
                 return TRUE;
             }
@@ -1680,18 +1685,18 @@ stanza_is_room_nick_change(xmpp_stanza_t* const stanza)
 }
 
 const char*
-stanza_get_new_nick(xmpp_stanza_t* const stanza)
+stanza_get_new_nick(xmpp_stanza_t *const stanza)
 {
     if (!stanza_is_room_nick_change(stanza)) {
         return NULL;
     }
 
-    xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
-    xmpp_stanza_t* x_children = xmpp_stanza_get_children(x);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
+    xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
 
     while (x_children) {
         if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) {
-            const char* nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK);
+            const char *nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK);
             if (nick) {
                 return nick;
             }
@@ -1703,15 +1708,15 @@ stanza_get_new_nick(xmpp_stanza_t* const stanza)
 }
 
 int
-stanza_get_idle_time(xmpp_stanza_t* const stanza)
+stanza_get_idle_time(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
+    xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
 
     if (query == NULL) {
         return 0;
     }
 
-    const char* ns = xmpp_stanza_get_ns(query);
+    const char *ns = xmpp_stanza_get_ns(query);
     if (ns == NULL) {
         return 0;
     }
@@ -1720,7 +1725,7 @@ stanza_get_idle_time(xmpp_stanza_t* const stanza)
         return 0;
     }
 
-    const char* seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS);
+    const char *seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS);
     if (seconds_str == NULL) {
         return 0;
     }
@@ -1734,24 +1739,24 @@ stanza_get_idle_time(xmpp_stanza_t* const stanza)
 }
 
 XMPPCaps*
-stanza_parse_caps(xmpp_stanza_t* const stanza)
+stanza_parse_caps(xmpp_stanza_t *const stanza)
 {
-    xmpp_stanza_t* caps_st = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C);
+    xmpp_stanza_t *caps_st = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_C);
 
     if (!caps_st) {
         return NULL;
     }
 
-    const char* ns = xmpp_stanza_get_ns(caps_st);
+    const char *ns = xmpp_stanza_get_ns(caps_st);
     if (g_strcmp0(ns, STANZA_NS_CAPS) != 0) {
         return NULL;
     }
 
-    const char* hash = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_HASH);
-    const char* node = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_NODE);
-    const char* ver = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_VER);
+    const char *hash = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_HASH);
+    const char *node = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_NODE);
+    const char *ver = xmpp_stanza_get_attribute(caps_st, STANZA_ATTR_VER);
 
-    XMPPCaps* caps = (XMPPCaps*)malloc(sizeof(XMPPCaps));
+    XMPPCaps *caps = (XMPPCaps *)malloc(sizeof(XMPPCaps));
     caps->hash = hash ? strdup(hash) : NULL;
     caps->node = node ? strdup(node) : NULL;
     caps->ver = ver ? strdup(ver) : NULL;
@@ -1760,21 +1765,21 @@ stanza_parse_caps(xmpp_stanza_t* const stanza)
 }
 
 EntityCapabilities*
-stanza_create_caps_from_query_element(xmpp_stanza_t* query)
+stanza_create_caps_from_query_element(xmpp_stanza_t *query)
 {
-    char* software = NULL;
-    char* software_version = NULL;
-    char* os = NULL;
-    char* os_version = NULL;
+    char *software = NULL;
+    char *software_version = NULL;
+    char *os = NULL;
+    char *os_version = NULL;
 
-    xmpp_stanza_t* softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
+    xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA);
     if (softwareinfo) {
-        DataForm* form = form_create(softwareinfo);
-        FormField* formField = NULL;
+        DataForm *form = form_create(softwareinfo);
+        FormField *formField = NULL;
 
-        char* form_type = form_get_form_type_field(form);
+        char *form_type = form_get_form_type_field(form);
         if (g_strcmp0(form_type, STANZA_DATAFORM_SOFTWARE) == 0) {
-            GSList* field = form->fields;
+            GSList *field = form->fields;
             while (field) {
                 formField = field->data;
                 if (formField->values) {
@@ -1803,9 +1808,9 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
         form_destroy(form);
     }
 
-    xmpp_stanza_t* child = xmpp_stanza_get_children(query);
-    GSList* identity_stanzas = NULL;
-    GSList* features = NULL;
+    xmpp_stanza_t *child = xmpp_stanza_get_children(query);
+    GSList *identity_stanzas = NULL;
+    GSList *features = NULL;
     while (child) {
         if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) {
             features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var")));
@@ -1818,13 +1823,13 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
     }
 
     // find identity by locale
-    const gchar* const* langs = g_get_language_names();
+    const gchar* const *langs = g_get_language_names();
     int num_langs = g_strv_length((gchar**)langs);
-    xmpp_stanza_t* found = NULL;
-    GSList* curr_identity = identity_stanzas;
+    xmpp_stanza_t *found = NULL;
+    GSList *curr_identity = identity_stanzas;
     while (curr_identity) {
-        xmpp_stanza_t* id_stanza = curr_identity->data;
-        const char* stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang");
+        xmpp_stanza_t *id_stanza = curr_identity->data;
+        const char *stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang");
         if (stanza_lang) {
             int i = 0;
             for (i = 0; i < num_langs; i++) {
@@ -1844,8 +1849,8 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
     if (!found) {
         curr_identity = identity_stanzas;
         while (curr_identity) {
-            xmpp_stanza_t* id_stanza = curr_identity->data;
-            const char* stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang");
+            xmpp_stanza_t *id_stanza = curr_identity->data;
+            const char *stanza_lang = xmpp_stanza_get_attribute(id_stanza, "xml:lang");
             if (!stanza_lang) {
                 found = id_stanza;
                 break;
@@ -1864,16 +1869,16 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
 
     g_slist_free(identity_stanzas);
 
-    const char* category = NULL;
-    const char* type = NULL;
-    const char* name = NULL;
+    const char *category = NULL;
+    const char *type = NULL;
+    const char *name = NULL;
     if (found) {
         category = xmpp_stanza_get_attribute(found, "category");
         type = xmpp_stanza_get_type(found);
         name = xmpp_stanza_get_attribute(found, "name");
     }
 
-    EntityCapabilities* result = caps_create(category, type, name, software, software_version, os, os_version, features);
+    EntityCapabilities *result = caps_create(category, type, name, software, software_version, os, os_version, features);
     g_slist_free_full(features, free);
     free(software);
     free(software_version);
@@ -1884,9 +1889,9 @@ stanza_create_caps_from_query_element(xmpp_stanza_t* query)
 }
 
 char*
-stanza_get_error_message(xmpp_stanza_t* stanza)
+stanza_get_error_message(xmpp_stanza_t *stanza)
 {
-    xmpp_stanza_t* error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
 
     // return nothing if no error stanza
     if (error_stanza == NULL) {
@@ -1894,18 +1899,18 @@ stanza_get_error_message(xmpp_stanza_t* stanza)
     }
 
     // check for text child
-    xmpp_stanza_t* text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
+    xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
 
     // check for text
     if (text_stanza) {
-        char* err_msg = stanza_text_strdup(text_stanza);
+        char *err_msg = stanza_text_strdup(text_stanza);
         if (err_msg) {
             return err_msg;
         }
 
-        // otherwise check each defined-condition RFC-6120 8.3.3
+    // otherwise check each defined-condition RFC-6120 8.3.3
     } else {
-        gchar* defined_conditions[] = {
+        gchar *defined_conditions[] = {
             STANZA_NAME_BAD_REQUEST,
             STANZA_NAME_CONFLICT,
             STANZA_NAME_FEATURE_NOT_IMPLEMENTED,
@@ -1931,9 +1936,9 @@ stanza_get_error_message(xmpp_stanza_t* stanza)
 
         int i;
         for (i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
-            xmpp_stanza_t* cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
+            xmpp_stanza_t *cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
             if (cond_stanza) {
-                char* result = strdup(xmpp_stanza_get_name(cond_stanza));
+                char *result = strdup(xmpp_stanza_get_name(cond_stanza));
                 return result;
             }
         }
@@ -1944,41 +1949,41 @@ stanza_get_error_message(xmpp_stanza_t* stanza)
 }
 
 void
-stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const iq, const char* const option, const char* const value)
+stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const iq, const char *const option, const char *const value)
 {
-    xmpp_stanza_t* publish_options = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *publish_options = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(publish_options, STANZA_NAME_PUBLISH_OPTIONS);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_DATA);
     xmpp_stanza_set_type(x, "submit");
     xmpp_stanza_add_child(publish_options, x);
 
-    xmpp_stanza_t* form_type = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *form_type = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(form_type, STANZA_NAME_FIELD);
     xmpp_stanza_set_attribute(form_type, STANZA_ATTR_VAR, "FORM_TYPE");
     xmpp_stanza_set_type(form_type, "hidden");
-    xmpp_stanza_t* form_type_value = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *form_type_value = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(form_type_value, STANZA_NAME_VALUE);
-    xmpp_stanza_t* form_type_value_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *form_type_value_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(form_type_value_text, XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS);
     xmpp_stanza_add_child(form_type_value, form_type_value_text);
     xmpp_stanza_add_child(form_type, form_type_value);
     xmpp_stanza_add_child(x, form_type);
 
-    xmpp_stanza_t* access_model = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *access_model = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(access_model, STANZA_NAME_FIELD);
     xmpp_stanza_set_attribute(access_model, STANZA_ATTR_VAR, option);
-    xmpp_stanza_t* access_model_value = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *access_model_value = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(access_model_value, STANZA_NAME_VALUE);
-    xmpp_stanza_t* access_model_value_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *access_model_value_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(access_model_value_text, value);
     xmpp_stanza_add_child(access_model_value, access_model_value_text);
     xmpp_stanza_add_child(access_model, access_model_value);
     xmpp_stanza_add_child(x, access_model);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
+    xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
     xmpp_stanza_add_child(pubsub, publish_options);
 
     xmpp_stanza_release(access_model_value_text);
@@ -1992,7 +1997,7 @@ stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const iq, co
 }
 
 void
-stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int pri)
+stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri)
 {
     if (pri == 0) {
         return;
@@ -2001,10 +2006,10 @@ stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, con
     char pri_str[10];
     snprintf(pri_str, sizeof(pri_str), "%d", pri);
 
-    xmpp_stanza_t* priority = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *priority = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(priority, STANZA_NAME_PRIORITY);
 
-    xmpp_stanza_t* value = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *value = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(value, pri_str);
 
     xmpp_stanza_add_child(priority, value);
@@ -2015,16 +2020,16 @@ stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, con
 }
 
 void
-stanza_attach_show(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence,
-                   const char* const show)
+stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence,
+    const char *const show)
 {
     if (show == NULL) {
         return;
     }
 
-    xmpp_stanza_t* show_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *show_stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(show_stanza, STANZA_NAME_SHOW);
-    xmpp_stanza_t* text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(text, show);
     xmpp_stanza_add_child(show_stanza, text);
     xmpp_stanza_add_child(presence, show_stanza);
@@ -2033,16 +2038,16 @@ 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)
+stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence,
+    const char *const status)
 {
     if (status == NULL) {
         return;
     }
 
-    xmpp_stanza_t* status_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *status_stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(status_stanza, STANZA_NAME_STATUS);
-    xmpp_stanza_t* text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(text, status);
     xmpp_stanza_add_child(status_stanza, text);
     xmpp_stanza_add_child(presence, status_stanza);
@@ -2051,10 +2056,10 @@ stanza_attach_status(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence,
 }
 
 void
-stanza_attach_last_activity(xmpp_ctx_t* const ctx,
-                            xmpp_stanza_t* const presence, const int idle)
+stanza_attach_last_activity(xmpp_ctx_t *const ctx,
+    xmpp_stanza_t *const presence, const int idle)
 {
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_LASTACTIVITY);
     char idle_str[10];
@@ -2065,14 +2070,14 @@ stanza_attach_last_activity(xmpp_ctx_t* const ctx,
 }
 
 void
-stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence)
+stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence)
 {
-    xmpp_stanza_t* caps = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *caps = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(caps, STANZA_NAME_C);
     xmpp_stanza_set_ns(caps, STANZA_NS_CAPS);
-    xmpp_stanza_t* query = stanza_create_caps_query_element(ctx);
+    xmpp_stanza_t *query = stanza_create_caps_query_element(ctx);
 
-    char* sha1 = caps_get_my_sha1(ctx);
+    char *sha1 = caps_get_my_sha1(ctx);
     xmpp_stanza_set_attribute(caps, STANZA_ATTR_HASH, "sha-1");
     xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, "http://profanity-im.github.io");
     xmpp_stanza_set_attribute(caps, STANZA_ATTR_VER, sha1);
@@ -2084,25 +2089,26 @@ stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence)
 const char*
 stanza_get_presence_string_from_type(resource_presence_t presence_type)
 {
-    switch (presence_type) {
-    case RESOURCE_AWAY:
-        return STANZA_TEXT_AWAY;
-    case RESOURCE_DND:
-        return STANZA_TEXT_DND;
-    case RESOURCE_CHAT:
-        return STANZA_TEXT_CHAT;
-    case RESOURCE_XA:
-        return STANZA_TEXT_XA;
-    default:
-        return NULL;
+    switch(presence_type)
+    {
+        case RESOURCE_AWAY:
+            return STANZA_TEXT_AWAY;
+        case RESOURCE_DND:
+            return STANZA_TEXT_DND;
+        case RESOURCE_CHAT:
+            return STANZA_TEXT_CHAT;
+        case RESOURCE_XA:
+            return STANZA_TEXT_XA;
+        default:
+            return NULL;
     }
 }
 
 Resource*
-stanza_resource_from_presence(XMPPPresence* presence)
+stanza_resource_from_presence(XMPPPresence *presence)
 {
     // create Resource
-    Resource* resource = NULL;
+    Resource *resource = NULL;
     resource_presence_t resource_presence = resource_presence_from_string(presence->show);
     if (presence->jid->resourcepart == NULL) { // hack for servers that do not send full jid
         resource = resource_new("__prof_default", resource_presence, presence->status, presence->priority);
@@ -2114,12 +2120,12 @@ stanza_resource_from_presence(XMPPPresence* presence)
 }
 
 char*
-stanza_text_strdup(xmpp_stanza_t* stanza)
+stanza_text_strdup(xmpp_stanza_t *stanza)
 {
-    xmpp_ctx_t* ctx = connection_get_ctx();
+    xmpp_ctx_t *ctx = connection_get_ctx();
 
-    char* string = NULL;
-    char* stanza_text = xmpp_stanza_get_text(stanza);
+    char *string = NULL;
+    char *stanza_text = xmpp_stanza_get_text(stanza);
     if (stanza_text) {
         string = strdup(stanza_text);
         xmpp_free(ctx, stanza_text);
@@ -2129,7 +2135,7 @@ stanza_text_strdup(xmpp_stanza_t* stanza)
 }
 
 void
-stanza_free_caps(XMPPCaps* caps)
+stanza_free_caps(XMPPCaps *caps)
 {
     if (caps == NULL) {
         return;
@@ -2148,7 +2154,7 @@ stanza_free_caps(XMPPCaps* caps)
 }
 
 void
-stanza_free_presence(XMPPPresence* presence)
+stanza_free_presence(XMPPPresence *presence)
 {
     if (presence == NULL) {
         return;
@@ -2170,21 +2176,21 @@ stanza_free_presence(XMPPPresence* presence)
 }
 
 XMPPPresence*
-stanza_parse_presence(xmpp_stanza_t* stanza, int* err)
+stanza_parse_presence(xmpp_stanza_t *stanza, int *err)
 {
-    const char* from = xmpp_stanza_get_from(stanza);
+    const char *from = xmpp_stanza_get_from(stanza);
     if (!from) {
         *err = STANZA_PARSE_ERROR_NO_FROM;
         return NULL;
     }
 
-    Jid* from_jid = jid_create(from);
+    Jid *from_jid = jid_create(from);
     if (!from_jid) {
         *err = STANZA_PARSE_ERROR_INVALID_FROM;
         return NULL;
     }
 
-    XMPPPresence* result = (XMPPPresence*)malloc(sizeof(XMPPPresence));
+    XMPPPresence *result = (XMPPPresence *)malloc(sizeof(XMPPPresence));
     result->jid = from_jid;
 
     result->show = stanza_get_show(stanza, "online");
@@ -2192,7 +2198,7 @@ stanza_parse_presence(xmpp_stanza_t* stanza, int* err)
 
     int idle_seconds = stanza_get_idle_time(stanza);
     if (idle_seconds > 0) {
-        GDateTime* now = g_date_time_new_now_local();
+        GDateTime *now = g_date_time_new_now_local();
         result->last_activity = g_date_time_add_seconds(now, 0 - idle_seconds);
         g_date_time_unref(now);
     } else {
@@ -2200,13 +2206,13 @@ stanza_parse_presence(xmpp_stanza_t* stanza, int* err)
     }
 
     result->priority = 0;
-    xmpp_stanza_t* priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY);
+    xmpp_stanza_t *priority_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PRIORITY);
     if (priority_stanza) {
-        char* priority_str = xmpp_stanza_get_text(priority_stanza);
+        char *priority_str = xmpp_stanza_get_text(priority_stanza);
         if (priority_str) {
             result->priority = atoi(priority_str);
         }
-        xmpp_ctx_t* ctx = connection_get_ctx();
+        xmpp_ctx_t *ctx = connection_get_ctx();
         xmpp_free(ctx, priority_str);
     }
 
@@ -2214,15 +2220,15 @@ stanza_parse_presence(xmpp_stanza_t* stanza, int* err)
 }
 
 xmpp_stanza_t*
-stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target,
-                              const char* const node)
+stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target,
+    const char *const node)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, target);
 
-    xmpp_stanza_t* command = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *command = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(command, STANZA_NAME_COMMAND);
 
     xmpp_stanza_set_ns(command, STANZA_NS_COMMAND);
@@ -2236,15 +2242,15 @@ stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target,
 }
 
 xmpp_stanza_t*
-stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room,
-                                       const char* const node, const char* const sessionid, DataForm* form)
+stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room,
+    const char *const node, const char *const sessionid, DataForm *form)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     xmpp_stanza_set_to(iq, room);
 
-    xmpp_stanza_t* command = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *command = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(command, STANZA_NAME_COMMAND);
     xmpp_stanza_set_ns(command, STANZA_NS_COMMAND);
     xmpp_stanza_set_attribute(command, "node", node);
@@ -2252,7 +2258,7 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room,
         xmpp_stanza_set_attribute(command, "sessionid", sessionid);
     }
 
-    xmpp_stanza_t* x = form_create_submission(form);
+    xmpp_stanza_t *x = form_create_submission(form);
     xmpp_stanza_add_child(command, x);
     xmpp_stanza_release(x);
 
@@ -2263,17 +2269,17 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room,
 }
 
 xmpp_stanza_t*
-stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id,
-                                       const char* const jid)
+stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id,
+    const char *const jid)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* items = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *items = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(items, "items");
     xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST);
 
@@ -2287,17 +2293,17 @@ stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id,
 }
 
 xmpp_stanza_t*
-stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid)
+stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* subscribe = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *subscribe = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(subscribe, STANZA_NAME_SUBSCRIBE);
     xmpp_stanza_set_attribute(subscribe, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST);
     xmpp_stanza_set_attribute(subscribe, "jid", jid);
@@ -2312,33 +2318,33 @@ stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid)
 }
 
 xmpp_stanza_t*
-stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids)
+stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* publish = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *publish = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH);
     xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, STANZA_NS_OMEMO_DEVICELIST);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "id", "current");
 
-    xmpp_stanza_t* list = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *list = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(list, "list");
     xmpp_stanza_set_ns(list, "eu.siacs.conversations.axolotl");
 
-    GList* i;
+    GList *i;
     for (i = ids; i != NULL; i = i->next) {
-        xmpp_stanza_t* device = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *device = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(device, "device");
-        char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
+        char *id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
         xmpp_stanza_set_attribute(device, "id", id);
         g_free(id);
 
@@ -2360,77 +2366,77 @@ stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids)
 }
 
 xmpp_stanza_t*
-stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
-                                   uint32_t device_id,
-                                   const unsigned char* const identity_key, size_t identity_key_length,
-                                   const unsigned char* const signed_prekey, size_t signed_prekey_length,
-                                   const unsigned char* const signed_prekey_signature, size_t signed_prekey_signature_length,
-                                   GList* const prekeys, GList* const prekeys_id, GList* const prekeys_length)
+stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, const char *const id,
+    uint32_t device_id,
+    const unsigned char * const identity_key, size_t identity_key_length,
+    const unsigned char * const signed_prekey, size_t signed_prekey_length,
+    const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length,
+    GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* publish = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *publish = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(publish, STANZA_NAME_PUBLISH);
-    char* node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id);
+    char *node = g_strdup_printf("%s:%d", "eu.siacs.conversations.axolotl.bundles", device_id);
     xmpp_stanza_set_attribute(publish, STANZA_ATTR_NODE, node);
     g_free(node);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "id", "current");
 
-    xmpp_stanza_t* bundle = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *bundle = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(bundle, "bundle");
     xmpp_stanza_set_ns(bundle, "eu.siacs.conversations.axolotl");
 
-    xmpp_stanza_t* signed_prekey_public_stanza = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(signed_prekey_public_stanza, "signedPreKeyPublic");
+    xmpp_stanza_t *signed_prekey_public_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(signed_prekey_public_stanza , "signedPreKeyPublic");
     xmpp_stanza_set_attribute(signed_prekey_public_stanza, "signedPreKeyId", "1");
 
-    xmpp_stanza_t* signed_prekey_public_stanza_text = xmpp_stanza_new(ctx);
-    char* signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length);
+    xmpp_stanza_t *signed_prekey_public_stanza_text= xmpp_stanza_new(ctx);
+    char *signed_prekey_b64 = g_base64_encode(signed_prekey, signed_prekey_length);
     xmpp_stanza_set_text(signed_prekey_public_stanza_text, signed_prekey_b64);
     g_free(signed_prekey_b64);
     xmpp_stanza_add_child(signed_prekey_public_stanza, signed_prekey_public_stanza_text);
     xmpp_stanza_release(signed_prekey_public_stanza_text);
 
-    xmpp_stanza_t* signed_prekey_signature_stanza = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(signed_prekey_signature_stanza, "signedPreKeySignature");
+    xmpp_stanza_t *signed_prekey_signature_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(signed_prekey_signature_stanza , "signedPreKeySignature");
 
-    xmpp_stanza_t* signed_prekey_signature_stanza_text = xmpp_stanza_new(ctx);
-    char* signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length);
+    xmpp_stanza_t *signed_prekey_signature_stanza_text= xmpp_stanza_new(ctx);
+    char *signed_prekey_signature_b64 = g_base64_encode(signed_prekey_signature, signed_prekey_signature_length);
     xmpp_stanza_set_text(signed_prekey_signature_stanza_text, signed_prekey_signature_b64);
     g_free(signed_prekey_signature_b64);
     xmpp_stanza_add_child(signed_prekey_signature_stanza, signed_prekey_signature_stanza_text);
     xmpp_stanza_release(signed_prekey_signature_stanza_text);
 
-    xmpp_stanza_t* identity_key_stanza = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(identity_key_stanza, "identityKey");
+    xmpp_stanza_t *identity_key_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_set_name(identity_key_stanza , "identityKey");
 
-    xmpp_stanza_t* identity_key_stanza_text = xmpp_stanza_new(ctx);
-    char* identity_key_b64 = g_base64_encode(identity_key, identity_key_length);
+    xmpp_stanza_t *identity_key_stanza_text= xmpp_stanza_new(ctx);
+    char *identity_key_b64 = g_base64_encode(identity_key, identity_key_length);
     xmpp_stanza_set_text(identity_key_stanza_text, identity_key_b64);
     g_free(identity_key_b64);
     xmpp_stanza_add_child(identity_key_stanza, identity_key_stanza_text);
     xmpp_stanza_release(identity_key_stanza_text);
 
-    xmpp_stanza_t* prekeys_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *prekeys_stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(prekeys_stanza, "prekeys");
 
     GList *p, *i, *l;
     for (p = prekeys, i = prekeys_id, l = prekeys_length; p != NULL; p = p->next, i = i->next, l = l->next) {
-        xmpp_stanza_t* prekey = xmpp_stanza_new(ctx);
+        xmpp_stanza_t *prekey = xmpp_stanza_new(ctx);
         xmpp_stanza_set_name(prekey, "preKeyPublic");
-        char* id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
+        char *id = g_strdup_printf("%d", GPOINTER_TO_INT(i->data));
         xmpp_stanza_set_attribute(prekey, "preKeyId", id);
         g_free(id);
 
-        xmpp_stanza_t* prekey_text = xmpp_stanza_new(ctx);
-        char* prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data));
+        xmpp_stanza_t *prekey_text = xmpp_stanza_new(ctx);
+        char *prekey_b64 = g_base64_encode(p->data, GPOINTER_TO_INT(l->data));
         xmpp_stanza_set_text(prekey_text, prekey_b64);
         g_free(prekey_b64);
 
@@ -2462,18 +2468,18 @@ stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id,
 }
 
 xmpp_stanza_t*
-stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, uint32_t device_id)
+stanza_create_omemo_bundle_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, uint32_t device_id)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* items = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *items = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(items, "items");
-    char* node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id);
+    char *node = g_strdup_printf("%s:%d", STANZA_NS_OMEMO_BUNDLES, device_id);
     xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node);
     g_free(node);
 
@@ -2487,16 +2493,16 @@ stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const
 }
 
 xmpp_stanza_t*
-stanza_create_pubsub_configure_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node)
+stanza_create_pubsub_configure_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB_OWNER);
 
-    xmpp_stanza_t* configure = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *configure = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(configure, STANZA_NAME_CONFIGURE);
     xmpp_stanza_set_attribute(configure, STANZA_ATTR_NODE, node);
 
@@ -2510,20 +2516,20 @@ stanza_create_pubsub_configure_request(xmpp_ctx_t* ctx, const char* const id, co
 }
 
 xmpp_stanza_t*
-stanza_create_pubsub_configure_submit(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form)
+stanza_create_pubsub_configure_submit(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node, DataForm *form)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB_OWNER);
 
-    xmpp_stanza_t* configure = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *configure = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(configure, STANZA_NAME_CONFIGURE);
     xmpp_stanza_set_attribute(configure, STANZA_ATTR_NODE, node);
 
-    xmpp_stanza_t* x = form_create_submission(form);
+    xmpp_stanza_t *x = form_create_submission(form);
 
     xmpp_stanza_add_child(configure, x);
     xmpp_stanza_add_child(pubsub, configure);
@@ -2537,9 +2543,9 @@ stanza_create_pubsub_configure_submit(xmpp_ctx_t* ctx, const char* const id, con
 }
 
 xmpp_stanza_t*
-stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const id)
+stanza_attach_origin_id(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const id)
 {
-    xmpp_stanza_t* origin_id = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *origin_id = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(origin_id, STANZA_NAME_ORIGIN_ID);
     xmpp_stanza_set_ns(origin_id, STANZA_NS_STABLE_ID);
     xmpp_stanza_set_attribute(origin_id, STANZA_ATTR_ID, id);
@@ -2552,34 +2558,34 @@ stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* cons
 }
 
 static void
-_stanza_add_unique_id(xmpp_stanza_t* stanza)
+_stanza_add_unique_id(xmpp_stanza_t *stanza)
 {
-    char* id = connection_create_stanza_id();
+    char *id = connection_create_stanza_id();
     xmpp_stanza_set_id(stanza, id);
     free(id);
 }
 
 static char*
-_stanza_create_sha1_hash(char* str)
+_stanza_create_sha1_hash(char *str)
 {
-    unsigned char* digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
-    assert(digest != NULL);
+   unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
+   assert(digest != NULL);
 
-    xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
+   xmpp_sha1_digest((unsigned char*)str, strlen(str), digest);
 
-    char* b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
-    assert(b64 != NULL);
-    free(digest);
+   char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
+   assert(b64 != NULL);
+   free(digest);
 
-    return b64;
+   return b64;
 }
 
 xmpp_stanza_t*
-stanza_get_child_by_name_and_ns(xmpp_stanza_t* const stanza, const char* const name, const char* const ns)
+stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns)
 {
-    xmpp_stanza_t* child;
-    const char* child_ns;
-    const char* child_name;
+    xmpp_stanza_t *child;
+    const char *child_ns;
+    const char *child_name;
 
     for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) {
         child_name = xmpp_stanza_get_name(child);
@@ -2595,22 +2601,22 @@ stanza_get_child_by_name_and_ns(xmpp_stanza_t* const stanza, const char* const n
 }
 
 xmpp_stanza_t*
-stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid)
+stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid)
 {
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, stanza_id);
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_GET, stanza_id);
     xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* pubsub = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
     xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
 
-    xmpp_stanza_t* items = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *items = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(items, "items");
-    char* node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA);
+    char *node = g_strdup_printf("%s", STANZA_NS_USER_AVATAR_DATA);
     xmpp_stanza_set_attribute(items, STANZA_ATTR_NODE, node);
     g_free(node);
 
-    xmpp_stanza_t* item = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *item = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
     xmpp_stanza_set_attribute(item, "id", item_id);
 
@@ -2626,9 +2632,9 @@ stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_i
 }
 
 xmpp_stanza_t*
-stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const replace_id)
+stanza_attach_correction(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const replace_id)
 {
-    xmpp_stanza_t* replace_stanza = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *replace_stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(replace_stanza, "replace");
     xmpp_stanza_set_id(replace_stanza, replace_id);
     xmpp_stanza_set_ns(replace_stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
@@ -2639,60 +2645,60 @@ stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* con
 }
 
 xmpp_stanza_t*
-stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate)
+stanza_create_mam_iq(xmpp_ctx_t *ctx, const char *const jid, const char *const startdate)
 {
-    char* id = connection_create_stanza_id();
-    xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
+    char *id = connection_create_stanza_id();
+    xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
     free(id);
     //xmpp_stanza_set_to(iq, jid);
 
-    xmpp_stanza_t* query = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
     xmpp_stanza_set_ns(query, STANZA_NS_MAM2);
 
-    xmpp_stanza_t* x = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
     xmpp_stanza_set_ns(x, STANZA_NS_DATA);
     xmpp_stanza_set_type(x, "submit");
 
     // field FORM_TYPE MAM2
-    xmpp_stanza_t* field_form_type = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *field_form_type = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(field_form_type, STANZA_NAME_FIELD);
     xmpp_stanza_set_attribute(field_form_type, STANZA_ATTR_VAR, "FORM_TYPE");
     xmpp_stanza_set_type(field_form_type, "hidden");
 
-    xmpp_stanza_t* value_mam = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *value_mam = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(value_mam, STANZA_NAME_VALUE);
 
-    xmpp_stanza_t* mam_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *mam_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(mam_text, STANZA_NS_MAM2);
     xmpp_stanza_add_child(value_mam, mam_text);
 
     xmpp_stanza_add_child(field_form_type, value_mam);
 
     // field 'with'
-    xmpp_stanza_t* field_with = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *field_with = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(field_with, STANZA_NAME_FIELD);
     xmpp_stanza_set_attribute(field_with, STANZA_ATTR_VAR, "with");
 
-    xmpp_stanza_t* value_with = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *value_with = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(value_with, STANZA_NAME_VALUE);
 
-    xmpp_stanza_t* with_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *with_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(with_text, jid);
     xmpp_stanza_add_child(value_with, with_text);
 
     xmpp_stanza_add_child(field_with, value_with);
 
     // field 'start'
-    xmpp_stanza_t* field_start = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *field_start = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(field_start, STANZA_NAME_FIELD);
     xmpp_stanza_set_attribute(field_start, STANZA_ATTR_VAR, "start");
 
-    xmpp_stanza_t* value_start = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *value_start = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(value_start, STANZA_NAME_VALUE);
 
-    xmpp_stanza_t* date_text = xmpp_stanza_new(ctx);
+    xmpp_stanza_t *date_text = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(date_text, startdate);
     xmpp_stanza_add_child(value_start, date_text);
 
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index a51ee3c6..5910a7d9 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -48,193 +48,192 @@
 
 #include <xmpp/xmpp.h>
 
-#define STANZA_NAME_ACTIVE    "active"
-#define STANZA_NAME_INACTIVE  "inactive"
+#define STANZA_NAME_ACTIVE "active"
+#define STANZA_NAME_INACTIVE "inactive"
 #define STANZA_NAME_COMPOSING "composing"
-#define STANZA_NAME_PAUSED    "paused"
-#define STANZA_NAME_GONE      "gone"
+#define STANZA_NAME_PAUSED "paused"
+#define STANZA_NAME_GONE "gone"
 
-#define STANZA_NAME_MESSAGE   "message"
-#define STANZA_NAME_BODY      "body"
-#define STANZA_NAME_BLOCK     "block"
-#define STANZA_NAME_UNBLOCK   "unblock"
+#define STANZA_NAME_MESSAGE "message"
+#define STANZA_NAME_BODY "body"
+#define STANZA_NAME_BLOCK "block"
+#define STANZA_NAME_UNBLOCK "unblock"
 #define STANZA_NAME_BLOCKLIST "blocklist"
-#define STANZA_NAME_PRESENCE  "presence"
-#define STANZA_NAME_PRIORITY  "priority"
-#define STANZA_NAME_X         "x"
+#define STANZA_NAME_PRESENCE "presence"
+#define STANZA_NAME_PRIORITY "priority"
+#define STANZA_NAME_X "x"
 // XEP-0373: OpenPGP for XMPP
-#define STANZA_NAME_OPENPGP          "openpgp"
-#define STANZA_NAME_PUPKEY           "pubkey"
+#define STANZA_NAME_OPENPGP "openpgp"
+#define STANZA_NAME_PUPKEY "pubkey"
 #define STANZA_NAME_PUBLIC_KEYS_LIST "public-keys-list"
-#define STANZA_NAME_PUBKEY_METADATA  "pubkey-metadata"
-#define STANZA_NAME_DATA             "data"
-#define STANZA_NAME_SHOW             "show"
-#define STANZA_NAME_STATUS           "status"
-#define STANZA_NAME_IQ               "iq"
-#define STANZA_NAME_QUERY            "query"
-#define STANZA_NAME_REQUEST          "request"
-#define STANZA_NAME_DELAY            "delay"
-#define STANZA_NAME_ERROR            "error"
-#define STANZA_NAME_PING             "ping"
-#define STANZA_NAME_TEXT             "text"
-#define STANZA_NAME_SUBJECT          "subject"
-#define STANZA_NAME_ITEM             "item"
-#define STANZA_NAME_ITEMS            "items"
-#define STANZA_NAME_C                "c"
-#define STANZA_NAME_IDENTITY         "identity"
-#define STANZA_NAME_FEATURE          "feature"
-#define STANZA_NAME_INVITE           "invite"
-#define STANZA_NAME_REASON           "reason"
-#define STANZA_NAME_GROUP            "group"
-#define STANZA_NAME_PUBSUB           "pubsub"
-#define STANZA_NAME_PUBLISH          "publish"
-#define STANZA_NAME_PUBLISH_OPTIONS  "publish-options"
-#define STANZA_NAME_SUBSCRIBE        "subscribe"
-#define STANZA_NAME_FIELD            "field"
-#define STANZA_NAME_STORAGE          "storage"
-#define STANZA_NAME_NICK             "nick"
-#define STANZA_NAME_PASSWORD         "password"
-#define STANZA_NAME_CONFERENCE       "conference"
-#define STANZA_NAME_VALUE            "value"
-#define STANZA_NAME_DESTROY          "destroy"
-#define STANZA_NAME_ACTOR            "actor"
-#define STANZA_NAME_ENABLE           "enable"
-#define STANZA_NAME_DISABLE          "disable"
-#define STANZA_NAME_FILENAME         "filename"
-#define STANZA_NAME_SIZE             "size"
-#define STANZA_NAME_CONTENT_TYPE     "content-type"
-#define STANZA_NAME_SLOT             "slot"
-#define STANZA_NAME_PUT              "put"
-#define STANZA_NAME_GET              "get"
-#define STANZA_NAME_URL              "url"
-#define STANZA_NAME_COMMAND          "command"
-#define STANZA_NAME_CONFIGURE        "configure"
-#define STANZA_NAME_ORIGIN_ID        "origin-id"
-#define STANZA_NAME_MINIMIZE         "minimize"
+#define STANZA_NAME_PUBKEY_METADATA "pubkey-metadata"
+#define STANZA_NAME_DATA "data"
+#define STANZA_NAME_SHOW "show"
+#define STANZA_NAME_STATUS "status"
+#define STANZA_NAME_IQ "iq"
+#define STANZA_NAME_QUERY "query"
+#define STANZA_NAME_REQUEST "request"
+#define STANZA_NAME_DELAY "delay"
+#define STANZA_NAME_ERROR "error"
+#define STANZA_NAME_PING "ping"
+#define STANZA_NAME_TEXT "text"
+#define STANZA_NAME_SUBJECT "subject"
+#define STANZA_NAME_ITEM "item"
+#define STANZA_NAME_ITEMS "items"
+#define STANZA_NAME_C "c"
+#define STANZA_NAME_IDENTITY "identity"
+#define STANZA_NAME_FEATURE "feature"
+#define STANZA_NAME_INVITE "invite"
+#define STANZA_NAME_REASON "reason"
+#define STANZA_NAME_GROUP "group"
+#define STANZA_NAME_PUBSUB "pubsub"
+#define STANZA_NAME_PUBLISH "publish"
+#define STANZA_NAME_PUBLISH_OPTIONS "publish-options"
+#define STANZA_NAME_SUBSCRIBE "subscribe"
+#define STANZA_NAME_FIELD "field"
+#define STANZA_NAME_STORAGE "storage"
+#define STANZA_NAME_NICK "nick"
+#define STANZA_NAME_PASSWORD "password"
+#define STANZA_NAME_CONFERENCE "conference"
+#define STANZA_NAME_VALUE "value"
+#define STANZA_NAME_DESTROY "destroy"
+#define STANZA_NAME_ACTOR "actor"
+#define STANZA_NAME_ENABLE "enable"
+#define STANZA_NAME_DISABLE "disable"
+#define STANZA_NAME_FILENAME "filename"
+#define STANZA_NAME_SIZE "size"
+#define STANZA_NAME_CONTENT_TYPE "content-type"
+#define STANZA_NAME_SLOT "slot"
+#define STANZA_NAME_PUT "put"
+#define STANZA_NAME_GET "get"
+#define STANZA_NAME_URL "url"
+#define STANZA_NAME_COMMAND "command"
+#define STANZA_NAME_CONFIGURE "configure"
+#define STANZA_NAME_ORIGIN_ID "origin-id"
+#define STANZA_NAME_MINIMIZE "minimize"
 
 // error conditions
-#define STANZA_NAME_BAD_REQUEST             "bad-request"
-#define STANZA_NAME_CONFLICT                "conflict"
+#define STANZA_NAME_BAD_REQUEST "bad-request"
+#define STANZA_NAME_CONFLICT "conflict"
 #define STANZA_NAME_FEATURE_NOT_IMPLEMENTED "feature-not-implemented"
-#define STANZA_NAME_FORBIDDEN               "forbidden"
-#define STANZA_NAME_GONE                    "gone"
-#define STANZA_NAME_INTERNAL_SERVER_ERROR   "internal-server-error"
-#define STANZA_NAME_ITEM_NOT_FOUND          "item-not-found"
-#define STANZA_NAME_JID_MALFORMED           "jid-malformed"
-#define STANZA_NAME_NOT_ACCEPTABLE          "not-acceptable"
-#define STANZA_NAME_NOT_ALLOWED             "not-allowed"
-#define STANZA_NAME_NOT_AUTHORISED          "not-authorised"
-#define STANZA_NAME_POLICY_VIOLATION        "policy-violation"
-#define STANZA_NAME_RECIPIENT_UNAVAILABLE   "recipient-unavailable"
-#define STANZA_NAME_REDIRECT                "redirect"
-#define STANZA_NAME_REGISTRATION_REQUIRED   "registration-required"
+#define STANZA_NAME_FORBIDDEN "forbidden"
+#define STANZA_NAME_GONE "gone"
+#define STANZA_NAME_INTERNAL_SERVER_ERROR "internal-server-error"
+#define STANZA_NAME_ITEM_NOT_FOUND "item-not-found"
+#define STANZA_NAME_JID_MALFORMED "jid-malformed"
+#define STANZA_NAME_NOT_ACCEPTABLE "not-acceptable"
+#define STANZA_NAME_NOT_ALLOWED "not-allowed"
+#define STANZA_NAME_NOT_AUTHORISED "not-authorised"
+#define STANZA_NAME_POLICY_VIOLATION "policy-violation"
+#define STANZA_NAME_RECIPIENT_UNAVAILABLE "recipient-unavailable"
+#define STANZA_NAME_REDIRECT "redirect"
+#define STANZA_NAME_REGISTRATION_REQUIRED "registration-required"
 #define STANZA_NAME_REMOTE_SERVER_NOT_FOUND "remote-server-not-found"
-#define STANZA_NAME_REMOTE_SERVER_TIMEOUT   "remote-server-timeout"
-#define STANZA_NAME_RESOURCE_CONSTRAINT     "resource-constraint"
-#define STANZA_NAME_SERVICE_UNAVAILABLE     "service-unavailable"
-#define STANZA_NAME_SUBSCRIPTION_REQUIRED   "subscription-required"
-#define STANZA_NAME_UNDEFINED_CONDITION     "undefined-condition"
-#define STANZA_NAME_UNEXPECTED_REQUEST      "unexpected-request"
-
-#define STANZA_TYPE_CHAT         "chat"
-#define STANZA_TYPE_GROUPCHAT    "groupchat"
-#define STANZA_TYPE_HEADLINE     "headline"
-#define STANZA_TYPE_NORMAL       "normal"
-#define STANZA_TYPE_UNAVAILABLE  "unavailable"
-#define STANZA_TYPE_SUBSCRIBE    "subscribe"
-#define STANZA_TYPE_SUBSCRIBED   "subscribed"
+#define STANZA_NAME_REMOTE_SERVER_TIMEOUT "remote-server-timeout"
+#define STANZA_NAME_RESOURCE_CONSTRAINT "resource-constraint"
+#define STANZA_NAME_SERVICE_UNAVAILABLE "service-unavailable"
+#define STANZA_NAME_SUBSCRIPTION_REQUIRED "subscription-required"
+#define STANZA_NAME_UNDEFINED_CONDITION "undefined-condition"
+#define STANZA_NAME_UNEXPECTED_REQUEST "unexpected-request"
+
+#define STANZA_TYPE_CHAT "chat"
+#define STANZA_TYPE_GROUPCHAT "groupchat"
+#define STANZA_TYPE_HEADLINE "headline"
+#define STANZA_TYPE_NORMAL "normal"
+#define STANZA_TYPE_UNAVAILABLE "unavailable"
+#define STANZA_TYPE_SUBSCRIBE "subscribe"
+#define STANZA_TYPE_SUBSCRIBED "subscribed"
 #define STANZA_TYPE_UNSUBSCRIBED "unsubscribed"
-#define STANZA_TYPE_GET          "get"
-#define STANZA_TYPE_SET          "set"
-#define STANZA_TYPE_ERROR        "error"
-#define STANZA_TYPE_RESULT       "result"
-
-#define STANZA_ATTR_TO             "to"
-#define STANZA_ATTR_FROM           "from"
-#define STANZA_ATTR_STAMP          "stamp"
-#define STANZA_ATTR_TYPE           "type"
-#define STANZA_ATTR_CODE           "code"
-#define STANZA_ATTR_JID            "jid"
-#define STANZA_ATTR_NAME           "name"
-#define STANZA_ATTR_SUBSCRIPTION   "subscription"
-#define STANZA_ATTR_XMLNS          "xmlns"
-#define STANZA_ATTR_NICK           "nick"
-#define STANZA_ATTR_ASK            "ask"
-#define STANZA_ATTR_ID             "id"
-#define STANZA_ATTR_SECONDS        "seconds"
-#define STANZA_ATTR_NODE           "node"
-#define STANZA_ATTR_VER            "ver"
-#define STANZA_ATTR_VAR            "var"
-#define STANZA_ATTR_HASH           "hash"
-#define STANZA_ATTR_CATEGORY       "category"
-#define STANZA_ATTR_REASON         "reason"
-#define STANZA_ATTR_AUTOJOIN       "autojoin"
-#define STANZA_ATTR_PASSWORD       "password"
-#define STANZA_ATTR_STATUS         "status"
-#define STANZA_ATTR_DATE           "date"
+#define STANZA_TYPE_GET "get"
+#define STANZA_TYPE_SET "set"
+#define STANZA_TYPE_ERROR "error"
+#define STANZA_TYPE_RESULT "result"
+
+#define STANZA_ATTR_TO "to"
+#define STANZA_ATTR_FROM "from"
+#define STANZA_ATTR_STAMP "stamp"
+#define STANZA_ATTR_TYPE "type"
+#define STANZA_ATTR_CODE "code"
+#define STANZA_ATTR_JID "jid"
+#define STANZA_ATTR_NAME "name"
+#define STANZA_ATTR_SUBSCRIPTION "subscription"
+#define STANZA_ATTR_XMLNS "xmlns"
+#define STANZA_ATTR_NICK "nick"
+#define STANZA_ATTR_ASK "ask"
+#define STANZA_ATTR_ID "id"
+#define STANZA_ATTR_SECONDS "seconds"
+#define STANZA_ATTR_NODE "node"
+#define STANZA_ATTR_VER "ver"
+#define STANZA_ATTR_VAR "var"
+#define STANZA_ATTR_HASH "hash"
+#define STANZA_ATTR_CATEGORY "category"
+#define STANZA_ATTR_REASON "reason"
+#define STANZA_ATTR_AUTOJOIN "autojoin"
+#define STANZA_ATTR_PASSWORD "password"
+#define STANZA_ATTR_STATUS "status"
+#define STANZA_ATTR_DATE "date"
 #define STANZA_ATTR_V4_FINGERPRINT "v4-fingerprint"
 
-#define STANZA_TEXT_AWAY   "away"
-#define STANZA_TEXT_DND    "dnd"
-#define STANZA_TEXT_CHAT   "chat"
-#define STANZA_TEXT_XA     "xa"
+
+#define STANZA_TEXT_AWAY "away"
+#define STANZA_TEXT_DND "dnd"
+#define STANZA_TEXT_CHAT "chat"
+#define STANZA_TEXT_XA "xa"
 #define STANZA_TEXT_ONLINE "online"
 
-#define STANZA_NS_STANZAS      "urn:ietf:params:xml:ns:xmpp-stanzas"
-#define STANZA_NS_CHATSTATES   "http://jabber.org/protocol/chatstates"
-#define STANZA_NS_MUC          "http://jabber.org/protocol/muc"
-#define STANZA_NS_MUC_USER     "http://jabber.org/protocol/muc#user"
-#define STANZA_NS_MUC_OWNER    "http://jabber.org/protocol/muc#owner"
-#define STANZA_NS_MUC_ADMIN    "http://jabber.org/protocol/muc#admin"
-#define STANZA_NS_CAPS         "http://jabber.org/protocol/caps"
-#define STANZA_NS_PING         "urn:xmpp:ping"
+#define STANZA_NS_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"
+#define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates"
+#define STANZA_NS_MUC "http://jabber.org/protocol/muc"
+#define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user"
+#define STANZA_NS_MUC_OWNER "http://jabber.org/protocol/muc#owner"
+#define STANZA_NS_MUC_ADMIN "http://jabber.org/protocol/muc#admin"
+#define STANZA_NS_CAPS "http://jabber.org/protocol/caps"
+#define STANZA_NS_PING "urn:xmpp:ping"
 #define STANZA_NS_LASTACTIVITY "jabber:iq:last"
-#define STANZA_NS_DATA         "jabber:x:data"
-#define STANZA_NS_VERSION      "jabber:iq:version"
-#define STANZA_NS_CONFERENCE   "jabber:x:conference"
-#define STANZA_NS_CAPTCHA      "urn:xmpp:captcha"
-#define STANZA_NS_PUBSUB       "http://jabber.org/protocol/pubsub"
+#define STANZA_NS_DATA "jabber:x:data"
+#define STANZA_NS_VERSION "jabber:iq:version"
+#define STANZA_NS_CONFERENCE "jabber:x:conference"
+#define STANZA_NS_CAPTCHA "urn:xmpp:captcha"
+#define STANZA_NS_PUBSUB "http://jabber.org/protocol/pubsub"
 #define STANZA_NS_PUBSUB_OWNER "http://jabber.org/protocol/pubsub#owner"
 #define STANZA_NS_PUBSUB_EVENT "http://jabber.org/protocol/pubsub#event"
-#define STANZA_NS_CARBONS      "urn:xmpp:carbons:2"
-#define STANZA_NS_HINTS        "urn:xmpp:hints"
-#define STANZA_NS_FORWARD      "urn:xmpp:forward:0"
-#define STANZA_NS_RECEIPTS     "urn:xmpp:receipts"
-#define STANZA_NS_SIGNED       "jabber:x:signed"
-#define STANZA_NS_ENCRYPTED    "jabber:x:encrypted"
+#define STANZA_NS_CARBONS "urn:xmpp:carbons:2"
+#define STANZA_NS_HINTS "urn:xmpp:hints"
+#define STANZA_NS_FORWARD "urn:xmpp:forward:0"
+#define STANZA_NS_RECEIPTS "urn:xmpp:receipts"
+#define STANZA_NS_SIGNED "jabber:x:signed"
+#define STANZA_NS_ENCRYPTED "jabber:x:encrypted"
 // XEP-0373: OpenPGP for XMPP
-#define STANZA_NS_OPENPGP_0               "urn:xmpp:openpgp:0"
-#define STANZA_NS_OPENPGP_0_PUBLIC_KEYS   "urn:xmpp:openpgp:0:public-keys"
-#define STANZA_NS_HTTP_UPLOAD             "urn:xmpp:http:upload"
-#define STANZA_NS_X_OOB                   "jabber:x:oob"
-#define STANZA_NS_BLOCKING                "urn:xmpp:blocking"
-#define STANZA_NS_COMMAND                 "http://jabber.org/protocol/commands"
-#define STANZA_NS_OMEMO                   "eu.siacs.conversations.axolotl"
-#define STANZA_NS_OMEMO_DEVICELIST        "eu.siacs.conversations.axolotl.devicelist"
-#define STANZA_NS_OMEMO_BUNDLES           "eu.siacs.conversations.axolotl.bundles"
-#define STANZA_NS_STABLE_ID               "urn:xmpp:sid:0"
-#define STANZA_NS_USER_AVATAR_DATA        "urn:xmpp:avatar:data"
-#define STANZA_NS_USER_AVATAR_METADATA    "urn:xmpp:avatar:metadata"
+#define STANZA_NS_OPENPGP_0 "urn:xmpp:openpgp:0"
+#define STANZA_NS_OPENPGP_0_PUBLIC_KEYS "urn:xmpp:openpgp:0:public-keys"
+#define STANZA_NS_HTTP_UPLOAD "urn:xmpp:http:upload"
+#define STANZA_NS_X_OOB "jabber:x:oob"
+#define STANZA_NS_BLOCKING "urn:xmpp:blocking"
+#define STANZA_NS_COMMAND "http://jabber.org/protocol/commands"
+#define STANZA_NS_OMEMO "eu.siacs.conversations.axolotl"
+#define STANZA_NS_OMEMO_DEVICELIST "eu.siacs.conversations.axolotl.devicelist"
+#define STANZA_NS_OMEMO_BUNDLES "eu.siacs.conversations.axolotl.bundles"
+#define STANZA_NS_STABLE_ID "urn:xmpp:sid:0"
+#define STANZA_NS_USER_AVATAR_DATA "urn:xmpp:avatar:data"
+#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata"
 #define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
-#define STANZA_NS_MAM2                    "urn:xmpp:mam:2"
-#define STANZA_NS_EXT_GAJIM_BOOKMARKS     "xmpp:gajim.org/bookmarks"
+#define STANZA_NS_MAM2 "urn:xmpp:mam:2"
+#define STANZA_NS_EXT_GAJIM_BOOKMARKS "xmpp:gajim.org/bookmarks"
 
 #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
 
-typedef struct caps_stanza_t
-{
-    char* hash;
-    char* node;
-    char* ver;
+typedef struct caps_stanza_t {
+    char *hash;
+    char *node;
+    char *ver;
 } XMPPCaps;
 
-typedef struct presence_stanza_t
-{
-    Jid* jid;
-    char* show;
-    char* status;
+typedef struct presence_stanza_t {
+    Jid *jid;
+    char *show;
+    char *status;
     int priority;
-    GDateTime* last_activity;
+    GDateTime *last_activity;
 } XMPPPresence;
 
 typedef enum {
@@ -242,141 +241,141 @@ typedef enum {
     STANZA_PARSE_ERROR_INVALID_FROM
 } stanza_parse_error_t;
 
-xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t* ctx);
+xmpp_stanza_t* stanza_create_bookmarks_storage_request(xmpp_ctx_t *ctx);
 
-xmpp_stanza_t* stanza_create_blocked_list_request(xmpp_ctx_t* ctx);
+xmpp_stanza_t* stanza_create_blocked_list_request(xmpp_ctx_t *ctx);
 
-xmpp_stanza_t* stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, HTTPUpload* upload);
+xmpp_stanza_t* stanza_create_http_upload_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, HTTPUpload *upload);
 
-xmpp_stanza_t* stanza_enable_carbons(xmpp_ctx_t* ctx);
+xmpp_stanza_t* stanza_enable_carbons(xmpp_ctx_t *ctx);
 
-xmpp_stanza_t* stanza_disable_carbons(xmpp_ctx_t* ctx);
+xmpp_stanza_t* stanza_disable_carbons(xmpp_ctx_t *ctx);
 
-xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t* ctx,
-                                        const char* const fulljid, const char* const state);
+xmpp_stanza_t* stanza_create_chat_state(xmpp_ctx_t *ctx,
+    const char *const fulljid, const char *const state);
 
-xmpp_stanza_t* stanza_attach_state(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const state);
-xmpp_stanza_t* stanza_attach_carbons_private(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
-xmpp_stanza_t* stanza_attach_hints_no_copy(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
-xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
-xmpp_stanza_t* stanza_attach_hints_store(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
-xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza);
-xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const url);
-xmpp_stanza_t* stanza_attach_origin_id(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const id);
-xmpp_stanza_t* stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* const replace_id);
+xmpp_stanza_t* stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const state);
+xmpp_stanza_t* stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_hints_no_copy(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_hints_no_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_hints_store(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza);
+xmpp_stanza_t* stanza_attach_x_oob_url(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const url);
+xmpp_stanza_t* stanza_attach_origin_id(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const id);
+xmpp_stanza_t* stanza_attach_correction(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, const char *const replace_id);
 
-xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t* const ctx,
-                                                const char* const full_room_jid, const char* const passwd);
+xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t *const ctx,
+    const char *const full_room_jid, const char *const passwd);
 
-xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t* ctx,
-                                                   const char* const full_room_jid);
+xmpp_stanza_t* stanza_create_room_newnick_presence(xmpp_ctx_t *ctx,
+    const char *const full_room_jid);
 
-xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t* ctx,
-                                                 const char* const room, const char* const nick);
+xmpp_stanza_t* stanza_create_room_leave_presence(xmpp_ctx_t *ctx,
+    const char *const room, const char *const nick);
 
-xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t* ctx);
-xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t* ctx, const char* const target);
-xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t* ctx, const char* const id,
-                                           const char* const to, const char* const node);
+xmpp_stanza_t* stanza_create_roster_iq(xmpp_ctx_t *ctx);
+xmpp_stanza_t* stanza_create_ping_iq(xmpp_ctx_t *ctx, const char *const target);
+xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char *const id,
+    const char *const to, const char *const node);
 
-xmpp_stanza_t* stanza_create_last_activity_iq(xmpp_ctx_t* ctx, const char* const id,
-                                              const char* const to);
+xmpp_stanza_t* stanza_create_last_activity_iq(xmpp_ctx_t *ctx, const char *const id,
+    const char *const to);
 
-xmpp_stanza_t* stanza_create_invite(xmpp_ctx_t* ctx, const char* const room,
-                                    const char* const contact, const char* const reason, const char* const password);
-xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t* ctx, const char* const room,
-                                             const char* const contact, const char* const reason);
+xmpp_stanza_t* stanza_create_invite(xmpp_ctx_t *ctx, const char *const room,
+    const char *const contact, const char *const reason, const char *const password);
+xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
+    const char *const contact, const char *const reason);
 
-gboolean stanza_contains_chat_state(xmpp_stanza_t* stanza);
+gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza);
 
-GDateTime* stanza_get_delay(xmpp_stanza_t* const stanza);
-GDateTime* stanza_get_delay_from(xmpp_stanza_t* const stanza, gchar* from);
-GDateTime* stanza_get_oldest_delay(xmpp_stanza_t* const stanza);
+GDateTime* stanza_get_delay(xmpp_stanza_t *const stanza);
+GDateTime* stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from);
+GDateTime* stanza_get_oldest_delay(xmpp_stanza_t *const stanza);
 
-gboolean stanza_is_muc_presence(xmpp_stanza_t* const stanza);
-gboolean stanza_is_muc_self_presence(xmpp_stanza_t* const stanza,
-                                     const char* const self_jid);
-gboolean stanza_is_room_nick_change(xmpp_stanza_t* const stanza);
-gboolean stanza_muc_requires_config(xmpp_stanza_t* const stanza);
+gboolean stanza_is_muc_presence(xmpp_stanza_t *const stanza);
+gboolean stanza_is_muc_self_presence(xmpp_stanza_t *const stanza,
+    const char *const self_jid);
+gboolean stanza_is_room_nick_change(xmpp_stanza_t *const stanza);
+gboolean stanza_muc_requires_config(xmpp_stanza_t *const stanza);
 
-const char* stanza_get_new_nick(xmpp_stanza_t* const stanza);
-xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t* ctx, const char* const room_jid);
-xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t* ctx, const char* const room_jid);
-xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t* ctx, const char* const room_jid);
-xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t* ctx, const char* const room_jid);
-xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, DataForm* form);
-xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t* ctx, const char* const room,
-                                                      const char* const affiliation);
-xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t* ctx, const char* const room, const char* const jid,
-                                                     const char* const affiliation, const char* const reason);
-xmpp_stanza_t* stanza_create_room_role_set_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const jid,
-                                              const char* const role, const char* const reason);
-xmpp_stanza_t* stanza_create_room_role_list_iq(xmpp_ctx_t* ctx, const char* const room, const char* const role);
+const char* stanza_get_new_nick(xmpp_stanza_t *const stanza);
+xmpp_stanza_t* stanza_create_instant_room_request_iq(xmpp_ctx_t *ctx, const char *const room_jid);
+xmpp_stanza_t* stanza_create_instant_room_destroy_iq(xmpp_ctx_t *ctx, const char *const room_jid);
+xmpp_stanza_t* stanza_create_room_config_request_iq(xmpp_ctx_t *ctx, const char *const room_jid);
+xmpp_stanza_t* stanza_create_room_config_cancel_iq(xmpp_ctx_t *ctx, const char *const room_jid);
+xmpp_stanza_t* stanza_create_room_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, DataForm *form);
+xmpp_stanza_t* stanza_create_room_affiliation_list_iq(xmpp_ctx_t *ctx, const char *const room,
+    const char *const affiliation);
+xmpp_stanza_t* stanza_create_room_affiliation_set_iq(xmpp_ctx_t *ctx, const char *const room, const char *const jid,
+    const char *const affiliation, const char *const reason);
+xmpp_stanza_t* stanza_create_room_role_set_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const jid,
+    const char *const role, const char *const reason);
+xmpp_stanza_t* stanza_create_room_role_list_iq(xmpp_ctx_t *ctx, const char *const room, const char *const role);
 
-xmpp_stanza_t* stanza_create_room_subject_message(xmpp_ctx_t* ctx, const char* const room, const char* const subject);
-xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t* const ctx, const char* const room, const char* const nick,
-                                          const char* const reason);
+xmpp_stanza_t* stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject);
+xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *const room, const char *const nick,
+    const char *const reason);
 
-xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t* ctx, const char* const target, const char* const node);
-xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t* ctx, const char* const room, const char* const node, const char* const sessionid, DataForm* form);
+xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, const char *const node);
+xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, const char *const node, const char *const sessionid, DataForm *form);
 
-void stanza_attach_publish_options(xmpp_ctx_t* const ctx, xmpp_stanza_t* const publish, const char* const option, const char* const value);
+void stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const publish, const char *const option, const char *const value);
 
-xmpp_stanza_t* stanza_create_omemo_devicelist_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid);
-xmpp_stanza_t* stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t* ctx, const char* const jid);
-xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t* ctx, GList* const ids);
-xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t* ctx, const char* const id, uint32_t device_id, const unsigned char* const identity_key, size_t identity_key_length, const unsigned char* const signed_prekey, size_t signed_prekey_length, const unsigned char* const signed_prekey_signature, size_t signed_prekey_signature_length, GList* const prekeys, GList* const prekeys_id, GList* const prekeys_length);
-xmpp_stanza_t* stanza_create_omemo_bundle_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, uint32_t device_id);
+xmpp_stanza_t* stanza_create_omemo_devicelist_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid);
+xmpp_stanza_t* stanza_create_omemo_devicelist_subscribe(xmpp_ctx_t *ctx, const char *const jid);
+xmpp_stanza_t* stanza_create_omemo_devicelist_publish(xmpp_ctx_t *ctx, GList *const ids);
+xmpp_stanza_t* stanza_create_omemo_bundle_publish(xmpp_ctx_t *ctx, const char *const id, uint32_t device_id, const unsigned char * const identity_key, size_t identity_key_length, const unsigned char * const signed_prekey, size_t signed_prekey_length, const unsigned char * const signed_prekey_signature, size_t signed_prekey_signature_length, GList *const prekeys, GList *const prekeys_id, GList *const prekeys_length);
+xmpp_stanza_t* stanza_create_omemo_bundle_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, uint32_t device_id);
 
-xmpp_stanza_t* stanza_create_pubsub_configure_request(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node);
-xmpp_stanza_t* stanza_create_pubsub_configure_submit(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node, DataForm* form);
+xmpp_stanza_t* stanza_create_pubsub_configure_request(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node);
+xmpp_stanza_t* stanza_create_pubsub_configure_submit(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node, DataForm *form);
 
-int stanza_get_idle_time(xmpp_stanza_t* const stanza);
+int stanza_get_idle_time(xmpp_stanza_t *const stanza);
 
-void stanza_attach_priority(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int pri);
-void stanza_attach_last_activity(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const int idle);
-void stanza_attach_caps(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence);
-void stanza_attach_show(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const char* const show);
-void stanza_attach_status(xmpp_ctx_t* const ctx, xmpp_stanza_t* const presence, const char* const status);
+void stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri);
+void stanza_attach_last_activity(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int idle);
+void stanza_attach_caps(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence);
+void stanza_attach_show(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const show);
+void stanza_attach_status(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const char *const status);
 
-xmpp_stanza_t* stanza_create_caps_query_element(xmpp_ctx_t* ctx);
-char* stanza_create_caps_sha1_from_query(xmpp_stanza_t* const query);
-EntityCapabilities* stanza_create_caps_from_query_element(xmpp_stanza_t* query);
+xmpp_stanza_t* stanza_create_caps_query_element(xmpp_ctx_t *ctx);
+char* stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query);
+EntityCapabilities* stanza_create_caps_from_query_element(xmpp_stanza_t *query);
 
 const char* stanza_get_presence_string_from_type(resource_presence_t presence_type);
-xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t* ctx, const char* const fulljid);
-xmpp_stanza_t* stanza_create_disco_items_iq(xmpp_ctx_t* ctx, const char* const id, const char* const jid, const char* const node);
+xmpp_stanza_t* stanza_create_software_version_iq(xmpp_ctx_t *ctx, const char *const fulljid);
+xmpp_stanza_t* stanza_create_disco_items_iq(xmpp_ctx_t *ctx, const char *const id, const char *const jid, const char *const node);
 
-char* stanza_get_status(xmpp_stanza_t* stanza, char* def);
-char* stanza_get_show(xmpp_stanza_t* stanza, char* def);
+char* stanza_get_status(xmpp_stanza_t *stanza, char *def);
+char* stanza_get_show(xmpp_stanza_t *stanza, char *def);
 
-xmpp_stanza_t* stanza_create_roster_set(xmpp_ctx_t* ctx, const char* const id, const char* const jid,
-                                        const char* const handle, GSList* groups);
-xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t* ctx, const char* const barejid);
+xmpp_stanza_t* stanza_create_roster_set(xmpp_ctx_t *ctx, const char *const id, const char *const jid,
+    const char *const handle, GSList *groups);
+xmpp_stanza_t* stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char *const barejid);
 
-char* stanza_get_error_message(xmpp_stanza_t* const stanza);
+char* stanza_get_error_message(xmpp_stanza_t *const stanza);
 
-GSList* stanza_get_status_codes_by_ns(xmpp_stanza_t* const stanza, char* ns);
-gboolean stanza_room_destroyed(xmpp_stanza_t* stanza);
-const char* stanza_get_muc_destroy_alternative_room(xmpp_stanza_t* stanza);
-char* stanza_get_muc_destroy_alternative_password(xmpp_stanza_t* stanza);
-char* stanza_get_muc_destroy_reason(xmpp_stanza_t* stanza);
-const char* stanza_get_actor(xmpp_stanza_t* stanza);
-char* stanza_get_reason(xmpp_stanza_t* stanza);
+GSList* stanza_get_status_codes_by_ns(xmpp_stanza_t *const stanza, char *ns);
+gboolean stanza_room_destroyed(xmpp_stanza_t *stanza);
+const char* stanza_get_muc_destroy_alternative_room(xmpp_stanza_t *stanza);
+char* stanza_get_muc_destroy_alternative_password(xmpp_stanza_t *stanza);
+char* stanza_get_muc_destroy_reason(xmpp_stanza_t *stanza);
+const char* stanza_get_actor(xmpp_stanza_t *stanza);
+char* stanza_get_reason(xmpp_stanza_t *stanza);
 
-Resource* stanza_resource_from_presence(XMPPPresence* presence);
-XMPPPresence* stanza_parse_presence(xmpp_stanza_t* stanza, int* err);
-void stanza_free_presence(XMPPPresence* presence);
+Resource* stanza_resource_from_presence(XMPPPresence *presence);
+XMPPPresence* stanza_parse_presence(xmpp_stanza_t *stanza, int *err);
+void stanza_free_presence(XMPPPresence *presence);
 
-char* stanza_text_strdup(xmpp_stanza_t* stanza);
+char* stanza_text_strdup(xmpp_stanza_t *stanza);
 
-XMPPCaps* stanza_parse_caps(xmpp_stanza_t* const stanza);
-void stanza_free_caps(XMPPCaps* caps);
+XMPPCaps* stanza_parse_caps(xmpp_stanza_t *const stanza);
+void stanza_free_caps(XMPPCaps *caps);
 
-xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t* const stanza, const char* const name, const char* const ns);
+xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns);
 
-xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid);
+xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t *ctx, const char *stanza_id, const char *const item_id, const char *const jid);
 
-xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate);
+xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t *ctx, const char *const jid, const char *const startdate);
 
 #endif
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index da98048a..c097387b 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -58,18 +58,18 @@
 #define JABBER_PRIORITY_MIN -128
 #define JABBER_PRIORITY_MAX 127
 
-#define XMPP_FEATURE_PING                        "urn:xmpp:ping"
-#define XMPP_FEATURE_BLOCKING                    "urn:xmpp:blocking"
-#define XMPP_FEATURE_RECEIPTS                    "urn:xmpp:receipts"
-#define XMPP_FEATURE_LASTACTIVITY                "jabber:iq:last"
-#define XMPP_FEATURE_MUC                         "http://jabber.org/protocol/muc"
-#define XMPP_FEATURE_COMMANDS                    "http://jabber.org/protocol/commands"
-#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY     "eu.siacs.conversations.axolotl.devicelist+notify"
-#define XMPP_FEATURE_PUBSUB                      "http://jabber.org/protocol/pubsub"
-#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS      "http://jabber.org/protocol/pubsub#publish-options"
+#define XMPP_FEATURE_PING "urn:xmpp:ping"
+#define XMPP_FEATURE_BLOCKING "urn:xmpp:blocking"
+#define XMPP_FEATURE_RECEIPTS "urn:xmpp:receipts"
+#define XMPP_FEATURE_LASTACTIVITY "jabber:iq:last"
+#define XMPP_FEATURE_MUC "http://jabber.org/protocol/muc"
+#define XMPP_FEATURE_COMMANDS "http://jabber.org/protocol/commands"
+#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY "eu.siacs.conversations.axolotl.devicelist+notify"
+#define XMPP_FEATURE_PUBSUB "http://jabber.org/protocol/pubsub"
+#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS "http://jabber.org/protocol/pubsub#publish-options"
 #define XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY "urn:xmpp:avatar:metadata+notify"
-#define XMPP_FEATURE_LAST_MESSAGE_CORRECTION     "urn:xmpp:message-correct:0"
-#define XMPP_FEATURE_MAM2                        "urn:xmpp:mam:2"
+#define XMPP_FEATURE_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
+#define XMPP_FEATURE_MAM2 "urn:xmpp:mam:2"
 
 typedef enum {
     JABBER_CONNECTING,
@@ -89,42 +89,37 @@ typedef enum {
     INVITE_MEDIATED
 } jabber_invite_t;
 
-typedef struct bookmark_t
-{
-    char* barejid;
-    char* nick;
-    char* password;
-    char* name;
+typedef struct bookmark_t {
+    char *barejid;
+    char *nick;
+    char *password;
+    char *name;
     gboolean autojoin;
     int ext_gajim_minimize; //0 - non existant, 1 - true, 2 - false
 } Bookmark;
 
-typedef struct disco_identity_t
-{
-    char* name;
-    char* type;
-    char* category;
+typedef struct disco_identity_t {
+    char *name;
+    char *type;
+    char *category;
 } DiscoIdentity;
 
-typedef struct software_version_t
-{
-    char* software;
-    char* software_version;
-    char* os;
-    char* os_version;
+typedef struct software_version_t {
+    char *software;
+    char *software_version;
+    char *os;
+    char *os_version;
 } SoftwareVersion;
 
-typedef struct entity_capabilities_t
-{
-    DiscoIdentity* identity;
-    SoftwareVersion* software_version;
-    GSList* features;
+typedef struct entity_capabilities_t {
+    DiscoIdentity *identity;
+    SoftwareVersion *software_version;
+    GSList *features;
 } EntityCapabilities;
 
-typedef struct disco_item_t
-{
-    char* jid;
-    char* name;
+typedef struct disco_item_t {
+    char *jid;
+    char *name;
 } DiscoItem;
 
 typedef enum {
@@ -145,156 +140,155 @@ typedef enum {
     PROF_MSG_TYPE_MUCPM
 } prof_msg_type_t;
 
-typedef struct prof_message_t
-{
-    Jid* from_jid;
-    Jid* to_jid;
-    /* regular <message id=""> */
-    char* id;
-    /* </origin-id> XEP-0359 */
-    char* originid;
-    /* <replace id> XEP-0308 LMC */
-    char* replace_id;
-    /* for MAM we will need archive_id (stanza-id in XEP-0359) (see database.c) */
-    /* The raw body from xmpp message, either plaintext or OTR encrypted text */
-    char* body;
-    /* The encrypted message as for PGP */
-    char* encrypted;
-    /* The message that will be printed on screen and logs */
-    char* plain;
-    GDateTime* timestamp;
-    prof_enc_t enc;
-    gboolean trusted;
-    gboolean is_mam;
-    prof_msg_type_t type;
+typedef struct prof_message_t {
+   Jid *from_jid;
+   Jid *to_jid;
+   /* regular <message id=""> */
+   char *id;
+   /* </origin-id> XEP-0359 */
+   char *originid;
+   /* <replace id> XEP-0308 LMC */
+   char *replace_id;
+   /* for MAM we will need archive_id (stanza-id in XEP-0359) (see database.c) */
+   /* The raw body from xmpp message, either plaintext or OTR encrypted text */
+   char *body;
+   /* The encrypted message as for PGP */
+   char *encrypted;
+   /* The message that will be printed on screen and logs */
+   char *plain;
+   GDateTime *timestamp;
+   prof_enc_t enc;
+   gboolean trusted;
+   gboolean is_mam;
+   prof_msg_type_t type;
 } ProfMessage;
 
 void session_init(void);
-jabber_conn_status_t session_connect_with_details(const char* const jid, const char* const passwd,
-                                                  const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
-jabber_conn_status_t session_connect_with_account(const ProfAccount* const account);
+jabber_conn_status_t session_connect_with_details(const char *const jid, const char *const passwd,
+    const char *const altdomain, const int port, const char *const tls_policy, const char *const auth_policy);
+jabber_conn_status_t session_connect_with_account(const ProfAccount *const account);
 void session_disconnect(void);
 void session_shutdown(void);
 void session_process_events(void);
 char* session_get_account_name(void);
 
 jabber_conn_status_t connection_get_status(void);
-char* connection_get_presence_msg(void);
-void connection_set_presence_msg(const char* const message);
+char *connection_get_presence_msg(void);
+void connection_set_presence_msg(const char *const message);
 const char* connection_get_fulljid(void);
 char* connection_get_barejid(void);
 char* connection_create_uuid(void);
-void connection_free_uuid(char* uuid);
+void connection_free_uuid(char *uuid);
 #ifdef HAVE_LIBMESODE
 TLSCertificate* connection_get_tls_peer_cert(void);
 #endif
 gboolean connection_is_secured(void);
-gboolean connection_send_stanza(const char* const stanza);
+gboolean connection_send_stanza(const char *const stanza);
 GList* connection_get_available_resources(void);
-gboolean connection_supports(const char* const feature);
-char* connection_jid_for_feature(const char* const feature);
+gboolean connection_supports(const char *const feature);
+char* connection_jid_for_feature(const char *const feature);
 
 const char* connection_get_profanity_identifier(void);
 
-char* message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id);
-char* message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
-char* message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
+char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id);
+char* message_send_chat_otr(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id);
+char* message_send_chat_pgp(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id);
 // XEP-0373: OpenPGP for XMPP
-char* message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id);
-char* message_send_chat_omemo(const char* const jid, uint32_t sid, GList* keys, const unsigned char* const iv, size_t iv_len, const unsigned char* const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc, const char* const replace_id);
-char* message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url);
-char* message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id);
-void message_send_groupchat_subject(const char* const roomjid, const char* const subject);
-void message_send_inactive(const char* const jid);
-void message_send_composing(const char* const jid);
-void message_send_paused(const char* const jid);
-void message_send_gone(const char* const jid);
-void message_send_invite(const char* const room, const char* const contact, const char* const reason);
-
-bool message_is_sent_by_us(const ProfMessage* const message, bool checkOID);
-
-void presence_subscription(const char* const jid, const jabber_subscr_t action);
+char* message_send_chat_ox(const char *const barejid, const char *const msg, gboolean request_receipt, const char *const replace_id);
+char* message_send_chat_omemo(const char *const jid, uint32_t sid, GList *keys, const unsigned char *const iv, size_t iv_len, const unsigned char *const ciphertext, size_t ciphertext_len, gboolean request_receipt, gboolean muc, const char *const replace_id);
+char* message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url);
+char* message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id);
+void message_send_groupchat_subject(const char *const roomjid, const char *const subject);
+void message_send_inactive(const char *const jid);
+void message_send_composing(const char *const jid);
+void message_send_paused(const char *const jid);
+void message_send_gone(const char *const jid);
+void message_send_invite(const char *const room, const char *const contact, const char *const reason);
+
+bool message_is_sent_by_us(const ProfMessage *const message, bool checkOID);
+
+void presence_subscription(const char *const jid, const jabber_subscr_t action);
 GList* presence_get_subscription_requests(void);
 gint presence_sub_request_count(void);
 void presence_reset_sub_request_search(void);
-char* presence_sub_request_find(const char* const search_str, gboolean previous, void* context);
-void presence_join_room(const char* const room, const char* const nick, const char* const passwd);
-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_send(resource_presence_t status, int idle, char* signed_status);
-gboolean presence_sub_request_exists(const char* const bare_jid);
+char* presence_sub_request_find(const char *const search_str, gboolean previous, void *context);
+void presence_join_room(const char *const room, const char *const nick, const char *const passwd);
+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_send(resource_presence_t status, int idle, char *signed_status);
+gboolean presence_sub_request_exists(const char *const bare_jid);
 
 void iq_enable_carbons(void);
 void iq_disable_carbons(void);
-void iq_send_software_version(const char* const fulljid);
+void iq_send_software_version(const char *const fulljid);
 void iq_rooms_cache_clear(void);
 void iq_handlers_clear();
-void iq_room_list_request(gchar* conferencejid, gchar* filter);
-void iq_disco_info_request(gchar* jid);
-void iq_disco_items_request(gchar* jid);
-void iq_last_activity_request(gchar* jid);
+void iq_room_list_request(gchar *conferencejid, gchar *filter);
+void iq_disco_info_request(gchar *jid);
+void iq_disco_items_request(gchar *jid);
+void iq_last_activity_request(gchar *jid);
 void iq_set_autoping(int seconds);
-void iq_confirm_instant_room(const char* const room_jid);
-void iq_destroy_room(const char* const room_jid);
-void iq_request_room_config_form(const char* const room_jid);
-void iq_submit_room_config(ProfConfWin* confwin);
-void iq_room_config_cancel(ProfConfWin* confwin);
-void iq_send_ping(const char* const target);
-void iq_room_info_request(const char* const room, gboolean display_result);
-void iq_room_affiliation_list(const char* const room, char* affiliation, bool show);
-void iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation,
-                             const char* const reason);
-void iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason);
-void iq_room_role_set(const char* const room, const char* const nick, char* role, const char* const reason);
-void iq_room_role_list(const char* const room, char* role);
+void iq_confirm_instant_room(const char *const room_jid);
+void iq_destroy_room(const char *const room_jid);
+void iq_request_room_config_form(const char *const room_jid);
+void iq_submit_room_config(ProfConfWin *confwin);
+void iq_room_config_cancel(ProfConfWin *confwin);
+void iq_send_ping(const char *const target);
+void iq_room_info_request(const char *const room, gboolean display_result);
+void iq_room_affiliation_list(const char *const room, char *affiliation, bool show);
+void iq_room_affiliation_set(const char *const room, const char *const jid, char *affiliation,
+    const char *const reason);
+void iq_room_kick_occupant(const char *const room, const char *const nick, const char *const reason);
+void iq_room_role_set(const char *const room, const char *const nick, char *role, const char *const reason);
+void iq_room_role_list(const char * const room, char *role);
 void iq_autoping_timer_cancel(void);
 void iq_autoping_check(void);
-void iq_http_upload_request(HTTPUpload* upload);
-void iq_command_list(const char* const target);
-void iq_command_exec(const char* const target, const char* const command);
-void iq_mam_request(ProfChatWin* win);
+void iq_http_upload_request(HTTPUpload *upload);
+void iq_command_list(const char *const target);
+void iq_command_exec(const char *const target, const char *const command);
+void iq_mam_request(ProfChatWin *win);
 
-EntityCapabilities* caps_lookup(const char* const jid);
+EntityCapabilities* caps_lookup(const char *const jid);
 void caps_close(void);
-void caps_destroy(EntityCapabilities* caps);
+void caps_destroy(EntityCapabilities *caps);
 void caps_reset_ver(void);
-void caps_add_feature(char* feature);
-void caps_remove_feature(char* feature);
-gboolean caps_jid_has_feature(const char* const jid, const char* const feature);
-
-gboolean bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name);
-gboolean bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name);
-gboolean bookmark_remove(const char* jid);
-gboolean bookmark_join(const char* jid);
+void caps_add_feature(char *feature);
+void caps_remove_feature(char *feature);
+gboolean caps_jid_has_feature(const char *const jid, const char *const feature);
+
+gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name);
+gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name);
+gboolean bookmark_remove(const char *jid);
+gboolean bookmark_join(const char *jid);
 GList* bookmark_get_list(void);
-char* bookmark_find(const char* const search_str, gboolean previous, void* context);
+char* bookmark_find(const char *const search_str, gboolean previous, void *context);
 void bookmark_autocomplete_reset(void);
-gboolean bookmark_exists(const char* const room);
+gboolean bookmark_exists(const char *const room);
 
-void roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups);
-void roster_send_add_to_group(const char* const group, PContact contact);
-void roster_send_remove_from_group(const char* const group, PContact contact);
-void roster_send_add_new(const char* const barejid, const char* const name);
-void roster_send_remove(const char* const barejid);
+void roster_send_name_change(const char *const barejid, const char *const new_name, GSList *groups);
+void roster_send_add_to_group(const char *const group, PContact contact);
+void roster_send_remove_from_group(const char *const group, PContact contact);
+void roster_send_add_new(const char *const barejid, const char *const name);
+void roster_send_remove(const char *const barejid);
 
 GList* blocked_list(void);
-gboolean blocked_add(char* jid);
-gboolean blocked_remove(char* jid);
-char* blocked_ac_find(const char* const search_str, gboolean previous, void* context);
+gboolean blocked_add(char *jid);
+gboolean blocked_remove(char *jid);
+char* blocked_ac_find(const char *const search_str, gboolean previous, void *context);
 void blocked_ac_reset(void);
 
-void form_destroy(DataForm* form);
-void form_set_value(DataForm* form, const char* const tag, char* value);
-gboolean form_add_unique_value(DataForm* form, const char* const tag, char* value);
-void form_add_value(DataForm* form, const char* const tag, char* value);
-gboolean form_remove_value(DataForm* form, const char* const tag, char* value);
-gboolean form_remove_text_multi_value(DataForm* form, const char* const tag, int index);
-gboolean form_tag_exists(DataForm* form, const char* const tag);
-form_field_type_t form_get_field_type(DataForm* form, const char* const tag);
-gboolean form_field_contains_option(DataForm* form, const char* const tag, char* value);
-int form_get_value_count(DataForm* form, const char* const tag);
-FormField* form_get_field_by_tag(DataForm* form, const char* const tag);
-Autocomplete form_get_value_ac(DataForm* form, const char* const tag);
-void form_reset_autocompleters(DataForm* form);
+void form_destroy(DataForm *form);
+void form_set_value(DataForm *form, const char *const tag, char *value);
+gboolean form_add_unique_value(DataForm *form, const char *const tag, char *value);
+void form_add_value(DataForm *form, const char *const tag, char *value);
+gboolean form_remove_value(DataForm *form, const char *const tag, char *value);
+gboolean form_remove_text_multi_value(DataForm *form, const char *const tag, int index);
+gboolean form_tag_exists(DataForm *form, const char *const tag);
+form_field_type_t form_get_field_type(DataForm *form, const char *const tag);
+gboolean form_field_contains_option(DataForm *form, const char *const tag, char *value);
+int form_get_value_count(DataForm *form, const char *const tag);
+FormField* form_get_field_by_tag(DataForm *form, const char *const tag);
+Autocomplete form_get_value_ac(DataForm *form, const char *const tag);
+void form_reset_autocompleters(DataForm *form);
 
 #endif