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

[libvirt] [libvirt-gconfig PATCHv2 07/32] Add some GVirConfigClock setters



--
v2: use g_return_if_fail to test function args for sanity
---
 libvirt-gconfig/libvirt-gconfig-clock.c |   38 +++++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-clock.h |    5 ++++
 libvirt-gconfig/libvirt-gconfig.sym     |    2 +
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c
index 1f28efb..25f6159 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-object-private.h"
 
 extern gboolean debugFlag;
 
@@ -79,3 +80,40 @@ GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml,
                                              "clock", NULL, xml, error);
     return GVIR_CONFIG_CLOCK(object);
 }
+
+void gvir_config_clock_set_timezone(GVirConfigClock *klock,
+                                    const char *tz)
+{
+    xmlNodePtr node;
+    xmlChar *encoded_tz;
+
+    g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock));
+    g_return_if_fail(tz != NULL);
+
+    node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock));
+    if (node == NULL)
+        return;
+
+    xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)"timezone");
+    encoded_tz = xmlEncodeEntitiesReentrant(node->doc, (xmlChar*)tz);
+    xmlNewProp(node, (xmlChar*)"timezone", encoded_tz);
+    xmlFree(encoded_tz);
+}
+
+void gvir_config_clock_set_variable_offset(GVirConfigClock *klock,
+                                           gint seconds)
+{
+    xmlNodePtr node;
+    char *offset_str;
+
+    g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock));
+
+    node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(klock), "clock");
+    if (node == NULL)
+        return;
+
+    xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)"variable");
+    offset_str = g_strdup_printf("%d", seconds);
+    xmlNewProp(node, (xmlChar*)"timezone", (xmlChar*)offset_str);
+    g_free(offset_str);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-clock.h b/libvirt-gconfig/libvirt-gconfig-clock.h
index fc8850a..26f4b53 100644
--- a/libvirt-gconfig/libvirt-gconfig-clock.h
+++ b/libvirt-gconfig/libvirt-gconfig-clock.h
@@ -63,6 +63,11 @@ GVirConfigClock *gvir_config_clock_new(void);
 GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml,
                                                 GError **error);
 
+void gvir_config_clock_set_timezone(GVirConfigClock *klock,
+                                    const char *tz);
+void gvir_config_clock_set_variable_offset(GVirConfigClock *klock,
+                                           gint seconds);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GCONFIG_CLOCK_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index a01c22d..c3d46d5 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -7,6 +7,8 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_clock_get_type;
 	gvir_config_clock_new;
 	gvir_config_clock_new_from_xml;
+	gvir_config_clock_set_timezone;
+	gvir_config_clock_set_variable_offset;
 
 	gvir_config_domain_get_type;
 	gvir_config_domain_new;
-- 
1.7.7.3


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