1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program 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 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
25 #include "empathy-contact-list.h"
26 #include "empathy-marshal.h"
28 static void contact_list_base_init (gpointer klass);
31 empathy_contact_list_get_type (void)
33 static GType type = 0;
36 static const GTypeInfo type_info = {
37 sizeof (EmpathyContactListIface),
38 contact_list_base_init,
42 type = g_type_register_static (G_TYPE_INTERFACE,
51 contact_list_base_init (gpointer klass)
53 static gboolean initialized = FALSE;
56 g_signal_new ("members-changed",
57 G_TYPE_FROM_CLASS (klass),
61 empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
63 5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
64 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
66 g_signal_new ("pendings-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 ("groups-changed",
77 G_TYPE_FROM_CLASS (klass),
81 empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
83 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
90 empathy_contact_list_add (EmpathyContactList *list,
91 EmpathyContact *contact,
94 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
95 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
97 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
98 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
103 empathy_contact_list_remove (EmpathyContactList *list,
104 EmpathyContact *contact,
105 const gchar *message)
107 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
108 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
110 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
111 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
116 empathy_contact_list_get_members (EmpathyContactList *list)
118 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
120 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
121 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
128 empathy_contact_list_get_pendings (EmpathyContactList *list)
130 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
132 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
133 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
140 empathy_contact_list_get_all_groups (EmpathyContactList *list)
142 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
144 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
145 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
152 empathy_contact_list_get_groups (EmpathyContactList *list,
153 EmpathyContact *contact)
155 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
156 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
158 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
159 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
166 empathy_contact_list_add_to_group (EmpathyContactList *list,
167 EmpathyContact *contact,
170 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
171 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
172 g_return_if_fail (group != NULL);
174 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
175 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
180 empathy_contact_list_remove_from_group (EmpathyContactList *list,
181 EmpathyContact *contact,
184 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
185 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
186 g_return_if_fail (group != NULL);
188 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
189 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
194 empathy_contact_list_rename_group (EmpathyContactList *list,
195 const gchar *old_group,
196 const gchar *new_group)
198 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
199 g_return_if_fail (old_group != NULL);
200 g_return_if_fail (new_group != NULL);
202 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
203 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);