]> git.0d.be Git - empathy.git/commitdiff
Bug 637151 — Hide the user Individual from the contact list
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Sat, 29 Jan 2011 16:16:29 +0000 (16:16 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 17 Feb 2011 23:47:31 +0000 (23:47 +0000)
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
libempathy-gtk/empathy-individual-information-dialog.c
libempathy-gtk/empathy-individual-menu.c
libempathy-gtk/empathy-individual-store.c
libempathy-gtk/empathy-individual-view.c
libempathy-gtk/empathy-individual-widget.c
libempathy-gtk/empathy-linking-dialog.c
libempathy/empathy-contact.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index d15e72fb75cefe805efd789b400dc3b251819fb0..30a1104a10812f51b8ace6052add9240e00e0180 100644 (file)
@@ -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
index 7659c8ba6384ff10f8cb8c592b3d4d4335bb6b4b..fcbec12281fbd9ad6f506820be496b2f0ce1621f 100644 (file)
@@ -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++;
         }
     }
index 1dc4633307271f7459fb782b4eb6ffdd6d2526ac..8b9f98486faf4f4c64fe878597afac52acf1f4e1 100644 (file)
@@ -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);
index feec91a57503661940adde6db5ea533717b47faf..cf7d6865e408386a0742c990fd07ec883e1c4fb0 100644 (file)
@@ -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)
index fe236b3fda7103dd3653adecc83ae88c9c48e57f..9be022139dee10039e95a38b885f4b942dd78d36 100644 (file)
@@ -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++;
index 808c33fbcfaf1759d1e1dee3b8e377b815bfd91d..35e12dbe2eb4e3ab2f1765bcf974adc01354fecd 100644 (file)
@@ -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));
index e6d408fb454e7666a265cabbe1ae741168334423..35328a3d7e5b891851c6e6c3a645d6f2d8cdf658 100644 (file)
@@ -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++;
     }
 
index 9ae26142a9e2e12432b69c76ead516f579a863e7..0547ef82d250b085070f94c997124b3e4c3c7fdf 100644 (file)
@@ -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));
index 7ab59814fa0904d314a1407f468e64d0b0d6f361..da7dc3b9f6dee6dc9b7c1043b03c2ba073fa3370 100644 (file)
@@ -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)
 {
index 0f5f968a55526e5c4da1798a79451d66b19c2ff7..6e16f0a77dcc53bf50e1fd488744d3d91b5dd8e9 100644 (file)
@@ -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);