[libgovirt] Implement ovirt_resource_update_async()



commit 8e0cb5f3634430d4675e41daabf319a403a82ec2
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Thu Sep 5 19:11:13 2013 +0200

    Implement ovirt_resource_update_async()

 govirt/govirt.sym       |    2 +
 govirt/ovirt-resource.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++
 govirt/ovirt-resource.h |    8 ++++++
 3 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
index 536494e..e3dd5b9 100644
--- a/govirt/govirt.sym
+++ b/govirt/govirt.sym
@@ -68,6 +68,8 @@ GOVIRT_0.2.1 {
         ovirt_proxy_fetch_api_finish;
 
         ovirt_resource_update;
+        ovirt_resource_update_async;
+        ovirt_resource_update_finish;
 
         ovirt_storage_domain_get_type;
         ovirt_storage_domain_state_get_type;
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index d28df6c..e0fa108 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -28,6 +28,7 @@
 
 #include "govirt-private.h"
 #include "ovirt-error.h"
+#include "ovirt-proxy-private.h"
 #include "ovirt-resource.h"
 
 #define OVIRT_RESOURCE_GET_PRIVATE(obj)                         \
@@ -530,3 +531,57 @@ gboolean ovirt_resource_update(OvirtResource *resource,
 
     return call_successful;
 }
+
+static gboolean ovirt_resource_update_async_cb(OvirtProxy *proxy, RestProxyCall *call,
+                                               gpointer user_data, GError **error)
+{
+    g_return_val_if_fail(REST_IS_PROXY_CALL(call), FALSE);
+    g_warning("foo");
+
+    /* if error */
+#if 0
+    root = ovirt_rest_xml_node_from_call(call);
+    parse_action_response(call, data->vm, data->parser, &action_error);
+    rest_xml_node_unref(root);
+#endif
+
+    return TRUE;
+}
+
+
+void ovirt_resource_update_async(OvirtResource *resource,
+                                 OvirtProxy *proxy,
+                                 GCancellable *cancellable,
+                                 GAsyncReadyCallback callback,
+                                 gpointer user_data)
+{
+    GSimpleAsyncResult *result;
+    OvirtResourceRestCall *call;
+
+    g_return_if_fail(OVIRT_IS_RESOURCE(resource));
+    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(resource), callback,
+                                       user_data,
+                                       ovirt_resource_update_async);
+
+    call = ovirt_resource_rest_call_new(REST_PROXY(proxy), resource);
+    rest_proxy_call_set_method(REST_PROXY_CALL(call), "PUT");
+    ovirt_rest_call_async(OVIRT_REST_CALL(call), result, cancellable,
+                          ovirt_resource_update_async_cb, NULL, NULL);
+}
+
+
+gboolean ovirt_resource_update_finish(OvirtResource *resource,
+                                      GAsyncResult *result,
+                                      GError **err)
+{
+    g_return_val_if_fail(OVIRT_IS_RESOURCE(resource), FALSE);
+    g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(resource),
+                                                        ovirt_resource_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-resource.h b/govirt/ovirt-resource.h
index 20795fe..805d53e 100644
--- a/govirt/ovirt-resource.h
+++ b/govirt/ovirt-resource.h
@@ -69,6 +69,14 @@ const char *ovirt_resource_get_sub_collection(OvirtResource *resource,
 gboolean ovirt_resource_update(OvirtResource *resource,
                                OvirtProxy *proxy,
                                GError **error);
+void ovirt_resource_update_async(OvirtResource *resource,
+                                 OvirtProxy *proxy,
+                                 GCancellable *cancellable,
+                                 GAsyncReadyCallback callback,
+                                 gpointer user_data);
+gboolean ovirt_resource_update_finish(OvirtResource *resource,
+                                      GAsyncResult *result,
+                                      GError **err);
 
 G_END_DECLS
 


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