static void new_connection_callback (DBusServer *server, DBusConnection *new_connection, void *data) { TestServiceData *testdata = data; if (!test_connection_try_setup (testdata->loop, new_connection)) dbus_connection_close (new_connection); }
DBusConnection * test_try_connect_to_bus (TestMainContext *ctx, const gchar *address, GError **gerror) { DBusConnection *conn; DBusError error = DBUS_ERROR_INIT; conn = dbus_connection_open_private (address, &error); if (conn == NULL) goto fail; if (!dbus_bus_register (conn, &error)) goto fail; g_assert (dbus_bus_get_unique_name (conn) != NULL); if (ctx != NULL && !test_connection_try_setup (ctx, conn)) { _DBUS_SET_OOM (&error); goto fail; } return conn; fail: if (gerror != NULL) *gerror = g_dbus_error_new_for_dbus_error (error.name, error.message); if (conn != NULL) { dbus_connection_close (conn); dbus_connection_unref (conn); } dbus_error_free (&error); return FALSE; }