[virt-tools-list] [libosinfo 7/8] rfc: Infer ISO language from label

Daniel P. Berrange berrange at redhat.com
Tue Dec 4 11:01:24 UTC 2012


On Tue, Dec 04, 2012 at 11:47:06AM +0100, Christophe Fergeau wrote:
> On Mon, Dec 03, 2012 at 06:30:18PM +0200, Zeeshan Ali (Khattak) wrote:
> > I agree with you that it would be nice to avoid this mapping all
> > together but if its not possible/feasible, these mappings should be in
> > the XML like rest of OS specific stuff.
> 
> I could do that, but the C code would still have to match the regex with
> data from the table, which is only useful to Windows anyway, so the C code
> would still be somehow Windows specific.

Looking at the problem more broadly, I believe we have a general need
to have OS specific data maps for several installation aspects. In the
OsinfoInstallConfig class we have setters for the keyboard layout,
language, and timezone. The values required for each of these setters
is really OS-specific. To properly isolate apps from this, we need to
have a data map concept, so libosinfo defines a canonical set of keyboard,
language and timezone values, and then maps to the OS-specific values
internally.

This ISO language extraction is just another example of the need for
a general datamap capability IMHO, and while we only see it for Windows
currently, I would not be suprised if other OS we encounter in the future
need it too.

I did actually start hacking up datamap support, but never finished it.


Daniel

>From 6fc4ae75a51b9d26ae018795e151c18b992b77e6 Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange at redhat.com>
Date: Mon, 12 Mar 2012 19:15:23 +0000
Subject: [PATCH] Add install datamap class

---
 osinfo/Makefile.am                  |   4 +
 osinfo/libosinfo.syms               |  10 +++
 osinfo/osinfo.h                     |   2 +
 osinfo/osinfo_db.c                  |  48 ++++++++++
 osinfo/osinfo_db.h                  |   3 +
 osinfo/osinfo_install_datamap.c     | 149 +++++++++++++++++++++++++++++++
 osinfo/osinfo_install_datamap.h     |  81 +++++++++++++++++
 osinfo/osinfo_install_datamaplist.c | 169 ++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_install_datamaplist.h |  82 +++++++++++++++++
 9 files changed, 548 insertions(+)
 create mode 100644 osinfo/osinfo_install_datamap.c
 create mode 100644 osinfo/osinfo_install_datamap.h
 create mode 100644 osinfo/osinfo_install_datamaplist.c
 create mode 100644 osinfo/osinfo_install_datamaplist.h

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index f4aea47..ccedaba 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -59,6 +59,8 @@ libosinfo_1_0_include_HEADERS = \
   osinfo_entity.h		\
   osinfo_filter.h		\
   osinfo_install_config.h       \
+  osinfo_install_datamap.h      \
+  osinfo_install_datamaplist.h  \
   osinfo_install_script.h       \
   osinfo_install_scriptlist.h   \
   osinfo_product.h		\
@@ -89,6 +91,8 @@ libosinfo_1_0_la_SOURCES =	\
   osinfo_devicelinklist.c	\
   osinfo_devicelinkfilter.c	\
   osinfo_install_config.c       \
+  osinfo_install_datamap.c      \
+  osinfo_install_datamaplist.c  \
   osinfo_install_script.c       \
   osinfo_install_scriptlist.c   \
   osinfo_product.c		\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 2f90183..82158f8 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -264,6 +264,16 @@ LIBOSINFO_0.2.0 {
 	osinfo_install_config_set_user_administrator;
 	osinfo_install_config_set_user_autologin;
 	osinfo_install_config_set_hostname;
+	osinfo_install_datamap_get_type;
+	osinfo_install_datamap_new;
+	osinfo_install_datamap_insert;
+	osinfo_install_datamap_lookup;
+	osinfo_install_datamaplist_new;
+	osinfo_install_datamaplist_new_filtered;
+	osinfo_install_datamaplist_new_union;
+	osinfo_install_datamaplist_new_intersection;
+	osinfo_install_datamaplist_new_copy;
+	osinfo_install_datamaplist_get_type;
 	osinfo_install_script_get_type;
 	osinfo_install_script_new;
 	osinfo_install_script_new_data;
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index aa06095..6e56558 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -34,6 +34,8 @@
 #include <osinfo/osinfo_devicelinklist.h>
 #include <osinfo/osinfo_devicelinkfilter.h>
 #include <osinfo/osinfo_install_config.h>
+#include <osinfo/osinfo_install_datamap.h>
+#include <osinfo/osinfo_install_datamaplist.h>
 #include <osinfo/osinfo_install_script.h>
 #include <osinfo/osinfo_install_scriptlist.h>
 #include <osinfo/osinfo_productlist.h>
diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 6ae8a82..606f4bf 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -52,6 +52,7 @@ struct _OsinfoDbPrivate
     OsinfoPlatformList *platforms;
     OsinfoOsList *oses;
     OsinfoDeploymentList *deployments;
+    OsinfoInstallDatamapList *datamaps;
     OsinfoInstallScriptList *scripts;
 };
 
@@ -66,6 +67,7 @@ osinfo_db_finalize (GObject *object)
     g_object_unref(db->priv->platforms);
     g_object_unref(db->priv->oses);
     g_object_unref(db->priv->deployments);
+    g_object_unref(db->priv->datamaps);
     g_object_unref(db->priv->scripts);
 
     /* Chain up to the parent class */
@@ -95,6 +97,7 @@ osinfo_db_init (OsinfoDb *db)
     db->priv->platforms = osinfo_platformlist_new();
     db->priv->oses = osinfo_oslist_new();
     db->priv->deployments = osinfo_deploymentlist_new();
+    db->priv->datamaps = osinfo_install_datamaplist_new();
     db->priv->scripts = osinfo_install_scriptlist_new();
 }
 
@@ -172,6 +175,22 @@ OsinfoDeployment *osinfo_db_get_deployment(OsinfoDb *db, const gchar *id)
 }
 
 /**
+ * osinfo_db_get_install_datamap:
+ * @db: the database
+ * @id: the unique operating system identifier
+ *
+ * Returns: (transfer none): the install datamap, or NULL if none is found
+ */
+OsinfoInstallDatamap *osinfo_db_get_install_datamap(OsinfoDb *db, const gchar *id)
+{
+    g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+    g_return_val_if_fail(id != NULL, NULL);
+
+    return OSINFO_INSTALL_DATAMAP(osinfo_list_find_by_id(OSINFO_LIST(db->priv->datamaps), id));
+}
+
+
+/**
  * osinfo_db_get_install_script:
  * @db: the database
  * @id: the unique operating system identifier
@@ -284,6 +303,20 @@ OsinfoDeploymentList *osinfo_db_get_deployment_list(OsinfoDb *db)
 
 
 /**
+ * osinfo_db_get_install_datamap_list:
+ * @db: the database
+ *
+ * Returns: (transfer full): the list of install datamaps
+ */
+OsinfoInstallDatamapList *osinfo_db_get_install_datamap_list(OsinfoDb *db)
+{
+    g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+
+    return osinfo_install_datamaplist_new_copy(db->priv->datamaps);
+}
+
+
+/**
  * osinfo_db_get_install_script_list:
  * @db: the database
  *
@@ -358,6 +391,21 @@ void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment)
 
 
 /**
+ * osinfo_db_add_install_datamap:
+ * @db: the database
+ * @datamap: (transfer none): a install datamap
+ *
+ */
+void osinfo_db_add_install_datamap(OsinfoDb *db, OsinfoInstallDatamap *datamap)
+{
+    g_return_if_fail(OSINFO_IS_DB(db));
+    g_return_if_fail(OSINFO_IS_INSTALL_DATAMAP(datamap));
+
+    osinfo_list_add(OSINFO_LIST(db->priv->datamaps), OSINFO_ENTITY(datamap));
+}
+
+
+/**
  * osinfo_db_add_install_script:
  * @db: the database
  * @script: (transfer none): a install script
diff --git a/osinfo/osinfo_db.h b/osinfo/osinfo_db.h
index d789802..975d547 100644
--- a/osinfo/osinfo_db.h
+++ b/osinfo/osinfo_db.h
@@ -78,6 +78,7 @@ OsinfoPlatform *osinfo_db_get_platform(OsinfoDb *db, const gchar *id);
 OsinfoDevice *osinfo_db_get_device(OsinfoDb *db, const gchar *id);
 OsinfoOs *osinfo_db_get_os(OsinfoDb *db, const gchar *id);
 OsinfoDeployment *osinfo_db_get_deployment(OsinfoDb *db, const gchar *id);
+OsinfoInstallDatamap *osinfo_db_get_install_datamap(OsinfoDb *db, const gchar *id);
 OsinfoInstallScript *osinfo_db_get_install_script(OsinfoDb *db, const gchar *id);
 
 OsinfoDeployment *osinfo_db_find_deployment(OsinfoDb *db,
@@ -89,11 +90,13 @@ OsinfoPlatformList *osinfo_db_get_platform_list(OsinfoDb *db);
 OsinfoDeviceList *osinfo_db_get_device_list(OsinfoDb *db);
 OsinfoDeploymentList *osinfo_db_get_deployment_list(OsinfoDb *db);
 OsinfoInstallScriptList *osinfo_db_get_install_script_list(OsinfoDb *db);
+OsinfoInstallDatamapList *osinfo_db_get_install_datamap_list(OsinfoDb *db);
 
 void osinfo_db_add_os(OsinfoDb *db, OsinfoOs *os);
 void osinfo_db_add_platform(OsinfoDb *db, OsinfoPlatform *platform);
 void osinfo_db_add_device(OsinfoDb *db, OsinfoDevice *device);
 void osinfo_db_add_deployment(OsinfoDb *db, OsinfoDeployment *deployment);
+void osinfo_db_add_install_datamap(OsinfoDb *db, OsinfoInstallDatamap *datamap);
 void osinfo_db_add_install_script(OsinfoDb *db, OsinfoInstallScript *script);
 
 OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db,
diff --git a/osinfo/osinfo_install_datamap.c b/osinfo/osinfo_install_datamap.c
new file mode 100644
index 0000000..a4f55db
--- /dev/null
+++ b/osinfo/osinfo_install_datamap.c
@@ -0,0 +1,149 @@
+/*
+ * libosinfo:
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange at redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <string.h>
+#include <libxml/tree.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
+#include <libxslt/xsltInternals.h>
+
+G_DEFINE_TYPE (OsinfoInstallDatamap, osinfo_install_datamap, OSINFO_TYPE_ENTITY);
+
+#define OSINFO_INSTALL_DATAMAP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_DATAMAP, OsinfoInstallDatamapPrivate))
+
+/**
+ * SECTION:osinfo_install_datamap
+ * @short_dedatamapion: OS install datamapuration
+ * @see_also: #OsinfoInstallDatamap
+ *
+ * #OsinfoInstallDatamap is an object for representing OS
+ * install datamapuration data. It is used to generate an
+ * automated installation datamap
+ */
+
+struct _OsinfoInstallDatamapPrivate
+{
+    GHashTable *map;
+};
+
+enum {
+    PROP_0,
+
+};
+
+
+#if 0
+static void
+osinfo_os_set_property(GObject    *object,
+                       guint       property_id,
+                       const GValue     *value,
+                       GParamSpec *pspec)
+{
+    OsinfoInstallDatamap *datamap = OSINFO_INSTALL_DATAMAP(object);
+    const gchar *data;
+
+    switch (property_id) {
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+osinfo_os_get_property(GObject    *object,
+                       guint       property_id,
+                       GValue     *value,
+                       GParamSpec *pspec)
+{
+    OsinfoInstallDatamap *datamap = OSINFO_INSTALL_DATAMAP(object);
+
+    switch (property_id) {
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+#endif
+
+
+static void
+osinfo_install_datamap_finalize (GObject *object)
+{
+    OsinfoInstallDatamap *map = OSINFO_INSTALL_DATAMAP(object);
+
+    g_hash_table_unref(map->priv->map);
+
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_install_datamap_parent_class)->finalize (object);
+}
+
+/* Init functions */
+static void
+osinfo_install_datamap_class_init (OsinfoInstallDatamapClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+
+#if 0
+    g_klass->get_property = osinfo_os_get_property;
+    g_klass->set_property = osinfo_os_set_property;
+#endif
+    g_klass->finalize = osinfo_install_datamap_finalize;
+
+    g_type_class_add_private (klass, sizeof (OsinfoInstallDatamapPrivate));
+}
+
+static void
+osinfo_install_datamap_init (OsinfoInstallDatamap *list)
+{
+    OsinfoInstallDatamapPrivate *priv;
+    list->priv = priv = OSINFO_INSTALL_DATAMAP_GET_PRIVATE(list);
+
+    list->priv->map = g_hash_table_new_full(g_str_hash,
+                                            g_str_equal,
+                                            g_free,
+                                            g_free);
+}
+
+
+OsinfoInstallDatamap *osinfo_install_datamap_new(const gchar *id)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_DATAMAP,
+                        "id", id,
+                        NULL);
+}
+
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_datamap.h b/osinfo/osinfo_install_datamap.h
new file mode 100644
index 0000000..e96f1a4
--- /dev/null
+++ b/osinfo/osinfo_install_datamap.h
@@ -0,0 +1,81 @@
+/*
+ * libosinfo: OS installation script data map
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Daniel P. Berrange <berrange at redhat.com>
+ */
+
+#include <glib-object.h>
+
+#ifndef __OSINFO_INSTALL_DATAMAP_H__
+#define __OSINFO_INSTALL_DATAMAP_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_INSTALL_DATAMAP                  (osinfo_install_datamap_get_type ())
+#define OSINFO_INSTALL_DATAMAP(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_INSTALL_DATAMAP, OsinfoInstallDatamap))
+#define OSINFO_IS_INSTALL_DATAMAP(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_INSTALL_DATAMAP))
+#define OSINFO_INSTALL_DATAMAP_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_INSTALL_DATAMAP, OsinfoInstallDatamapClass))
+#define OSINFO_IS_INSTALL_DATAMAP_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_DATAMAP))
+#define OSINFO_INSTALL_DATAMAP_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_DATAMAP, OsinfoInstallDatamapClass))
+
+typedef struct _OsinfoInstallDatamap        OsinfoInstallDatamap;
+typedef struct _OsinfoInstallDatamapClass   OsinfoInstallDatamapClass;
+typedef struct _OsinfoInstallDatamapPrivate OsinfoInstallDatamapPrivate;
+
+
+/* object */
+struct _OsinfoInstallDatamap
+{
+    OsinfoEntity parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoInstallDatamapPrivate *priv;
+};
+
+/* class */
+struct _OsinfoInstallDatamapClass
+{
+    OsinfoEntityClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_install_datamap_get_type(void);
+
+OsinfoInstallDatamap *osinfo_install_datamap_new(const gchar *id);
+
+void osinfo_install_datamap_insert(OsinfoInstallDatamap *map,
+                                   const gchar *inval,
+                                   const gchar *outval);
+
+const gchar *osinfo_install_datamap_lookup(OsinfoInstallDatamap *map,
+                                           const gchar *inval);
+
+#endif /* __OSINFO_INSTALL_DATAMAP_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_datamaplist.c b/osinfo/osinfo_install_datamaplist.c
new file mode 100644
index 0000000..776b94f
--- /dev/null
+++ b/osinfo/osinfo_install_datamaplist.c
@@ -0,0 +1,169 @@
+/*
+ * libosinfo:
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Arjun Roy <arroy at redhat.com>
+ *   Daniel P. Berrange <berrange at redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+G_DEFINE_TYPE (OsinfoInstallDatamapList, osinfo_install_datamaplist, OSINFO_TYPE_LIST);
+
+#define OSINFO_INSTALL_DATAMAPLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_DATAMAPLIST, OsinfoInstallDatamapListPrivate))
+
+/**
+ * SECTION:osinfo_install_datamaplist
+ * @short_dedatamapion: A list of installation install_datamap
+ * @see_also: #OsinfoList, #OsinfoInstallDatamap
+ *
+ * #OsinfoInstallDatamapList is a list specialization that stores
+ * only #OsinfoInstallDatamap objects.
+ */
+
+struct _OsinfoInstallDatamapListPrivate
+{
+    gboolean unused;
+};
+
+static void
+osinfo_install_datamaplist_finalize (GObject *object)
+{
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_install_datamaplist_parent_class)->finalize (object);
+}
+
+/* Init functions */
+static void
+osinfo_install_datamaplist_class_init (OsinfoInstallDatamapListClass *klass)
+{
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+
+    g_klass->finalize = osinfo_install_datamaplist_finalize;
+    g_type_class_add_private (klass, sizeof (OsinfoInstallDatamapListPrivate));
+}
+
+static void
+osinfo_install_datamaplist_init (OsinfoInstallDatamapList *list)
+{
+    OsinfoInstallDatamapListPrivate *priv;
+    list->priv = priv = OSINFO_INSTALL_DATAMAPLIST_GET_PRIVATE(list);
+
+}
+
+/**
+ * osinfo_install_datamaplist_new:
+ *
+ * Construct a new install_datamap list that is initially empty.
+ *
+ * Returns: (transfer full): an empty install_datamap list
+ */
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new(void)
+{
+    return g_object_new(OSINFO_TYPE_INSTALL_DATAMAPLIST,
+                        "element-type", OSINFO_TYPE_INSTALL_DATAMAP,
+                        NULL);
+}
+
+/**
+ * osinfo_install_datamaplist_new_copy:
+ * @source: the install_datamap list to copy
+ *
+ * Construct a new install_datamap list that is filled with install_datamaps
+ * from @source
+ *
+ * Returns: (transfer full): a copy of the install_datamap list
+ */
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_copy(OsinfoInstallDatamapList *source)
+{
+    OsinfoInstallDatamapList *newList = osinfo_install_datamaplist_new();
+    osinfo_list_add_all(OSINFO_LIST(newList),
+                        OSINFO_LIST(source));
+    return newList;
+}
+
+/**
+ * osinfo_install_datamaplist_new_filtered:
+ * @source: the install_datamap list to copy
+ * @filter: the filter to apply
+ *
+ * Construct a new install_datamap list that is filled with install_datamaps
+ * from @source that match @filter
+ *
+ * Returns: (transfer full): a filtered copy of the install_datamap list
+ */
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_filtered(OsinfoInstallDatamapList *source,
+								  OsinfoFilter *filter)
+{
+    OsinfoInstallDatamapList *newList = osinfo_install_datamaplist_new();
+    osinfo_list_add_filtered(OSINFO_LIST(newList),
+                             OSINFO_LIST(source),
+                             filter);
+    return newList;
+}
+
+/**
+ * osinfo_install_datamaplist_new_intersection:
+ * @sourceOne: the first install_datamap list to copy
+ * @sourceTwo: the second install_datamap list to copy
+ *
+ * Construct a new install_datamap list that is filled with only the
+ * install_datamaps that are present in both @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): an intersection of the two install_datamap lists
+ */
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_intersection(OsinfoInstallDatamapList *sourceOne,
+								      OsinfoInstallDatamapList *sourceTwo)
+{
+    OsinfoInstallDatamapList *newList = osinfo_install_datamaplist_new();
+    osinfo_list_add_intersection(OSINFO_LIST(newList),
+                                 OSINFO_LIST(sourceOne),
+                                 OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/**
+ * osinfo_install_datamaplist_new_union:
+ * @sourceOne: the first install_datamap list to copy
+ * @sourceTwo: the second install_datamap list to copy
+ *
+ * Construct a new install_datamap list that is filled with all the
+ * install_datamaps that are present in either @sourceOne and @sourceTwo.
+ *
+ * Returns: (transfer full): a union of the two install_datamap lists
+ */
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_union(OsinfoInstallDatamapList *sourceOne,
+							       OsinfoInstallDatamapList *sourceTwo)
+{
+    OsinfoInstallDatamapList *newList = osinfo_install_datamaplist_new();
+    osinfo_list_add_union(OSINFO_LIST(newList),
+                          OSINFO_LIST(sourceOne),
+                          OSINFO_LIST(sourceTwo));
+    return newList;
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_install_datamaplist.h b/osinfo/osinfo_install_datamaplist.h
new file mode 100644
index 0000000..58f473f
--- /dev/null
+++ b/osinfo/osinfo_install_datamaplist.h
@@ -0,0 +1,82 @@
+/*
+ * libosinfo: a list of installation install_datamap
+ *
+ * Copyright (C) 2009-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors:
+ *   Zeeshan Ali <zeenix at redhat.com>
+ *   Arjun Roy <arroy at redhat.com>
+ *   Daniel P. Berrange <berrange at redhat.com>
+ */
+
+#include <glib-object.h>
+#include <osinfo/osinfo_list.h>
+
+#ifndef __OSINFO_INSTALL_DATAMAPLIST_H__
+#define __OSINFO_INSTALL_DATAMAPLIST_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_INSTALL_DATAMAPLIST                  (osinfo_install_datamaplist_get_type ())
+#define OSINFO_INSTALL_DATAMAPLIST(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_INSTALL_DATAMAPLIST, OsinfoInstallDatamapList))
+#define OSINFO_IS_INSTALL_DATAMAPLIST(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_INSTALL_DATAMAPLIST))
+#define OSINFO_INSTALL_DATAMAPLIST_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_INSTALL_DATAMAPLIST, OsinfoInstallDatamapListClass))
+#define OSINFO_IS_INSTALL_DATAMAPLIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_DATAMAPLIST))
+#define OSINFO_INSTALL_DATAMAPLIST_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_DATAMAPLIST, OsinfoInstallDatamapListClass))
+
+typedef struct _OsinfoInstallDatamapList        OsinfoInstallDatamapList;
+
+typedef struct _OsinfoInstallDatamapListClass   OsinfoInstallDatamapListClass;
+
+typedef struct _OsinfoInstallDatamapListPrivate OsinfoInstallDatamapListPrivate;
+
+/* object */
+struct _OsinfoInstallDatamapList
+{
+    OsinfoList parent_instance;
+
+    /* public */
+
+    /* private */
+    OsinfoInstallDatamapListPrivate *priv;
+};
+
+/* class */
+struct _OsinfoInstallDatamapListClass
+{
+    OsinfoListClass parent_class;
+
+    /* class members */
+};
+
+GType osinfo_install_datamaplist_get_type(void);
+
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new(void);
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_copy(OsinfoInstallDatamapList *source);
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_filtered(OsinfoInstallDatamapList *source, OsinfoFilter *filter);
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_intersection(OsinfoInstallDatamapList *sourceOne, OsinfoInstallDatamapList *sourceTwo);
+OsinfoInstallDatamapList *osinfo_install_datamaplist_new_union(OsinfoInstallDatamapList *sourceOne, OsinfoInstallDatamapList *sourceTwo);
+
+#endif /* __OSINFO_INSTALL_DATAMAPLIST_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
1.7.11.7





>From 4fa076b019a8f398dea1ad0ed8279999d454fdcd Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange at redhat.com>
Date: Tue, 13 Mar 2012 16:27:32 +0000
Subject: [PATCH] keymap

---
 docs/reference/Libosinfo.types      |  2 ++
 osinfo/osinfo_install_datamaplist.c |  6 +++---
 osinfo/osinfo_install_script.c      | 34 +++++++++++++++++++++++++++++++++-
 osinfo/osinfo_install_script.h      |  4 ++++
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index 7bf1e2e..0d5fdaa 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -46,7 +46,9 @@ G_DEFINE_TYPE (OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY);
 
 struct _OsinfoInstallScriptPrivate
 {
-    gboolean unused;
+    OsinfoInstallDatamap *language_map;
+    OsinfoInstallDatamap *timezone_map;
+    OsinfoInstallDatamap *keyboard_map;
 };
 
 enum {
@@ -141,6 +143,17 @@ osinfo_os_get_property(GObject    *object,
 static void
 osinfo_install_script_finalize (GObject *object)
 {
+    OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT(object);
+
+    if (script->priv->language_map)
+        g_object_unref(script->priv->language_map);
+
+    if (script->priv->timezone_map)
+        g_object_unref(script->priv->timezone_map);
+
+    if (script->priv->keyboard_map)
+        g_object_unref(script->priv->keyboard_map);
+
     /* Chain up to the parent class */
     G_OBJECT_CLASS (osinfo_install_script_parent_class)->finalize (object);
 }
@@ -267,6 +280,25 @@ OsinfoInstallScript *osinfo_install_script_new_uri(const gchar *id,
 }
 
 
+OsinfoInstallDatamap *osinfo_install_script_get_language_map(OsinfoInstallScript *script)
+{
+    return script->priv->language_map;
+}
+
+
+OsinfoInstallDatamap *osinfo_install_script_get_timezone_map(OsinfoInstallScript *script)
+{
+    return script->priv->timezone_map;
+}
+
+
+OsinfoInstallDatamap *osinfo_install_script_get_keyboard_map(OsinfoInstallScript *script)
+{
+    return script->priv->keyboard_map;
+}
+
+
+
 const gchar *osinfo_install_script_get_template_uri(OsinfoInstallScript *script)
 {
     return osinfo_entity_get_param_value(OSINFO_ENTITY(script),
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index 00740c2..30d5fb7 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -79,6 +79,10 @@ OsinfoInstallScript *osinfo_install_script_new_data(const gchar *id,
                                                     const gchar *profile,
                                                     const gchar *templateData);
 
+OsinfoInstallDatamap *osinfo_install_script_get_language_map(OsinfoInstallScript *script);
+OsinfoInstallDatamap *osinfo_install_script_get_timezone_map(OsinfoInstallScript *script);
+OsinfoInstallDatamap *osinfo_install_script_get_keyboard_map(OsinfoInstallScript *script);
+
 const gchar *osinfo_install_script_get_template_uri(OsinfoInstallScript *script);
 const gchar *osinfo_install_script_get_template_data(OsinfoInstallScript *script);
 const gchar *osinfo_install_script_get_profile(OsinfoInstallScript *script);
-- 
1.7.11.7



-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the virt-tools-list mailing list