[Libosinfo] [PATCHv4 06/11] Add OsinfoInstallConfig:config-params property
Christophe Fergeau
cfergeau at redhat.com
Mon Dec 17 21:07:49 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/libosinfo.syms | 3 ++
osinfo/osinfo_install_config.c | 95 +++++++++++++++++++++++++++++++++++++++++-
osinfo/osinfo_install_config.h | 7 ++++
3 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index a1c2d71..d0582ea 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -388,6 +388,9 @@ LIBOSINFO_0.2.3 {
osinfo_db_get_datamap_list;
osinfo_db_identify_media;
+ osinfo_install_config_get_config_params;
+ osinfo_install_config_set_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 64e7ed5..8078f8c 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -42,14 +42,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));
}
@@ -637,6 +714,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..89215d1 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,15 @@ 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);
+void osinfo_install_config_set_config_params(OsinfoInstallConfig *config,
+ OsinfoInstallConfigParamList *config_params);
+OsinfoInstallConfigParamList *osinfo_install_config_get_config_params(OsinfoInstallConfig *config);
+
#endif /* __OSINFO_INSTALL_CONFIG_H__ */
/*
* Local variables:
--
1.8.0.2
More information about the Libosinfo
mailing list