Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Secret.xml | 6 ++++++
src/secret.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/data/org.libvirt.Secret.xml b/data/org.libvirt.Secret.xml
index 509c46a..563167b 100644
--- a/data/org.libvirt.Secret.xml
+++ b/data/org.libvirt.Secret.xml
@@ -18,6 +18,12 @@
value="See
https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUsageTyp...
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal"
value="const"/>
</property>
+ <method name="GetValue">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetValue&qu...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="value" type="ay" direction="out"/>
+ </method>
<method name="GetXMLDesc">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetXMLDesc&...
diff --git a/src/secret.c b/src/secret.c
index ecbd809..653dc5c 100644
--- a/src/secret.c
+++ b/src/secret.c
@@ -86,6 +86,42 @@ virtDBusSecretGetUsageType(const gchar *objectPath,
*value = g_variant_new("u", usageType);
}
+static void
+virtDBusSecretGetValue(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virSecret) secret = NULL;
+ g_autofree guchar *value = NULL;
+ gsize size;
+ guint flags;
+ GVariantBuilder builder;
+ GVariant *res;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ secret = virtDBusSecretGetVirSecret(connect, objectPath, error);
+ if (!secret)
+ return;
+
+ value = virSecretGetValue(secret, &size, flags);
+ if (!value)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("ay"));
+ for (unsigned int i = 0; i < size; i++)
+ g_variant_builder_add(&builder, "y", value[i]);
+
+ res = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&res, 1);
+}
+
static void
virtDBusSecretGetXMLDesc(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -143,6 +179,7 @@ static virtDBusGDBusPropertyTable virtDBusSecretPropertyTable[] = {
static virtDBusGDBusMethodTable virtDBusSecretMethodTable[] = {
{ "GetXMLDesc", virtDBusSecretGetXMLDesc },
{ "Undefine", virtDBusSecretUndefine },
+ { "GetValue", virtDBusSecretGetValue },
{ 0 }
};
--
2.15.0