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);
  };
};
This commit is contained in:
David Zeuthen 2010-05-10 16:20:59 -04:00
parent 6e23b0b785
commit 2d208c9d36

View File

@ -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);