]> git.0d.be Git - empathy.git/blob - libempathy/empathy-contact-list.c
Fix indentation Fix not returning the contact in tp_contact_list_find()
[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 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program 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  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include "config.h"
24
25 #include "empathy-contact-list.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
46         return type;
47 }
48
49 static void
50 contact_list_base_init (gpointer klass)
51 {
52         static gboolean initialized = FALSE;
53
54         if (!initialized) {
55                 g_signal_new ("contact-added",
56                               G_TYPE_FROM_CLASS (klass),
57                               G_SIGNAL_RUN_LAST,
58                               0,
59                               NULL, NULL,
60                               g_cclosure_marshal_VOID__OBJECT,
61                               G_TYPE_NONE,
62                               1, GOSSIP_TYPE_CONTACT);
63
64                 g_signal_new ("contact-removed",
65                               G_TYPE_FROM_CLASS (klass),
66                               G_SIGNAL_RUN_LAST,
67                               0,
68                               NULL, NULL,
69                               g_cclosure_marshal_VOID__OBJECT,
70                               G_TYPE_NONE,
71                               1, GOSSIP_TYPE_CONTACT);
72
73                 initialized = TRUE;
74         }
75 }
76
77 void
78 empathy_contact_list_setup (EmpathyContactList *list)
79 {
80         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
81
82         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup) {
83                 EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup (list);
84         }
85 }
86
87 GossipContact *
88 empathy_contact_list_find (EmpathyContactList *list,
89                            const gchar        *id)
90 {
91         g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
92
93         if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->find) {
94                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->find (list, id);
95         }
96
97         return NULL;
98 }
99
100 void
101 empathy_contact_list_add (EmpathyContactList *list,
102                           GossipContact      *contact,
103                           const gchar        *message)
104 {
105         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
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                              GossipContact      *contact,
115                              const gchar        *message)
116 {
117         g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
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_contacts (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_contacts) {
130                 return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_contacts (list);
131         }
132
133         return NULL;
134 }
135