]> git.0d.be Git - empathy.git/blob - libempathy/empathy-contact-list.c
Updated Polish translation
[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 ("member-renamed",
58                               G_TYPE_FROM_CLASS (klass),
59                               G_SIGNAL_RUN_LAST,
60                               0,
61                               NULL, NULL,
62                               _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING,
63                               G_TYPE_NONE,
64                               4, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT, G_TYPE_UINT, G_TYPE_STRING);
65
66                 g_signal_new ("members-changed",
67                               G_TYPE_FROM_CLASS (klass),
68                               G_SIGNAL_RUN_LAST,
69                               0,
70                               NULL, NULL,
71                               _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
72                               G_TYPE_NONE,
73                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
74                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
75
76                 g_signal_new ("pendings-changed",
77                               G_TYPE_FROM_CLASS (klass),
78                               G_SIGNAL_RUN_LAST,
79                               0,
80                               NULL, NULL,
81                               _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
82                               G_TYPE_NONE,
83                               5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
84                               G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
85
86                 g_signal_new ("groups-changed",
87                               G_TYPE_FROM_CLASS (klass),
88                               G_SIGNAL_RUN_LAST,
89                               0,
90                               NULL, NULL,
91                               _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
92                               G_TYPE_NONE,
93                               3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
94
95                 initialized = TRUE;
96         }
97 }
98
99 void
100 empathy_contact_list_add (EmpathyContactList *list,
101                           EmpathyContact     *contact,
102                           const gchar        *message)
103 {
104         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
105         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
106
107         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
108                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
109         }
110 }
111
112 void
113 empathy_contact_list_remove (EmpathyContactList *list,
114                              EmpathyContact     *contact,
115                              const gchar        *message)
116 {
117         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
118         g_return_if_fail (EMPATHY_IS_CONTACT (contact));
119
120         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
121                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
122         }
123 }
124
125 GList *
126 empathy_contact_list_get_members (EmpathyContactList *list)
127 {
128         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
129
130         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
131                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
132         }
133
134         return NULL;
135 }
136
137 EmpathyContactMonitor *
138 empathy_contact_list_get_monitor (EmpathyContactList *list)
139 {
140         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
141
142         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor) {
143                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_monitor (list);
144         }
145
146         return NULL;
147 }
148
149 GList *
150 empathy_contact_list_get_pendings (EmpathyContactList *list)
151 {
152         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
153
154         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
155                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
156         }
157
158         return NULL;
159 }
160
161 GList *
162 empathy_contact_list_get_all_groups (EmpathyContactList *list)
163 {
164         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
165
166         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
167                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
168         }
169
170         return NULL;
171 }
172
173 GList *
174 empathy_contact_list_get_groups (EmpathyContactList *list,
175                                  EmpathyContact     *contact)
176 {
177         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
178         g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
179
180         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
181                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
182         }
183
184         return NULL;
185 }
186
187 void
188 empathy_contact_list_add_to_group (EmpathyContactList *list,
189                                    EmpathyContact     *contact,
190                                    const gchar        *group)
191 {
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);
195
196         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
197                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
198         }
199 }
200
201 void
202 empathy_contact_list_remove_from_group (EmpathyContactList *list,
203                                         EmpathyContact     *contact,
204                                         const gchar        *group)
205 {
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);
209
210         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
211                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
212         }
213 }
214
215 void
216 empathy_contact_list_rename_group (EmpathyContactList *list,
217                                    const gchar        *old_group,
218                                    const gchar        *new_group)
219 {
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);
223
224         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
225                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
226         }
227 }
228
229 void
230 empathy_contact_list_remove_group (EmpathyContactList *list,
231                                    const gchar *group)
232 {
233         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
234         g_return_if_fail (group != NULL);
235
236         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
237                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
238         }
239 }
240
241 EmpathyContactListFlags
242 empathy_contact_list_get_flags (EmpathyContactList *list)
243 {
244         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), 0);
245
246         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags) {
247                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags (list);
248         } else {
249                 return 0;
250         }
251 }