]> git.0d.be Git - empathy.git/commitdiff
Create and use People Nearby group
authorLaurent Contzen <lcontzen@gmail.com>
Tue, 19 Jun 2012 14:20:29 +0000 (16:20 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 20 Jun 2012 11:50:00 +0000 (13:50 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=678156

libempathy-gtk/empathy-roster-view.c

index 0decfd14f7207205e1a9f03fc8c84bbf05738d59..111b643b6d53c8a1a7d15a6988f0f219b02313a7 100644 (file)
@@ -8,6 +8,8 @@
 #include <libempathy-gtk/empathy-roster-group.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
+#include <libempathy/empathy-utils.h>
+
 G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX)
 
 /* Flashing delay for icons (milliseconds). */
@@ -36,6 +38,7 @@ static guint signals[LAST_SIGNAL];
 #define NO_GROUP "X-no-group"
 #define UNGROUPED _("Ungrouped")
 #define TOP_GROUP _("Top Contacts")
+#define PEOPLE_NEARBY _("People Nearby")
 
 struct _EmpathyRosterViewPriv
 {
@@ -163,6 +166,27 @@ roster_contact_changed_cb (GtkWidget *child,
   egg_list_box_child_changed (EGG_LIST_BOX (self), child);
 }
 
+static gboolean
+is_xmpp_local_contact (FolksIndividual *individual)
+{
+  EmpathyContact *contact;
+  TpConnection *connection;
+  const gchar *protocol_name = NULL;
+  gboolean result;
+
+  contact = empathy_contact_dup_from_folks_individual (individual);
+
+  if (contact == NULL)
+    return FALSE;
+
+  connection = empathy_contact_get_connection (contact);
+  protocol_name = tp_connection_get_protocol_name (connection);
+  result = !tp_strdiff (protocol_name, "local-xmpp");
+  g_object_unref (contact);
+
+  return result;
+}
+
 static GtkWidget *
 add_roster_contact (EmpathyRosterView *self,
     FolksIndividual *individual,
@@ -221,6 +245,8 @@ ensure_roster_group (EmpathyRosterView *self,
 
   if (!tp_strdiff (group, TOP_GROUP))
     roster_group = empathy_roster_group_new (group, "emblem-favorite-symbolic");
+  else if (!tp_strdiff (group, PEOPLE_NEARBY))
+    roster_group = empathy_roster_group_new (group, "im-local-xmpp");
   else
     roster_group = empathy_roster_group_new (group, NULL);
 
@@ -299,6 +325,10 @@ individual_added (EmpathyRosterView *self,
     {
       add_to_group (self, individual, NO_GROUP);
     }
+  else if (is_xmpp_local_contact (individual))
+    {
+      add_to_group (self, individual, PEOPLE_NEARBY);
+    }
   else
     {
       GeeSet *groups;