[empathy] roster-model: add API to track individuals



commit 2e9ea0fb13d570edeca7161d827d8041298c2134
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Jul 4 09:43:05 2012 +0200

    roster-model: add API to track individuals

 libempathy-gtk/empathy-roster-model.c |   55 +++++++++++++++++++++++++++++++++
 libempathy-gtk/empathy-roster-model.h |   14 ++++++++
 2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-roster-model.c b/libempathy-gtk/empathy-roster-model.c
index f8a890a..ce86e58 100644
--- a/libempathy-gtk/empathy-roster-model.c
+++ b/libempathy-gtk/empathy-roster-model.c
@@ -23,7 +23,62 @@
 
 G_DEFINE_INTERFACE (EmpathyRosterModel, empathy_roster_model, G_TYPE_OBJECT)
 
+enum
+{
+  SIG_INDIVIDUAL_ADDED,
+  SIG_INDIVIDUAL_REMOVED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
 static void
 empathy_roster_model_default_init (EmpathyRosterModelInterface *iface)
 {
+  signals[SIG_INDIVIDUAL_ADDED] =
+    g_signal_new ("individual-added",
+        EMPATHY_TYPE_ROSTER_MODEL,
+        G_SIGNAL_RUN_LAST,
+        0, NULL, NULL, NULL,
+        G_TYPE_NONE, 1,
+        FOLKS_TYPE_INDIVIDUAL);
+
+  signals[SIG_INDIVIDUAL_REMOVED] =
+    g_signal_new ("individual-removed",
+        EMPATHY_TYPE_ROSTER_MODEL,
+        G_SIGNAL_RUN_LAST,
+        0, NULL, NULL, NULL,
+        G_TYPE_NONE, 1,
+        FOLKS_TYPE_INDIVIDUAL);
+}
+
+/***** Restricted *****/
+
+void
+empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
+    FolksIndividual *individual)
+{
+  g_signal_emit (self, signals[SIG_INDIVIDUAL_ADDED], 0, individual);
+}
+
+void
+empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
+    FolksIndividual *individual)
+{
+  g_signal_emit (self, signals[SIG_INDIVIDUAL_REMOVED], 0, individual);
+}
+
+/***** Public *****/
+
+GList *
+empathy_roster_model_get_individuals (EmpathyRosterModel *self)
+{
+  EmpathyRosterModelInterface *iface;
+
+  g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
+
+  iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
+  g_return_val_if_fail (iface->get_individuals != NULL, NULL);
+
+  return (* iface->get_individuals) (self);
 }
diff --git a/libempathy-gtk/empathy-roster-model.h b/libempathy-gtk/empathy-roster-model.h
index 75b0b10..e6c3828 100644
--- a/libempathy-gtk/empathy-roster-model.h
+++ b/libempathy-gtk/empathy-roster-model.h
@@ -22,6 +22,8 @@
 
 #include <glib-object.h>
 
+#include <folks/folks.h>
+
 G_BEGIN_DECLS
 
 typedef struct _EmpathyRosterModel EmpathyRosterModel;
@@ -33,6 +35,7 @@ struct _EmpathyRosterModelInterface
   GTypeInterface g_iface;
 
   /* Virtual table */
+  GList * (* get_individuals) (EmpathyRosterModel *self);
 };
 
 GType empathy_roster_model_get_type (void);
@@ -52,6 +55,17 @@ GType empathy_roster_model_get_type (void);
     EMPATHY_TYPE_ROSTER_MODEL, \
     EmpathyRosterModelInterface))
 
+/* Restricted */
+
+void empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
+    FolksIndividual *individual);
+
+void empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
+    FolksIndividual *individual);
+
+/* Public API */
+GList * empathy_roster_model_get_individuals (EmpathyRosterModel *self);
+
 G_END_DECLS
 
 #endif /* #ifndef __EMPATHY_ROSTER_MODEL_H__*/



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