[folks] Move the Telepathy backend test setup code into a library class



commit dd72b7a7fa216158f94ea25257666833e41a0536
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Sep 16 13:21:49 2010 +0100

    Move the Telepathy backend test setup code into a library class
    
    This means that future tests can more easily set up a fake Telepathy backend
    to test against.

 tests/lib/telepathy/contactlist/Makefile.am        |    2 +
 tests/lib/telepathy/contactlist/backend.c          |  218 ++++++++++++++++++++
 tests/lib/telepathy/contactlist/backend.h          |   69 ++++++
 .../telepathy/contactlist/tp-test-contactlist.h    |    1 +
 tests/telepathy/individual-properties.vala         |   97 +--------
 tests/telepathy/individual-retrieval.vala          |   94 +--------
 tests/telepathy/persona-store-capabilities.vala    |   95 +--------
 7 files changed, 306 insertions(+), 270 deletions(-)
---
diff --git a/tests/lib/telepathy/contactlist/Makefile.am b/tests/lib/telepathy/contactlist/Makefile.am
index 8ce4470..6557834 100644
--- a/tests/lib/telepathy/contactlist/Makefile.am
+++ b/tests/lib/telepathy/contactlist/Makefile.am
@@ -22,6 +22,8 @@ libtp_test_contactlist_la_SOURCES = \
         account.h \
         account-manager.c \
         account-manager.h \
+        backend.c \
+        backend.h \
         conn.c \
         conn.h \
         contact-list.c \
diff --git a/tests/lib/telepathy/contactlist/backend.c b/tests/lib/telepathy/contactlist/backend.c
new file mode 100644
index 0000000..317dd7e
--- /dev/null
+++ b/tests/lib/telepathy/contactlist/backend.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *       Philip Withnall <philip withnall collabora co uk>
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <telepathy-glib/base-connection.h>
+#include <telepathy-glib/dbus.h>
+
+#include "account.h"
+#include "account-manager.h"
+#include "conn.h"
+#include "contact-list.h"
+
+#include "backend.h"
+
+struct _TpTestBackendPrivate
+{
+  TpDBusDaemon *daemon;
+  TpTestAccount *account;
+  TpTestAccountManager *account_manager;
+  TpBaseConnection *conn;
+  gchar *bus_name;
+  gchar *object_path;
+};
+
+G_DEFINE_TYPE (TpTestBackend, tp_test_backend, G_TYPE_OBJECT)
+
+enum
+{
+  PROP_CONNECTION = 1,
+  N_PROPS
+};
+
+static void
+tp_test_backend_init (TpTestBackend *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TEST_TYPE_BACKEND,
+      TpTestBackendPrivate);
+}
+
+static void
+tp_test_backend_finalize (GObject *object)
+{
+  tp_test_backend_tear_down (TP_TEST_BACKEND (object));
+  G_OBJECT_CLASS (tp_test_backend_parent_class)->finalize (object);
+}
+
+static void
+tp_test_backend_get_property (GObject *object,
+    guint property_id,
+    GValue *value,
+    GParamSpec *spec)
+{
+  TpTestBackend *self = TP_TEST_BACKEND (object);
+
+  switch (property_id)
+    {
+    case PROP_CONNECTION:
+      g_value_set_object (value, self->priv->conn);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec);
+    }
+}
+
+static void
+tp_test_backend_set_property (GObject *object,
+    guint property_id,
+    const GValue *value,
+    GParamSpec *spec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec);
+    }
+}
+
+static void
+tp_test_backend_class_init (TpTestBackendClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GParamSpec *param_spec;
+
+  g_type_class_add_private (klass, sizeof (TpTestBackendPrivate));
+  object_class->finalize = tp_test_backend_finalize;
+  object_class->get_property = tp_test_backend_get_property;
+  object_class->set_property = tp_test_backend_set_property;
+
+  param_spec = g_param_spec_object ("connection", "Connection",
+      "The base ContactListConnection",
+      TP_TEST_TYPE_CONTACT_LIST_CONNECTION,
+      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_CONNECTION, param_spec);
+}
+
+TpTestBackend *
+tp_test_backend_new (void)
+{
+  return g_object_new (TP_TEST_TYPE_BACKEND, NULL);
+}
+
+void
+tp_test_backend_set_up (TpTestBackend *self)
+{
+  TpTestBackendPrivate *priv = self->priv;
+  TpHandleRepoIface *handle_repo;
+  TpHandle self_handle;
+  gchar *object_path;
+  GError *error = NULL;
+
+  priv->daemon = tp_dbus_daemon_dup (&error);
+  if (error != NULL)
+    g_error ("Couldn't get D-Bus daemon: %s", error->message);
+
+  /* Set up a contact list connection */
+  priv->conn =
+      TP_BASE_CONNECTION (tp_test_contact_list_connection_new ("me example com",
+          "protocol", 0, 0));
+
+  tp_base_connection_register (priv->conn, "cm", &priv->bus_name,
+      &priv->object_path, &error);
+  if (error != NULL)
+    {
+      g_error ("Failed to register connection %p: %s", priv->conn,
+          error->message);
+    }
+
+  handle_repo = tp_base_connection_get_handles (priv->conn,
+      TP_HANDLE_TYPE_CONTACT);
+  self_handle = tp_handle_ensure (handle_repo, "me example com", NULL, &error);
+  if (error != NULL)
+    {
+      g_error ("Couldn't ensure self handle '%s': %s", "me example com",
+              error->message);
+    }
+
+  tp_base_connection_set_self_handle (priv->conn, self_handle);
+  tp_base_connection_change_status (priv->conn,
+      TP_CONNECTION_STATUS_CONNECTED, TP_CONNECTION_STATUS_REASON_REQUESTED);
+
+  /* Create an account */
+  priv->account = tp_test_account_new (priv->object_path);
+  object_path =
+      g_strdup_printf ("%scm/protocol/account", TP_ACCOUNT_OBJECT_PATH_BASE);
+  tp_dbus_daemon_register_object (priv->daemon, object_path, priv->account);
+  g_free (object_path);
+
+  /* Create an account manager */
+  tp_dbus_daemon_request_name (priv->daemon, TP_ACCOUNT_MANAGER_BUS_NAME, FALSE,
+      &error);
+  if (error != NULL)
+    {
+      g_error ("Couldn't request account manager bus name '%s': %s",
+          TP_ACCOUNT_MANAGER_BUS_NAME, error->message);
+    }
+
+  priv->account_manager = tp_test_account_manager_new ();
+  tp_dbus_daemon_register_object (priv->daemon, TP_ACCOUNT_MANAGER_OBJECT_PATH,
+      priv->account_manager);
+}
+
+void
+tp_test_backend_tear_down (TpTestBackend *self)
+{
+  TpTestBackendPrivate *priv = self->priv;
+  GError *error = NULL;
+
+  tp_base_connection_change_status (priv->conn,
+      TP_CONNECTION_STATUS_DISCONNECTED, TP_CONNECTION_STATUS_REASON_REQUESTED);
+
+  tp_dbus_daemon_unregister_object (priv->daemon, priv->account_manager);
+  tp_clear_object (&priv->account_manager);
+
+  tp_dbus_daemon_release_name (priv->daemon, TP_ACCOUNT_MANAGER_BUS_NAME,
+      &error);
+  if (error != NULL)
+    {
+      g_error ("Couldn't release account manager bus name '%s': %s",
+          TP_ACCOUNT_MANAGER_BUS_NAME, error->message);
+    }
+
+  tp_dbus_daemon_unregister_object (priv->daemon, priv->account);
+  tp_clear_object (&priv->account);
+
+  tp_clear_object (&priv->conn);
+  tp_clear_object (&priv->daemon);
+  g_free (priv->bus_name);
+  priv->bus_name = NULL;
+  g_free (priv->object_path);
+  priv->object_path = NULL;
+}
+
+TpTestContactListConnection *
+tp_test_backend_get_connection (TpTestBackend *self)
+{
+  g_return_val_if_fail (TP_TEST_IS_BACKEND (self), NULL);
+
+  return TP_TEST_CONTACT_LIST_CONNECTION (self->priv->conn);
+}
diff --git a/tests/lib/telepathy/contactlist/backend.h b/tests/lib/telepathy/contactlist/backend.h
new file mode 100644
index 0000000..40181df
--- /dev/null
+++ b/tests/lib/telepathy/contactlist/backend.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *       Philip Withnall <philip withnall collabora co uk>
+ */
+
+#ifndef TP_TEST_BACKEND_H
+#define TP_TEST_BACKEND_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "conn.h"
+
+G_BEGIN_DECLS
+
+#define TP_TEST_TYPE_BACKEND (tp_test_backend_get_type ())
+#define TP_TEST_BACKEND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
+    TP_TEST_TYPE_BACKEND, TpTestBackend))
+#define TP_TEST_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
+    TP_TEST_TYPE_BACKEND, TpTestBackendClass))
+#define TP_TEST_IS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
+    TP_TEST_TYPE_BACKEND))
+#define TP_TEST_IS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
+    TP_TEST_TYPE_BACKEND))
+#define TP_TEST_BACKEND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
+    TP_TEST_TYPE_BACKEND, TpTestBackendClass))
+
+typedef struct _TpTestBackendPrivate TpTestBackendPrivate;
+
+typedef struct
+{
+  /*< private >*/
+  GObject parent;
+  TpTestBackendPrivate *priv;
+} TpTestBackend;
+
+typedef struct
+{
+  /*< private > */
+  GObjectClass parent;
+} TpTestBackendClass;
+
+GType tp_test_backend_get_type (void) G_GNUC_CONST;
+
+TpTestBackend *tp_test_backend_new (void);
+
+void tp_test_backend_set_up (TpTestBackend *self);
+void tp_test_backend_tear_down (TpTestBackend *self);
+TpTestContactListConnection *tp_test_backend_get_connection (
+    TpTestBackend *self);
+
+G_END_DECLS
+
+#endif /* !TP_TEST_BACKEND_H */
diff --git a/tests/lib/telepathy/contactlist/tp-test-contactlist.h b/tests/lib/telepathy/contactlist/tp-test-contactlist.h
index 19088b9..2ce4b65 100644
--- a/tests/lib/telepathy/contactlist/tp-test-contactlist.h
+++ b/tests/lib/telepathy/contactlist/tp-test-contactlist.h
@@ -3,6 +3,7 @@
 
 #include <account-manager.h>
 #include <account.h>
+#include <backend.h>
 #include <conn.h>
 #include <contact-list-manager.h>
 #include <contact-list.h>
diff --git a/tests/telepathy/individual-properties.vala b/tests/telepathy/individual-properties.vala
index 8f969e1..2572591 100644
--- a/tests/telepathy/individual-properties.vala
+++ b/tests/telepathy/individual-properties.vala
@@ -7,19 +7,16 @@ using Gee;
 
 public class IndividualPropertiesTests : Folks.TestCase
 {
-  private DBusDaemon daemon;
-  private TpTest.Account account;
-  private TpTest.AccountManager account_manager;
-  private TpTest.ContactListConnection conn;
+  private TpTest.Backend tp_backend;
   private MainLoop main_loop;
-  private string bus_name;
-  private string object_path;
   private string individual_id_prefix = "telepathy:protocol:";
 
   public IndividualPropertiesTests ()
     {
       base ("IndividualProperties");
 
+      this.tp_backend = new TpTest.Backend ();
+
       this.add_test ("individual properties",
           this.test_individual_properties);
       this.add_test ("individual properties:change alias through tp backend",
@@ -31,94 +28,12 @@ public class IndividualPropertiesTests : Folks.TestCase
   public override void set_up ()
     {
       this.main_loop = new GLib.MainLoop (null, false);
-
-      try
-        {
-          this.daemon = DBusDaemon.dup ();
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't get D-Bus daemon: %s", e.message);
-        }
-
-      /* Set up a contact list connection */
-      this.conn = new TpTest.ContactListConnection ("me example com",
-          "protocol", 0, 0);
-
-      try
-        {
-          this.conn.register ("cm", out this.bus_name, out this.object_path);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Failed to register connection %p.", this.conn);
-        }
-
-      var handle_repo = this.conn.get_handles (HandleType.CONTACT);
-      Handle self_handle = 0;
-      try
-        {
-          self_handle = TelepathyGLib.handle_ensure (handle_repo,
-              "me example com", null);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't ensure self handle '%s': %s", "me example com",
-              e.message);
-        }
-
-      this.conn.set_self_handle (self_handle);
-      this.conn.change_status (ConnectionStatus.CONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      /* Create an account */
-      this.account = new TpTest.Account (this.object_path);
-      this.daemon.register_object (
-          TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE + "cm/protocol/account",
-          this.account);
-
-      /* Create an account manager */
-      try
-        {
-          this.daemon.request_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME,
-              false);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't request account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.account_manager = new TpTest.AccountManager ();
-      this.daemon.register_object (TelepathyGLib.ACCOUNT_MANAGER_OBJECT_PATH,
-          this.account_manager);
+      this.tp_backend.set_up ();
     }
 
   public override void tear_down ()
     {
-      this.conn.change_status (ConnectionStatus.DISCONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      this.daemon.unregister_object (this.account_manager);
-      this.account_manager = null;
-
-      try
-        {
-          this.daemon.release_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't release account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.daemon.unregister_object (this.account);
-      this.account = null;
-
-      this.conn = null;
-      this.daemon = null;
-      this.bus_name = null;
-      this.object_path = null;
+      this.tp_backend.tear_down ();
 
       Timeout.add_seconds (5, () =>
         {
@@ -305,7 +220,7 @@ public class IndividualPropertiesTests : Folks.TestCase
                * alias notification callback above */
 
               var handle = (Handle) ((Tpf.Persona) persona).contact.handle;
-              this.conn.manager.set_alias (handle, new_alias);
+              this.tp_backend.connection.manager.set_alias (handle, new_alias);
             }
 
           assert (removed == null);
diff --git a/tests/telepathy/individual-retrieval.vala b/tests/telepathy/individual-retrieval.vala
index 35b253b..9417941 100644
--- a/tests/telepathy/individual-retrieval.vala
+++ b/tests/telepathy/individual-retrieval.vala
@@ -7,13 +7,8 @@ using Gee;
 
 public class IndividualRetrievalTests : Folks.TestCase
 {
-  private DBusDaemon daemon;
-  private TpTest.Account account;
-  private TpTest.AccountManager account_manager;
-  private TpTest.ContactListConnection conn;
+  private TpTest.Backend tp_backend;
   private MainLoop main_loop;
-  private string bus_name;
-  private string object_path;
   private HashSet<string> default_individuals;
   private string individual_id_prefix = "telepathy:protocol:";
 
@@ -21,6 +16,8 @@ public class IndividualRetrievalTests : Folks.TestCase
     {
       base ("IndividualRetrieval");
 
+      this.tp_backend = new TpTest.Backend ();
+
       /* Create a set of the individuals we expect to see */
       this.default_individuals = new HashSet<string> (str_hash, str_equal);
 
@@ -42,93 +39,12 @@ public class IndividualRetrievalTests : Folks.TestCase
     {
       this.main_loop = new GLib.MainLoop (null, false);
 
-      try
-        {
-          this.daemon = DBusDaemon.dup ();
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't get D-Bus daemon: %s", e.message);
-        }
-
-      /* Set up a contact list connection */
-      this.conn = new TpTest.ContactListConnection ("me example com",
-          "protocol", 0, 0);
-
-      try
-        {
-          this.conn.register ("cm", out this.bus_name, out this.object_path);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Failed to register connection %p.", this.conn);
-        }
-
-      var handle_repo = this.conn.get_handles (HandleType.CONTACT);
-      Handle self_handle = 0;
-      try
-        {
-          self_handle = TelepathyGLib.handle_ensure (handle_repo,
-              "me example com", null);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't ensure self handle '%s': %s", "me example com",
-              e.message);
-        }
-
-      this.conn.set_self_handle (self_handle);
-      this.conn.change_status (ConnectionStatus.CONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      /* Create an account */
-      this.account = new TpTest.Account (this.object_path);
-      this.daemon.register_object (
-          TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE + "cm/protocol/account",
-          this.account);
-
-      /* Create an account manager */
-      try
-        {
-          this.daemon.request_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME,
-              false);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't request account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.account_manager = new TpTest.AccountManager ();
-      this.daemon.register_object (TelepathyGLib.ACCOUNT_MANAGER_OBJECT_PATH,
-          this.account_manager);
+      this.tp_backend.set_up ();
     }
 
   public override void tear_down ()
     {
-      this.conn.change_status (ConnectionStatus.DISCONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      this.daemon.unregister_object (this.account_manager);
-      this.account_manager = null;
-
-      try
-        {
-          this.daemon.release_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't release account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.daemon.unregister_object (this.account);
-      this.account = null;
-
-      this.conn = null;
-      this.daemon = null;
-      this.bus_name = null;
-      this.object_path = null;
+      this.tp_backend.tear_down ();
 
       Timeout.add_seconds (5, () =>
         {
diff --git a/tests/telepathy/persona-store-capabilities.vala b/tests/telepathy/persona-store-capabilities.vala
index da1fa14..61e6d53 100644
--- a/tests/telepathy/persona-store-capabilities.vala
+++ b/tests/telepathy/persona-store-capabilities.vala
@@ -7,19 +7,16 @@ using Gee;
 
 public class PersonaStoreCapabilitiesTests : Folks.TestCase
 {
-  private DBusDaemon daemon;
-  private TpTest.Account account;
-  private TpTest.AccountManager account_manager;
-  private TpTest.ContactListConnection conn;
+  private TpTest.Backend tp_backend;
   private MainLoop main_loop;
-  private string bus_name;
-  private string object_path;
   private HashSet<string> group_flags_received;
 
   public PersonaStoreCapabilitiesTests ()
     {
       base ("PersonaStoreCapabilities");
 
+      this.tp_backend = new TpTest.Backend ();
+
       this.add_test ("persona store capabilities",
           this.test_persona_store_capabilities);
     }
@@ -29,94 +26,12 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
       this.group_flags_received = new HashSet<string> (str_hash, str_equal);
 
       this.main_loop = new GLib.MainLoop (null, false);
-
-      try
-        {
-          this.daemon = DBusDaemon.dup ();
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't get D-Bus daemon: %s", e.message);
-        }
-
-      /* Set up a contact list connection */
-      this.conn = new TpTest.ContactListConnection ("me example com",
-          "protocol", 0, 0);
-
-      try
-        {
-          this.conn.register ("cm", out this.bus_name, out this.object_path);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Failed to register connection %p.", this.conn);
-        }
-
-      var handle_repo = this.conn.get_handles (HandleType.CONTACT);
-      Handle self_handle = 0;
-      try
-        {
-          self_handle = TelepathyGLib.handle_ensure (handle_repo,
-              "me example com", null);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't ensure self handle '%s': %s", "me example com",
-              e.message);
-        }
-
-      this.conn.set_self_handle (self_handle);
-      this.conn.change_status (ConnectionStatus.CONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      /* Create an account */
-      this.account = new TpTest.Account (this.object_path);
-      this.daemon.register_object (
-          TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE + "cm/protocol/account",
-          this.account);
-
-      /* Create an account manager */
-      try
-        {
-          this.daemon.request_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME,
-              false);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't request account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.account_manager = new TpTest.AccountManager ();
-      this.daemon.register_object (TelepathyGLib.ACCOUNT_MANAGER_OBJECT_PATH,
-          this.account_manager);
+      this.tp_backend.set_up ();
     }
 
   public override void tear_down ()
     {
-      this.conn.change_status (ConnectionStatus.DISCONNECTED,
-          ConnectionStatusReason.REQUESTED);
-
-      this.daemon.unregister_object (this.account_manager);
-      this.account_manager = null;
-
-      try
-        {
-          this.daemon.release_name (TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME);
-        }
-      catch (GLib.Error e)
-        {
-          error ("Couldn't release account manager bus name '%s': %s",
-              TelepathyGLib.ACCOUNT_MANAGER_BUS_NAME, e.message);
-        }
-
-      this.daemon.unregister_object (this.account);
-      this.account = null;
-
-      this.conn = null;
-      this.daemon = null;
-      this.bus_name = null;
-      this.object_path = null;
+      this.tp_backend.tear_down ();
 
       Timeout.add_seconds (5, () =>
         {



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