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 ("contact-added",
57 G_TYPE_FROM_CLASS (klass),
61 g_cclosure_marshal_VOID__OBJECT,
63 1, EMPATHY_TYPE_CONTACT);
65 g_signal_new ("contact-removed",
66 G_TYPE_FROM_CLASS (klass),
70 g_cclosure_marshal_VOID__OBJECT,
72 1, EMPATHY_TYPE_CONTACT);
74 g_signal_new ("local-pending",
75 G_TYPE_FROM_CLASS (klass),
79 empathy_marshal_VOID__OBJECT_STRING,
81 2, EMPATHY_TYPE_CONTACT, G_TYPE_STRING);
87 EmpathyContactListInfo *
88 empathy_contact_list_info_new (EmpathyContact *contact,
91 EmpathyContactListInfo *info;
93 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
95 info = g_slice_new0 (EmpathyContactListInfo);
96 info->contact = g_object_ref (contact);
97 info->message = g_strdup (message);
103 empathy_contact_list_info_free (EmpathyContactListInfo *info)
110 g_object_unref (info->contact);
112 g_free (info->message);
114 g_slice_free (EmpathyContactListInfo, info);
118 empathy_contact_list_setup (EmpathyContactList *list)
120 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
122 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup) {
123 EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup (list);
128 empathy_contact_list_find (EmpathyContactList *list,
131 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
133 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->find) {
134 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->find (list, id);
141 empathy_contact_list_add (EmpathyContactList *list,
142 EmpathyContact *contact,
143 const gchar *message)
145 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
147 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
148 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
153 empathy_contact_list_remove (EmpathyContactList *list,
154 EmpathyContact *contact,
155 const gchar *message)
157 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
159 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
160 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
165 empathy_contact_list_get_members (EmpathyContactList *list)
167 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
169 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
170 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
177 empathy_contact_list_get_local_pending (EmpathyContactList *list)
179 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
181 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_local_pending) {
182 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_local_pending (list);
189 empathy_contact_list_process_pending (EmpathyContactList *list,
190 EmpathyContact *contact,
193 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
195 if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->process_pending) {
196 EMPATHY_CONTACT_LIST_GET_IFACE (list)->process_pending (list,