GDBus: In gdbus(1), try Get() if GetAll() fails
authorDavid Zeuthen <davidz@redhat.com>
Mon, 10 May 2010 20:20:59 +0000 (16:20 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Mon, 10 May 2010 20:20:59 +0000 (16:20 -0400)
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

index ddec985175ddddf4a2bbab73ca71ecc1ac3b2524..ce5e5dba1529b52c2a03854910557026c905b9e1 100644 (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);