~ubuntu-branches/ubuntu/natty/empathy/natty-updates

« back to all changes in this revision

Viewing changes to libempathy/empathy-tp-chat.c

Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
2
/*
3
 
 * Copyright (C) 2007 Collabora Ltd.
 
3
 * Copyright (C) 2007-2008 Collabora Ltd.
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Lesser General Public
28
28
#include <libtelepathy/tp-conn.h>
29
29
#include <libtelepathy/tp-helpers.h>
30
30
#include <libtelepathy/tp-props-iface.h>
 
31
#include <telepathy-glib/util.h>
31
32
 
32
33
#include "empathy-tp-chat.h"
33
34
#include "empathy-contact-factory.h"
48
49
        gchar                 *id;
49
50
        MissionControl        *mc;
50
51
        gboolean               acknowledge;
51
 
 
 
52
        gboolean               had_pending_messages;
 
53
        GSList                *message_queue;
52
54
        TpChan                *tp_chan;
53
55
        DBusGProxy            *props_iface;
54
56
        DBusGProxy            *text_iface;
55
57
        DBusGProxy            *chat_state_iface;
56
58
};
57
59
 
58
 
static void             empathy_tp_chat_class_init    (EmpathyTpChatClass    *klass);
59
 
static void             empathy_tp_chat_init          (EmpathyTpChat         *chat);
60
 
static void             tp_chat_finalize              (GObject               *object);
61
 
static GObject *        tp_chat_constructor           (GType                  type,
62
 
                                                       guint                  n_props,
63
 
                                                       GObjectConstructParam *props);
64
 
static void             tp_chat_get_property          (GObject               *object,
65
 
                                                       guint                  param_id,
66
 
                                                       GValue                *value,
67
 
                                                       GParamSpec            *pspec);
68
 
static void             tp_chat_set_property          (GObject               *object,
69
 
                                                       guint                  param_id,
70
 
                                                       const GValue          *value,
71
 
                                                       GParamSpec            *pspec);
72
 
static void             tp_chat_destroy_cb            (TpChan                *text_chan,
73
 
                                                       EmpathyTpChat         *chat);
74
 
static void             tp_chat_closed_cb             (TpChan                *text_chan,
75
 
                                                       EmpathyTpChat         *chat);
76
 
static void             tp_chat_received_cb           (DBusGProxy            *text_iface,
77
 
                                                       guint                  message_id,
78
 
                                                       guint                  timestamp,
79
 
                                                       guint                  from_handle,
80
 
                                                       guint                  message_type,
81
 
                                                       guint                  message_flags,
82
 
                                                       gchar                 *message_body,
83
 
                                                       EmpathyTpChat         *chat);
84
 
static void             tp_chat_sent_cb               (DBusGProxy            *text_iface,
85
 
                                                       guint                  timestamp,
86
 
                                                       guint                  message_type,
87
 
                                                       gchar                 *message_body,
88
 
                                                       EmpathyTpChat         *chat);
89
 
static void             tp_chat_send_error_cb         (DBusGProxy            *text_iface,
90
 
                                                       guint                  error_code,
91
 
                                                       guint                  timestamp,
92
 
                                                       guint                  message_type,
93
 
                                                       gchar                 *message_body,
94
 
                                                       EmpathyTpChat         *chat);
95
 
static void             tp_chat_state_changed_cb      (DBusGProxy            *chat_state_iface,
96
 
                                                       guint                  handle,
97
 
                                                       TpChannelChatState     state,
98
 
                                                       EmpathyTpChat         *chat);
99
 
static EmpathyMessage * tp_chat_build_message         (EmpathyTpChat         *chat,
100
 
                                                       guint                  type,
101
 
                                                       guint                  timestamp,
102
 
                                                       guint                  from_handle,
103
 
                                                       const gchar           *message_body);
104
 
static void             tp_chat_properties_ready_cb   (TpPropsIface          *props_iface,
105
 
                                                       EmpathyTpChat         *chat);
106
 
static void             tp_chat_properties_changed_cb (TpPropsIface          *props_iface,
107
 
                                                       guint                  prop_id,
108
 
                                                       TpPropsChanged         flag,
109
 
                                                       EmpathyTpChat         *chat);
 
60
static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass);
 
61
static void empathy_tp_chat_init       (EmpathyTpChat      *chat);
 
62
 
110
63
enum {
111
64
        PROP_0,
112
65
        PROP_ACCOUNT,
142
95
G_DEFINE_TYPE (EmpathyTpChat, empathy_tp_chat, G_TYPE_OBJECT);
143
96
 
144
97
static void
145
 
empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
146
 
{
147
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
148
 
 
149
 
        object_class->finalize = tp_chat_finalize;
150
 
        object_class->constructor = tp_chat_constructor;
151
 
        object_class->get_property = tp_chat_get_property;
152
 
        object_class->set_property = tp_chat_set_property;
153
 
 
154
 
        /* Construct-only properties */
155
 
        g_object_class_install_property (object_class,
156
 
                                         PROP_ACCOUNT,
157
 
                                         g_param_spec_object ("account",
158
 
                                                              "channel Account",
159
 
                                                              "The account associated with the channel",
160
 
                                                              MC_TYPE_ACCOUNT,
161
 
                                                              G_PARAM_READWRITE |
162
 
                                                              G_PARAM_CONSTRUCT_ONLY));
163
 
        g_object_class_install_property (object_class,
164
 
                                         PROP_TP_CHAN,
165
 
                                         g_param_spec_object ("tp-chan",
166
 
                                                              "telepathy channel",
167
 
                                                              "The text channel for the chat",
168
 
                                                              TELEPATHY_CHAN_TYPE,
169
 
                                                              G_PARAM_READWRITE |
170
 
                                                              G_PARAM_CONSTRUCT_ONLY));
171
 
 
172
 
        /* Normal properties */
173
 
        g_object_class_install_property (object_class,
174
 
                                         PROP_ACKNOWLEDGE,
175
 
                                         g_param_spec_boolean ("acknowledge",
176
 
                                                               "acknowledge",
177
 
                                                               "acknowledge",
178
 
                                                               FALSE,
179
 
                                                               G_PARAM_READWRITE));
180
 
 
181
 
        /* Properties of Text Channel */
182
 
        g_object_class_install_property (object_class,
183
 
                                         PROP_ANONYMOUS,
184
 
                                         g_param_spec_boolean ("anonymous",
185
 
                                                               "anonymous",
186
 
                                                               "anonymous",
187
 
                                                               FALSE,
188
 
                                                               G_PARAM_READWRITE));
189
 
        g_object_class_install_property (object_class,
190
 
                                         PROP_INVITE_ONLY,
191
 
                                         g_param_spec_boolean ("invite-only",
192
 
                                                               "invite-only",
193
 
                                                               "invite-only",
194
 
                                                               FALSE,
195
 
                                                               G_PARAM_READWRITE));
196
 
        g_object_class_install_property (object_class,
197
 
                                         PROP_LIMIT,
198
 
                                         g_param_spec_uint ("limit",
199
 
                                                            "limit",
200
 
                                                            "limit",
201
 
                                                            0,
202
 
                                                            G_MAXUINT,
203
 
                                                            0,
204
 
                                                            G_PARAM_READWRITE));
205
 
        g_object_class_install_property (object_class,
206
 
                                         PROP_LIMITED,
207
 
                                         g_param_spec_boolean ("limited",
208
 
                                                               "limited",
209
 
                                                               "limited",
210
 
                                                               FALSE,
211
 
                                                               G_PARAM_READWRITE));
212
 
        g_object_class_install_property (object_class,
213
 
                                         PROP_MODERATED,
214
 
                                         g_param_spec_boolean ("moderated",
215
 
                                                               "moderated",
216
 
                                                               "moderated",
217
 
                                                               FALSE,
218
 
                                                               G_PARAM_READWRITE));
219
 
        g_object_class_install_property (object_class,
220
 
                                         PROP_NAME,
221
 
                                         g_param_spec_string ("name",
222
 
                                                              "name",
223
 
                                                              "name",
224
 
                                                              NULL,
225
 
                                                              G_PARAM_READWRITE));
226
 
        g_object_class_install_property (object_class,
227
 
                                         PROP_DESCRIPTION,
228
 
                                         g_param_spec_string ("description",
229
 
                                                              "description",
230
 
                                                              "description",
231
 
                                                              NULL,
232
 
                                                              G_PARAM_READWRITE));
233
 
        g_object_class_install_property (object_class,
234
 
                                         PROP_PASSWORD,
235
 
                                         g_param_spec_string ("password",
236
 
                                                              "password",
237
 
                                                              "password",
238
 
                                                              NULL,
239
 
                                                              G_PARAM_READWRITE));
240
 
        g_object_class_install_property (object_class,
241
 
                                         PROP_PASSWORD_REQUIRED,
242
 
                                         g_param_spec_boolean ("password-required",
243
 
                                                               "password-required",
244
 
                                                               "password-required",
245
 
                                                               FALSE,
246
 
                                                               G_PARAM_READWRITE));
247
 
        g_object_class_install_property (object_class,
248
 
                                         PROP_PERSISTENT,
249
 
                                         g_param_spec_boolean ("persistent",
250
 
                                                               "persistent",
251
 
                                                               "persistent",
252
 
                                                               FALSE,
253
 
                                                               G_PARAM_READWRITE));
254
 
        g_object_class_install_property (object_class,
255
 
                                         PROP_PRIVATE,
256
 
                                         g_param_spec_boolean ("private",
257
 
                                                               "private",
258
 
                                                               "private"
259
 
                                                               "private",
260
 
                                                               FALSE,
261
 
                                                               G_PARAM_READWRITE));
262
 
        g_object_class_install_property (object_class,
263
 
                                         PROP_SUBJECT,
264
 
                                         g_param_spec_string ("subject",
265
 
                                                              "subject",
266
 
                                                              "subject",
267
 
                                                              NULL,
268
 
                                                              G_PARAM_READWRITE));
269
 
        g_object_class_install_property (object_class,
270
 
                                         PROP_SUBJECT_CONTACT,
271
 
                                         g_param_spec_uint ("subject-contact",
272
 
                                                            "subject-contact",
273
 
                                                            "subject-contact",
274
 
                                                            0,
275
 
                                                            G_MAXUINT,
276
 
                                                            0,
277
 
                                                            G_PARAM_READWRITE));
278
 
        g_object_class_install_property (object_class,
279
 
                                         PROP_SUBJECT_TIMESTAMP,
280
 
                                         g_param_spec_uint ("subject-timestamp",
281
 
                                                            "subject-timestamp",
282
 
                                                            "subject-timestamp",
283
 
                                                            0,
284
 
                                                            G_MAXUINT,
285
 
                                                            0,
286
 
                                                            G_PARAM_READWRITE));
287
 
 
288
 
        /* Signals */
289
 
        signals[MESSAGE_RECEIVED] =
290
 
                g_signal_new ("message-received",
291
 
                              G_TYPE_FROM_CLASS (klass),
292
 
                              G_SIGNAL_RUN_LAST,
293
 
                              0,
294
 
                              NULL, NULL,
295
 
                              g_cclosure_marshal_VOID__OBJECT,
296
 
                              G_TYPE_NONE,
297
 
                              1, EMPATHY_TYPE_MESSAGE);
298
 
 
299
 
        signals[SEND_ERROR] =
300
 
                g_signal_new ("send-error",
301
 
                              G_TYPE_FROM_CLASS (klass),
302
 
                              G_SIGNAL_RUN_LAST,
303
 
                              0,
304
 
                              NULL, NULL,
305
 
                              _empathy_marshal_VOID__OBJECT_UINT,
306
 
                              G_TYPE_NONE,
307
 
                              2, EMPATHY_TYPE_MESSAGE, G_TYPE_UINT);
308
 
 
309
 
        signals[CHAT_STATE_CHANGED] =
310
 
                g_signal_new ("chat-state-changed",
311
 
                              G_TYPE_FROM_CLASS (klass),
312
 
                              G_SIGNAL_RUN_LAST,
313
 
                              0,
314
 
                              NULL, NULL,
315
 
                              _empathy_marshal_VOID__OBJECT_UINT,
316
 
                              G_TYPE_NONE,
317
 
                              2, EMPATHY_TYPE_CONTACT, G_TYPE_UINT);
318
 
 
319
 
        signals[DESTROY] =
320
 
                g_signal_new ("destroy",
321
 
                              G_TYPE_FROM_CLASS (klass),
322
 
                              G_SIGNAL_RUN_LAST,
323
 
                              0,
324
 
                              NULL, NULL,
325
 
                              g_cclosure_marshal_VOID__VOID,
326
 
                              G_TYPE_NONE,
327
 
                              0);
328
 
 
329
 
        g_type_class_add_private (object_class, sizeof (EmpathyTpChatPriv));
330
 
}
331
 
 
332
 
static void
333
 
empathy_tp_chat_init (EmpathyTpChat *chat)
334
 
{
335
 
}
336
 
 
 
98
tp_chat_destroy_cb (TpChan        *text_chan,
 
99
                    EmpathyTpChat *chat)
 
100
{
 
101
        EmpathyTpChatPriv *priv;
 
102
 
 
103
        priv = GET_PRIV (chat);
 
104
 
 
105
        empathy_debug (DEBUG_DOMAIN, "Channel Closed or CM crashed");
 
106
 
 
107
        g_object_unref  (priv->tp_chan);
 
108
        priv->tp_chan = NULL;
 
109
        priv->text_iface = NULL;
 
110
        priv->chat_state_iface = NULL;
 
111
        priv->props_iface = NULL;
 
112
 
 
113
        g_signal_emit (chat, signals[DESTROY], 0);
 
114
}
 
115
 
 
116
static void
 
117
tp_chat_closed_cb (TpChan        *text_chan,
 
118
                   EmpathyTpChat *chat)
 
119
{
 
120
        EmpathyTpChatPriv *priv;
 
121
 
 
122
        priv = GET_PRIV (chat);
 
123
 
 
124
        /* The channel is closed, do just like if the proxy was destroyed */
 
125
        g_signal_handlers_disconnect_by_func (priv->tp_chan,
 
126
                                              tp_chat_destroy_cb,
 
127
                                              chat);
 
128
        tp_chat_destroy_cb (text_chan, chat);
 
129
}
 
130
 
 
131
static EmpathyMessage *
 
132
tp_chat_build_message (EmpathyTpChat *chat,
 
133
                       guint          type,
 
134
                       guint          timestamp,
 
135
                       guint          from_handle,
 
136
                       const gchar   *message_body)
 
137
{
 
138
        EmpathyTpChatPriv *priv;
 
139
        EmpathyMessage    *message;
 
140
        EmpathyContact    *sender;
 
141
 
 
142
        priv = GET_PRIV (chat);
 
143
 
 
144
        if (from_handle == 0) {
 
145
                sender = g_object_ref (priv->user);
 
146
        } else {
 
147
                sender = empathy_contact_factory_get_from_handle (priv->factory,
 
148
                                                                  priv->account,
 
149
                                                                  from_handle);
 
150
        }
 
151
 
 
152
        message = empathy_message_new (message_body);
 
153
        empathy_message_set_type (message, type);
 
154
        empathy_message_set_sender (message, sender);
 
155
        empathy_message_set_receiver (message, priv->user);
 
156
        empathy_message_set_timestamp (message, timestamp);
 
157
 
 
158
        g_object_unref (sender);
 
159
 
 
160
        return message;
 
161
}
 
162
 
 
163
static void
 
164
tp_chat_sender_ready_notify_cb (EmpathyContact *contact,
 
165
                                GParamSpec     *param_spec,
 
166
                                EmpathyTpChat  *chat)
 
167
{
 
168
        EmpathyTpChatPriv *priv = GET_PRIV (chat);
 
169
        EmpathyMessage    *message;
 
170
        EmpathyContact    *sender;
 
171
        gboolean           removed = FALSE;
 
172
        const gchar       *name, *id;
 
173
 
 
174
        /* Emit all messages queued until we find a message with not
 
175
         * ready sender. When leaving this loop, sender is the first not ready
 
176
         * contact queued and removed tells if at least one message got removed
 
177
         * from the queue. */
 
178
        while (priv->message_queue) {
 
179
                message = priv->message_queue->data;
 
180
                sender = empathy_message_get_sender (message);
 
181
                name = empathy_contact_get_name (sender);
 
182
                id = empathy_contact_get_id (sender);
 
183
 
 
184
                if (!tp_strdiff (name, id)) {
 
185
                        break;
 
186
                }
 
187
 
 
188
                empathy_debug (DEBUG_DOMAIN, "Queued message ready");
 
189
                g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
 
190
                priv->message_queue = g_slist_remove (priv->message_queue,
 
191
                                                      message);
 
192
                g_object_unref (message);
 
193
                removed = TRUE;
 
194
        }
 
195
 
 
196
        if (removed) {
 
197
                g_signal_handlers_disconnect_by_func (contact,
 
198
                                                      tp_chat_sender_ready_notify_cb,
 
199
                                                      chat);
 
200
 
 
201
                if (priv->message_queue) {
 
202
                        g_signal_connect (sender, "notify::name",
 
203
                                          G_CALLBACK (tp_chat_sender_ready_notify_cb),
 
204
                                          chat);
 
205
                }
 
206
        }
 
207
}
 
208
 
 
209
static void
 
210
tp_chat_emit_or_queue_message (EmpathyTpChat  *chat,
 
211
                               EmpathyMessage *message)
 
212
{
 
213
        EmpathyTpChatPriv   *priv = GET_PRIV (chat);
 
214
        EmpathyContact      *sender;
 
215
        const gchar         *name, *id;
 
216
 
 
217
        if (priv->message_queue != NULL) {
 
218
                empathy_debug (DEBUG_DOMAIN, "Message queue not empty");
 
219
                priv->message_queue = g_slist_append (priv->message_queue,
 
220
                                                      g_object_ref (message));
 
221
                return;
 
222
        }
 
223
 
 
224
        sender = empathy_message_get_sender (message);
 
225
        name = empathy_contact_get_name (sender);
 
226
        id = empathy_contact_get_id (sender);
 
227
        if (tp_strdiff (name, id)) {
 
228
                empathy_debug (DEBUG_DOMAIN, "Message queue empty and sender ready");
 
229
                g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
 
230
                return;
 
231
        }
 
232
 
 
233
        empathy_debug (DEBUG_DOMAIN, "Sender not ready");
 
234
        priv->message_queue = g_slist_append (priv->message_queue, 
 
235
                                              g_object_ref (message));
 
236
        g_signal_connect (sender, "notify::name",
 
237
                          G_CALLBACK (tp_chat_sender_ready_notify_cb),
 
238
                          chat);
 
239
}
 
240
 
 
241
static void
 
242
tp_chat_received_cb (DBusGProxy    *text_iface,
 
243
                     guint          message_id,
 
244
                     guint          timestamp,
 
245
                     guint          from_handle,
 
246
                     guint          message_type,
 
247
                     guint          message_flags,
 
248
                     gchar         *message_body,
 
249
                     EmpathyTpChat *chat)
 
250
{
 
251
        EmpathyTpChatPriv *priv;
 
252
        EmpathyMessage    *message;
 
253
 
 
254
        priv = GET_PRIV (chat);
 
255
 
 
256
        if (!priv->had_pending_messages) {
 
257
                return;
 
258
        }
 
259
 
 
260
        empathy_debug (DEBUG_DOMAIN, "Message received: %s", message_body);
 
261
 
 
262
        message = tp_chat_build_message (chat,
 
263
                                         message_type,
 
264
                                         timestamp,
 
265
                                         from_handle,
 
266
                                         message_body);
 
267
 
 
268
        tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
 
269
        g_object_unref (message);
 
270
 
 
271
        if (priv->acknowledge) {
 
272
                GArray *message_ids;
 
273
 
 
274
                message_ids = g_array_new (FALSE, FALSE, sizeof (guint));
 
275
                g_array_append_val (message_ids, message_id);
 
276
                tp_chan_type_text_acknowledge_pending_messages (priv->text_iface,
 
277
                                                                message_ids, NULL);
 
278
                g_array_free (message_ids, TRUE);
 
279
        }
 
280
}
 
281
 
 
282
static void
 
283
tp_chat_sent_cb (DBusGProxy    *text_iface,
 
284
                 guint          timestamp,
 
285
                 guint          message_type,
 
286
                 gchar         *message_body,
 
287
                 EmpathyTpChat *chat)
 
288
{
 
289
        EmpathyMessage *message;
 
290
 
 
291
        empathy_debug (DEBUG_DOMAIN, "Message sent: %s", message_body);
 
292
 
 
293
        message = tp_chat_build_message (chat,
 
294
                                         message_type,
 
295
                                         timestamp,
 
296
                                         0,
 
297
                                         message_body);
 
298
 
 
299
        tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
 
300
        g_object_unref (message);
 
301
}
 
302
 
 
303
static void
 
304
tp_chat_send_error_cb (DBusGProxy    *text_iface,
 
305
                       guint          error_code,
 
306
                       guint          timestamp,
 
307
                       guint          message_type,
 
308
                       gchar         *message_body,
 
309
                       EmpathyTpChat *chat)
 
310
{
 
311
        EmpathyMessage *message;
 
312
 
 
313
        empathy_debug (DEBUG_DOMAIN, "Message sent error: %s (%d)",
 
314
                       message_body, error_code);
 
315
 
 
316
        message = tp_chat_build_message (chat,
 
317
                                         message_type,
 
318
                                         timestamp,
 
319
                                         0,
 
320
                                         message_body);
 
321
 
 
322
        g_signal_emit (chat, signals[SEND_ERROR], 0, message, error_code);
 
323
        g_object_unref (message);
 
324
}
 
325
 
 
326
static void
 
327
tp_chat_state_changed_cb (DBusGProxy         *chat_state_iface,
 
328
                          guint               handle,
 
329
                          TpChannelChatState  state,
 
330
                          EmpathyTpChat      *chat)
 
331
{
 
332
        EmpathyTpChatPriv *priv;
 
333
        EmpathyContact     *contact;
 
334
 
 
335
        priv = GET_PRIV (chat);
 
336
 
 
337
        contact = empathy_contact_factory_get_from_handle (priv->factory,
 
338
                                                           priv->account,
 
339
                                                           handle);
 
340
 
 
341
        empathy_debug (DEBUG_DOMAIN, "Chat state changed for %s (%d): %d",
 
342
                      empathy_contact_get_name (contact),
 
343
                      handle,
 
344
                      state);
 
345
 
 
346
        g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state);
 
347
        g_object_unref (contact);
 
348
}
 
349
 
 
350
static void
 
351
tp_chat_list_pending_messages_cb (DBusGProxy *proxy,
 
352
                                  GPtrArray *messages_list,
 
353
                                  GError *error,
 
354
                                  gpointer chat)
 
355
{
 
356
        EmpathyTpChatPriv *priv = GET_PRIV (chat);
 
357
        guint              i;
 
358
 
 
359
        priv->had_pending_messages = TRUE;
 
360
 
 
361
        for (i = 0; i < messages_list->len; i++) {
 
362
                EmpathyMessage *message;
 
363
                GValueArray    *message_struct;
 
364
                const gchar    *message_body;
 
365
                guint           message_id;
 
366
                guint           timestamp;
 
367
                guint           from_handle;
 
368
                guint           message_type;
 
369
                guint           message_flags;
 
370
 
 
371
                message_struct = g_ptr_array_index (messages_list, i);
 
372
 
 
373
                message_id = g_value_get_uint (g_value_array_get_nth (message_struct, 0));
 
374
                timestamp = g_value_get_uint (g_value_array_get_nth (message_struct, 1));
 
375
                from_handle = g_value_get_uint (g_value_array_get_nth (message_struct, 2));
 
376
                message_type = g_value_get_uint (g_value_array_get_nth (message_struct, 3));
 
377
                message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4));
 
378
                message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5));
 
379
 
 
380
                empathy_debug (DEBUG_DOMAIN, "Message pending: %s", message_body);
 
381
 
 
382
                message = tp_chat_build_message (chat,
 
383
                                                 message_type,
 
384
                                                 timestamp,
 
385
                                                 from_handle,
 
386
                                                 message_body);
 
387
 
 
388
                tp_chat_emit_or_queue_message (chat, message);
 
389
                g_object_unref (message);
 
390
 
 
391
                g_value_array_free (message_struct);
 
392
        }
 
393
 
 
394
        g_ptr_array_free (messages_list, TRUE);
 
395
}
 
396
 
 
397
static void
 
398
tp_chat_properties_ready_cb (TpPropsIface  *props_iface,
 
399
                             EmpathyTpChat *chat)
 
400
{
 
401
        g_object_notify (G_OBJECT (chat), "anonymous");
 
402
        g_object_notify (G_OBJECT (chat), "invite-only");
 
403
        g_object_notify (G_OBJECT (chat), "limit");
 
404
        g_object_notify (G_OBJECT (chat), "limited");
 
405
        g_object_notify (G_OBJECT (chat), "moderated");
 
406
        g_object_notify (G_OBJECT (chat), "name");
 
407
        g_object_notify (G_OBJECT (chat), "description");
 
408
        g_object_notify (G_OBJECT (chat), "password");
 
409
        g_object_notify (G_OBJECT (chat), "password-required");
 
410
        g_object_notify (G_OBJECT (chat), "persistent");
 
411
        g_object_notify (G_OBJECT (chat), "private");
 
412
        g_object_notify (G_OBJECT (chat), "subject");
 
413
        g_object_notify (G_OBJECT (chat), "subject-contact");
 
414
        g_object_notify (G_OBJECT (chat), "subject-timestamp");
 
415
}
 
416
 
 
417
static void
 
418
tp_chat_properties_changed_cb (TpPropsIface   *props_iface,
 
419
                               guint           prop_id,
 
420
                               TpPropsChanged  flag,
 
421
                               EmpathyTpChat  *chat)
 
422
{
 
423
        switch (prop_id) {
 
424
        case PROP_ANONYMOUS:
 
425
                g_object_notify (G_OBJECT (chat), "anonymous");
 
426
                break;
 
427
        case PROP_INVITE_ONLY:
 
428
                g_object_notify (G_OBJECT (chat), "invite-only");
 
429
                break;
 
430
        case PROP_LIMIT:
 
431
                g_object_notify (G_OBJECT (chat), "limit");
 
432
                break;
 
433
        case PROP_LIMITED:
 
434
                g_object_notify (G_OBJECT (chat), "limited");
 
435
                break;
 
436
        case PROP_MODERATED:
 
437
                g_object_notify (G_OBJECT (chat), "moderated");
 
438
                break;
 
439
        case PROP_NAME:
 
440
                g_object_notify (G_OBJECT (chat), "name");
 
441
                break;
 
442
        case PROP_DESCRIPTION:
 
443
                g_object_notify (G_OBJECT (chat), "description");
 
444
                break;
 
445
        case PROP_PASSWORD:
 
446
                g_object_notify (G_OBJECT (chat), "password");
 
447
                break;
 
448
        case PROP_PASSWORD_REQUIRED:
 
449
                g_object_notify (G_OBJECT (chat), "password-required");
 
450
                break;
 
451
        case PROP_PERSISTENT:
 
452
                g_object_notify (G_OBJECT (chat), "persistent");
 
453
                break;
 
454
        case PROP_PRIVATE:
 
455
                g_object_notify (G_OBJECT (chat), "private");
 
456
                break;
 
457
        case PROP_SUBJECT:
 
458
                g_object_notify (G_OBJECT (chat), "subject");
 
459
                break;
 
460
        case PROP_SUBJECT_CONTACT:
 
461
                g_object_notify (G_OBJECT (chat), "subject-contact");
 
462
                break;
 
463
        case PROP_SUBJECT_TIMESTAMP:
 
464
                g_object_notify (G_OBJECT (chat), "subject-timestamp");
 
465
                break;
 
466
        }
 
467
}
337
468
 
338
469
static void
339
470
tp_chat_finalize (GObject *object)
382
513
                g_object_unref (priv->tp_chan);
383
514
        }
384
515
 
385
 
        if (priv->factory) {
386
 
                g_object_unref (priv->factory);
387
 
        }
388
 
        if (priv->user) {
389
 
                g_object_unref (priv->user);
390
 
        }
391
 
        if (priv->account) {
392
 
                g_object_unref (priv->account);
393
 
        }
394
 
        if (priv->mc) {
395
 
                g_object_unref (priv->mc);
396
 
        }
 
516
        g_object_unref (priv->factory);
 
517
        g_object_unref (priv->user);
 
518
        g_object_unref (priv->account);
 
519
        g_object_unref (priv->mc);
397
520
        g_free (priv->id);
398
521
 
399
522
        G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object);
469
592
                                  chat);
470
593
        }
471
594
 
 
595
        /* FIXME: We do that in a cb to let time to set the acknowledge
 
596
         * property, this property should be required for construct. */
 
597
        g_idle_add ((GSourceFunc) empathy_tp_chat_get_pendings, chat);
 
598
 
472
599
        return chat;
473
600
}
474
601
 
551
678
        };
552
679
}
553
680
 
 
681
static void
 
682
empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
 
683
{
 
684
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
685
 
 
686
        object_class->finalize = tp_chat_finalize;
 
687
        object_class->constructor = tp_chat_constructor;
 
688
        object_class->get_property = tp_chat_get_property;
 
689
        object_class->set_property = tp_chat_set_property;
 
690
 
 
691
        /* Construct-only properties */
 
692
        g_object_class_install_property (object_class,
 
693
                                         PROP_ACCOUNT,
 
694
                                         g_param_spec_object ("account",
 
695
                                                              "channel Account",
 
696
                                                              "The account associated with the channel",
 
697
                                                              MC_TYPE_ACCOUNT,
 
698
                                                              G_PARAM_READWRITE |
 
699
                                                              G_PARAM_CONSTRUCT_ONLY));
 
700
        g_object_class_install_property (object_class,
 
701
                                         PROP_TP_CHAN,
 
702
                                         g_param_spec_object ("tp-chan",
 
703
                                                              "telepathy channel",
 
704
                                                              "The text channel for the chat",
 
705
                                                              TELEPATHY_CHAN_TYPE,
 
706
                                                              G_PARAM_READWRITE |
 
707
                                                              G_PARAM_CONSTRUCT_ONLY));
 
708
 
 
709
        /* Normal properties */
 
710
        g_object_class_install_property (object_class,
 
711
                                         PROP_ACKNOWLEDGE,
 
712
                                         g_param_spec_boolean ("acknowledge",
 
713
                                                               "acknowledge",
 
714
                                                               "acknowledge",
 
715
                                                               FALSE,
 
716
                                                               G_PARAM_READWRITE));
 
717
 
 
718
        /* Properties of Text Channel */
 
719
        g_object_class_install_property (object_class,
 
720
                                         PROP_ANONYMOUS,
 
721
                                         g_param_spec_boolean ("anonymous",
 
722
                                                               "anonymous",
 
723
                                                               "anonymous",
 
724
                                                               FALSE,
 
725
                                                               G_PARAM_READWRITE));
 
726
        g_object_class_install_property (object_class,
 
727
                                         PROP_INVITE_ONLY,
 
728
                                         g_param_spec_boolean ("invite-only",
 
729
                                                               "invite-only",
 
730
                                                               "invite-only",
 
731
                                                               FALSE,
 
732
                                                               G_PARAM_READWRITE));
 
733
        g_object_class_install_property (object_class,
 
734
                                         PROP_LIMIT,
 
735
                                         g_param_spec_uint ("limit",
 
736
                                                            "limit",
 
737
                                                            "limit",
 
738
                                                            0,
 
739
                                                            G_MAXUINT,
 
740
                                                            0,
 
741
                                                            G_PARAM_READWRITE));
 
742
        g_object_class_install_property (object_class,
 
743
                                         PROP_LIMITED,
 
744
                                         g_param_spec_boolean ("limited",
 
745
                                                               "limited",
 
746
                                                               "limited",
 
747
                                                               FALSE,
 
748
                                                               G_PARAM_READWRITE));
 
749
        g_object_class_install_property (object_class,
 
750
                                         PROP_MODERATED,
 
751
                                         g_param_spec_boolean ("moderated",
 
752
                                                               "moderated",
 
753
                                                               "moderated",
 
754
                                                               FALSE,
 
755
                                                               G_PARAM_READWRITE));
 
756
        g_object_class_install_property (object_class,
 
757
                                         PROP_NAME,
 
758
                                         g_param_spec_string ("name",
 
759
                                                              "name",
 
760
                                                              "name",
 
761
                                                              NULL,
 
762
                                                              G_PARAM_READWRITE));
 
763
        g_object_class_install_property (object_class,
 
764
                                         PROP_DESCRIPTION,
 
765
                                         g_param_spec_string ("description",
 
766
                                                              "description",
 
767
                                                              "description",
 
768
                                                              NULL,
 
769
                                                              G_PARAM_READWRITE));
 
770
        g_object_class_install_property (object_class,
 
771
                                         PROP_PASSWORD,
 
772
                                         g_param_spec_string ("password",
 
773
                                                              "password",
 
774
                                                              "password",
 
775
                                                              NULL,
 
776
                                                              G_PARAM_READWRITE));
 
777
        g_object_class_install_property (object_class,
 
778
                                         PROP_PASSWORD_REQUIRED,
 
779
                                         g_param_spec_boolean ("password-required",
 
780
                                                               "password-required",
 
781
                                                               "password-required",
 
782
                                                               FALSE,
 
783
                                                               G_PARAM_READWRITE));
 
784
        g_object_class_install_property (object_class,
 
785
                                         PROP_PERSISTENT,
 
786
                                         g_param_spec_boolean ("persistent",
 
787
                                                               "persistent",
 
788
                                                               "persistent",
 
789
                                                               FALSE,
 
790
                                                               G_PARAM_READWRITE));
 
791
        g_object_class_install_property (object_class,
 
792
                                         PROP_PRIVATE,
 
793
                                         g_param_spec_boolean ("private",
 
794
                                                               "private",
 
795
                                                               "private"
 
796
                                                               "private",
 
797
                                                               FALSE,
 
798
                                                               G_PARAM_READWRITE));
 
799
        g_object_class_install_property (object_class,
 
800
                                         PROP_SUBJECT,
 
801
                                         g_param_spec_string ("subject",
 
802
                                                              "subject",
 
803
                                                              "subject",
 
804
                                                              NULL,
 
805
                                                              G_PARAM_READWRITE));
 
806
        g_object_class_install_property (object_class,
 
807
                                         PROP_SUBJECT_CONTACT,
 
808
                                         g_param_spec_uint ("subject-contact",
 
809
                                                            "subject-contact",
 
810
                                                            "subject-contact",
 
811
                                                            0,
 
812
                                                            G_MAXUINT,
 
813
                                                            0,
 
814
                                                            G_PARAM_READWRITE));
 
815
        g_object_class_install_property (object_class,
 
816
                                         PROP_SUBJECT_TIMESTAMP,
 
817
                                         g_param_spec_uint ("subject-timestamp",
 
818
                                                            "subject-timestamp",
 
819
                                                            "subject-timestamp",
 
820
                                                            0,
 
821
                                                            G_MAXUINT,
 
822
                                                            0,
 
823
                                                            G_PARAM_READWRITE));
 
824
 
 
825
        /* Signals */
 
826
        signals[MESSAGE_RECEIVED] =
 
827
                g_signal_new ("message-received",
 
828
                              G_TYPE_FROM_CLASS (klass),
 
829
                              G_SIGNAL_RUN_LAST,
 
830
                              0,
 
831
                              NULL, NULL,
 
832
                              g_cclosure_marshal_VOID__OBJECT,
 
833
                              G_TYPE_NONE,
 
834
                              1, EMPATHY_TYPE_MESSAGE);
 
835
 
 
836
        signals[SEND_ERROR] =
 
837
                g_signal_new ("send-error",
 
838
                              G_TYPE_FROM_CLASS (klass),
 
839
                              G_SIGNAL_RUN_LAST,
 
840
                              0,
 
841
                              NULL, NULL,
 
842
                              _empathy_marshal_VOID__OBJECT_UINT,
 
843
                              G_TYPE_NONE,
 
844
                              2, EMPATHY_TYPE_MESSAGE, G_TYPE_UINT);
 
845
 
 
846
        signals[CHAT_STATE_CHANGED] =
 
847
                g_signal_new ("chat-state-changed",
 
848
                              G_TYPE_FROM_CLASS (klass),
 
849
                              G_SIGNAL_RUN_LAST,
 
850
                              0,
 
851
                              NULL, NULL,
 
852
                              _empathy_marshal_VOID__OBJECT_UINT,
 
853
                              G_TYPE_NONE,
 
854
                              2, EMPATHY_TYPE_CONTACT, G_TYPE_UINT);
 
855
 
 
856
        signals[DESTROY] =
 
857
                g_signal_new ("destroy",
 
858
                              G_TYPE_FROM_CLASS (klass),
 
859
                              G_SIGNAL_RUN_LAST,
 
860
                              0,
 
861
                              NULL, NULL,
 
862
                              g_cclosure_marshal_VOID__VOID,
 
863
                              G_TYPE_NONE,
 
864
                              0);
 
865
 
 
866
        g_type_class_add_private (object_class, sizeof (EmpathyTpChatPriv));
 
867
}
 
868
 
 
869
static void
 
870
empathy_tp_chat_init (EmpathyTpChat *chat)
 
871
{
 
872
}
 
873
 
554
874
EmpathyTpChat *
555
875
empathy_tp_chat_new (McAccount *account,
556
876
                     TpChan    *tp_chan)
658
978
empathy_tp_chat_get_pendings (EmpathyTpChat *chat)
659
979
{
660
980
        EmpathyTpChatPriv *priv;
661
 
        GPtrArray         *messages_list;
662
 
        guint              i;
663
 
        GList             *messages = NULL;
664
 
        GError            *error = NULL;
665
981
 
666
982
        g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
667
983
 
668
984
        priv = GET_PRIV (chat);
669
985
 
670
 
        /* If we do this call async, don't forget to ignore Received signal
671
 
         * until we get the answer */
672
 
        if (!tp_chan_type_text_list_pending_messages (priv->text_iface,
673
 
                                                      priv->acknowledge,
674
 
                                                      &messages_list,
675
 
                                                      &error)) {
676
 
                empathy_debug (DEBUG_DOMAIN, 
677
 
                              "Error retrieving pending messages: %s",
678
 
                              error ? error->message : "No error given");
679
 
                g_clear_error (&error);
680
 
                return NULL;
681
 
        }
682
 
 
683
 
        for (i = 0; i < messages_list->len; i++) {
684
 
                EmpathyMessage *message;
685
 
                GValueArray    *message_struct;
686
 
                const gchar    *message_body;
687
 
                guint           message_id;
688
 
                guint           timestamp;
689
 
                guint           from_handle;
690
 
                guint           message_type;
691
 
                guint           message_flags;
692
 
 
693
 
                message_struct = g_ptr_array_index (messages_list, i);
694
 
 
695
 
                message_id = g_value_get_uint (g_value_array_get_nth (message_struct, 0));
696
 
                timestamp = g_value_get_uint (g_value_array_get_nth (message_struct, 1));
697
 
                from_handle = g_value_get_uint (g_value_array_get_nth (message_struct, 2));
698
 
                message_type = g_value_get_uint (g_value_array_get_nth (message_struct, 3));
699
 
                message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4));
700
 
                message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5));
701
 
 
702
 
                empathy_debug (DEBUG_DOMAIN, "Message pending: %s", message_body);
703
 
 
704
 
                message = tp_chat_build_message (chat,
705
 
                                                 message_type,
706
 
                                                 timestamp,
707
 
                                                 from_handle,
708
 
                                                 message_body);
709
 
 
710
 
                messages = g_list_prepend (messages, message);
711
 
 
712
 
                g_value_array_free (message_struct);
713
 
        }
714
 
        messages = g_list_reverse (messages);
715
 
 
716
 
        g_ptr_array_free (messages_list, TRUE);
717
 
 
718
 
        return messages;
 
986
        tp_chan_type_text_list_pending_messages_async (priv->text_iface,
 
987
                                                       priv->acknowledge,
 
988
                                                       tp_chat_list_pending_messages_cb,
 
989
                                                       chat);
 
990
 
 
991
        return NULL;
719
992
}
720
993
 
721
994
void
787
1060
        return priv->id;
788
1061
}
789
1062
 
790
 
static void
791
 
tp_chat_destroy_cb (TpChan        *text_chan,
792
 
                    EmpathyTpChat *chat)
793
 
{
794
 
        EmpathyTpChatPriv *priv;
795
 
 
796
 
        priv = GET_PRIV (chat);
797
 
 
798
 
        empathy_debug (DEBUG_DOMAIN, "Channel Closed or CM crashed");
799
 
 
800
 
        g_object_unref  (priv->tp_chan);
801
 
        priv->tp_chan = NULL;
802
 
        priv->text_iface = NULL;
803
 
        priv->chat_state_iface = NULL;
804
 
        priv->props_iface = NULL;
805
 
 
806
 
        g_signal_emit (chat, signals[DESTROY], 0);
807
 
}
808
 
 
809
 
static void
810
 
tp_chat_closed_cb (TpChan        *text_chan,
811
 
                   EmpathyTpChat *chat)
812
 
{
813
 
        EmpathyTpChatPriv *priv;
814
 
 
815
 
        priv = GET_PRIV (chat);
816
 
 
817
 
        /* The channel is closed, do just like if the proxy was destroyed */
818
 
        g_signal_handlers_disconnect_by_func (priv->tp_chan,
819
 
                                              tp_chat_destroy_cb,
820
 
                                              chat);
821
 
        tp_chat_destroy_cb (text_chan, chat);
822
 
}
823
 
 
824
 
static void
825
 
tp_chat_received_cb (DBusGProxy    *text_iface,
826
 
                     guint          message_id,
827
 
                     guint          timestamp,
828
 
                     guint          from_handle,
829
 
                     guint          message_type,
830
 
                     guint          message_flags,
831
 
                     gchar         *message_body,
832
 
                     EmpathyTpChat *chat)
833
 
{
834
 
        EmpathyTpChatPriv *priv;
835
 
        EmpathyMessage    *message;
836
 
 
837
 
        priv = GET_PRIV (chat);
838
 
 
839
 
        empathy_debug (DEBUG_DOMAIN, "Message received: %s", message_body);
840
 
 
841
 
        message = tp_chat_build_message (chat,
842
 
                                         message_type,
843
 
                                         timestamp,
844
 
                                         from_handle,
845
 
                                         message_body);
846
 
 
847
 
        g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
848
 
        g_object_unref (message);
849
 
 
850
 
        if (priv->acknowledge) {
851
 
                GArray *message_ids;
852
 
 
853
 
                message_ids = g_array_new (FALSE, FALSE, sizeof (guint));
854
 
                g_array_append_val (message_ids, message_id);
855
 
                tp_chan_type_text_acknowledge_pending_messages (priv->text_iface,
856
 
                                                                message_ids, NULL);
857
 
                g_array_free (message_ids, TRUE);
858
 
        }
859
 
}
860
 
 
861
 
static void
862
 
tp_chat_sent_cb (DBusGProxy    *text_iface,
863
 
                 guint          timestamp,
864
 
                 guint          message_type,
865
 
                 gchar         *message_body,
866
 
                 EmpathyTpChat *chat)
867
 
{
868
 
        EmpathyMessage *message;
869
 
 
870
 
        empathy_debug (DEBUG_DOMAIN, "Message sent: %s", message_body);
871
 
 
872
 
        message = tp_chat_build_message (chat,
873
 
                                         message_type,
874
 
                                         timestamp,
875
 
                                         0,
876
 
                                         message_body);
877
 
 
878
 
        g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
879
 
        g_object_unref (message);
880
 
}
881
 
 
882
 
static void
883
 
tp_chat_send_error_cb (DBusGProxy    *text_iface,
884
 
                       guint          error_code,
885
 
                       guint          timestamp,
886
 
                       guint          message_type,
887
 
                       gchar         *message_body,
888
 
                       EmpathyTpChat *chat)
889
 
{
890
 
        EmpathyMessage *message;
891
 
 
892
 
        empathy_debug (DEBUG_DOMAIN, "Message sent error: %s (%d)",
893
 
                       message_body, error_code);
894
 
 
895
 
        message = tp_chat_build_message (chat,
896
 
                                         message_type,
897
 
                                         timestamp,
898
 
                                         0,
899
 
                                         message_body);
900
 
 
901
 
        g_signal_emit (chat, signals[SEND_ERROR], 0, message, error_code);
902
 
        g_object_unref (message);
903
 
}
904
 
 
905
 
static void
906
 
tp_chat_state_changed_cb (DBusGProxy         *chat_state_iface,
907
 
                          guint               handle,
908
 
                          TpChannelChatState  state,
909
 
                          EmpathyTpChat      *chat)
910
 
{
911
 
        EmpathyTpChatPriv *priv;
912
 
        EmpathyContact     *contact;
913
 
 
914
 
        priv = GET_PRIV (chat);
915
 
 
916
 
        contact = empathy_contact_factory_get_from_handle (priv->factory,
917
 
                                                           priv->account,
918
 
                                                           handle);
919
 
 
920
 
        empathy_debug (DEBUG_DOMAIN, "Chat state changed for %s (%d): %d",
921
 
                      empathy_contact_get_name (contact),
922
 
                      handle,
923
 
                      state);
924
 
 
925
 
        g_signal_emit (chat, signals[CHAT_STATE_CHANGED], 0, contact, state);
926
 
        g_object_unref (contact);
927
 
}
928
 
 
929
 
static EmpathyMessage *
930
 
tp_chat_build_message (EmpathyTpChat *chat,
931
 
                       guint          type,
932
 
                       guint          timestamp,
933
 
                       guint          from_handle,
934
 
                       const gchar   *message_body)
935
 
{
936
 
        EmpathyTpChatPriv *priv;
937
 
        EmpathyMessage    *message;
938
 
        EmpathyContact    *sender;
939
 
 
940
 
        priv = GET_PRIV (chat);
941
 
 
942
 
        if (from_handle == 0) {
943
 
                sender = g_object_ref (priv->user);
944
 
        } else {
945
 
                sender = empathy_contact_factory_get_from_handle (priv->factory,
946
 
                                                                  priv->account,
947
 
                                                                  from_handle);
948
 
        }
949
 
 
950
 
        message = empathy_message_new (message_body);
951
 
        empathy_message_set_type (message, type);
952
 
        empathy_message_set_sender (message, sender);
953
 
        empathy_message_set_receiver (message, priv->user);
954
 
        empathy_message_set_timestamp (message, timestamp);
955
 
 
956
 
        g_object_unref (sender);
957
 
 
958
 
        return message;
959
 
}
960
 
 
961
 
static void
962
 
tp_chat_properties_ready_cb (TpPropsIface  *props_iface,
963
 
                             EmpathyTpChat *chat)
964
 
{
965
 
        g_object_notify (G_OBJECT (chat), "anonymous");
966
 
        g_object_notify (G_OBJECT (chat), "invite-only");
967
 
        g_object_notify (G_OBJECT (chat), "limit");
968
 
        g_object_notify (G_OBJECT (chat), "limited");
969
 
        g_object_notify (G_OBJECT (chat), "moderated");
970
 
        g_object_notify (G_OBJECT (chat), "name");
971
 
        g_object_notify (G_OBJECT (chat), "description");
972
 
        g_object_notify (G_OBJECT (chat), "password");
973
 
        g_object_notify (G_OBJECT (chat), "password-required");
974
 
        g_object_notify (G_OBJECT (chat), "persistent");
975
 
        g_object_notify (G_OBJECT (chat), "private");
976
 
        g_object_notify (G_OBJECT (chat), "subject");
977
 
        g_object_notify (G_OBJECT (chat), "subject-contact");
978
 
        g_object_notify (G_OBJECT (chat), "subject-timestamp");
979
 
}
980
 
 
981
 
static void
982
 
tp_chat_properties_changed_cb (TpPropsIface   *props_iface,
983
 
                               guint           prop_id,
984
 
                               TpPropsChanged  flag,
985
 
                               EmpathyTpChat  *chat)
986
 
{
987
 
        switch (prop_id) {
988
 
        case PROP_ANONYMOUS:
989
 
                g_object_notify (G_OBJECT (chat), "anonymous");
990
 
                break;
991
 
        case PROP_INVITE_ONLY:
992
 
                g_object_notify (G_OBJECT (chat), "invite-only");
993
 
                break;
994
 
        case PROP_LIMIT:
995
 
                g_object_notify (G_OBJECT (chat), "limit");
996
 
                break;
997
 
        case PROP_LIMITED:
998
 
                g_object_notify (G_OBJECT (chat), "limited");
999
 
                break;
1000
 
        case PROP_MODERATED:
1001
 
                g_object_notify (G_OBJECT (chat), "moderated");
1002
 
                break;
1003
 
        case PROP_NAME:
1004
 
                g_object_notify (G_OBJECT (chat), "name");
1005
 
                break;
1006
 
        case PROP_DESCRIPTION:
1007
 
                g_object_notify (G_OBJECT (chat), "description");
1008
 
                break;
1009
 
        case PROP_PASSWORD:
1010
 
                g_object_notify (G_OBJECT (chat), "password");
1011
 
                break;
1012
 
        case PROP_PASSWORD_REQUIRED:
1013
 
                g_object_notify (G_OBJECT (chat), "password-required");
1014
 
                break;
1015
 
        case PROP_PERSISTENT:
1016
 
                g_object_notify (G_OBJECT (chat), "persistent");
1017
 
                break;
1018
 
        case PROP_PRIVATE:
1019
 
                g_object_notify (G_OBJECT (chat), "private");
1020
 
                break;
1021
 
        case PROP_SUBJECT:
1022
 
                g_object_notify (G_OBJECT (chat), "subject");
1023
 
                break;
1024
 
        case PROP_SUBJECT_CONTACT:
1025
 
                g_object_notify (G_OBJECT (chat), "subject-contact");
1026
 
                break;
1027
 
        case PROP_SUBJECT_TIMESTAMP:
1028
 
                g_object_notify (G_OBJECT (chat), "subject-timestamp");
1029
 
                break;
1030
 
        }
1031
 
}
1032