From d858f899525dc40fe684a8ed15f5103ed8d733b7 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 2 Jan 2012 00:16:08 +0100 Subject: move to system d-bus --- fmrx-ctl.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'fmrx-ctl.c') diff --git a/fmrx-ctl.c b/fmrx-ctl.c index 408dadd..5738c99 100644 --- a/fmrx-ctl.c +++ b/fmrx-ctl.c @@ -35,10 +35,15 @@ static void tune(double f) dbus_message_append_args(msg, DBUS_TYPE_DOUBLE, &f, DBUS_TYPE_INVALID); reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &err); - g_assert(reply != NULL); - g_assert(!dbus_error_is_set(&err)); dbus_message_unref(msg); + if (!reply) { + g_assert(dbus_error_is_set(&err)); + g_printerr("Tune error: %s", err.message); + dbus_error_free(&err); + return; + } + dbus_message_unref(reply); } @@ -53,10 +58,15 @@ static void next() dbus_error_init(&err); reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &err); - g_assert(reply != NULL); - g_assert(!dbus_error_is_set(&err)); dbus_message_unref(msg); + if (!reply) { + g_assert(dbus_error_is_set(&err)); + g_printerr("Tune error: %s", err.message); + dbus_error_free(&err); + return; + } + dbus_message_unref(reply); } @@ -71,17 +81,22 @@ static void prev() dbus_error_init(&err); reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &err); - g_assert(reply != NULL); - g_assert(!dbus_error_is_set(&err)); dbus_message_unref(msg); + if (!reply) { + g_assert(dbus_error_is_set(&err)); + g_printerr("Tune error: %s", err.message); + dbus_error_free(&err); + return; + } + dbus_message_unref(reply); } static void dbus_init() { DBusError err; dbus_error_init(&err); - bus = dbus_bus_get(DBUS_BUS_SESSION, &err); + bus = dbus_bus_get(DBUS_BUS_SYSTEM, &err); g_assert(bus != NULL); g_assert(!dbus_error_is_set(&err)); dbus_connection_setup_with_g_main(bus, g_main_loop_get_context(main_loop)); -- cgit v1.2.3