]> git.0d.be Git - empathy.git/blob - libempathy/empathy-contact-list.c
individual-menu: remove link-contacts-activated signal
[empathy.git] / libempathy / empathy-contact-list.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
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.
9  *
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.
14  *
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
18  *
19  * Authors: Xavier Claessens <xclaesse@gmail.com>
20  */
21
22 #include "config.h"
23
24 #include "empathy-contact-list.h"
25
26 static void contact_list_base_init (gpointer klass);
27
28 GType
29 empathy_contact_list_get_type (void)
30 {
31         static GType type = 0;
32
33         if (!type) {
34                 static const GTypeInfo type_info = {
35                         sizeof (EmpathyContactListIface),
36                         contact_list_base_init,
37                         NULL,
38                 };
39
40                 type = g_type_register_static (G_TYPE_INTERFACE,
41                                                "EmpathyContactList",
42                                                &type_info, 0);
43
44                 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
45         }
46
47         return type;
48 }
49
50 static void
51 contact_list_base_init (gpointer klass)
52 {
53         static gboolean initialized = FALSE;
54
55         if (!initialized) {
56                 g_signal_new ("member-renamed",
57                               G_TYPE_FROM_CLASS (klass),
58                               G_SIGNAL_RUN_LAST,
59                               0,
60                               NULL, NULL,
61                               g_cclosure_marshal_generic,
62                               G_TYPE_NONE,
63                               4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
64
65                 g_signal_new ("members-changed",
66                               G_TYPE_FROM_CLASS (klass),
67                               G_SIGNAL_RUN_LAST,
68                               0,
69                               NULL, NULL,
70                               g_cclosure_marshal_generic,
71                               G_TYPE_NONE,
72                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
73                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
74
75                 g_signal_new ("pendings-changed",
76                               G_TYPE_FROM_CLASS (klass),
77                               G_SIGNAL_RUN_LAST,
78                               0,
79                               NULL, NULL,
80                               g_cclosure_marshal_generic,
81                               G_TYPE_NONE,
82                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
83                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
84
85                 g_signal_new ("groups-changed",
86                               G_TYPE_FROM_CLASS (klass),
87                               G_SIGNAL_RUN_LAST,
88                               0,
89                               NULL, NULL,
90                               g_cclosure_marshal_generic,
91                               G_TYPE_NONE,
92                               3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
93
94                 initialized = TRUE;
95         }
96 }
97
98 void
99 empathy_contact_list_add (EmpathyContactList *list,
100                           EmpathyContact     *contact,
101                           const gchar        *message)
102 {
103         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
104         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
105
106         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
107                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
108         }
109 }
110
111 void
112 empathy_contact_list_remove (EmpathyContactList *list,
113                              EmpathyContact     *contact,
114                              const gchar        *message)
115 {
116         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
117         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
118
119         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
120                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
121         }
122 }
123
124 GList *
125 empathy_contact_list_get_members (EmpathyContactList *list)
126 {
127         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
128
129         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
130                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
131         }
132
133         return NULL;
134 }
135
136 GList *
137 empathy_contact_list_get_pendings (EmpathyContactList *list)
138 {
139         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
140
141         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
142                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
143         }
144
145         return NULL;
146 }
147
148 GList *
149 empathy_contact_list_get_groups (EmpathyContactList *list,
150                                  EmpathyContact     *contact)
151 {
152         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
153         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
154
155         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
156                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
157         }
158
159         return NULL;
160 }
161
162 void
163 empathy_contact_list_add_to_group (EmpathyContactList *list,
164                                    EmpathyContact     *contact,
165                                    const gchar        *group)
166 {
167         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
168         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
169         g_return_if_fail (group != NULL);
170
171         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
172                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
173         }
174 }
175
176 void
177 empathy_contact_list_remove_from_group (EmpathyContactList *list,
178                                         EmpathyContact     *contact,
179                                         const gchar        *group)
180 {
181         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
182         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
183         g_return_if_fail (group != NULL);
184
185         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
186                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
187         }
188 }
189
190 void
191 empathy_contact_list_rename_group (EmpathyContactList *list,
192                                    const gchar        *old_group,
193                                    const gchar        *new_group)
194 {
195         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
196         g_return_if_fail (old_group != NULL);
197         g_return_if_fail (new_group != NULL);
198
199         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
200                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
201         }
202 }
203
204 void
205 empathy_contact_list_remove_group (EmpathyContactList *list,
206                                    const gchar *group)
207 {
208         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
209         g_return_if_fail (group != NULL);
210
211         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
212                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
213         }
214 }