int main (int argc, char **argv) { DRouteContext *cnx; DRoutePath *path; AnObject *object; DBusError error; /* Setup some server object */ object = g_new0(AnObject, 1); object->astring = g_strdup (STRING_ONE); object->anint = INT_ONE; dbus_error_init (&error); main_loop = g_main_loop_new(NULL, FALSE); bus = dbus_bus_get (DBUS_BUS_SESSION, &error); atspi_dbus_connection_setup_with_g_main(bus, g_main_context_default()); cnx = droute_new (); path = droute_add_one (cnx, TEST_OBJECT_PATH, object); droute_path_add_interface (path, TEST_INTERFACE_ONE, test_interface_One, test_methods_one, test_properties); droute_path_add_interface (path, TEST_INTERFACE_TWO, test_interface_Two, test_methods_two, test_properties); droute_path_register (path, bus); g_idle_add (do_tests_func, NULL); g_main_loop_run(main_loop); if (success) return 0; else return 1; }
DBusMessage * dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusError *error) { DBusPendingCall *pending; SpiReentrantCallClosure *closure; const char *unique_name = dbus_bus_get_unique_name (bus); const char *destination = dbus_message_get_destination (message); struct timeval tv; DBusMessage *ret; if (unique_name && destination && strcmp (destination, unique_name) != 0) return dbus_connection_send_with_reply_and_block (bus, message, dbind_timeout, error); closure = g_new0 (SpiReentrantCallClosure, 1); closure->reply = NULL; atspi_dbus_connection_setup_with_g_main(bus, NULL); if (!dbus_connection_send_with_reply (bus, message, &pending, dbind_timeout)) return NULL; if (!pending) return NULL; dbus_pending_call_set_notify (pending, set_reply, (void *) closure, g_free); closure->reply = NULL; gettimeofday (&tv, NULL); dbus_pending_call_ref (pending); while (!closure->reply) { if (!dbus_connection_read_write_dispatch (bus, dbind_timeout) || time_elapsed (&tv) > dbind_timeout) { dbus_pending_call_unref (pending); return NULL; } } ret = closure->reply; dbus_pending_call_unref (pending); return ret; }