aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd@luon.net>2013-01-03 18:42:13 +0800
committerSjoerd Simons <sjoerd@luon.net>2013-01-03 22:30:47 +0800
commit55ce28ebe490bc803dd524970ebb187402bb6031 (patch)
tree9add34c7bd5b98583fa64feb6ed04c2a7d168dfb
parent05c170e3de251f2161e9ff5bb1eac4785cdc91da (diff)
downloadgsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar.gz
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar.bz2
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar.lz
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar.xz
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.tar.zst
gsoc2013-empathy-55ce28ebe490bc803dd524970ebb187402bb6031.zip
Recognize both handheld and phone clienttypes as mobile devices
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.
-rw-r--r--libempathy-gtk/empathy-cell-renderer-text.c4
-rw-r--r--libempathy-gtk/empathy-individual-widget.c4
-rw-r--r--libempathy-gtk/empathy-roster-contact.c20
-rw-r--r--libempathy/empathy-utils.c14
-rw-r--r--libempathy/empathy-utils.h3
-rw-r--r--src/empathy-chat-window.c4
6 files changed, 26 insertions, 23 deletions
diff --git a/libempathy-gtk/empathy-cell-renderer-text.c b/libempathy-gtk/empathy-cell-renderer-text.c
index d52abb485..d96ccc403 100644
--- a/libempathy-gtk/empathy-cell-renderer-text.c
+++ b/libempathy-gtk/empathy-cell-renderer-text.c
@@ -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)
diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c
index 735397456..4dab7390c 100644
--- a/libempathy-gtk/empathy-individual-widget.c
+++ b/libempathy-gtk/empathy-individual-widget.c
@@ -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);
}
diff --git a/libempathy-gtk/empathy-roster-contact.c b/libempathy-gtk/empathy-roster-contact.c
index 918ccdb96..7ab808746 100644
--- a/libempathy-gtk/empathy-roster-contact.c
+++ b/libempathy-gtk/empathy-roster-contact.c
@@ -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
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index a7ae0bdd7..191544fbf 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -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)
{
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index a310d2b02..3950c5be3 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -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);
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 06d1b0cec..676c4ef23 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -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);