[folks] Port away from tp_connection_new since it has been deprecated. Synced some sources from telepathy-gl



commit 42bbfe492850c760a4fc46d9b2c7cba944477280
Author: Jeremy Whiting <jpwhiting kde org>
Date:   Wed Jul 4 17:10:27 2012 -0600

    Port away from tp_connection_new since it has been deprecated.
    Synced some sources from telepathy-glib/tests/lib/.

 tests/lib/telepathy/contactlist/backend.c          |    6 +++-
 .../telepathy/contactlist/contact-list-manager.c   |    5 ++-
 tests/lib/telepathy/contactlist/contacts-conn.c    |    9 +++----
 tests/lib/telepathy/contactlist/simple-conn.c      |   23 +++++++++----------
 tests/lib/telepathy/contactlist/textchan-null.c    |    6 +++-
 tests/lib/telepathy/contactlist/util.c             |    7 ++++-
 6 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/tests/lib/telepathy/contactlist/backend.c b/tests/lib/telepathy/contactlist/backend.c
index 826aa82..da97d07 100644
--- a/tests/lib/telepathy/contactlist/backend.c
+++ b/tests/lib/telepathy/contactlist/backend.c
@@ -268,6 +268,7 @@ tp_tests_backend_add_account (TpTestsBackend *self,
     const gchar *account)
 {
   TpTestsBackendPrivate *priv = self->priv;
+  TpSimpleClientFactory *factory;
   AccountData *data;
   gchar *conn_path;
   GError *error = NULL;
@@ -284,8 +285,9 @@ tp_tests_backend_add_account (TpTestsBackend *self,
         NULL, &conn_path, &error);
   g_assert_no_error (error);
 
-  data->client_conn = tp_connection_new (priv->daemon, NULL, conn_path,
-      &error);
+  factory = tp_proxy_get_factory (priv->client_am);
+  data->client_conn = tp_simple_client_factory_ensure_connection (factory,
+      conn_path, NULL, &error);
   g_assert_no_error (error);
 
   /* Create an account */
diff --git a/tests/lib/telepathy/contactlist/contact-list-manager.c b/tests/lib/telepathy/contactlist/contact-list-manager.c
index 6d01282..b816673 100644
--- a/tests/lib/telepathy/contactlist/contact-list-manager.c
+++ b/tests/lib/telepathy/contactlist/contact-list-manager.c
@@ -881,8 +881,9 @@ tp_tests_contact_list_manager_add_initial_contacts (TpTestsContactListManager *s
   TpHandleSet *handles;
   guint i;
 
-  g_assert_cmpint (self->priv->conn->status, ==,
-      TP_INTERNAL_CONNECTION_STATUS_NEW);
+  g_assert_cmpint (tp_base_connection_get_status (self->priv->conn), ==,
+      TP_CONNECTION_STATUS_DISCONNECTED);
+  g_assert (!tp_base_connection_is_destroyed (self->priv->conn));
 
   handles = tp_handle_set_new (self->priv->contact_repo);
   for (i = 0; i < n_members; i++)
diff --git a/tests/lib/telepathy/contactlist/contacts-conn.c b/tests/lib/telepathy/contactlist/contacts-conn.c
index ea974bf..6f30880 100644
--- a/tests/lib/telepathy/contactlist/contacts-conn.c
+++ b/tests/lib/telepathy/contactlist/contacts-conn.c
@@ -454,10 +454,7 @@ my_status_available (GObject *object,
 {
   TpBaseConnection *base = TP_BASE_CONNECTION (object);
 
-  if (base->status != TP_CONNECTION_STATUS_CONNECTED)
-    return FALSE;
-
-  return TRUE;
+  return tp_base_connection_check_connected (base, NULL);
 }
 
 static GHashTable *
@@ -506,6 +503,7 @@ my_set_own_status (GObject *object,
   TpBaseConnection *base_conn = TP_BASE_CONNECTION (object);
   TpTestsContactsConnectionPresenceStatusIndex index = status->index;
   const gchar *message = "";
+  TpHandle self_handle;
 
   if (status->optional_arguments != NULL)
     {
@@ -515,8 +513,9 @@ my_set_own_status (GObject *object,
         message = "";
     }
 
+  self_handle = tp_base_connection_get_self_handle (base_conn);
   tp_tests_contacts_connection_change_presences (TP_TESTS_CONTACTS_CONNECTION (object),
-      1, &(base_conn->self_handle), &index, &message);
+      1, &self_handle, &index, &message);
 
   return TRUE;
 }
diff --git a/tests/lib/telepathy/contactlist/simple-conn.c b/tests/lib/telepathy/contactlist/simple-conn.c
index 51bf9e2..e6ee214 100644
--- a/tests/lib/telepathy/contactlist/simple-conn.c
+++ b/tests/lib/telepathy/contactlist/simple-conn.c
@@ -99,12 +99,8 @@ get_property (GObject *object,
         }
       else
         {
-          guint32 status = TP_BASE_CONNECTION (self)->status;
-
-          if (status == TP_INTERNAL_CONNECTION_STATUS_NEW)
-            g_value_set_uint (value, TP_CONNECTION_STATUS_DISCONNECTED);
-          else
-            g_value_set_uint (value, status);
+          g_value_set_uint (value,
+              tp_base_connection_get_status (TP_BASE_CONNECTION (self)));
         }
       break;
     default:
@@ -227,11 +223,13 @@ pretend_connected (gpointer data)
   TpBaseConnection *conn = (TpBaseConnection *) self;
   TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
       TP_HANDLE_TYPE_CONTACT);
+  TpHandle self_handle;
 
-  conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+  self_handle = tp_handle_ensure (contact_repo, self->priv->account,
       NULL, NULL);
+  tp_base_connection_set_self_handle (conn, self_handle);
 
-  if (conn->status == TP_CONNECTION_STATUS_CONNECTING)
+  if (tp_base_connection_get_status (conn) == TP_CONNECTION_STATUS_CONNECTING)
     {
       tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
           TP_CONNECTION_STATUS_REASON_REQUESTED);
@@ -391,8 +389,8 @@ tp_tests_simple_connection_ensure_text_chan (TpTestsSimpleConnection *self,
     }
   else
     {
-      chan_path = g_strdup_printf ("%s/Channel%u", base_conn->object_path,
-          count++);
+      chan_path = g_strdup_printf ("%s/Channel%u",
+          tp_base_connection_get_object_path (base_conn), count++);
 
        chan = TP_TESTS_TEXT_CHANNEL_NULL (
           tp_tests_object_new_static_class (
@@ -436,7 +434,7 @@ tp_tests_simple_connection_ensure_room_list_chan (TpTestsSimpleConnection *self,
   else
     {
       chan_path = g_strdup_printf ("%s/RoomListChannel",
-          base_conn->object_path);
+          tp_base_connection_get_object_path (base_conn));
 
       self->priv->room_list_chan = TP_TESTS_ROOM_LIST_CHAN (
           tp_tests_object_new_static_class (
@@ -485,7 +483,8 @@ get_self_handle (TpSvcConnection *iface,
       return;
     }
 
-  tp_svc_connection_return_from_get_self_handle (context, base->self_handle);
+  tp_svc_connection_return_from_get_self_handle (context,
+      tp_base_connection_get_self_handle (base));
   g_signal_emit (self, signals[SIGNAL_GOT_SELF_HANDLE], 0);
 }
 
diff --git a/tests/lib/telepathy/contactlist/textchan-null.c b/tests/lib/telepathy/contactlist/textchan-null.c
index 64b156f..bbeb0c7 100644
--- a/tests/lib/telepathy/contactlist/textchan-null.c
+++ b/tests/lib/telepathy/contactlist/textchan-null.c
@@ -154,7 +154,8 @@ get_property (GObject *object,
       g_value_set_boolean (value, TRUE);
       break;
     case PROP_INITIATOR_HANDLE:
-      g_value_set_uint (value, self->priv->conn->self_handle);
+      g_value_set_uint (value, tp_base_connection_get_self_handle (
+            self->priv->conn));
       break;
     case PROP_INITIATOR_ID:
         {
@@ -162,7 +163,8 @@ get_property (GObject *object,
               self->priv->conn, TP_HANDLE_TYPE_CONTACT);
 
           g_value_set_string (value,
-              tp_handle_inspect (contact_repo, self->priv->conn->self_handle));
+              tp_handle_inspect (contact_repo,
+                tp_base_connection_get_self_handle (self->priv->conn)));
         }
       break;
     case PROP_INTERFACES:
diff --git a/tests/lib/telepathy/contactlist/util.c b/tests/lib/telepathy/contactlist/util.c
index 009d964..21d3855 100644
--- a/tests/lib/telepathy/contactlist/util.c
+++ b/tests/lib/telepathy/contactlist/util.c
@@ -183,6 +183,7 @@ tp_tests_create_conn (GType conn_type,
     TpConnection **client_conn)
 {
   TpDBusDaemon *dbus;
+  TpSimpleClientFactory *factory;
   gchar *name;
   gchar *conn_path;
   GError *error = NULL;
@@ -191,6 +192,7 @@ tp_tests_create_conn (GType conn_type,
   g_assert (client_conn != NULL);
 
   dbus = tp_tests_dbus_daemon_dup_or_die ();
+  factory = (TpSimpleClientFactory *) tp_automatic_client_factory_new (dbus);
 
   *service_conn = tp_tests_object_new_static_class (
         conn_type,
@@ -203,8 +205,8 @@ tp_tests_create_conn (GType conn_type,
         &name, &conn_path, &error));
   g_assert_no_error (error);
 
-  *client_conn = tp_connection_new (dbus, name, conn_path,
-      &error);
+  *client_conn = tp_simple_client_factory_ensure_connection (factory,
+      conn_path, NULL, &error);
   g_assert (*client_conn != NULL);
   g_assert_no_error (error);
 
@@ -220,6 +222,7 @@ tp_tests_create_conn (GType conn_type,
   g_free (conn_path);
 
   g_object_unref (dbus);
+  g_object_unref (factory);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]