summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-01-15 18:38:58 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-01-15 18:38:58 +0000
commit467f83c3ac4e4afba959e8cfd8aadb0f1614c9fb (patch)
tree0a783f172e5ba87596094dc857f8c5cb63a1b37f /common
parente1a0779f9e09f4620fdbb977f9e0a67caafdc5f3 (diff)
Preliminary support for catching the unique bus name of an execed service
Diffstat (limited to 'common')
-rw-r--r--common/dbus.c45
-rw-r--r--common/dbus.h3
2 files changed, 48 insertions, 0 deletions
diff --git a/common/dbus.c b/common/dbus.c
index 3b0c1097..070535d7 100644
--- a/common/dbus.c
+++ b/common/dbus.c
@@ -308,6 +308,51 @@ int name_listener_remove(DBusConnection *connection, const char *name,
return 0;
}
+dbus_bool_t dbus_bus_get_unix_process_id(DBusConnection *conn, const char *name,
+ unsigned long *pid)
+{
+ DBusMessage *msg, *reply;
+ dbus_uint32_t pid_arg;
+
+ msg = dbus_message_new_method_call("org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixProcessID");
+ if (!msg) {
+ error("Unable to allocate new message");
+ return FALSE;
+ }
+
+ if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID)) {
+ error("Unable to append arguments to message");
+ dbus_message_unref(msg);
+ return FALSE;
+ }
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL);
+ if (!reply) {
+ error("Sending GetConnectionUnixProcessID failed");
+ dbus_message_unref(msg);
+ return FALSE;
+ }
+
+ if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &pid_arg,
+ DBUS_TYPE_INVALID)) {
+ error("Getting GetConnectionUnixProcessID args failed");
+ dbus_message_unref(msg);
+ dbus_message_unref(reply);
+ return FALSE;
+ }
+
+ *pid = (unsigned long) pid_arg;
+
+ dbus_message_unref(msg);
+ dbus_message_unref(reply);
+
+ return TRUE;
+}
+
static DBusHandlerResult disconnect_filter(DBusConnection *conn,
DBusMessage *msg, void *data)
{
diff --git a/common/dbus.h b/common/dbus.h
index 393ebcf9..51049391 100644
--- a/common/dbus.h
+++ b/common/dbus.h
@@ -35,6 +35,9 @@ int name_listener_add(DBusConnection *connection, const char *name,
int name_listener_remove(DBusConnection *connection, const char *name,
name_cb_t func, void *user_data);
+dbus_bool_t dbus_bus_get_unix_process_id(DBusConnection *conn, const char *name,
+ unsigned long *pid);
+
DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void *data);
static inline DBusHandlerResult send_message_and_unref(DBusConnection *conn, DBusMessage *msg)