1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2008 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
24 #include "empathy-contact-list.h"
25 #include "empathy-marshal.h"
27 static void contact_list_base_init (gpointer klass);
30 empathy_contact_list_get_type (void)
32 static GType type = 0;
35 static const GTypeInfo type_info = {
36 sizeof (EmpathyContactListIface),
37 contact_list_base_init,
41 type = g_type_register_static (G_TYPE_INTERFACE,
45 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
52 contact_list_base_init (gpointer klass)
54 static gboolean initialized = FALSE;
57 g_signal_new ("member-renamed",
58 G_TYPE_FROM_CLASS (klass),
62 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
64 4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
66 g_signal_new ("members-changed",
67 G_TYPE_FROM_CLASS (klass),
71 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
73 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
74 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
76 g_signal_new ("favourites-changed",
77 G_TYPE_FROM_CLASS (klass),
81 _empathy_marshal_VOID__OBJECT_BOOLEAN,
83 2, EMPATHY_TYPE_CONTACT, G_TYPE_BOOLEAN);
85 g_signal_new ("pendings-changed",
86 G_TYPE_FROM_CLASS (klass),
90 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
92 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
93 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
95 g_signal_new ("groups-changed",
96 G_TYPE_FROM_CLASS (klass),
100 _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
102 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
109 empathy_contact_list_add (EmpathyContactList *list,
110 EmpathyContact *contact,
111 const gchar *message)
113 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
114 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
116 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
117 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
122 empathy_contact_list_remove (EmpathyContactList *list,
123 EmpathyContact *contact,
124 const gchar *message)
126 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
127 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
129 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
130 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
135 empathy_contact_list_get_members (EmpathyContactList *list)
137 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
139 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
140 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
147 empathy_contact_list_get_pendings (EmpathyContactList *list)
149 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
151 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
152 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
159 empathy_contact_list_get_all_groups (EmpathyContactList *list)
161 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
163 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
164 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
171 empathy_contact_list_get_groups (EmpathyContactList *list,
172 EmpathyContact *contact)
174 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
175 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
177 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
178 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
185 empathy_contact_list_add_to_group (EmpathyContactList *list,
186 EmpathyContact *contact,
189 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
190 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
191 g_return_if_fail (group != NULL);
193 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
194 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
199 empathy_contact_list_remove_from_group (EmpathyContactList *list,
200 EmpathyContact *contact,
203 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
204 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
205 g_return_if_fail (group != NULL);
207 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
208 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
213 empathy_contact_list_rename_group (EmpathyContactList *list,
214 const gchar *old_group,
215 const gchar *new_group)
217 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
218 g_return_if_fail (old_group != NULL);
219 g_return_if_fail (new_group != NULL);
221 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
222 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
227 empathy_contact_list_remove_group (EmpathyContactList *list,
230 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
231 g_return_if_fail (group != NULL);
233 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
234 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
238 EmpathyContactListFlags
239 empathy_contact_list_get_flags (EmpathyContactList *list)
241 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), 0);
243 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags) {
244 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags (list);
251 empathy_contact_list_is_favourite (EmpathyContactList *list,
252 EmpathyContact *contact)
254 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->is_favourite) {
255 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->is_favourite (
263 empathy_contact_list_add_to_favourites (EmpathyContactList *list,
264 EmpathyContact *contact)
266 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_favourite) {
267 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_favourite (list,
273 empathy_contact_list_remove_from_favourites (EmpathyContactList *list,
274 EmpathyContact *contact)
276 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_favourite) {
277 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_favourite (list,