+static void
+tp_chat_dispose (GObject *object)
+{
+ EmpathyTpChat *self = EMPATHY_TP_CHAT (object);
+ EmpathyTpChatPriv *priv = GET_PRIV (self);
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ if (priv->channel != NULL) {
+ g_signal_handlers_disconnect_by_func (priv->channel,
+ tp_chat_invalidated_cb, self);
+ g_object_unref (priv->channel);
+ }
+ priv->channel = NULL;
+
+ if (priv->remote_contact != NULL)
+ g_object_unref (priv->remote_contact);
+ priv->remote_contact = NULL;
+
+ if (priv->factory != NULL)
+ g_object_unref (priv->factory);
+ priv->factory = NULL;
+
+ if (priv->user != NULL);
+ g_object_unref (priv->user);
+ priv->user = NULL;
+
+ if (priv->contact_monitor)
+ g_object_unref (priv->contact_monitor);
+ priv->contact_monitor = NULL;
+
+ g_queue_foreach (priv->messages_queue, (GFunc) g_object_unref, NULL);
+ g_queue_clear (priv->messages_queue);
+
+ g_queue_foreach (priv->pending_messages_queue,
+ (GFunc) g_object_unref, NULL);
+ g_queue_clear (priv->pending_messages_queue);
+
+ if (G_OBJECT_CLASS (empathy_tp_chat_parent_class)->dispose)
+ G_OBJECT_CLASS (empathy_tp_chat_parent_class)->dispose (object);
+}
+
+static void
+tp_chat_finalize (GObject *object)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (object);
+ guint i;
+
+ DEBUG ("Finalize: %p", object);
+
+ if (priv->properties) {
+ for (i = 0; i < priv->properties->len; i++) {
+ TpChatProperty *property;
+
+ property = g_ptr_array_index (priv->properties, i);
+ g_free (property->name);
+ if (property->value) {
+ tp_g_value_slice_free (property->value);
+ }
+ g_slice_free (TpChatProperty, property);
+ }
+ g_ptr_array_free (priv->properties, TRUE);
+ }
+
+ g_queue_free (priv->messages_queue);
+ g_queue_free (priv->pending_messages_queue);
+
+ G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object);
+}
+
+static void
+tp_chat_check_if_ready (EmpathyTpChat *chat)