[Libosinfo] [PATCHv4 06/11] Add OsinfoInstallConfig:config-params property

Christophe Fergeau cfergeau at redhat.com
Thu Dec 20 16:45:09 UTC 2012


This property lists the parameters that can be set for a given
OsinfoInstallConfig. This is not enforced, it's only there for
informative purpose. This will also be used in later commits
in order to automatically apply transformations on values
for parameters which have an associated OsinfoDatamap.
---
 osinfo/Makefile.am                     |  1 +
 osinfo/libosinfo.syms                  |  2 +
 osinfo/osinfo_install_config.c         | 96 +++++++++++++++++++++++++++++++++-
 osinfo/osinfo_install_config.h         |  5 ++
 osinfo/osinfo_install_config_private.h | 39 ++++++++++++++
 5 files changed, 142 insertions(+), 1 deletion(-)
 create mode 100644 osinfo/osinfo_install_config_private.h

diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 9d03a34..9f3c20d 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -116,6 +116,7 @@ libosinfo_1_0_la_SOURCES =		\
   osinfo_install_config.c		\
   osinfo_install_config_param.c		\
   osinfo_install_config_paramlist.c	\
+  osinfo_install_config_private.h	\
   osinfo_install_script.c		\
   osinfo_install_script_private.h	\
   osinfo_install_scriptlist.c		\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 4615829..a32a8b7 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -388,6 +388,8 @@ LIBOSINFO_0.2.3 {
 	osinfo_db_get_datamap_list;
 	osinfo_db_identify_media;
 
+	osinfo_install_config_get_config_params;
+
 	osinfo_install_config_paramlist_get_type;
 	osinfo_install_config_paramlist_new;
 
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index 219a8e2..a77317b 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -24,6 +24,7 @@
 #include <config.h>
 
 #include <osinfo/osinfo.h>
+#include "osinfo/osinfo_install_config_private.h"
 #include <glib/gi18n-lib.h>
 
 G_DEFINE_TYPE (OsinfoInstallConfig, osinfo_install_config, OSINFO_TYPE_ENTITY);
@@ -42,14 +43,91 @@ G_DEFINE_TYPE (OsinfoInstallConfig, osinfo_install_config, OSINFO_TYPE_ENTITY);
 
 struct _OsinfoInstallConfigPrivate
 {
-    gboolean unused;
+    OsinfoInstallConfigParamList *config_params;
 };
 
+enum {
+    PROP_0,
+
+    PROP_CONFIG_PARAMS,
+};
+
+static void
+osinfo_install_config_set_property(GObject    *object,
+                                   guint       property_id,
+                                   const GValue     *value,
+                                   GParamSpec *pspec)
+{
+    OsinfoInstallConfig *config = OSINFO_INSTALL_CONFIG(object);
+
+    switch (property_id) {
+    case PROP_CONFIG_PARAMS:
+        osinfo_install_config_set_config_params(config, g_value_get_object(value));
+        break;
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+osinfo_install_config_get_property(GObject    *object,
+                                   guint       property_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+    OsinfoInstallConfig *config = OSINFO_INSTALL_CONFIG(object);
+
+    switch (property_id) {
+    case PROP_CONFIG_PARAMS:
+        g_value_set_object(value, osinfo_install_config_get_config_params(config));
+        break;
+
+    default:
+        /* We don't have any other property... */
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+
+static void
+osinfo_install_config_finalize (GObject *object)
+{
+    OsinfoInstallConfig *config = OSINFO_INSTALL_CONFIG (object);
+
+    if (config->priv->config_params)
+        g_object_unref(config->priv->config_params);
+
+    /* Chain up to the parent class */
+    G_OBJECT_CLASS (osinfo_install_config_parent_class)->finalize (object);
+}
+
 
 /* Init functions */
 static void
 osinfo_install_config_class_init (OsinfoInstallConfigClass *klass)
 {
+    GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+    GParamSpec *pspec;
+
+    g_klass->get_property = osinfo_install_config_get_property;
+    g_klass->set_property = osinfo_install_config_set_property;
+    g_klass->finalize = osinfo_install_config_finalize;
+
+    pspec = g_param_spec_object("config-params",
+                                "Config Parameters",
+                                _("Valid configuration parameters"),
+                                OSINFO_TYPE_INSTALL_CONFIG_PARAMLIST,
+                                G_PARAM_READWRITE |
+                                G_PARAM_CONSTRUCT_ONLY |
+                                G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(g_klass,
+                                    PROP_CONFIG_PARAMS,
+                                    pspec);
+
     g_type_class_add_private (klass, sizeof (OsinfoInstallConfigPrivate));
 }
 
@@ -643,6 +721,22 @@ const gchar *osinfo_install_config_get_post_install_drivers_location(OsinfoInsta
              OSINFO_INSTALL_CONFIG_PROP_POST_INSTALL_DRIVERS_LOCATION);
 }
 
+void osinfo_install_config_set_config_params(OsinfoInstallConfig *config,
+                                             OsinfoInstallConfigParamList *config_params)
+{
+    if (config->priv->config_params != NULL)
+        g_object_unref(config->priv->config_params);
+    if (config_params != NULL)
+        config->priv->config_params = g_object_ref(G_OBJECT(config_params));
+    else
+        config->priv->config_params = NULL;
+}
+
+OsinfoInstallConfigParamList *osinfo_install_config_get_config_params(OsinfoInstallConfig *config)
+{
+    return config->priv->config_params;
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_install_config.h b/osinfo/osinfo_install_config.h
index d650a0a..caf5518 100644
--- a/osinfo/osinfo_install_config.h
+++ b/osinfo/osinfo_install_config.h
@@ -22,6 +22,7 @@
  */
 
 #include <glib-object.h>
+#include <osinfo/osinfo_install_config_paramlist.h>
 
 #ifndef __OSINFO_INSTALL_CONFIG_H__
 #define __OSINFO_INSTALL_CONFIG_H__
@@ -182,6 +183,7 @@ const gchar *osinfo_install_config_get_avatar_disk(OsinfoInstallConfig *config);
 void osinfo_install_config_set_pre_install_drivers_disk(OsinfoInstallConfig *config,
                                                         const gchar *disk);
 const gchar *osinfo_install_config_get_pre_install_drivers_disk(OsinfoInstallConfig *config);
+
 void osinfo_install_config_set_pre_install_drivers_location(OsinfoInstallConfig *config,
                                                             const gchar *location);
 const gchar *osinfo_install_config_get_pre_install_drivers_location(OsinfoInstallConfig *config);
@@ -189,10 +191,13 @@ const gchar *osinfo_install_config_get_pre_install_drivers_location(OsinfoInstal
 void osinfo_install_config_set_post_install_drivers_disk(OsinfoInstallConfig *config,
                                                          const gchar *disk);
 const gchar *osinfo_install_config_get_post_install_drivers_disk(OsinfoInstallConfig *config);
+
 void osinfo_install_config_set_post_install_drivers_location(OsinfoInstallConfig *config,
                                                              const gchar *location);
 const gchar *osinfo_install_config_get_post_install_drivers_location(OsinfoInstallConfig *config);
 
+OsinfoInstallConfigParamList *osinfo_install_config_get_config_params(OsinfoInstallConfig *config);
+
 #endif /* __OSINFO_INSTALL_CONFIG_H__ */
 /*
  * Local variables:
diff --git a/osinfo/osinfo_install_config_private.h b/osinfo/osinfo_install_config_private.h
new file mode 100644
index 0000000..5a1edd3
--- /dev/null
+++ b/osinfo/osinfo_install_config_private.h
@@ -0,0 +1,39 @@
+/*
+ * libosinfo: OS installation config
+ *
+ * Copyright (C) 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:
+ *   Christophe Fergeau <cfergeau at redhat.com>
+ */
+
+#include <osinfo/osinfo_install_config.h>
+
+#ifndef __OSINFO_INSTALL_CONFIG_PRIVATE_H__
+#define __OSINFO_INSTALL_CONFIG_PRIVATE_H__
+
+void osinfo_install_config_set_config_params(OsinfoInstallConfig *config,
+                                             OsinfoInstallConfigParamList *config_params);
+
+#endif /* __OSINFO_INSTALL_CONFIG_PRIVATE_H__ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
1.8.0.2




More information about the Libosinfo mailing list