summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2013-11-26 13:55:15 +0000
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2013-11-29 11:21:12 +0000
commit24736dbdcbcb122da9a93ffd829a5a4d4f5d173e (patch)
tree50ed0a5aeba7ae264a52293f28a3b13ddb2094cc
parentabe9f1681d61ea493dce11014c781a36ddd78036 (diff)
downloadlibosinfo-24736dbdcbcb122da9a93ffd829a5a4d4f5d173e.tar.gz
Introducing OsinfoOsVariant
This is a new entity class that will represent variants of an OS. For example professional, enterprise and ultimate editions of Windows OSs and workstation and server variants of RHEL etc.
-rw-r--r--osinfo/Makefile.am2
-rw-r--r--osinfo/libosinfo.syms4
-rw-r--r--osinfo/osinfo.h1
-rw-r--r--osinfo/osinfo_os_variant.c158
-rw-r--r--osinfo/osinfo_os_variant.h81
-rw-r--r--po/POTFILES.in1
6 files changed, 247 insertions, 0 deletions
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index fc87123..e78c468 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -82,6 +82,7 @@ OSINFO_HEADER_FILES = \
osinfo_list.h \
osinfo_os.h \
osinfo_oslist.h \
+ osinfo_os_variant.h \
osinfo_deployment.h \
osinfo_deploymentlist.h \
osinfo_media.h \
@@ -127,6 +128,7 @@ libosinfo_1_0_la_SOURCES = \
osinfo_platformlist.c \
osinfo_oslist.c \
osinfo_os.c \
+ osinfo_os_variant.c \
osinfo_deployment.c \
osinfo_deploymentlist.c \
osinfo_media.c \
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index fa5be4e..77b8eaa 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -447,6 +447,10 @@ LIBOSINFO_0.2.8 {
LIBOSINFO_0.2.9 {
osinfo_os_get_release_status;
osinfo_release_status_get_type;
+
+ osinfo_os_variant_get_type;
+ osinfo_os_variant_get_name;
+ osinfo_os_variant_new;
} LIBOSINFO_0.2.8;
/* Symbols in next release...
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 0d0f3d2..0d1f66d 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -63,6 +63,7 @@
#include <osinfo/osinfo_treelist.h>
#include <osinfo/osinfo_db.h>
#include <osinfo/osinfo_loader.h>
+#include <osinfo/osinfo_os_variant.h>
#endif
/*
diff --git a/osinfo/osinfo_os_variant.c b/osinfo/osinfo_os_variant.c
new file mode 100644
index 0000000..f859235
--- /dev/null
+++ b/osinfo/osinfo_os_variant.c
@@ -0,0 +1,158 @@
+/*
+ * libosinfo: The variant of an OS
+ *
+ * Copyright (C) 2013 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Zeeshan Ali <zeenix@redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (OsinfoOsVariant, osinfo_os_variant, OSINFO_TYPE_ENTITY);
+
+#define OSINFO_OS_VARIANT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ OSINFO_TYPE_OS_VARIANT, \
+ OsinfoOsVariantPrivate))
+
+/**
+ * SECTION:osinfo_os_variant
+ * @short_description: A variant of an OS
+ * @see_also: #OsinfoOs
+ *
+ * #OsinfoOsVariant is an entity representing a variant of an operating system.
+ */
+struct _OsinfoOsVariantPrivate
+{
+ gboolean unused;
+};
+
+enum {
+ PROP_0,
+
+ PROP_NAME
+};
+
+static void
+osinfo_os_variant_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ OsinfoOsVariant *variant = OSINFO_OS_VARIANT (object);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_value_set_string (value,
+ osinfo_os_variant_get_name (variant));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+osinfo_os_variant_set_property(GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ OsinfoOsVariant *variant = OSINFO_OS_VARIANT (object);
+
+ switch (property_id) {
+ case PROP_NAME:
+ osinfo_entity_set_param (OSINFO_ENTITY(variant),
+ OSINFO_OS_VARIANT_PROP_NAME,
+ g_value_get_string (value));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+/* Init functions */
+static void
+osinfo_os_variant_class_init (OsinfoOsVariantClass *klass)
+{
+ GObjectClass *g_klass = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
+
+ g_klass->get_property = osinfo_os_variant_get_property;
+ g_klass->set_property = osinfo_os_variant_set_property;
+ g_type_class_add_private (klass, sizeof (OsinfoOsVariantPrivate));
+
+ /**
+ * OsinfoOsVariant:name:
+ *
+ * The name to this variant.
+ */
+ pspec = g_param_spec_string ("name",
+ "Name",
+ _("The name to this variant"),
+ NULL /* default value */,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (g_klass, PROP_NAME, pspec);
+}
+
+static void
+osinfo_os_variant_init (OsinfoOsVariant *variant)
+{
+ variant->priv = OSINFO_OS_VARIANT_GET_PRIVATE(variant);
+}
+
+OsinfoOsVariant *osinfo_os_variant_new(const gchar *id)
+{
+ OsinfoOsVariant *variant;
+
+ variant = g_object_new(OSINFO_TYPE_OS_VARIANT,
+ "id", id,
+ NULL);
+
+ return variant;
+}
+
+/**
+ * osinfo_os_variant_get_name:
+ * @variant: an #OsinfoOsVariant instance
+ *
+ * The name of the @variant
+ *
+ * Returns: (transfer none): the name, or NULL
+ */
+const gchar *osinfo_os_variant_get_name(OsinfoOsVariant *variant)
+{
+ return osinfo_entity_get_param_value(OSINFO_ENTITY(variant),
+ OSINFO_OS_VARIANT_PROP_NAME);
+}
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/osinfo/osinfo_os_variant.h b/osinfo/osinfo_os_variant.h
new file mode 100644
index 0000000..aa857c3
--- /dev/null
+++ b/osinfo/osinfo_os_variant.h
@@ -0,0 +1,81 @@
+/*
+ * libosinfo: The variant of an OS
+ *
+ * Copyright (C) 2013 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Zeeshan Ali <zeenix@redhat.com>
+ */
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <osinfo/osinfo_entity.h>
+
+#ifndef __OSINFO_OS_VARIANT_H__
+#define __OSINFO_OS_VARIANT_H__
+
+/*
+ * Type macros.
+ */
+#define OSINFO_TYPE_OS_VARIANT (osinfo_os_variant_get_type ())
+#define OSINFO_OS_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_OS_VARIANT, OsinfoOsVariant))
+#define OSINFO_IS_OS_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_OS_VARIANT))
+#define OSINFO_OS_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_OS_VARIANT, OsinfoOsVariantClass))
+#define OSINFO_IS_OS_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_OS_VARIANT))
+#define OSINFO_OS_VARIANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_OS_VARIANT, OsinfoOsVariantClass))
+
+typedef struct _OsinfoOsVariant OsinfoOsVariant;
+
+typedef struct _OsinfoOsVariantClass OsinfoOsVariantClass;
+
+typedef struct _OsinfoOsVariantPrivate OsinfoOsVariantPrivate;
+
+#define OSINFO_OS_VARIANT_PROP_NAME "name"
+
+/* object */
+struct _OsinfoOsVariant
+{
+ OsinfoEntity parent_instance;
+
+ /* public */
+
+ /* private */
+ OsinfoOsVariantPrivate *priv;
+};
+
+/* class */
+struct _OsinfoOsVariantClass
+{
+ /*< private >*/
+ OsinfoEntityClass parent_class;
+
+ /* class members */
+};
+
+GType osinfo_os_variant_get_type(void);
+
+OsinfoOsVariant *osinfo_os_variant_new(const gchar *id);
+const gchar *osinfo_os_variant_get_name(OsinfoOsVariant *variant);
+
+#endif /* __OSINFO_OS_VARIANT_H__ */
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8cbabed..a1a551f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,6 +41,7 @@ osinfo/osinfo_os.c
osinfo/osinfo_product.c
osinfo/osinfo_resources.c
osinfo/osinfo_tree.c
+osinfo/osinfo_os_variant.c
tools/osinfo-db-validate.c
tools/osinfo-detect.c
tools/osinfo-install-script.c