#include static void new_connection (DBusServer *server, DBusConnection *conn, void *data) { dbus_connection_disconnect (conn); } static DBusHandlerResult handle_message (DBusConnection *connection, DBusMessage *message, gpointer loop) { if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) { dbus_connection_disconnect (connection); dbus_connection_unref (connection); g_main_loop_quit (loop); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } int main (gchar *argv, gchar *argc) { DBusError error; DBusConnection *conn; DBusServer *server; GMainLoop *loop; DBusObjectPathVTable vtable = { NULL, handle_message, }; dbus_error_init (&error); loop = g_main_loop_new (NULL, FALSE); server = dbus_server_listen ("unix:tmpdir=/tmp", &error); if (!server) g_error ("Could not start server: %s\n", error.message); dbus_server_set_new_connection_function (server, new_connection, NULL, NULL); dbus_server_setup_with_g_main (server, NULL); conn = dbus_connection_open (dbus_server_get_address (server), &error); if (conn == NULL) g_error ("Couldn't open connection: %s\n", error.message); dbus_connection_setup_with_g_main (conn, NULL); dbus_connection_register_fallback (conn, "/", &vtable, loop); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }