2 * empathy-roster-model.c
4 * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "empathy-roster-model.h"
23 G_DEFINE_INTERFACE (EmpathyRosterModel, empathy_roster_model, G_TYPE_OBJECT)
28 SIG_INDIVIDUAL_REMOVED,
33 static guint signals[LAST_SIGNAL];
36 empathy_roster_model_default_init (EmpathyRosterModelInterface *iface)
38 signals[SIG_INDIVIDUAL_ADDED] =
39 g_signal_new ("individual-added",
40 EMPATHY_TYPE_ROSTER_MODEL,
44 FOLKS_TYPE_INDIVIDUAL);
46 signals[SIG_INDIVIDUAL_REMOVED] =
47 g_signal_new ("individual-removed",
48 EMPATHY_TYPE_ROSTER_MODEL,
52 FOLKS_TYPE_INDIVIDUAL);
54 signals[SIG_GROUPS_CHANGED] =
55 g_signal_new ("groups-changed",
56 EMPATHY_TYPE_ROSTER_MODEL,
60 FOLKS_TYPE_INDIVIDUAL,
65 /***** Restricted *****/
68 empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
69 FolksIndividual *individual)
71 g_signal_emit (self, signals[SIG_INDIVIDUAL_ADDED], 0, individual);
75 empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
76 FolksIndividual *individual)
78 g_signal_emit (self, signals[SIG_INDIVIDUAL_REMOVED], 0, individual);
82 empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self,
83 FolksIndividual *individual,
87 g_signal_emit (self, signals[SIG_GROUPS_CHANGED], 0, individual, group,
94 * empathy_roster_model_get_individuals:
95 * @self: a #EmpathyRosterModel
97 * Returns all the individuals stored by @self.
99 * Returns: (transfer container): a #GList of #FolksIndividual
102 empathy_roster_model_get_individuals (EmpathyRosterModel *self)
104 EmpathyRosterModelInterface *iface;
106 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
108 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
109 g_return_val_if_fail (iface->get_individuals != NULL, NULL);
111 return (* iface->get_individuals) (self);
115 * empathy_roster_model_dup_groups_for_individual:
116 * @self: a #EmpathyRosterModel
117 * @individual: a #FolksIndidivual
119 * Returns the groups of which @individual is a member of.
121 * Returns: (transfer full): a #GList of (gchar *) representing the
122 * groups of @individual
125 empathy_roster_model_dup_groups_for_individual (EmpathyRosterModel *self,
126 FolksIndividual *individual)
128 EmpathyRosterModelInterface *iface;
130 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
132 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
133 g_return_val_if_fail (iface->dup_groups_for_individual != NULL, NULL);
135 return (* iface->dup_groups_for_individual) (self, individual);