[empathy] Bug 637151 — Hide the user Individual from the contact list



commit 753a1862257d4c14fb2475a73ec08aeabdb7d907
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Sat Jan 29 16:16:29 2011 +0000

    Bug 637151 â?? Hide the user Individual from the contact list
    
    Generalise the mechanism used to determine whether a persona is to be
    displayed by Empathy to also take into account whether the persona is the
    user and, if so, whether they're in the contact list.
    
    This bumps the libfolks dependency to 0.3.5.
    
    Closes: bgo#637151

 configure.ac                                       |    2 +-
 .../empathy-individual-information-dialog.c        |    2 +-
 libempathy-gtk/empathy-individual-menu.c           |    8 +++---
 libempathy-gtk/empathy-individual-store.c          |    4 +-
 libempathy-gtk/empathy-individual-view.c           |   21 +++++++++++++++---
 libempathy-gtk/empathy-individual-widget.c         |   20 +++++++++---------
 libempathy-gtk/empathy-linking-dialog.c            |    2 +-
 libempathy/empathy-contact.c                       |    4 +-
 libempathy/empathy-utils.c                         |   22 ++++++++++++++++++-
 libempathy/empathy-utils.h                         |    1 +
 10 files changed, 59 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d15e72f..30a1104 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,7 +31,7 @@ AC_COPYRIGHT([
 # Minimal version required
 
 # Hardp deps
-FOLKS_REQUIRED=0.3.4
+FOLKS_REQUIRED=0.3.5
 GLIB_REQUIRED=2.27.2
 GNUTLS_REQUIRED=2.8.5
 GTK_REQUIRED=2.99.0
diff --git a/libempathy-gtk/empathy-individual-information-dialog.c b/libempathy-gtk/empathy-individual-information-dialog.c
index 7659c8b..fcbec12 100644
--- a/libempathy-gtk/empathy-individual-information-dialog.c
+++ b/libempathy-gtk/empathy-individual-information-dialog.c
@@ -139,7 +139,7 @@ set_label_visibility (EmpathyIndividualInformationDialog *dialog)
       personas = folks_individual_get_personas (priv->individual);
       for (l = personas; l != NULL; l = l->next)
         {
-          if (TPF_IS_PERSONA (l->data))
+          if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             num_personas++;
         }
     }
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 1dc4633..8b9f984 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -87,7 +87,7 @@ individual_menu_add_personas (GtkMenuShell *menu,
    * functionality */
   for (l = personas; l != NULL; l = l->next)
     {
-      if (!TPF_IS_PERSONA (l->data))
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         continue;
 
       persona_count++;
@@ -116,7 +116,7 @@ individual_menu_add_personas (GtkMenuShell *menu,
       const gchar *account;
       GtkWidget *action;
 
-      if (!TPF_IS_PERSONA (persona))
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         continue;
 
       tp_contact = tpf_persona_get_contact (persona);
@@ -937,7 +937,7 @@ room_sub_menu_activate_cb (GtkWidget *item,
           TpContact *tp_contact;
           GList *rooms;
 
-          if (!TPF_IS_PERSONA (persona))
+          if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             continue;
 
           tp_contact = tpf_persona_get_contact (persona);
@@ -1037,7 +1037,7 @@ empathy_individual_invite_menu_item_new (FolksIndividual *individual,
           TpContact *tp_contact;
           EmpathyContact *contact_cur;
 
-          if (!TPF_IS_PERSONA (persona))
+          if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             continue;
 
           tp_contact = tpf_persona_get_contact (persona);
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index feec91a..cf7d686 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -132,7 +132,7 @@ individual_can_audio_video_call (FolksIndividual *individual,
       TpContact *tp_contact;
       EmpathyContact *contact;
 
-      if (!TPF_IS_PERSONA (l->data))
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         continue;
 
       tp_contact = tpf_persona_get_contact (TPF_PERSONA (l->data));
@@ -1954,7 +1954,7 @@ individual_store_get_individual_status_icon_with_icon_name (
   personas = folks_individual_get_personas (individual);
   for (l = personas, contact_count = 0; l; l = l->next)
     {
-      if (TPF_IS_PERSONA (l->data))
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         contact_count++;
 
       if (contact_count > 1)
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index fe236b3..9be0221 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -1681,7 +1681,7 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
   EmpathyLiveSearch *live = EMPATHY_LIVE_SEARCH (priv->search_widget);
   const gchar *str;
   GList *personas, *l;
-  gboolean is_favorite;
+  gboolean is_favorite, contains_interesting_persona = FALSE;
 
   /* We're only giving the visibility wrt filtering here, not things like
    * presence. */
@@ -1691,6 +1691,20 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
       return FALSE;
     }
 
+  /* Hide all individuals which consist entirely of uninteresting personas */
+  personas = folks_individual_get_personas (individual);
+  for (l = personas; l; l = l->next)
+    {
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
+        {
+          contains_interesting_persona = TRUE;
+          break;
+        }
+    }
+
+  if (contains_interesting_persona == FALSE)
+    return FALSE;
+
   is_favorite = folks_favouritable_get_is_favourite (
       FOLKS_FAVOURITABLE (individual));
   if (is_searching == FALSE)
@@ -1703,14 +1717,13 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
     return TRUE;
 
   /* check contact id, remove the @server.com part */
-  personas = folks_individual_get_personas (individual);
   for (l = personas; l; l = l->next)
     {
       const gchar *p;
       gchar *dup_str = NULL;
       gboolean visible;
 
-      if (!TPF_IS_PERSONA (l->data))
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         continue;
 
       str = folks_persona_get_display_id (l->data);
@@ -2388,7 +2401,7 @@ individual_view_remove_activate_cb (GtkMenuItem *menuitem,
        * be removed. */
       for (l = personas; l != NULL; l = l->next)
         {
-          if (!TPF_IS_PERSONA (l->data))
+          if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             continue;
 
           persona_count++;
diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c
index 808c33f..35e12db 100644
--- a/libempathy-gtk/empathy-individual-widget.c
+++ b/libempathy-gtk/empathy-individual-widget.c
@@ -238,8 +238,8 @@ update_weak_contact (EmpathyIndividualWidget *self)
 
           if (folks_presence_owner_typecmp (
                   folks_presence_owner_get_presence_type (presence),
-                  presence_type) > 0
-              && TPF_IS_PERSONA (presence))
+                  presence_type) > 0 &&
+              empathy_folks_persona_is_interesting (FOLKS_PERSONA (presence)))
             {
               presence_type = folks_presence_owner_get_presence_type (presence);
               tp_contact = tpf_persona_get_contact (TPF_PERSONA (l->data));
@@ -581,7 +581,7 @@ location_update (EmpathyIndividualWidget *self)
     {
       FolksPersona *persona = FOLKS_PERSONA (l->data);
 
-      if (TPF_IS_PERSONA (persona))
+      if (empathy_folks_persona_is_interesting (persona))
         {
           TpContact *tp_contact;
 
@@ -754,7 +754,7 @@ location_update (EmpathyIndividualWidget *self)
         {
           FolksPersona *persona = FOLKS_PERSONA (l->data);
 
-          if (TPF_IS_PERSONA (persona))
+          if (empathy_folks_persona_is_interesting (persona))
             {
               gdouble lat = 0.0, lon = 0.0;
               ClutterActor *marker;
@@ -877,7 +877,7 @@ persona_dup_avatar (FolksPersona *persona)
   EmpathyContact *contact;
   EmpathyAvatar *avatar;
 
-  if (!TPF_IS_PERSONA (persona))
+  if (!empathy_folks_persona_is_interesting (persona))
     return NULL;
 
   tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
@@ -1472,7 +1472,7 @@ add_persona (EmpathyIndividualWidget *self,
   GtkWidget *label, *account_label, *account_image, *separator;
   guint current_row = 0;
 
-  if (!TPF_IS_PERSONA (persona))
+  if (!empathy_folks_persona_is_interesting (persona))
     return;
 
   if (priv->flags & EMPATHY_INDIVIDUAL_WIDGET_EDIT_FAVOURITE)
@@ -1575,7 +1575,7 @@ remove_persona (EmpathyIndividualWidget *self,
   GtkWidget *separator;
   GtkTable *table;
 
-  if (!TPF_IS_PERSONA (persona))
+  if (!empathy_folks_persona_is_interesting (persona))
     return;
 
   table = g_hash_table_lookup (priv->persona_tables, persona);
@@ -1647,7 +1647,7 @@ individual_table_set_up (EmpathyIndividualWidget *self)
       personas = folks_individual_get_personas (priv->individual);
       for (l = personas; l != NULL; l = l->next)
         {
-          if (TPF_IS_PERSONA (l->data))
+          if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             num_personas++;
         }
 
@@ -1714,7 +1714,7 @@ personas_changed_cb (FolksIndividual *individual,
 
   for (l = personas; l != NULL; l = l->next)
     {
-      if (TPF_IS_PERSONA (l->data))
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         new_num_personas++;
     }
 
@@ -1890,7 +1890,7 @@ individual_update (EmpathyIndividualWidget *self)
       personas = folks_individual_get_personas (priv->individual);
       for (l = personas; l != NULL; l = l->next)
         {
-          if (!TPF_IS_PERSONA (l->data))
+          if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
             continue;
 
           update_persona (self, FOLKS_PERSONA (l->data));
diff --git a/libempathy-gtk/empathy-linking-dialog.c b/libempathy-gtk/empathy-linking-dialog.c
index e6d408f..35328a3 100644
--- a/libempathy-gtk/empathy-linking-dialog.c
+++ b/libempathy-gtk/empathy-linking-dialog.c
@@ -248,7 +248,7 @@ empathy_linking_dialog_show (FolksIndividual *individual,
   personas = folks_individual_get_personas (individual);
   for (l = personas; l != NULL; l = l->next)
     {
-      if (TPF_IS_PERSONA (l->data))
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         num_personas++;
     }
 
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 9ae2614..0547ef8 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -885,7 +885,7 @@ empathy_contact_get_persona (EmpathyContact *contact)
             {
               TpfPersona *persona = j->data;
 
-              if (TPF_IS_PERSONA (persona))
+              if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona)))
                 {
                   TpContact *tp_contact = tpf_persona_get_contact (persona);
 
@@ -1958,7 +1958,7 @@ empathy_contact_dup_best_for_action (FolksIndividual *individual,
       TpContact *tp_contact;
       EmpathyContact *contact;
 
-      if (!TPF_IS_PERSONA (l->data))
+      if (!empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         continue;
 
       tp_contact = tpf_persona_get_contact (TPF_PERSONA (l->data));
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 7ab5981..da7dc3b 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -782,7 +782,7 @@ empathy_folks_individual_contains_contact (FolksIndividual *individual)
   personas = folks_individual_get_personas (individual);
   for (l = personas; l != NULL; l = l->next)
     {
-      if (TPF_IS_PERSONA (l->data))
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (l->data)))
         return (tpf_persona_get_contact (TPF_PERSONA (l->data)) != NULL);
     }
 
@@ -809,7 +809,7 @@ empathy_contact_dup_from_folks_individual (FolksIndividual *individual)
     {
       TpfPersona *persona = l->data;
 
-      if (TPF_IS_PERSONA (persona))
+      if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona)))
         {
           TpContact *tp_contact;
 
@@ -909,6 +909,24 @@ empathy_connection_can_group_personas (TpConnection *connection)
       FOLKS_MAYBE_BOOL_TRUE);
 }
 
+gboolean
+empathy_folks_persona_is_interesting (FolksPersona *persona)
+{
+  /* We're not interested in non-Telepathy personas */
+  if (!TPF_IS_PERSONA (persona))
+    return FALSE;
+
+  /* We're not interested in user personas which haven't been added to the
+   * contact list (see bgo#637151). */
+  if (folks_persona_get_is_user (persona) &&
+      !tpf_persona_get_is_in_contact_list (TPF_PERSONA (persona)))
+    {
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
 gchar *
 empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert)
 {
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 0f5f968..6e16f0a 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -113,6 +113,7 @@ TpfPersonaStore * empathy_get_persona_store_for_connection (TpConnection *connec
 gboolean empathy_connection_can_add_personas (TpConnection *connection);
 gboolean empathy_connection_can_alias_personas (TpConnection *connection);
 gboolean empathy_connection_can_group_personas (TpConnection *connection);
+gboolean empathy_folks_persona_is_interesting (FolksPersona *persona);
 
 gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert);
 



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