about summary refs log tree commit diff stats
path: root/src/xmpp/contact.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-07-07 14:18:57 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-07 14:18:57 +0200
commita2726b6a7d16f5f846a882fbbe9127e4604bb8bb (patch)
treee6d101676dec96430eafa645ad2b7bd5391a4294 /src/xmpp/contact.c
parent95015cec56fa56f2ef97227edf06de17c65000d9 (diff)
downloadprofani-tty-a2726b6a7d16f5f846a882fbbe9127e4604bb8bb.tar.gz
Apply coding style
Diffstat (limited to 'src/xmpp/contact.c')
-rw-r--r--src/xmpp/contact.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/xmpp/contact.c b/src/xmpp/contact.c
index 31568237..cb1b7f05 100644
--- a/src/xmpp/contact.c
+++ b/src/xmpp/contact.c
@@ -44,24 +44,25 @@
 #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);
@@ -91,7 +92,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();
 
@@ -99,7 +100,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);
@@ -110,7 +111,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);
@@ -121,9 +122,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;
@@ -141,7 +142,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);
@@ -209,12 +210,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
@@ -224,14 +225,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;
@@ -264,10 +265,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;
@@ -276,7 +277,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;
         }
@@ -298,7 +299,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);
 }
@@ -313,7 +314,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;
 }
@@ -339,7 +340,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);
 }
@@ -360,12 +361,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);
     }
@@ -384,9 +385,8 @@ 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);