Signed-off-by: Katerina Koukiou <kkouk...@redhat.com> --- data/org.libvirt.Secret.xml | 5 +++++ src/secret.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
diff --git a/data/org.libvirt.Secret.xml b/data/org.libvirt.Secret.xml index 1cc1e31..8ee6f0c 100644 --- a/data/org.libvirt.Secret.xml +++ b/data/org.libvirt.Secret.xml @@ -3,5 +3,10 @@ <node name="/org/libvirt/secret"> <interface name="org.libvirt.Secret"> + <property name="UUID" type="s" access="read"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUUIDString"/> + <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/> + </property> </interface> </node> diff --git a/src/secret.c b/src/secret.c index c7cbb02..1780d96 100644 --- a/src/secret.c +++ b/src/secret.c @@ -3,7 +3,49 @@ #include <libvirt/libvirt.h> +static virSecretPtr +virtDBusSecretGetVirSecret(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virSecretPtr secret; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + secret = virtDBusUtilVirSecretFromBusPath(connect->connection, + objectPath, + connect->secretPath); + if (!secret) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return secret; +} + +static void +virtDBusSecretGetUUID(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virSecret) secret = NULL; + gchar uuid[VIR_UUID_STRING_BUFLEN] = ""; + + secret = virtDBusSecretGetVirSecret(connect, objectPath, error); + if (!secret) + return; + + if (virSecretGetUUIDString(secret, uuid) < 0) + return virtDBusUtilSetLastVirtError(error); + + *value = g_variant_new("s", uuid); +} + static virtDBusGDBusPropertyTable virtDBusSecretPropertyTable[] = { + { "UUID", virtDBusSecretGetUUID, NULL }, { 0 } }; -- 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list