summaryrefslogtreecommitdiffstats
path: root/src/modules/dbus/module-dbus-protocol.c
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2009-08-26 14:20:26 +0300
committerTanu Kaskinen <tanuk@iki.fi>2009-08-26 14:20:26 +0300
commit219f7508f6420f94ad8c426c6aa3dc79df246f36 (patch)
tree4ba1f8967b6e61dae3eee6d9315d7f2da656850a /src/modules/dbus/module-dbus-protocol.c
parent11fcc8c85f15dba8e78dffb88b3d0d04ebc329e1 (diff)
dbus: Finish the Client D-Bus interface.
Diffstat (limited to 'src/modules/dbus/module-dbus-protocol.c')
-rw-r--r--src/modules/dbus/module-dbus-protocol.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/modules/dbus/module-dbus-protocol.c b/src/modules/dbus/module-dbus-protocol.c
index 807d32da..11064c33 100644
--- a/src/modules/dbus/module-dbus-protocol.c
+++ b/src/modules/dbus/module-dbus-protocol.c
@@ -40,6 +40,7 @@
#include <pulsecore/module.h>
#include <pulsecore/protocol-dbus.h>
+#include "iface-client.h"
#include "iface-core.h"
#include "module-dbus-protocol-symdef.h"
@@ -117,10 +118,36 @@ static void client_kill_cb(pa_client *c) {
conn = c->userdata;
connection_free(conn);
+ c->userdata = NULL;
pa_log_info("Connection killed.");
}
+/* Called from pa_client_send_event(). */
+static void client_send_event_cb(pa_client *c, const char *name, pa_proplist *data) {
+ struct connection *conn = NULL;
+ DBusMessage *signal = NULL;
+ DBusMessageIter msg_iter;
+
+ pa_assert(c);
+ pa_assert(name);
+ pa_assert(data);
+ pa_assert(c->userdata);
+
+ conn = c->userdata;
+
+ pa_assert_se(signal = dbus_message_new_signal(pa_dbusiface_core_get_client_path(conn->server->userdata->core_iface, c),
+ PA_DBUSIFACE_CLIENT_INTERFACE,
+ "ClientEvent"));
+ dbus_message_iter_init_append(signal, &msg_iter);
+ pa_assert_se(dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_STRING, &name));
+ pa_dbus_append_proplist(&msg_iter, data);
+
+ pa_assert_se(dbus_connection_send(pa_dbus_wrap_connection_get(conn->wrap_conn), signal, NULL));
+ dbus_message_unref(signal);
+}
+
+/* Called by D-Bus at the authentication phase. */
static dbus_bool_t user_check_cb(DBusConnection *connection, unsigned long uid, void *data) {
pa_log_debug("Allowing connection by user %lu.", uid);
@@ -140,7 +167,7 @@ static void connection_new_cb(DBusServer *dbus_server, DBusConnection *new_conne
pa_client_new_data_init(&new_data);
new_data.module = s->userdata->module;
new_data.driver = __FILE__;
- pa_proplist_sets(new_data.proplist, PA_PROP_APPLICATION_NAME, "D-Bus client"); /* TODO: It's probably possible to generate a fancier name. Other props? */
+ pa_proplist_sets(new_data.proplist, PA_PROP_APPLICATION_NAME, "D-Bus client");
client = pa_client_new(s->userdata->module->core, &new_data);
pa_client_new_data_done(&new_data);
@@ -162,7 +189,7 @@ static void connection_new_cb(DBusServer *dbus_server, DBusConnection *new_conne
c->client = client;
c->client->kill = client_kill_cb;
- c->client->send_event = NULL; /* TODO: Implement this. */
+ c->client->send_event = client_send_event_cb;
c->client->userdata = c;
pa_idxset_put(s->userdata->connections, c, NULL);