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

[libvirt] [libvirt-glib 10/13] Simplify GVirConfigDomainGraphicsSpice creation



Now that we have gvir_config_object_set_attribute, we can use
the gvir_config_object_new{_from_xml} helpers.
---
 .../libvirt-gconfig-domain-graphics-spice.c        |   34 +++++++++-----------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
index a5d0775..bea85e7 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
@@ -61,30 +61,26 @@ static void gvir_config_domain_graphics_spice_init(GVirConfigDomainGraphicsSpice
 
 GVirConfigDomainGraphicsSpice *gvir_config_domain_graphics_spice_new(void)
 {
-    xmlDocPtr doc;
-    xmlNodePtr node;
-
-    doc = xmlNewDoc((xmlChar *)"1.0");
-    node= xmlNewDocNode(doc, NULL, (xmlChar *)"graphics", NULL);
-    xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"spice");
-    xmlDocSetRootElement(doc, node);
-    return GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE(g_object_new(GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SPICE,
-                                             "node", node,
-                                             NULL));
+    GVirConfigObject *object;
+
+    object = gvir_config_object_new(GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SPICE,
+                                    "graphics", NULL);
+    gvir_config_object_set_attribute(object, "type", "spice", NULL);
+    return GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE(object);
 }
 
-GVirConfigDomainGraphicsSpice *gvir_config_domain_graphics_spice_new_from_xml(const gchar *xml,
-                                                                 GError **error)
+GVirConfigDomainGraphicsSpice *
+gvir_config_domain_graphics_spice_new_from_xml(const gchar *xml,
+                                               GError **error)
 {
-    xmlNodePtr node;
+    GVirConfigObject *object;
 
-    node = gvir_config_xml_parse(xml, "graphics", error);
-    if ((error != NULL) && (*error != NULL))
+    object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SPICE,
+                                             "graphics", NULL, xml, error);
+    if (object == NULL)
         return NULL;
-    xmlNewProp(node, (xmlChar*)"type", (xmlChar*)"spice");
-    return GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE(g_object_new(GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SPICE,
-                                                          "node", node,
-                                                          NULL));
+    gvir_config_object_set_attribute(object, "type", "spice", NULL);
+    return GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE(object);
 }
 
 void gvir_config_domain_graphics_spice_set_port(GVirConfigDomainGraphicsSpice *graphics,
-- 
1.7.7.3


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