From 40ebcf393b790a4e6553e1314b29f0f34b3377a3 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 27 Mar 2007 10:27:01 +0000 Subject: Improve integration with D-Bus system bus --- input/main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'input/main.c') diff --git a/input/main.c b/input/main.c index 2a6b3b59..057ee0db 100644 --- a/input/main.c +++ b/input/main.c @@ -51,6 +51,7 @@ static void sig_term(int sig) int main(int argc, char *argv[]) { + DBusConnection *conn; struct sigaction sa; start_logging("input", "Bluetooth Input daemon"); @@ -67,16 +68,22 @@ int main(int argc, char *argv[]) enable_debug(); - /* Create event loop */ main_loop = g_main_loop_new(NULL, FALSE); - if (input_init() < 0) { - error("Unable to get on D-Bus"); + conn = dbus_bus_system_setup_with_main_loop(NULL, NULL, NULL); + if (!conn) { + g_main_loop_unref(main_loop); + exit(1); + } + + if (input_init(conn) < 0) { + dbus_connection_unref(conn); + g_main_loop_unref(main_loop); exit(1); } if (argc > 1 && !strcmp(argv[1], "-s")) - internal_service("input"); + register_external_service(conn, "input", "Input service", ""); server_start(); @@ -86,6 +93,8 @@ int main(int argc, char *argv[]) input_exit(); + dbus_connection_unref(conn); + g_main_loop_unref(main_loop); info("Exit"); -- cgit