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 ("pendings-changed",
77 G_TYPE_FROM_CLASS (klass
),
81 _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN
,
83 5, EMPATHY_TYPE_CONTACT
, EMPATHY_TYPE_CONTACT
,
84 G_TYPE_UINT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
);
86 g_signal_new ("groups-changed",
87 G_TYPE_FROM_CLASS (klass
),
91 _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN
,
93 3, EMPATHY_TYPE_CONTACT
, G_TYPE_STRING
, G_TYPE_BOOLEAN
);
100 empathy_contact_list_add (EmpathyContactList
*list
,
101 EmpathyContact
*contact
,
102 const gchar
*message
)
104 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
105 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
107 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add
) {
108 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add (list
, contact
, message
);
113 empathy_contact_list_remove (EmpathyContactList
*list
,
114 EmpathyContact
*contact
,
115 const gchar
*message
)
117 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
118 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
120 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove
) {
121 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove (list
, contact
, message
);
126 empathy_contact_list_get_members (EmpathyContactList
*list
)
128 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
130 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_members
) {
131 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_members (list
);
137 EmpathyContactMonitor
*
138 empathy_contact_list_get_monitor (EmpathyContactList
*list
)
140 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
142 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_monitor
) {
143 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_monitor (list
);
150 empathy_contact_list_get_pendings (EmpathyContactList
*list
)
152 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
154 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_pendings
) {
155 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_pendings (list
);
162 empathy_contact_list_get_all_groups (EmpathyContactList
*list
)
164 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
166 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_all_groups
) {
167 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_all_groups (list
);
174 empathy_contact_list_get_groups (EmpathyContactList
*list
,
175 EmpathyContact
*contact
)
177 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), NULL
);
178 g_return_val_if_fail (EMPATHY_IS_CONTACT (contact
), NULL
);
180 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_groups
) {
181 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_groups (list
, contact
);
188 empathy_contact_list_add_to_group (EmpathyContactList
*list
,
189 EmpathyContact
*contact
,
192 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
193 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
194 g_return_if_fail (group
!= NULL
);
196 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add_to_group
) {
197 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->add_to_group (list
, contact
, group
);
202 empathy_contact_list_remove_from_group (EmpathyContactList
*list
,
203 EmpathyContact
*contact
,
206 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
207 g_return_if_fail (EMPATHY_IS_CONTACT (contact
));
208 g_return_if_fail (group
!= NULL
);
210 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_from_group
) {
211 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_from_group (list
, contact
, group
);
216 empathy_contact_list_rename_group (EmpathyContactList
*list
,
217 const gchar
*old_group
,
218 const gchar
*new_group
)
220 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
221 g_return_if_fail (old_group
!= NULL
);
222 g_return_if_fail (new_group
!= NULL
);
224 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->rename_group
) {
225 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->rename_group (list
, old_group
, new_group
);
230 empathy_contact_list_remove_group (EmpathyContactList
*list
,
233 g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list
));
234 g_return_if_fail (group
!= NULL
);
236 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_group
) {
237 EMPATHY_CONTACT_LIST_GET_IFACE (list
)->remove_group (list
, group
);
241 EmpathyContactListFlags
242 empathy_contact_list_get_flags (EmpathyContactList
*list
)
244 g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list
), 0);
246 if (EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_flags
) {
247 return EMPATHY_CONTACT_LIST_GET_IFACE (list
)->get_flags (list
);