]> git.0d.be Git - empathy.git/blob - libempathy/empathy-contact-list.c
Added functions to determine if a contact has video capabilities
[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 #include "empathy-marshal.h"
26
27 static void contact_list_base_init (gpointer klass);
28
29 GType
30 empathy_contact_list_get_type (void)
31 {
32         static GType type = 0;
33
34         if (!type) {
35                 static const GTypeInfo type_info = {
36                         sizeof (EmpathyContactListIface),
37                         contact_list_base_init,
38                         NULL,
39                 };
40
41                 type = g_type_register_static (G_TYPE_INTERFACE,
42                                                "EmpathyContactList",
43                                                &type_info, 0);
44
45                 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
46         }
47
48         return type;
49 }
50
51 static void
52 contact_list_base_init (gpointer klass)
53 {
54         static gboolean initialized = FALSE;
55
56         if (!initialized) {
57                 g_signal_new ("members-changed",
58                               G_TYPE_FROM_CLASS (klass),
59                               G_SIGNAL_RUN_LAST,
60                               0,
61                               NULL, NULL,
62                               _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
63                               G_TYPE_NONE,
64                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
65                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
66
67                 g_signal_new ("pendings-changed",
68                               G_TYPE_FROM_CLASS (klass),
69                               G_SIGNAL_RUN_LAST,
70                               0,
71                               NULL, NULL,
72                               _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
73                               G_TYPE_NONE,
74                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
75                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
76
77                 g_signal_new ("groups-changed",
78                               G_TYPE_FROM_CLASS (klass),
79                               G_SIGNAL_RUN_LAST,
80                               0,
81                               NULL, NULL,
82                               _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
83                               G_TYPE_NONE,
84                               3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
85
86                 initialized = TRUE;
87         }
88 }
89
90 void
91 empathy_contact_list_add (EmpathyContactList *list,
92                           EmpathyContact     *contact,
93                           const gchar        *message)
94 {
95         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
96         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
97
98         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
99                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
100         }
101 }
102
103 void
104 empathy_contact_list_remove (EmpathyContactList *list,
105                              EmpathyContact     *contact,
106                              const gchar        *message)
107 {
108         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
109         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
110
111         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
112                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
113         }
114 }
115
116 GList *
117 empathy_contact_list_get_members (EmpathyContactList *list)
118 {
119         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
120
121         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
122                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
123         }
124
125         return NULL;
126 }
127
128 EmpathyContactMonitor *
129 empathy_contact_list_get_monitor (EmpathyContactList *list)
130 {
131         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
132
133         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor) {
134                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor (list);
135         }
136
137         return NULL;
138 }
139
140 GList *
141 empathy_contact_list_get_pendings (EmpathyContactList *list)
142 {
143         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
144
145         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
146                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
147         }
148
149         return NULL;
150 }
151
152 GList *
153 empathy_contact_list_get_all_groups (EmpathyContactList *list)
154 {
155         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
156
157         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
158                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
159         }
160
161         return NULL;
162 }
163
164 GList *
165 empathy_contact_list_get_groups (EmpathyContactList *list,
166                                  EmpathyContact     *contact)
167 {
168         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
169         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
170
171         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
172                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
173         }
174
175         return NULL;
176 }
177
178 void
179 empathy_contact_list_add_to_group (EmpathyContactList *list,
180                                    EmpathyContact     *contact,
181                                    const gchar        *group)
182 {
183         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
184         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
185         g_return_if_fail (group != NULL);
186
187         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
188                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
189         }
190 }
191
192 void
193 empathy_contact_list_remove_from_group (EmpathyContactList *list,
194                                         EmpathyContact     *contact,
195                                         const gchar        *group)
196 {
197         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
198         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
199         g_return_if_fail (group != NULL);
200
201         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
202                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
203         }
204 }
205
206 void
207 empathy_contact_list_rename_group (EmpathyContactList *list,
208                                    const gchar        *old_group,
209                                    const gchar        *new_group)
210 {
211         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
212         g_return_if_fail (old_group != NULL);
213         g_return_if_fail (new_group != NULL);
214
215         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
216                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
217         }
218 }
219
220 void
221 empathy_contact_list_remove_group (EmpathyContactList *list,
222                                    const gchar *group)
223 {
224         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
225         g_return_if_fail (group != NULL);
226
227         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
228                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
229         }
230 }
231