[dbus PATCH 12/13] Implement SetValue method for Secret Interface

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

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Secret.xml |  6 ++++++
 src/secret.c                | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/data/org.libvirt.Secret.xml b/data/org.libvirt.Secret.xml
index 563167b..3a5d742 100644
--- a/data/org.libvirt.Secret.xml
+++ b/data/org.libvirt.Secret.xml
@@ -30,6 +30,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="xml" type="s" direction="out"/>
     </method>
+    <method name="SetValue">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretSetValue"/>
+      <arg name="value" type="ay" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+    </method>
     <method name="Undefine">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretUndefine"/>
diff --git a/src/secret.c b/src/secret.c
index 653dc5c..028a7b4 100644
--- a/src/secret.c
+++ b/src/secret.c
@@ -149,6 +149,39 @@ virtDBusSecretGetXMLDesc(GVariant *inArgs,
     *outArgs = g_variant_new("(s)", xml);
 }
 
+static void
+virtDBusSecretSetValue(GVariant *inArgs,
+                       GUnixFDList *inFDs G_GNUC_UNUSED,
+                       const gchar *objectPath,
+                       gpointer userData,
+                       GVariant **outArgs G_GNUC_UNUSED,
+                       GUnixFDList **outFDs G_GNUC_UNUSED,
+                       GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virSecret) secret = NULL;
+    g_autoptr(GVariantIter) iter = NULL;
+    guint flags;
+    g_autofree guchar *value = NULL;
+    guchar *tmp;
+    gsize size;
+
+    g_variant_get(inArgs, "(ayu)", &iter, &flags);
+
+    secret = virtDBusSecretGetVirSecret(connect, objectPath, error);
+    if (!secret)
+        return;
+
+    size = g_variant_iter_n_children(iter);
+    value = g_new0(guchar, size);
+    tmp = value;
+    while (g_variant_iter_next(iter, "y", tmp))
+        tmp++;
+
+    if (virSecretSetValue(secret, value, size, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusSecretUndefine(GVariant *inArgs G_GNUC_UNUSED,
                        GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -180,6 +213,7 @@ static virtDBusGDBusMethodTable virtDBusSecretMethodTable[] = {
     { "GetXMLDesc", virtDBusSecretGetXMLDesc },
     { "Undefine", virtDBusSecretUndefine },
     { "GetValue", virtDBusSecretGetValue },
+    { "SetValue", virtDBusSecretSetValue },
     { 0 }
 };
 
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux