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
22 #include "empathy-roster-model.h"
24 G_DEFINE_INTERFACE (EmpathyRosterModel, empathy_roster_model, G_TYPE_OBJECT)
29 SIG_INDIVIDUAL_REMOVED,
34 static guint signals[LAST_SIGNAL];
37 empathy_roster_model_default_init (EmpathyRosterModelInterface *iface)
39 signals[SIG_INDIVIDUAL_ADDED] =
40 g_signal_new ("individual-added",
41 EMPATHY_TYPE_ROSTER_MODEL,
45 FOLKS_TYPE_INDIVIDUAL);
47 signals[SIG_INDIVIDUAL_REMOVED] =
48 g_signal_new ("individual-removed",
49 EMPATHY_TYPE_ROSTER_MODEL,
53 FOLKS_TYPE_INDIVIDUAL);
55 signals[SIG_GROUPS_CHANGED] =
56 g_signal_new ("groups-changed",
57 EMPATHY_TYPE_ROSTER_MODEL,
61 FOLKS_TYPE_INDIVIDUAL,
66 /***** Restricted *****/
69 empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
70 FolksIndividual *individual)
72 g_signal_emit (self, signals[SIG_INDIVIDUAL_ADDED], 0, individual);
76 empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
77 FolksIndividual *individual)
79 g_signal_emit (self, signals[SIG_INDIVIDUAL_REMOVED], 0, individual);
83 empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self,
84 FolksIndividual *individual,
88 g_signal_emit (self, signals[SIG_GROUPS_CHANGED], 0, individual, group,
95 * empathy_roster_model_get_individuals:
96 * @self: a #EmpathyRosterModel
98 * Returns all the individuals stored by @self.
100 * Returns: (transfer container): a #GList of #FolksIndividual
103 empathy_roster_model_get_individuals (EmpathyRosterModel *self)
105 EmpathyRosterModelInterface *iface;
107 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
109 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
110 g_return_val_if_fail (iface->get_individuals != NULL, NULL);
112 return (* iface->get_individuals) (self);
116 * empathy_roster_model_dup_groups_for_individual:
117 * @self: a #EmpathyRosterModel
118 * @individual: a #FolksIndidivual
120 * Returns the groups of which @individual is a member of.
122 * Returns: (transfer full): a #GList of (gchar *) representing the
123 * groups of @individual
126 empathy_roster_model_dup_groups_for_individual (EmpathyRosterModel *self,
127 FolksIndividual *individual)
129 EmpathyRosterModelInterface *iface;
131 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
133 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
134 g_return_val_if_fail (iface->dup_groups_for_individual != NULL, NULL);
136 return (* iface->dup_groups_for_individual) (self, individual);