Use tp_connection_get_self_handle where needed
authorXavier Claessens <xclaesse@gmail.com>
Wed, 18 Mar 2009 00:28:03 +0000 (01:28 +0100)
committerXavier Claessens <xclaesse@gmail.com>
Wed, 22 Apr 2009 10:21:14 +0000 (12:21 +0200)
configure.ac
libempathy-gtk/empathy-contact-widget.c
libempathy/empathy-contact.c
libempathy/empathy-tp-chat.c
libempathy/empathy-tp-contact-factory.c

index c3926fdb20aafd2c0e56dc71472ff154cd6323a7..a387b0e36019d07aaa6712c8802fec175dd2fd68 100644 (file)
@@ -29,7 +29,7 @@ GLIB_REQUIRED=2.16.0
 GTK_REQUIRED=2.16.0
 GCONF_REQUIRED=1.2.0
 LIBPANELAPPLET_REQUIRED=2.10.0
-TELEPATHY_GLIB_REQUIRED=0.7.23
+TELEPATHY_GLIB_REQUIRED=0.7.26
 MISSION_CONTROL_REQUIRED=4.61
 ENCHANT_REQUIRED=1.2.0
 ISO_CODES_REQUIRED=0.35
index 18d7f415ad6700cfcb8cbb5c611b8d29d54faabf..e8ddc01a2845e732020cc09c0b415d0b3fc4f77d 100644 (file)
@@ -706,31 +706,10 @@ contact_widget_got_contact_cb (EmpathyTpContactFactory *factory,
   contact_widget_set_contact (information, contact);
 }
 
-static void
-contact_widget_get_self_handle_cb (TpConnection *connection,
-                                   TpHandle self_handle,
-                                   const GError *error,
-                                   gpointer information,
-                                   GObject *weak_object)
-{
-  EmpathyTpContactFactory *factory;
-
-  if (error != NULL)
-    {
-      DEBUG ("Error: %s", error->message);
-      return;
-    }
-
-  factory = empathy_tp_contact_factory_dup_singleton (connection);
-  empathy_tp_contact_factory_get_from_handle (factory, self_handle,
-      contact_widget_got_contact_cb, information, NULL,
-      weak_object);
-  g_object_unref (factory);
-}
-
 static void
 contact_widget_change_contact (EmpathyContactWidget *information)
 {
+  EmpathyTpContactFactory *factory;
   TpConnection *connection;
 
   connection = empathy_account_chooser_get_connection (
@@ -738,6 +717,7 @@ contact_widget_change_contact (EmpathyContactWidget *information)
   if (!connection)
       return;
 
+  factory = empathy_tp_contact_factory_dup_singleton (connection);
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
     {
       const gchar *id;
@@ -745,22 +725,20 @@ contact_widget_change_contact (EmpathyContactWidget *information)
       id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
       if (!EMP_STR_EMPTY (id))
         {
-          EmpathyTpContactFactory *factory;
-
-          factory = empathy_tp_contact_factory_dup_singleton (connection);
           empathy_tp_contact_factory_get_from_id (factory, id,
               contact_widget_got_contact_cb, information, NULL,
               G_OBJECT (information->vbox_contact_widget));
-          g_object_unref (factory);
         }
     }
   else
     {
-      /* FIXME: TpConnection should have a SelfHandle property */
-      tp_cli_connection_call_get_self_handle (connection, -1,
-          contact_widget_get_self_handle_cb, information, NULL,
+      empathy_tp_contact_factory_get_from_handle (factory,
+          tp_connection_get_self_handle (connection),
+          contact_widget_got_contact_cb, information, NULL,
           G_OBJECT (information->vbox_contact_widget));
     }
+
+  g_object_unref (factory);
 }
 
 static void
index 37910928501bbeac1b0e0653249dd98369395f7a..51259bddf631ac1148a244e5c7d27ab04f828a40 100644 (file)
@@ -727,20 +727,6 @@ empathy_contact_is_user (EmpathyContact *contact)
 
   priv = GET_PRIV (contact);
 
-  /* FIXME: Uncomment this once we depend on tp-glib 0.7.26
-  if (priv->tp_contact != NULL)
-    {
-      TpConnection *connection;
-      TpHandle handle;
-      TpHandle self_handle;
-
-      connection = tp_contact_get_connection (priv->tp_contact);
-      self_handle = tp_connection_get_self_handle (connection);
-      handle = tp_contact_get_handle (priv->tp_contact);
-      return self_handle == handle;      
-    }
-  */
-
   return priv->is_user;
 }
 
index bc99ba51398615a9254bbcfdfe7646cf7d97103a..ec28e2625ed9f146f035693689e2aaf5b46340b9 100644 (file)
@@ -962,27 +962,6 @@ tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
        tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
 }
 
-static void
-tp_chat_get_self_handle_cb (TpConnection *connection,
-                           TpHandle self_handle,
-                           const GError *error,
-                           gpointer user_data,
-                           GObject *chat)
-{
-       EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
-       if (error) {
-               DEBUG ("Error: %s", error->message);
-               tp_cli_channel_call_close (priv->channel, -1,
-                                          NULL, NULL, NULL, NULL);
-               return;
-       }
-
-       empathy_tp_contact_factory_get_from_handle (priv->factory,
-               self_handle, tp_chat_got_self_contact_cb,
-               NULL, NULL, chat);
-}
-
 static GObject *
 tp_chat_constructor (GType                  type,
                     guint                  n_props,
@@ -1025,8 +1004,10 @@ tp_chat_constructor (GType                  type,
                        G_CALLBACK (tp_chat_group_members_changed_cb), chat);
        } else {
                /* Get the self contact from the connection's self handle */
-               tp_cli_connection_call_get_self_handle (connection, -1,
-                       tp_chat_get_self_handle_cb, NULL, NULL, chat);
+               handle = tp_connection_get_self_handle (connection);
+               empathy_tp_contact_factory_get_from_handle (priv->factory,
+                       handle, tp_chat_got_self_contact_cb,
+                       NULL, NULL, chat);
 
                /* Get the remote contact */
                handle = tp_channel_get_handle (priv->channel, NULL);
index b96af76b889045147ccf305fa1f023c8d016eb3d..7735b0f1a19344d16da0573ccc33ca31779e8301 100644 (file)
@@ -502,6 +502,7 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
                                EmpathyContact          *contact)
 {
        EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
+       TpHandle self_handle;
        TpHandle handle;
        GArray handles = {(gchar*) &handle, 1};
        GHashTable *tokens;
@@ -529,8 +530,14 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
                empathy_contact_set_capabilities (contact, caps);
        }
 
-       /* FIXME: This should be done by TpContact */
+       /* Set is-user property. Note that it could still be the handle is
+        * different from the connection's self handle, in the case the handle
+        * comes from a group interface. */
+       self_handle = tp_connection_get_self_handle (priv->connection);
        handle = empathy_contact_get_handle (contact);
+       empathy_contact_set_is_user (contact, self_handle == handle);
+
+       /* FIXME: This should be done by TpContact */
        tp_cli_connection_interface_avatars_run_get_known_avatar_tokens (priv->connection,
                                                                         -1,
                                                                         &handles,