summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/protocol-dbus.c
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2009-08-09 09:19:33 +0300
committerTanu Kaskinen <tanuk@iki.fi>2009-08-09 09:19:33 +0300
commit16dce8d7cbe4dcad56c3fbd1f47af6b50d2581a7 (patch)
tree884e47b911eefbddee45adb33adae29f2ce5863b /src/pulsecore/protocol-dbus.c
parent7699cfd4c041eedd2dae124cac75da0879b87f1e (diff)
dbus-protocol: Take advantage of the helpers in dbus-util.
Diffstat (limited to 'src/pulsecore/protocol-dbus.c')
-rw-r--r--src/pulsecore/protocol-dbus.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/pulsecore/protocol-dbus.c b/src/pulsecore/protocol-dbus.c
index 2461e4ba..62f74a56 100644
--- a/src/pulsecore/protocol-dbus.c
+++ b/src/pulsecore/protocol-dbus.c
@@ -28,6 +28,7 @@
#include <pulse/xmalloc.h>
#include <pulsecore/core-util.h>
+#include <pulsecore/dbus-util.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/idxset.h>
#include <pulsecore/shared.h>
@@ -408,7 +409,6 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
pa_dbus_method_handler *method_handler = NULL;
pa_dbus_property_handler *property_handler = NULL;
const char *attempted_property = NULL;
- DBusMessage *reply = NULL;
pa_assert(connection);
pa_assert(message);
@@ -427,10 +427,7 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect") ||
(!dbus_message_get_interface(message) && dbus_message_has_member(message, "Introspect"))) {
- pa_assert_se((reply = dbus_message_new_method_return(message)));
- pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &obj_entry->introspection, DBUS_TYPE_INVALID));
- pa_assert_se(dbus_connection_send(connection, reply, NULL));
-
+ pa_dbus_send_basic_value_reply(connection, message, DBUS_TYPE_STRING, &obj_entry->introspection);
goto finish;
}
@@ -450,26 +447,23 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
case FOUND_GET_ALL:
if (iface_entry->get_all_properties_cb)
iface_entry->get_all_properties_cb(connection, message, iface_entry->userdata);
+ /* TODO: Write an else branch where a dummy response is sent. */
break;
case PROPERTY_ACCESS_DENIED:
- pa_assert_se((reply = dbus_message_new_error_printf(message, DBUS_ERROR_ACCESS_DENIED, "%s access denied for property %s", dbus_message_get_member(message), attempted_property)));
- pa_assert_se(dbus_connection_send(connection, reply, NULL));
+ pa_dbus_send_error(connection, message, DBUS_ERROR_ACCESS_DENIED, "%s access denied for property %s", dbus_message_get_member(message), attempted_property);
break;
case NO_SUCH_METHOD:
- pa_assert_se((reply = dbus_message_new_error_printf(message, DBUS_ERROR_UNKNOWN_METHOD, "%s: No such method", dbus_message_get_member(message))));
- pa_assert_se(dbus_connection_send(connection, reply, NULL));
+ pa_dbus_send_error(connection, message, DBUS_ERROR_UNKNOWN_METHOD, "%s: No such method", dbus_message_get_member(message));
break;
case NO_SUCH_PROPERTY:
- pa_assert_se((reply = dbus_message_new_error_printf(message, PA_DBUS_ERROR_NO_SUCH_PROPERTY, "%s: No such property", attempted_property)));
- pa_assert_se(dbus_connection_send(connection, reply, NULL));
+ pa_dbus_send_error(connection, message, PA_DBUS_ERROR_NO_SUCH_PROPERTY, "%s: No such property", attempted_property);
break;
case INVALID_MESSAGE_ARGUMENTS:
- pa_assert_se((reply = dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS, "Invalid arguments for %s", dbus_message_get_member(message))));
- pa_assert_se(dbus_connection_send(connection, reply, NULL));
+ pa_dbus_send_error(connection, message, DBUS_ERROR_INVALID_ARGS, "Invalid arguments for %s", dbus_message_get_member(message));
break;
default:
@@ -477,9 +471,6 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
}
finish:
- if (reply)
- dbus_message_unref(reply);
-
return DBUS_HANDLER_RESULT_HANDLED;
}