]> git.0d.be Git - empathy.git/blob - libempathy/empathy-tp-chatroom.c
Fix indentation Fix not returning the contact in tp_contact_list_find()
[empathy.git] / libempathy / empathy-tp-chatroom.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 <libmissioncontrol/mission-control.h>
26
27 #include "empathy-tp-chatroom.h"
28 #include "empathy-tp-contact-list.h"
29 #include "empathy-contact-list.h"
30 #include "empathy-contact-manager.h"
31 #include "gossip-telepathy-group.h"
32 #include "gossip-utils.h"
33
34 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
35                        EMPATHY_TYPE_TP_CHATROOM, EmpathyTpChatroomPriv))
36
37 #define DEBUG_DOMAIN "TpChatroom"
38
39 struct _EmpathyTpChatroomPriv {
40         EmpathyContactManager *manager;
41         EmpathyTpContactList  *list;
42         GossipTelepathyGroup  *group;
43 };
44
45 static void            empathy_tp_chatroom_class_init (EmpathyTpChatroomClass  *klass);
46 static void            tp_chatroom_iface_init         (EmpathyContactListIface *iface);
47 static void            empathy_tp_chatroom_init       (EmpathyTpChatroom       *chatroom);
48 static void            tp_chatroom_finalize           (GObject                 *object);
49 static void            tp_chatroom_setup              (EmpathyContactList      *list);
50 static GossipContact * tp_chatroom_find               (EmpathyContactList      *list,
51                                                        const gchar             *id);
52 static void            tp_chatroom_add                (EmpathyContactList      *list,
53                                                        GossipContact           *contact,
54                                                        const gchar             *message);
55 static void            tp_chatroom_remove             (EmpathyContactList      *list,
56                                                        GossipContact           *contact,
57                                                        const gchar             *message);
58 static GList *         tp_chatroom_get_contacts       (EmpathyContactList      *list);
59
60 G_DEFINE_TYPE_WITH_CODE (EmpathyTpChatroom, empathy_tp_chatroom, EMPATHY_TYPE_TP_CHAT,
61                          G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
62                                                 tp_chatroom_iface_init));
63
64 static void
65 empathy_tp_chatroom_class_init (EmpathyTpChatroomClass *klass)
66 {
67         GObjectClass *object_class = G_OBJECT_CLASS (klass);
68
69         object_class->finalize = tp_chatroom_finalize;
70
71         g_type_class_add_private (object_class, sizeof (EmpathyTpChatroomPriv));
72 }
73
74 static void
75 tp_chatroom_iface_init (EmpathyContactListIface *iface)
76 {
77         iface->setup = tp_chatroom_setup;
78         iface->find = tp_chatroom_find;
79         iface->add = tp_chatroom_add;
80         iface->remove = tp_chatroom_remove;
81         iface->get_contacts = tp_chatroom_get_contacts;
82 }
83
84 static void
85 empathy_tp_chatroom_init (EmpathyTpChatroom *chatroom)
86 {
87 }
88
89 static void
90 tp_chatroom_finalize (GObject *object)
91 {
92         EmpathyTpChatroomPriv *priv;
93         EmpathyTpChatroom     *chatroom;
94
95         chatroom = EMPATHY_TP_CHATROOM (object);
96         priv = GET_PRIV (chatroom);
97
98         g_object_unref (priv->group);
99         g_object_unref (priv->manager);
100         g_object_unref (priv->list);
101
102         G_OBJECT_CLASS (empathy_tp_chatroom_parent_class)->finalize (object);
103 }
104
105 EmpathyTpChatroom *
106 empathy_tp_chatroom_new (McAccount *account,
107                          TpChan    *tp_chan)
108 {
109         EmpathyTpChatroomPriv *priv;
110         EmpathyTpChatroom     *chatroom;
111         TpConn                *tp_conn;
112         MissionControl        *mc;
113
114         g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
115         g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL);
116
117         chatroom = g_object_new (EMPATHY_TYPE_TP_CHATROOM,
118                                  "account", account,
119                                  "tp-chan", tp_chan,
120                                  NULL);
121
122         priv = GET_PRIV (chatroom);
123
124         mc = gossip_mission_control_new ();
125         tp_conn = mission_control_get_connection (mc, account, NULL);
126         priv->manager = empathy_contact_manager_new ();
127         priv->group = gossip_telepathy_group_new (tp_chan, tp_conn);
128         priv->list = empathy_contact_manager_get_list (priv->manager, account);
129
130         g_object_unref (mc);
131         g_object_unref (tp_conn);
132
133         return chatroom;
134 }
135
136 static void
137 tp_chatroom_setup (EmpathyContactList *list)
138 {
139 }
140
141 static GossipContact *
142 tp_chatroom_find (EmpathyContactList *list,
143                   const gchar        *id)
144 {
145         return NULL;
146 }
147
148 static void
149 tp_chatroom_add (EmpathyContactList *list,
150                  GossipContact      *contact,
151                  const gchar        *message)
152 {
153 }
154
155 static void
156 tp_chatroom_remove (EmpathyContactList *list,
157                     GossipContact      *contact,
158                     const gchar        *message)
159 {
160 }
161
162 static GList *
163 tp_chatroom_get_contacts (EmpathyContactList *list)
164 {
165         return NULL;
166 }
167