]> git.0d.be Git - empathy.git/commitdiff
remove empathy_tp_chat_get_connection and priv->connection
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 12 Nov 2010 15:48:42 +0000 (16:48 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 25 May 2011 07:22:41 +0000 (09:22 +0200)
libempathy-gtk/empathy-chat.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-chat.h
src/empathy-chat-window.c
src/empathy-invite-participant-dialog.c

index ef4d7a53db1e04c9c2e431e0362680a52a1d8f6c..cf3336bdf70061bbe3c375eae0aad4d2787950c6 100644 (file)
@@ -700,7 +700,7 @@ nick_command_supported (EmpathyChat *chat)
        EmpathyChatPriv * priv = GET_PRIV (chat);
        TpConnection    *connection;
 
-       connection = empathy_tp_chat_get_connection (priv->tp_chat);
+       connection = tp_channel_borrow_connection (TP_CHANNEL (priv->tp_chat));
        return tp_proxy_has_interface_by_id (connection,
                EMP_IFACE_QUARK_CONNECTION_INTERFACE_RENAMING);
 }
@@ -975,7 +975,7 @@ chat_command_whois (EmpathyChat *chat,
        EmpathyChatPriv *priv = GET_PRIV (chat);
        TpConnection *conn;
 
-       conn = empathy_tp_chat_get_connection (priv->tp_chat);
+       conn = tp_channel_borrow_connection ((TpChannel *) priv->tp_chat);
        tp_connection_get_contacts_by_id (conn,
                /* Element 0 of 'strv' is "whois"; element 1 is the contact ID
                 * entered by the user (including spaces, if any). */
@@ -3636,7 +3636,6 @@ empathy_chat_set_tp_chat (EmpathyChat   *chat,
 
        g_return_if_fail (EMPATHY_IS_CHAT (chat));
        g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
-       g_return_if_fail (empathy_tp_chat_is_ready (tp_chat));
 
        if (priv->tp_chat) {
                return;
index d1338f2bf0ecdfe29ebd4302a1d03e6b140f7557..b33b41e482f9d35f43814492a7c862d86919c3f1 100644 (file)
@@ -41,7 +41,6 @@
 struct _EmpathyTpChatPrivate {
        gboolean               dispose_has_run;
        TpAccount             *account;
-       TpConnection          *connection;
        EmpathyContact        *user;
        EmpathyContact        *remote_contact;
        GList                 *members;
@@ -331,7 +330,10 @@ tp_chat_build_message (EmpathyTpChat *self,
                empathy_message_set_sender (message, self->priv->user);
                tp_chat_emit_queued_messages (self);
        } else {
-               empathy_tp_contact_factory_get_from_handle (self->priv->connection,
+               TpConnection *connection = tp_channel_borrow_connection (
+                       (TpChannel *) self);
+
+               empathy_tp_contact_factory_get_from_handle (connection,
                        tp_contact_get_handle (sender),
                        tp_chat_got_sender_cb,
                        message, NULL, G_OBJECT (self));
@@ -572,7 +574,10 @@ tp_chat_state_changed_cb (TpChannel *channel,
                          TpChannelChatState state,
                          EmpathyTpChat *self)
 {
-       empathy_tp_contact_factory_get_from_handle (self->priv->connection, handle,
+       TpConnection *connection = tp_channel_borrow_connection (
+               (TpChannel *) self);
+
+       empathy_tp_contact_factory_get_from_handle (connection, handle,
                tp_chat_state_changed_got_contact_cb, GUINT_TO_POINTER (state),
                NULL, G_OBJECT (self));
 }
@@ -823,10 +828,6 @@ tp_chat_dispose (GObject *object)
 
        tp_clear_object (&self->priv->account);
 
-       if (self->priv->connection != NULL)
-               g_object_unref (self->priv->connection);
-       self->priv->connection = NULL;
-
        if (self->priv->remote_contact != NULL)
                g_object_unref (self->priv->remote_contact);
        self->priv->remote_contact = NULL;
@@ -1141,6 +1142,8 @@ tp_chat_group_members_changed_cb (TpChannel     *channel,
        guint i;
        ContactRenameData *rename_data;
        TpHandle old_handle;
+       TpConnection *connection = tp_channel_borrow_connection (
+               (TpChannel *) self);
 
        /* Contact renamed */
        if (reason == TP_CHANNEL_GROUP_CHANGE_REASON_RENAMED) {
@@ -1154,7 +1157,7 @@ tp_chat_group_members_changed_cb (TpChannel     *channel,
                old_handle = g_array_index (removed, guint, 0);
 
                rename_data = contact_rename_data_new (old_handle, reason, message);
-               empathy_tp_contact_factory_get_from_handles (self->priv->connection,
+               empathy_tp_contact_factory_get_from_handles (connection,
                        added->len, (TpHandle *) added->data,
                        tp_chat_got_renamed_contacts_cb,
                        rename_data, (GDestroyNotify) contact_rename_data_free,
@@ -1188,7 +1191,7 @@ tp_chat_group_members_changed_cb (TpChannel     *channel,
 
        /* Request added contacts */
        if (added->len > 0) {
-               empathy_tp_contact_factory_get_from_handles (self->priv->connection,
+               empathy_tp_contact_factory_get_from_handles (connection,
                        added->len, (TpHandle *) added->data,
                        tp_chat_got_added_contacts_cb, NULL, NULL,
                        G_OBJECT (self));
@@ -1322,17 +1325,20 @@ tp_chat_constructor (GType                  type,
        EmpathyTpChat *self;
        TpHandle           handle;
        TpChannel         *channel;
+       TpConnection *connection;
+
 
        object = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);
        self = (EmpathyTpChat *) object;
        channel = (TpChannel *) object;
 
-       self->priv->connection = g_object_ref (tp_account_get_connection (self->priv->account));
+       connection = tp_channel_borrow_connection (channel);
+
        tp_g_signal_connect_object (self, "invalidated",
                          G_CALLBACK (tp_chat_invalidated_cb),
                          self, 0);
 
-       g_assert (tp_proxy_is_prepared (self->priv->connection,
+       g_assert (tp_proxy_is_prepared (connection,
                TP_CONNECTION_FEATURE_CAPABILITIES));
 
        if (tp_proxy_has_interface_by_id (self,
@@ -1342,14 +1348,14 @@ tp_chat_constructor (GType                  type,
 
                /* Get self contact from the group's self handle */
                handle = tp_channel_group_get_self_handle (channel);
-               empathy_tp_contact_factory_get_from_handle (self->priv->connection,
+               empathy_tp_contact_factory_get_from_handle (connection,
                        handle, tp_chat_got_self_contact_cb,
                        NULL, NULL, object);
 
                /* Get initial member contacts */
                members = tp_channel_group_get_members (channel);
                handles = tp_intset_to_array (members);
-               empathy_tp_contact_factory_get_from_handles (self->priv->connection,
+               empathy_tp_contact_factory_get_from_handles (connection,
                        handles->len, (TpHandle *) handles->data,
                        tp_chat_got_added_contacts_cb, NULL, NULL, object);
 
@@ -1363,18 +1369,18 @@ tp_chat_constructor (GType                  type,
                guint i;
 
                /* Get the self contact from the connection's self handle */
-               handle = tp_connection_get_self_handle (self->priv->connection);
-               empathy_tp_contact_factory_get_from_handle (self->priv->connection,
+               handle = tp_connection_get_self_handle (connection);
+               empathy_tp_contact_factory_get_from_handle (connection,
                        handle, tp_chat_got_self_contact_cb,
                        NULL, NULL, object);
 
                /* Get the remote contact */
                handle = tp_channel_get_handle (channel, NULL);
-               empathy_tp_contact_factory_get_from_handle (self->priv->connection,
+               empathy_tp_contact_factory_get_from_handle (connection,
                        handle, tp_chat_got_remote_contact_cb,
                        NULL, NULL, object);
 
-               caps = tp_connection_get_capabilities (self->priv->connection);
+               caps = tp_connection_get_capabilities (connection);
                g_assert (caps != NULL);
 
                classes = tp_capabilities_get_channel_classes (caps);
@@ -1690,13 +1696,6 @@ empathy_tp_chat_get_account (EmpathyTpChat *self)
        return self->priv->account;
 }
 
-TpConnection *
-empathy_tp_chat_get_connection (EmpathyTpChat *self)
-{
-       g_return_val_if_fail (EMPATHY_IS_TP_CHAT (self), NULL);
-
-       return tp_channel_borrow_connection ((TpChannel *) self);
-}
 gboolean
 empathy_tp_chat_is_ready (EmpathyTpChat *self)
 {
index f30325432e351044764ed33042143c9c44076a10..b5119fc46fd43ea805faada13fbe0aeca84f89d3 100644 (file)
@@ -76,7 +76,6 @@ EmpathyTpChat *empathy_tp_chat_new                  (TpAccount *account,
 const gchar *  empathy_tp_chat_get_id               (EmpathyTpChat      *chat);
 EmpathyContact *empathy_tp_chat_get_remote_contact   (EmpathyTpChat      *chat);
 TpAccount    * empathy_tp_chat_get_account          (EmpathyTpChat      *chat);
-TpConnection * empathy_tp_chat_get_connection       (EmpathyTpChat      *chat);
 gboolean       empathy_tp_chat_is_ready             (EmpathyTpChat      *chat);
 void           empathy_tp_chat_send                 (EmpathyTpChat      *chat,
                                                     TpMessage     *message);
index c0d1b1502e61b368ba36854980e93da73264b804..01736d75b306babe153581ab15f0011a64be0763 100644 (file)
@@ -403,7 +403,7 @@ chat_window_conversation_menu_update (EmpathyChatWindowPriv *priv,
        tp_chat = empathy_chat_get_tp_chat (priv->current_chat);
 
        if (tp_chat != NULL) {
-               connection = empathy_tp_chat_get_connection (tp_chat);
+               connection = tp_channel_borrow_connection (TP_CHANNEL (tp_chat));
 
                sensitive = empathy_tp_chat_can_add_contact (tp_chat) &&
                        (tp_connection_get_status (connection, NULL) ==
index c40bb945888b1b4316cbeb2cdb82b9de749755c1..4a669469001bb09aab3f1ccbaed7531e3e72c6b7 100644 (file)
@@ -130,7 +130,7 @@ get_tp_contact_for_chat (EmpathyInviteParticipantDialog *self,
   GList *personas, *l;
   TpConnection *chat_conn;
 
-  chat_conn = empathy_tp_chat_get_connection (self->priv->tp_chat);
+  chat_conn = tp_channel_borrow_connection ((TpChannel *) self->priv->tp_chat);
 
   personas = folks_individual_get_personas (individual);