[libvirt-gconfig PATCHv2 11/32] Implement gvir_config_clock_set_offset

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

 



--
v2: use gvir_config_genum_get_nick helper since it's now added before
this commit
    use g_return_if_fail to test function args for sanity
---
 libvirt-gconfig/libvirt-gconfig-clock.c |   17 +++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-clock.h |    8 ++++++++
 libvirt-gconfig/libvirt-gconfig.sym     |    2 ++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c
index 25f6159..0768e58 100644
--- a/libvirt-gconfig/libvirt-gconfig-clock.c
+++ b/libvirt-gconfig/libvirt-gconfig-clock.c
@@ -27,6 +27,7 @@
 #include <libxml/tree.h>
 
 #include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
 #include "libvirt-gconfig/libvirt-gconfig-object-private.h"
 
 extern gboolean debugFlag;
@@ -81,6 +82,22 @@ GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml,
     return GVIR_CONFIG_CLOCK(object);
 }
 
+void gvir_config_clock_set_offset(GVirConfigClock *klock,
+                                  GVirConfigClockOffset offset)
+{
+    xmlNodePtr node;
+    const char *offset_str;
+
+    g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock));
+
+    node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock));
+    g_return_if_fail(node != NULL);
+    offset_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_CLOCK_OFFSET,
+                                             offset);
+    g_return_if_fail(offset_str != NULL);
+    xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)offset_str);
+}
+
 void gvir_config_clock_set_timezone(GVirConfigClock *klock,
                                     const char *tz)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-clock.h b/libvirt-gconfig/libvirt-gconfig-clock.h
index 26f4b53..49cacef 100644
--- a/libvirt-gconfig/libvirt-gconfig-clock.h
+++ b/libvirt-gconfig/libvirt-gconfig-clock.h
@@ -56,6 +56,12 @@ struct _GVirConfigClockClass
     gpointer padding[20];
 };
 
+typedef enum {
+    GVIR_CONFIG_CLOCK_UTC,
+    GVIR_CONFIG_CLOCK_LOCALTIME,
+    GVIR_CONFIG_CLOCK_TIMEZONE,
+    GVIR_CONFIG_CLOCK_VARIABLE
+} GVirConfigClockOffset;
 
 GType gvir_config_clock_get_type(void);
 
@@ -63,6 +69,8 @@ GVirConfigClock *gvir_config_clock_new(void);
 GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml,
                                                 GError **error);
 
+void gvir_config_clock_set_offset(GVirConfigClock *klock,
+                                  GVirConfigClockOffset offset);
 void gvir_config_clock_set_timezone(GVirConfigClock *klock,
                                     const char *tz);
 void gvir_config_clock_set_variable_offset(GVirConfigClock *klock,
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 7b346a1..0b60c7c 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -5,8 +5,10 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_capabilities_new_from_xml;
 
 	gvir_config_clock_get_type;
+	gvir_config_clock_offset_get_type;
 	gvir_config_clock_new;
 	gvir_config_clock_new_from_xml;
+	gvir_config_clock_set_offset;
 	gvir_config_clock_set_timezone;
 	gvir_config_clock_set_variable_offset;
 
-- 
1.7.7.3

--
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]