]> git.0d.be Git - empathy.git/commitdiff
roster-model: add API to track individuals
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 4 Jul 2012 07:43:05 +0000 (09:43 +0200)
committerLaurent Contzen <lcontzen@gmail.com>
Mon, 23 Jul 2012 07:48:42 +0000 (09:48 +0200)
libempathy-gtk/empathy-roster-model.c
libempathy-gtk/empathy-roster-model.h

index f8a890aecc4b5e8d77509ce8f6eacca350acef26..ce86e58a698d5119c2981a1c8a1bc0b0f8db94d0 100644 (file)
 
 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);
 }
index 75b0b1055d7c9190d57c1a07951cb0587811a388..e6c382825852cb56157b93579ae7282a5f17c8b0 100644 (file)
@@ -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__*/