[libgovirt] Add ovirt_cdrom_update_async()



commit 597d98d50b8f83c004aafce0f8d61f9122fa1688
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed Sep 11 14:24:02 2013 +0200

    Add ovirt_cdrom_update_async()
    
    This is very similar to ovirt_resource_update_async() except
    that the user needs to be able to pass an additional parameter
    depending on the VM state.

 govirt/govirt.sym    |    2 ++
 govirt/ovirt-cdrom.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 govirt/ovirt-cdrom.h |   10 ++++++++++
 3 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
index e3dd5b9..a61e72c 100644
--- a/govirt/govirt.sym
+++ b/govirt/govirt.sym
@@ -57,6 +57,8 @@ GOVIRT_0.2.1 {
 
         ovirt_cdrom_get_type;
         ovirt_cdrom_update;
+        ovirt_cdrom_update_async;
+        ovirt_cdrom_update_finish;
 
         ovirt_collection_fetch;
         ovirt_collection_fetch_async;
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
index 91de068..9d2790f 100644
--- a/govirt/ovirt-cdrom.c
+++ b/govirt/ovirt-cdrom.c
@@ -23,6 +23,7 @@
 #include <config.h>
 #include "ovirt-cdrom.h"
 #include "ovirt-proxy.h"
+#include "ovirt-proxy-private.h"
 #include "ovirt-resource-private.h"
 #include "ovirt-resource-rest-call.h"
 
@@ -203,3 +204,46 @@ gboolean ovirt_cdrom_update(OvirtCdrom *cdrom,
 
     return success;
 }
+
+
+void ovirt_cdrom_update_async(OvirtCdrom *cdrom,
+                              gboolean current,
+                              OvirtProxy *proxy,
+                              GCancellable *cancellable,
+                              GAsyncReadyCallback callback,
+                              gpointer user_data)
+{
+
+    GSimpleAsyncResult *result;
+    OvirtResourceRestCall *call;
+
+    g_return_if_fail(OVIRT_IS_CDROM(cdrom));
+    g_return_if_fail(OVIRT_IS_PROXY(proxy));
+    g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
+
+    result = g_simple_async_result_new(G_OBJECT(cdrom), callback,
+                                       user_data,
+                                       ovirt_cdrom_update_async);
+
+    call = ovirt_resource_rest_call_new(REST_PROXY(proxy), OVIRT_RESOURCE(cdrom));
+    rest_proxy_call_set_method(REST_PROXY_CALL(call), "PUT");
+    if (current) {
+        rest_proxy_call_add_param(REST_PROXY_CALL(call), "current", NULL);
+    }
+    ovirt_rest_call_async(OVIRT_REST_CALL(call), result, cancellable,
+                          NULL, NULL, NULL);
+}
+
+
+gboolean ovirt_cdrom_update_finish(OvirtCdrom *cdrom,
+                                   GAsyncResult *result,
+                                   GError **err)
+{
+    g_return_val_if_fail(OVIRT_IS_CDROM(cdrom), FALSE);
+    g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(cdrom),
+                                                        ovirt_cdrom_update_async),
+                         FALSE);
+    g_return_val_if_fail((err == NULL) || (*err == NULL), FALSE);
+
+    return ovirt_rest_call_finish(result, err);
+}
diff --git a/govirt/ovirt-cdrom.h b/govirt/ovirt-cdrom.h
index 606744f..a268d01 100644
--- a/govirt/ovirt-cdrom.h
+++ b/govirt/ovirt-cdrom.h
@@ -61,6 +61,16 @@ GType ovirt_cdrom_get_type(void);
 gboolean ovirt_cdrom_update(OvirtCdrom *cdrom, gboolean current,
                             OvirtProxy *proxy, GError **error);
 
+void ovirt_cdrom_update_async(OvirtCdrom *cdrom,
+                              gboolean current,
+                              OvirtProxy *proxy,
+                              GCancellable *cancellable,
+                                  GAsyncReadyCallback callback,
+                                  gpointer user_data);
+gboolean ovirt_cdrom_update_finish(OvirtCdrom *cdrom,
+                                   GAsyncResult *result,
+                                   GError **err);
+
 G_END_DECLS
 
 #endif /* __OVIRT_CDROM_H__ */


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