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 ("members-changed",
58 G_TYPE_FROM_CLASS (klass
),
62 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN
,
64 5, EMPATHY_TYPE_CONTACT
, EMPATHY_TYPE_CONTACT
,
65 G_TYPE_UINT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
);
67 g_signal_new ("pendings-changed",
68 G_TYPE_FROM_CLASS (klass
),
72 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN
,
74 5, EMPATHY_TYPE_CONTACT
, EMPATHY_TYPE_CONTACT
,
75 G_TYPE_UINT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
);
77 g_signal_new ("groups-changed",
78 G_TYPE_FROM_CLASS (klass
),
82 _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN
,
84 3, EMPATHY_TYPE_CONTACT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
);
91 empathy_contact_list_add (EmpathyContactList
*list
,
92 EmpathyContact
*contact
,
95 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
96 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
98 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add
) {
99 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add (list
, contact
, message
);
104 empathy_contact_list_remove (EmpathyContactList
*list
,
105 EmpathyContact
*contact
,
106 const gchar
*message
)
108 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
109 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
111 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove
) {
112 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove (list
, contact
, message
);
117 empathy_contact_list_get_members (EmpathyContactList
*list
)
119 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
121 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_members
) {
122 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_members (list
);
129 empathy_contact_list_get_pendings (EmpathyContactList
*list
)
131 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
133 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_pendings
) {
134 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_pendings (list
);
141 empathy_contact_list_get_all_groups (EmpathyContactList
*list
)
143 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
145 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_all_groups
) {
146 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_all_groups (list
);
153 empathy_contact_list_get_groups (EmpathyContactList
*list
,
154 EmpathyContact
*contact
)
156 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
157 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact
), NULL
);
159 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_groups
) {
160 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_groups (list
, contact
);
167 empathy_contact_list_add_to_group (EmpathyContactList
*list
,
168 EmpathyContact
*contact
,
171 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
172 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
173 g_return_if_fail (group
!= NULL
);
175 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add_to_group
) {
176 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add_to_group (list
, contact
, group
);
181 empathy_contact_list_remove_from_group (EmpathyContactList
*list
,
182 EmpathyContact
*contact
,
185 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
186 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
187 g_return_if_fail (group
!= NULL
);
189 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_from_group
) {
190 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_from_group (list
, contact
, group
);
195 empathy_contact_list_rename_group (EmpathyContactList
*list
,
196 const gchar
*old_group
,
197 const gchar
*new_group
)
199 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
200 g_return_if_fail (old_group
!= NULL
);
201 g_return_if_fail (new_group
!= NULL
);
203 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->rename_group
) {
204 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->rename_group (list
, old_group
, new_group
);
209 empathy_contact_list_remove_group (EmpathyContactList
*list
,
212 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
213 g_return_if_fail (group
!= NULL
);
215 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_group
) {
216 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_group (list
, group
);