[telepathy-gabble/master] Leave the Disconnect handling to tp-glib

Sjoerd Simons sjoerd.simons at collabora.co.uk
Fri Dec 18 07:23:41 PST 2009


---
 tests/twisted/main-debug.c |   51 +++++++------------------------------------
 1 files changed, 9 insertions(+), 42 deletions(-)

diff --git a/tests/twisted/main-debug.c b/tests/twisted/main-debug.c
index 10771ec..d7569c2 100644
--- a/tests/twisted/main-debug.c
+++ b/tests/twisted/main-debug.c
@@ -25,67 +25,30 @@
 #include "jingle-factory.h"
 #include "jingle-session.h"
 
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <telepathy-glib/dbus.h>
-#include <wocky/wocky.h>
-
 #include "test-resolver.h"
 
-static DBusHandlerResult
-dbus_filter_function (DBusConnection *connection,
-    DBusMessage *message,
-    void *user_data)
-{
-  if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") &&
-      !tp_strdiff (dbus_message_get_path (message), DBUS_PATH_LOCAL))
-    {
-      wocky_deinit ();
-      exit (1);
-    }
-
-  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
+#include <dbus/dbus.h>
 
 int
 main (int argc,
       char **argv)
 {
-  TpDBusDaemon *bus_daemon = NULL;
-  GError *error = NULL;
-  DBusConnection *connection;
   int ret = 1;
   GResolver *kludged;
 
   gabble_init ();
 
-  bus_daemon = tp_dbus_daemon_dup (&error);
-  if (bus_daemon == NULL)
-    {
-      g_warning ("%s", error->message);
-      g_error_free (error);
-      error = NULL;
-      goto out;
-    }
-
-  /* It appears that dbus-glib registers a filter that wrongly returns
-   * DBUS_HANDLER_RESULT_HANDLED for signals, so for *our* filter to have any
-   * effect, we need to install it as soon as possible */
-  connection = dbus_g_connection_get_connection (
-      ((TpProxy *) bus_daemon)->dbus_connection);
-  dbus_connection_add_filter (connection, dbus_filter_function, NULL, NULL);
-
-  dbus_connection_set_exit_on_disconnect (connection, FALSE);
   /* needed for test-disco-no-reply.py */
   gabble_connection_set_disco_reply_timeout (3);
   /* needed for test-avatar-async.py */
   gabble_vcard_manager_set_suspend_reply_timeout (3);
   gabble_vcard_manager_set_default_request_timeout (3);
-  
+
   /* hook up the fake DNS resolver that lets us divert A and SRV queries *
    * into our local cache before asking the real DNS                     */
   kludged = g_object_new (TEST_TYPE_RESOLVER, NULL);
   g_resolver_set_default (kludged);
+  g_object_unref (kludged);
 
   test_resolver_add_A (TEST_RESOLVER (kludged),
       "resolves-to-5.4.3.2", "5.4.3.2");
@@ -100,7 +63,11 @@ main (int argc,
 
   ret = gabble_main (argc, argv);
 
-  g_object_unref (bus_daemon);
-out:
+  /* Hack, remove the ref g_resolver has on this object, atm there is no way to
+   * unset a custom resolver */
+  g_object_unref (kludged);
+
+  dbus_shutdown ();
+
   return ret;
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list