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,
31 SIG_TOP_INDIVIDUALS_CHANGED,
32 SIG_FAVOURITES_CHANGED,
36 static guint signals[LAST_SIGNAL];
39 empathy_roster_model_default_init (EmpathyRosterModelInterface *iface)
41 signals[SIG_INDIVIDUAL_ADDED] =
42 g_signal_new ("individual-added",
43 EMPATHY_TYPE_ROSTER_MODEL,
47 FOLKS_TYPE_INDIVIDUAL);
49 signals[SIG_INDIVIDUAL_REMOVED] =
50 g_signal_new ("individual-removed",
51 EMPATHY_TYPE_ROSTER_MODEL,
55 FOLKS_TYPE_INDIVIDUAL);
57 signals[SIG_GROUPS_CHANGED] =
58 g_signal_new ("groups-changed",
59 EMPATHY_TYPE_ROSTER_MODEL,
63 FOLKS_TYPE_INDIVIDUAL,
67 signals[SIG_TOP_INDIVIDUALS_CHANGED] =
68 g_signal_new ("top-individuals-changed",
69 EMPATHY_TYPE_ROSTER_MODEL,
74 signals[SIG_FAVOURITES_CHANGED] =
75 g_signal_new ("favourites-changed",
76 EMPATHY_TYPE_ROSTER_MODEL,
80 FOLKS_TYPE_INDIVIDUAL,
84 /***** Restricted *****/
87 empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
88 FolksIndividual *individual)
90 g_signal_emit (self, signals[SIG_INDIVIDUAL_ADDED], 0, individual);
94 empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
95 FolksIndividual *individual)
97 g_signal_emit (self, signals[SIG_INDIVIDUAL_REMOVED], 0, individual);
101 empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self,
102 FolksIndividual *individual,
106 g_signal_emit (self, signals[SIG_GROUPS_CHANGED], 0, individual, group, is_member);
110 empathy_roster_model_fire_top_individuals_changed (EmpathyRosterModel *self)
112 g_signal_emit (self, signals[SIG_TOP_INDIVIDUALS_CHANGED], 0);
116 empathy_roster_model_fire_favourites_changed (EmpathyRosterModel *self,
117 FolksIndividual *individual,
120 g_signal_emit (self, signals[SIG_FAVOURITES_CHANGED], 0, individual, favourite);
127 * empathy_roster_model_get_individuals:
128 * @self: a #EmpathyRosterModel
130 * Returns all the individuals stored by @self.
132 * Returns: (transfer container): a #GList of #FolksIndividual
135 empathy_roster_model_get_individuals (EmpathyRosterModel *self)
137 EmpathyRosterModelInterface *iface;
139 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
141 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
142 g_return_val_if_fail (iface->get_individuals != NULL, NULL);
144 return (* iface->get_individuals) (self);
148 * empathy_roster_model_get_groups_for_individual:
149 * @self: a #EmpathyRosterModel
150 * @individual: a #FolksIndidivual
152 * Returns the groups of which @individual is a member of.
154 * Returns: (transfer container): a #GList of (const gchar *) representing the
155 * groups of @individual
158 empathy_roster_model_get_groups_for_individual (EmpathyRosterModel *self,
159 FolksIndividual *individual)
161 EmpathyRosterModelInterface *iface;
163 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
165 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
166 g_return_val_if_fail (iface->get_groups_for_individual != NULL, NULL);
168 return (* iface->get_groups_for_individual) (self, individual);
172 * empathy_roster_model_get_top_individuals:
173 * @self: a #EmpathyRosterModel
175 * Returns a list of the top_individuals.
177 * Return value: (transfer none): a #GList of #FolksIndividual
180 empathy_roster_model_get_top_individuals (EmpathyRosterModel *self)
182 EmpathyRosterModelInterface *iface;
184 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
186 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
187 g_return_val_if_fail (iface->get_top_individuals != NULL, NULL);
189 return (* iface->get_top_individuals) (self);
193 * empathy_roster_model_contact_in_top:
194 * @self: a #EmpathyRosterModel
195 * @contact: a #EmpathyRosterContact
197 * Checks if the passed #EmpathyRosterContact should be displayed in
200 * Return value: %TRUE if it should be displayed in top contacts, %FALSE
204 empathy_roster_model_contact_in_top (EmpathyRosterModel *self,
205 EmpathyRosterContact *contact)
207 EmpathyRosterModelInterface *iface;
209 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), FALSE);
211 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
212 g_return_val_if_fail (iface->contact_in_top != NULL, FALSE);
214 return (* iface->contact_in_top) (self, contact);