]> git.0d.be Git - empathy.git/commitdiff
Recognize both handheld and phone clienttypes as mobile devices
authorSjoerd Simons <sjoerd@luon.net>
Thu, 3 Jan 2013 10:42:13 +0000 (11:42 +0100)
committerSjoerd Simons <sjoerd@luon.net>
Thu, 3 Jan 2013 14:30:47 +0000 (15:30 +0100)
Empathy currently displays a phone icon for clients which indicate that
they're phones. However some mobile clients use the "handheld" client
type instead (e.g. Xabber on android devices).

While changing things around, i've also refactored the code a bit to
ensure that the determination will stay consistent in the various
location if it's changed in future.

libempathy-gtk/empathy-cell-renderer-text.c
libempathy-gtk/empathy-individual-widget.c
libempathy-gtk/empathy-roster-contact.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h
src/empathy-chat-window.c

index d52abb4851fcc434b25be04cec0cedcc8e0fcadc..d96ccc403e886f8c4886f9e82f672b10f8dbd3c3 100644 (file)
@@ -364,8 +364,8 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
                        status = empathy_presence_get_default_message (priv->presence_type);
                }
 
-               if (!priv->is_group && priv->types != NULL && g_strv_length (priv->types) > 0
-                   && !tp_strdiff (priv->types[0], "phone")) {
+               if (!priv->is_group &&
+                               empathy_client_types_contains_mobile_device (priv->types)) {
                        on_a_phone = TRUE;
                        /* We want the phone black. */
                        if (attr_color)
index 73539745643ddc66f0673100ac9f3e63ba20e310..4dab7390cdbd7ba946956ba581cec2299819b082 100644 (file)
@@ -808,9 +808,7 @@ client_types_update (EmpathyIndividualWidget *self)
 
   types = tp_contact_get_client_types (priv->contact);
 
-  if (types != NULL
-      && g_strv_length ((gchar **) types) > 0
-      && !tp_strdiff (types[0], "phone"))
+  if (empathy_client_types_contains_mobile_device ((GStrv) types))
     {
       gtk_widget_show (priv->hbox_client_types);
     }
index 918ccdb96f0e731b9e5c9fb586eb54b8e673952b..7ab8087465d3827e607ee376bba15d057c11d4cd 100644 (file)
@@ -173,25 +173,11 @@ alias_changed_cb (FolksIndividual *individual,
   update_alias (self);
 }
 
-static gboolean
-is_phone (FolksIndividual *individual)
-{
-  const gchar * const *types;
-
-  types = empathy_individual_get_client_types (individual);
-  if (types == NULL)
-    return FALSE;
-
-  if (g_strv_length ((GStrv) types) <= 0)
-    return FALSE;
-
-  return !tp_strdiff (types[0], "phone");
-}
-
 static void
 update_presence_msg (EmpathyRosterContact *self)
 {
   const gchar *msg;
+  GStrv types;
 
   msg = folks_presence_details_get_presence_message (
       FOLKS_PRESENCE_DETAILS (self->priv->individual));
@@ -233,8 +219,10 @@ update_presence_msg (EmpathyRosterContact *self)
       gtk_widget_show (self->priv->presence_msg);
     }
 
+  types = (GStrv) empathy_individual_get_client_types (self->priv->individual);
+
   gtk_widget_set_visible (self->priv->phone_icon,
-      is_phone (self->priv->individual));
+      empathy_client_types_contains_mobile_device (types));
 }
 
 static void
index a7ae0bdd7e0d42d09ba998fd544fc187815b0c68..191544fbfb9389228215a293a611e78d246b537d 100644 (file)
@@ -1122,6 +1122,20 @@ while_finish:
     *can_video_call = can_video;
 }
 
+gboolean
+empathy_client_types_contains_mobile_device (const GStrv types) {
+  int i;
+
+  if (types == NULL)
+    return FALSE;
+
+  for (i = 0; types[i] != NULL; i++)
+    if (!tp_strdiff (types[i], "phone") || !tp_strdiff (types[i], "handheld"))
+        return TRUE;
+
+  return FALSE;
+}
+
 static FolksIndividual *
 create_individual_from_persona (FolksPersona *persona)
 {
index a310d2b0213a5354b65401aa3044ee7016c2907b..3950c5be3e5dfdfb3000c2577fe9764075220d52 100644 (file)
@@ -115,6 +115,9 @@ void empathy_individual_can_audio_video_call (FolksIndividual *individual,
     gboolean *can_video_call,
     EmpathyContact **out_contact);
 
+gboolean empathy_client_types_contains_mobile_device (
+    const GStrv types);
+
 FolksIndividual * empathy_create_individual_from_tp_contact (
     TpContact *contact);
 
index 06d1b0cec09769c483946f6348636d7fd089df73..676c4ef23541f52d6857c22b8f3a5c6a9aff9f81 100644 (file)
@@ -986,9 +986,9 @@ chat_window_update_chat_tab_full (EmpathyChat *chat,
       const gchar * const *types;
 
       types = empathy_contact_get_client_types (remote_contact);
-      if (types != NULL && !tp_strdiff (types[0], "phone"))
+      if (empathy_client_types_contains_mobile_device ((GStrv) types))
         {
-          /* I'm on a phone ! */
+          /* I'm on a mobile device ! */
           gchar *tmp = name;
 
           name = g_strdup_printf ("☎ %s", name);