[glib/gdbus-merge] GDBus: In gdbus(1), try Get() if GetAll() fails



commit 2d208c9d364369d68a54cfd0682e17f2ce771db5
Author: David Zeuthen <davidz redhat com>
Date:   Mon May 10 16:20:59 2010 -0400

    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 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c
index ddec985..ce5e5db 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]