From bb38909330e64c1774b1ba3afda2b6c323ce04df Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sat, 15 Sep 2012 07:02:24 +0300 Subject: [PATCH] D-Bus proxy for the jackdbus GetClientOriginalName method --- proxies/graph_proxy.c | 40 +++++++++++++++++++++++++++++++++++++++- proxies/graph_proxy.h | 3 ++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/proxies/graph_proxy.c b/proxies/graph_proxy.c index 92d55807..80b8c40a 100644 --- a/proxies/graph_proxy.c +++ b/proxies/graph_proxy.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009,2010,2011 Nedko Arnaudov + * Copyright (C) 2009,2010,2011,2012 Nedko Arnaudov * ************************************************************************** * This file contains implementation graph object that is backed through D-Bus @@ -975,6 +975,44 @@ bool graph_proxy_get_client_pid(graph_proxy_handle graph, uint64_t client_id, pi return true; } +bool graph_proxy_get_client_original_name(graph_proxy_handle graph, uint64_t client_id, char ** name) +{ + DBusMessage * reply_ptr; + const char * reply_signature; + DBusMessageIter iter; + const char * cvalue_ptr; + char * value_ptr; + + if (!cdbus_call(0, graph_ptr->service, graph_ptr->object, JACKDBUS_IFACE_PATCHBAY, "GetClientOriginalName", "t", &client_id, NULL, &reply_ptr)) + { + log_error("GetClientPID() failed."); + return false; + } + + reply_signature = dbus_message_get_signature(reply_ptr); + + if (strcmp(reply_signature, "s") != 0) + { + log_error("reply signature is '%s' but expected signature is 's'", reply_signature); + dbus_message_unref(reply_ptr); + return false; + } + + dbus_message_iter_init(reply_ptr, &iter); + dbus_message_iter_get_basic(&iter, &cvalue_ptr); + value_ptr = strdup(cvalue_ptr); + dbus_message_unref(reply_ptr); + if (value_ptr == NULL) + { + log_error("strdup() failed for dict value"); + return false; + } + + *name = value_ptr; + + return true; +} + bool graph_proxy_split( graph_proxy_handle graph, diff --git a/proxies/graph_proxy.h b/proxies/graph_proxy.h index 57729cd7..ba6918fb 100644 --- a/proxies/graph_proxy.h +++ b/proxies/graph_proxy.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009,2010,2011 Nedko Arnaudov + * Copyright (C) 2009,2010,2011,2012 Nedko Arnaudov * ************************************************************************** * This file contains interface to graph object that is backed through D-Bus @@ -112,6 +112,7 @@ graph_proxy_dict_entry_drop( const char * key); bool graph_proxy_get_client_pid(graph_proxy_handle graph, uint64_t client_id, pid_t * pid_ptr); +bool graph_proxy_get_client_original_name(graph_proxy_handle graph, uint64_t client_id, char ** name); bool graph_proxy_split(