On Thu, Nov 28, 2013 at 01:07:11AM +0000, Zeeshan Ali (Khattak) wrote: > 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. > --- > osinfo/Makefile.am | 2 + > osinfo/libosinfo.syms | 4 ++ > osinfo/osinfo.h | 1 + > osinfo/osinfo_os_variant.c | 158 +++++++++++++++++++++++++++++++++++++++++++++ > osinfo/osinfo_os_variant.h | 81 +++++++++++++++++++++++ > po/POTFILES.in | 1 + > 6 files changed, 247 insertions(+) > create mode 100644 osinfo/osinfo_os_variant.c > create mode 100644 osinfo/osinfo_os_variant.h > > diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am > index fc87123..12ec59d 100644 > --- a/osinfo/Makefile.am > +++ b/osinfo/Makefile.am > @@ -90,6 +90,7 @@ OSINFO_HEADER_FILES = \ > osinfo_resourceslist.h \ > osinfo_tree.h \ > osinfo_treelist.h \ > + osinfo_os_variant.h \ > $(NULL) > > libosinfo_1_0_include_HEADERS = \ > @@ -138,6 +139,7 @@ libosinfo_1_0_la_SOURCES = \ > osinfo_treelist.c \ > osinfo_db.c \ > osinfo_loader.c \ > + osinfo_os_variant.c \ > ignore-value.h \ > $(NULL) > > 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..e6aab40 > --- /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@xxxxxxxxxx> > + */ > + > +#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_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 > +{ > + guint64 _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_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..33a947f > --- /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@xxxxxxxxxx> > + */ > + > +#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_VARIANT (osinfo_os_variant_get_type ()) > +#define OSINFO_OS_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_VARIANT, OsinfoOsVariant)) > +#define OSINFO_IS_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_VARIANT)) > +#define OSINFO_OS_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_VARIANT, OsinfoOsVariantClass)) > +#define OSINFO_IS_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_VARIANT)) > +#define OSINFO_OS_VARIANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_VARIANT, OsinfoOsVariantClass)) Some renaming issues here as well (as in patch 2) > + > +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 > -- > 1.8.4.2 > > _______________________________________________ > Libosinfo mailing list > Libosinfo@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libosinfo
Attachment:
pgp5_UbxcwgWE.pgp
Description: PGP signature
_______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo