From 2d208c9d364369d68a54cfd0682e17f2ce771db5 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Mon, 10 May 2010 16:20:59 -0400 Subject: [PATCH] GDBus: In gdbus(1), try Get() if GetAll() fails This fixes a problem with services that doesn't implement GetAll() for one reason or another. $ gdbus introspect --session --dest org.freedesktop.ReserveDevice1.Audio0 --object-path /org/freedesktop/ReserveDevice1/Audio0 node /org/freedesktop/ReserveDevice1/Audio0 { interface org.freedesktop.ReserveDevice1 { methods: RequestRelease(in i priority, out b result); properties: readonly i Priority = 0; readonly s ApplicationName = 'PulseAudio Sound Server'; readonly s ApplicationDeviceName = 'Internal Audio Analog Stereo'; }; interface org.freedesktop.DBus.Properties { methods: Get(in s interface, in s property, out v value); }; interface org.freedesktop.DBus.Introspectable { methods: Introspect(out s data); }; }; --- gio/gdbus-tool.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index ddec98517..ce5e5dba1 100644 --- a/gio/gdbus-tool.c +++ b/gio/gdbus-tool.c @@ -1044,6 +1044,34 @@ dump_interface (GDBusConnection *c, } g_variant_unref (result); } + else + { + guint n; + for (n = 0; o->properties != NULL && o->properties[n] != NULL; n++) + { + result = g_dbus_connection_call_sync (c, + name, + object_path, + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new ("(ss)", o->name, o->properties[n]->name), + G_DBUS_CALL_FLAGS_NONE, + 3000, + NULL, + NULL); + if (result != NULL) + { + GVariant *property_value; + g_variant_get (result, + "(v)", + &property_value); + g_hash_table_insert (properties, + g_strdup (o->properties[n]->name), + g_variant_ref (property_value)); + g_variant_unref (result); + } + } + } } g_print ("%*sinterface %s {\n", indent, "", o->name);