1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 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,
50 contact_list_base_init (gpointer klass)
52 static gboolean initialized = FALSE;
55 g_signal_new ("members-changed",
56 G_TYPE_FROM_CLASS (klass),
60 empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
62 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
63 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
65 g_signal_new ("pendings-changed",
66 G_TYPE_FROM_CLASS (klass),
70 empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
72 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
73 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
75 g_signal_new ("groups-changed",
76 G_TYPE_FROM_CLASS (klass),
80 empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
82 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
89 empathy_contact_list_add (EmpathyContactList *list,
90 EmpathyContact *contact,
93 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
94 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
96 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
97 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
102 empathy_contact_list_remove (EmpathyContactList *list,
103 EmpathyContact *contact,
104 const gchar *message)
106 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
107 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
109 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
110 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
115 empathy_contact_list_get_members (EmpathyContactList *list)
117 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
119 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
120 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
127 empathy_contact_list_get_pendings (EmpathyContactList *list)
129 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
131 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
132 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
139 empathy_contact_list_get_all_groups (EmpathyContactList *list)
141 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
143 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
144 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
151 empathy_contact_list_get_groups (EmpathyContactList *list,
152 EmpathyContact *contact)
154 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
155 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
157 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
158 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
165 empathy_contact_list_add_to_group (EmpathyContactList *list,
166 EmpathyContact *contact,
169 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
170 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
171 g_return_if_fail (group != NULL);
173 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
174 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
179 empathy_contact_list_remove_from_group (EmpathyContactList *list,
180 EmpathyContact *contact,
183 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
184 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
185 g_return_if_fail (group != NULL);
187 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
188 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
193 empathy_contact_list_rename_group (EmpathyContactList *list,
194 const gchar *old_group,
195 const gchar *new_group)
197 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
198 g_return_if_fail (old_group != NULL);
199 g_return_if_fail (new_group != NULL);
201 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
202 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
207 empathy_contact_list_remove_group (EmpathyContactList *list,
210 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
211 g_return_if_fail (group != NULL);
213 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
214 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);