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

[virt-tools-list] [virt-viewer 06/20] Add methods to handle actions to OvirtVm



---
 src/ovirt-vm.c |   19 +++++++++++++++++++
 src/ovirt-vm.h |    2 ++
 2 files changed, 21 insertions(+)

diff --git a/src/ovirt-vm.c b/src/ovirt-vm.c
index 516593b..800388c 100644
--- a/src/ovirt-vm.c
+++ b/src/ovirt-vm.c
@@ -198,3 +198,22 @@ OvirtVm *ovirt_vm_new(void)
 {
     return OVIRT_VM(g_object_new(OVIRT_TYPE_VM, NULL));
 }
+
+void ovirt_vm_add_action(OvirtVm *vm, const char *action, const char *url)
+{
+    g_return_if_fail(OVIRT_IS_VM(vm));
+
+    if (vm->priv->actions == NULL) {
+        vm->priv->actions = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                                  g_free, g_free);
+    }
+    g_hash_table_insert(vm->priv->actions, g_strdup(action), g_strdup(url));
+}
+
+const char *ovirt_vm_get_action(OvirtVm *vm, const char *action)
+{
+    g_return_val_if_fail(OVIRT_IS_VM(vm), NULL);
+    g_return_val_if_fail(vm->priv->actions != NULL, NULL);
+
+    return g_hash_table_lookup(vm->priv->actions, action);
+}
diff --git a/src/ovirt-vm.h b/src/ovirt-vm.h
index 7e03853..889e84d 100644
--- a/src/ovirt-vm.h
+++ b/src/ovirt-vm.h
@@ -61,6 +61,8 @@ typedef enum {
 
 GType ovirt_vm_get_type(void);
 OvirtVm *ovirt_vm_new(void);
+void ovirt_vm_add_action(OvirtVm *vm, const char *action, const char *url);
+const char *ovirt_vm_get_action(OvirtVm *vm, const char *action);
 
 G_END_DECLS
 
-- 
1.7.10.2


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