]> git.0d.be Git - empathy.git/commitdiff
tp-chat: add 'account' property
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 12 Aug 2010 14:16:27 +0000 (16:16 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 12 Aug 2010 14:23:27 +0000 (16:23 +0200)
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-chat.h
src/empathy-chat-manager.c
src/empathy-event-manager.c

index 9a4e56acbb54b1d1dad4d61c06ab21930ab67383..7bc9a9c758e36ffb3291d9795e56688c00dca270 100644 (file)
@@ -41,6 +41,7 @@
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyTpChat)
 typedef struct {
        gboolean               dispose_has_run;
+       TpAccount             *account;
        TpConnection          *connection;
        EmpathyContact        *user;
        EmpathyContact        *remote_contact;
@@ -65,6 +66,7 @@ static void tp_chat_iface_init         (EmpathyContactListIface *iface);
 
 enum {
        PROP_0,
+       PROP_ACCOUNT,
        PROP_CHANNEL,
        PROP_REMOTE_CONTACT,
        PROP_PASSWORD_NEEDED,
@@ -164,8 +166,7 @@ tp_chat_add (EmpathyContactList *list,
                    /* FIXME: InvitationMessage ? */
                    NULL);
 
-               req = tp_account_channel_request_new (
-                       empathy_get_account_for_connection (priv->connection), props,
+               req = tp_account_channel_request_new (priv->account, props,
                        EMPATHY_DISPATCHER_NON_USER_ACTION);
 
                /* Although this is a MUC, it's anonymous, so CreateChannel is
@@ -778,6 +779,8 @@ tp_chat_dispose (GObject *object)
 
        priv->dispose_has_run = TRUE;
 
+       tp_clear_object (&priv->account);
+
        if (priv->connection != NULL)
                g_object_unref (priv->connection);
        priv->connection = NULL;
@@ -1261,7 +1264,7 @@ tp_chat_constructor (GType                  type,
 
        priv = GET_PRIV (chat);
 
-       priv->connection = g_object_ref (tp_channel_borrow_connection (priv->channel));
+       priv->connection = g_object_ref (tp_account_get_connection (priv->account));
        tp_g_signal_connect_object (priv->channel, "invalidated",
                          G_CALLBACK (tp_chat_invalidated_cb),
                          chat, 0);
@@ -1369,6 +1372,9 @@ tp_chat_get_property (GObject    *object,
        EmpathyTpChatPriv *priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_ACCOUNT:
+               g_value_set_object (value, priv->account);
+               break;
        case PROP_CHANNEL:
                g_value_set_object (value, priv->channel);
                break;
@@ -1396,6 +1402,9 @@ tp_chat_set_property (GObject      *object,
        EmpathyTpChatPriv *priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_ACCOUNT:
+               priv->account = g_value_dup_object (value);
+               break;
        case PROP_CHANNEL:
                priv->channel = g_value_dup_object (value);
                break;
@@ -1416,6 +1425,16 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
        object_class->get_property = tp_chat_get_property;
        object_class->set_property = tp_chat_set_property;
 
+       g_object_class_install_property (object_class,
+                                        PROP_ACCOUNT,
+                                        g_param_spec_object ("account",
+                                                             "TpAccount",
+                                                             "the account associated with the chat",
+                                                             TP_TYPE_ACCOUNT,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_CONSTRUCT_ONLY |
+                                                             G_PARAM_STATIC_STRINGS));
+
        g_object_class_install_property (object_class,
                                         PROP_CHANNEL,
                                         g_param_spec_object ("channel",
@@ -1523,9 +1542,11 @@ tp_chat_iface_init (EmpathyContactListIface *iface)
 }
 
 EmpathyTpChat *
-empathy_tp_chat_new (TpChannel *channel)
+empathy_tp_chat_new (TpAccount *account,
+                    TpChannel *channel)
 {
        return g_object_new (EMPATHY_TYPE_TP_CHAT,
+                            "account", account,
                             "channel", channel,
                             NULL);
 }
@@ -1580,6 +1601,16 @@ empathy_tp_chat_get_channel (EmpathyTpChat *chat)
        return priv->channel;
 }
 
+TpAccount *
+empathy_tp_chat_get_account (EmpathyTpChat *chat)
+{
+       EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+       g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
+
+       return priv->account;
+}
+
 TpConnection *
 empathy_tp_chat_get_connection (EmpathyTpChat *chat)
 {
@@ -1589,7 +1620,6 @@ empathy_tp_chat_get_connection (EmpathyTpChat *chat)
 
        return tp_channel_borrow_connection (priv->channel);
 }
-
 gboolean
 empathy_tp_chat_is_ready (EmpathyTpChat *chat)
 {
index 3ac5eaf58ce480d0aaf579d744350db134ca3e41..8858f4971a57d3e613da4bcf42f4ec204d247184 100644 (file)
@@ -60,10 +60,12 @@ typedef struct {
 } EmpathyTpChatProperty;
 
 GType          empathy_tp_chat_get_type             (void) G_GNUC_CONST;
-EmpathyTpChat *empathy_tp_chat_new                  (TpChannel          *channel);
+EmpathyTpChat *empathy_tp_chat_new                  (TpAccount *account,
+                                                    TpChannel *channel);
 const gchar *  empathy_tp_chat_get_id               (EmpathyTpChat      *chat);
 EmpathyContact *empathy_tp_chat_get_remote_contact   (EmpathyTpChat      *chat);
 TpChannel *    empathy_tp_chat_get_channel          (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,
index 8b9a73b62bbf7b0523bb86e205838290cda90a13..fdc4451dde5462cb7f1e8ab730e0c118c44c7b6e 100644 (file)
@@ -218,7 +218,7 @@ handle_channels (TpSimpleHandler *handler,
       TpChannel *channel = l->data;
       EmpathyTpChat *tp_chat;
 
-      tp_chat = empathy_tp_chat_new (channel);
+      tp_chat = empathy_tp_chat_new (account, channel);
 
       if (empathy_tp_chat_is_ready (tp_chat))
         {
index e60a9b100213d55d3eace7543488dc8e117905f0..bc998a861417267a7f23bf64cd44d69e64713280 100644 (file)
@@ -866,7 +866,7 @@ approve_channels (TpSimpleApprover *approver,
     {
       EmpathyTpChat *tp_chat;
 
-      tp_chat = empathy_tp_chat_new (channel);
+      tp_chat = empathy_tp_chat_new (account, channel);
       approval->handler_instance = G_OBJECT (tp_chat);
 
       if (tp_proxy_has_interface (channel, TP_IFACE_CHANNEL_INTERFACE_GROUP))