[calls] best-match: codestyle



commit fd45f0488605f39f7bd82c7cce91bb64ad8cb07c
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Wed Jun 30 23:23:11 2021 +0200

    best-match: codestyle

 src/calls-best-match.c | 138 +++++++++++++++++++++++--------------------------
 src/calls-best-match.h |   8 +--
 2 files changed, 68 insertions(+), 78 deletions(-)
---
diff --git a/src/calls-best-match.c b/src/calls-best-match.c
index 49499de2..ae513a16 100644
--- a/src/calls-best-match.c
+++ b/src/calls-best-match.c
@@ -37,8 +37,8 @@ struct _CallsBestMatch
 
   FolksSearchView    *view;
   FolksIndividual    *best_match;
-  gchar              *phone_number;
-  gchar              *country_code;
+  char               *phone_number;
+  char               *country_code;
   gboolean            had_country_code_last_time;
 };
 
@@ -131,31 +131,30 @@ set_property (GObject      *object,
               GParamSpec   *pspec)
 {
   CallsBestMatch *self = CALLS_BEST_MATCH (object);
-  const gchar *country_code;
-
-  switch (property_id)
-    {
-    case PROP_PHONE_NUMBER:
-      calls_best_match_set_phone_number (self, g_value_get_string (value));
-      break;
-
-    case PROP_COUNTRY_CODE:
-      country_code = g_value_get_string (value);
-      if (country_code) {
-        g_free (self->country_code);
-        self->country_code = g_strdup (country_code);
-
-        if (self->phone_number) {
-          g_autofree gchar *number = g_strdup (self->phone_number);
-          calls_best_match_set_phone_number (self, number);
-        }
+  const char *country_code;
+
+  switch (property_id) {
+  case PROP_PHONE_NUMBER:
+    calls_best_match_set_phone_number (self, g_value_get_string (value));
+    break;
+
+  case PROP_COUNTRY_CODE:
+    country_code = g_value_get_string (value);
+    if (country_code) {
+      g_free (self->country_code);
+      self->country_code = g_strdup (country_code);
+
+      if (self->phone_number) {
+        g_autofree char *number = g_strdup (self->phone_number);
+        calls_best_match_set_phone_number (self, number);
       }
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-      break;
     }
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
 static void
@@ -166,36 +165,35 @@ get_property (GObject      *object,
 {
   CallsBestMatch *self = CALLS_BEST_MATCH (object);
 
-  switch (property_id)
-    {
-    case PROP_HAS_INDIVIDUAL:
-      g_value_set_boolean (value,
-                           calls_best_match_has_individual (self));
-      break;
-
-    case PROP_PHONE_NUMBER:
-      g_value_set_string (value,
-                          calls_best_match_get_phone_number (self));
-      break;
-
-    case PROP_COUNTRY_CODE:
-      g_value_set_string (value, self->country_code);
-      break;
-
-    case PROP_NAME:
-      g_value_set_string (value,
-                          calls_best_match_get_name (self));
-      break;
-
-    case PROP_AVATAR:
-      g_value_set_object (value,
-                          calls_best_match_get_avatar (self));
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-      break;
-    }
+  switch (property_id) {
+  case PROP_HAS_INDIVIDUAL:
+    g_value_set_boolean (value,
+                         calls_best_match_has_individual (self));
+    break;
+
+  case PROP_PHONE_NUMBER:
+    g_value_set_string (value,
+                        calls_best_match_get_phone_number (self));
+    break;
+
+  case PROP_COUNTRY_CODE:
+    g_value_set_string (value, self->country_code);
+    break;
+
+  case PROP_NAME:
+    g_value_set_string (value,
+                        calls_best_match_get_name (self));
+    break;
+
+  case PROP_AVATAR:
+    g_value_set_object (value,
+                        calls_best_match_get_avatar (self));
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
 
@@ -276,7 +274,7 @@ calls_best_match_init (CallsBestMatch *self)
 
 
 CallsBestMatch *
-calls_best_match_new (const gchar *number)
+calls_best_match_new (const char *number)
 {
   return g_object_new (CALLS_TYPE_BEST_MATCH,
                        "phone_number", number,
@@ -291,7 +289,7 @@ calls_best_match_has_individual (CallsBestMatch *self)
   return !!self->best_match;
 }
 
-const gchar *
+const char *
 calls_best_match_get_phone_number (CallsBestMatch *self)
 {
   g_return_val_if_fail (CALLS_IS_BEST_MATCH (self), NULL);
@@ -301,7 +299,7 @@ calls_best_match_get_phone_number (CallsBestMatch *self)
 
 void
 calls_best_match_set_phone_number (CallsBestMatch *self,
-                                   const gchar    *phone_number)
+                                   const char    *phone_number)
 {
   g_autoptr (EPhoneNumber) number = NULL;
   g_autoptr (CallsPhoneNumberQuery) query = NULL;
@@ -352,23 +350,19 @@ calls_best_match_set_phone_number (CallsBestMatch *self,
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PHONE_NUMBER]);
 }
 
-const gchar *
+const char *
 calls_best_match_get_name (CallsBestMatch *self)
 {
   g_return_val_if_fail (CALLS_IS_BEST_MATCH (self), NULL);
 
   if (self->best_match)
-    {
-      return folks_individual_get_display_name (self->best_match);
-    }
+    return folks_individual_get_display_name (self->best_match);
+  else if (self->name_sip)
+    return self->name_sip;
   else if (self->phone_number)
-    {
-      return self->phone_number;
-    }
+    return self->phone_number;
   else
-    {
-      return _("Anonymous caller");
-    }
+    return _("Anonymous caller");
 }
 
 
@@ -378,11 +372,7 @@ calls_best_match_get_avatar (CallsBestMatch *self)
   g_return_val_if_fail (CALLS_IS_BEST_MATCH (self), NULL);
 
   if (self->best_match)
-    {
-      return folks_avatar_details_get_avatar (FOLKS_AVATAR_DETAILS (self->best_match));
-    }
+    return folks_avatar_details_get_avatar (FOLKS_AVATAR_DETAILS (self->best_match));
   else
-    {
-      return NULL;
-    }
+    return NULL;
 }
diff --git a/src/calls-best-match.h b/src/calls-best-match.h
index 84411173..04ac6d7e 100644
--- a/src/calls-best-match.h
+++ b/src/calls-best-match.h
@@ -33,12 +33,12 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (CallsBestMatch, calls_best_match, CALLS, BEST_MATCH, GObject);
 
-CallsBestMatch  *calls_best_match_new                (const gchar        *phone_number);
+CallsBestMatch  *calls_best_match_new                (const char         *phone_number);
 gboolean         calls_best_match_has_individual     (CallsBestMatch     *self);
-const gchar *    calls_best_match_get_phone_number   (CallsBestMatch     *self);
+const char      *calls_best_match_get_phone_number   (CallsBestMatch     *self);
 void             calls_best_match_set_phone_number   (CallsBestMatch     *self,
-                                                      const gchar        *phone_number);
-const gchar *    calls_best_match_get_name           (CallsBestMatch     *self);
+                                                      const char         *phone_number);
+const char      *calls_best_match_get_name           (CallsBestMatch     *self);
 GLoadableIcon   *calls_best_match_get_avatar         (CallsBestMatch     *self);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]