[empathy: 1/5] Make People Nearby into a Fake Group like Ungrouped and Favourites



commit 505b19ef1cd82dd94c701c3229cbab6626855167
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Mon Mar 22 16:19:14 2010 +1100

    Make People Nearby into a Fake Group like Ungrouped and Favourites

 libempathy-gtk/empathy-contact-list-store.c |   18 ++++++++++++++++--
 libempathy-gtk/empathy-contact-list-store.h |    1 +
 libempathy/empathy-tp-contact-list.c        |   19 -------------------
 3 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index 9feb446..25a2e7a 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -1037,6 +1037,7 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 	GList                      *groups = NULL, *l;
 	TpConnection               *connection;
 	EmpathyContactListFlags     flags = 0;
+	char                       *protocol_name;
 
 	priv = GET_PRIV (store);
 
@@ -1054,12 +1055,23 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 		flags = empathy_contact_manager_get_flags_for_connection (
 			EMPATHY_CONTACT_MANAGER (priv->list), connection);
 	}
+
+	tp_connection_parse_object_path (connection, &protocol_name, NULL);
+
 	if (!groups) {
 #if HAVE_FAVOURITE_CONTACTS
 		GtkTreeIter iter_group;
 
-		contact_list_store_get_group (store, EMPATHY_CONTACT_LIST_STORE_UNGROUPED,
-			&iter_group, NULL, NULL, TRUE);
+		if (!tp_strdiff (protocol_name, "local-xmpp")) {
+			/* these are People Nearby */
+			contact_list_store_get_group (store,
+				EMPATHY_CONTACT_LIST_STORE_PEOPLE_NEARBY,
+				&iter_group, NULL, NULL, TRUE);
+		} else {
+			contact_list_store_get_group (store,
+				EMPATHY_CONTACT_LIST_STORE_UNGROUPED,
+				&iter_group, NULL, NULL, TRUE);
+		}
 
 		gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter,
 					     &iter_group, NULL);
@@ -1089,6 +1101,8 @@ contact_list_store_add_contact (EmpathyContactListStore *store,
 		add_contact_to_store (GTK_TREE_STORE (store), &iter, contact, flags);
 	}
 
+	g_free (protocol_name);
+
 	/* Else add to each group. */
 	for (l = groups; l; l = l->next) {
 		GtkTreeIter iter_group;
diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h
index 1b36ea6..7fa400e 100644
--- a/libempathy-gtk/empathy-contact-list-store.h
+++ b/libempathy-gtk/empathy-contact-list-store.h
@@ -69,6 +69,7 @@ typedef enum {
 
 #define EMPATHY_CONTACT_LIST_STORE_UNGROUPED _("Ungrouped")
 #define EMPATHY_CONTACT_LIST_STORE_FAVORITE  _("Favorite People")
+#define EMPATHY_CONTACT_LIST_STORE_PEOPLE_NEARBY _("People Nearby")
 
 struct _EmpathyContactListStore {
 	GtkTreeStore parent;
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index b273ad2..49168cd 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -43,7 +43,6 @@
 typedef struct {
 	EmpathyTpContactFactory *factory;
 	TpConnection   *connection;
-	const gchar    *protocol_group;
 
 	TpChannel      *publish;
 	TpChannel      *subscribe;
@@ -783,7 +782,6 @@ static void
 tp_contact_list_constructed (GObject *list)
 {
 	EmpathyTpContactListPriv *priv = GET_PRIV (list);
-	gchar                    *protocol_name = NULL;
 
 	priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
 
@@ -825,15 +823,6 @@ tp_contact_list_constructed (GObject *list)
 						  tp_contact_list_new_channel_cb,
 						  NULL, NULL,
 						  list, NULL);
-
-	/* Check for protocols that does not support contact groups. We can
-	 * put all contacts into a special group in that case.
-	 * FIXME: Default group should be an information in the profile */
-	tp_connection_parse_object_path (priv->connection, &protocol_name, NULL);
-	if (!tp_strdiff (protocol_name, "local-xmpp")) {
-		priv->protocol_group = _("People nearby");
-	}
-	g_free (protocol_name);
 }
 
 static void
@@ -1035,10 +1024,6 @@ tp_contact_list_get_all_groups (EmpathyContactList *list)
 		l->data = g_strdup (l->data);
 	}
 
-	if (priv->protocol_group) {
-		ret = g_list_prepend (ret, g_strdup (priv->protocol_group));
-	}
-
 	return ret;
 }
 
@@ -1064,10 +1049,6 @@ tp_contact_list_get_groups (EmpathyContactList *list,
 		}
 	}
 
-	if (priv->protocol_group) {
-		ret = g_list_prepend (ret, g_strdup (priv->protocol_group));
-	}
-
 	return ret;
 }
 



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