On Tue, Nov 26, 2013 at 04:16:27PM +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. OsinfoVariant is a very generic name, I initially thought it had something to do with GVariant. OsinfoOsVariant would be more descriptive. > --- > osinfo/Makefile.am | 2 + > osinfo/libosinfo.syms | 4 ++ > osinfo/osinfo.h | 1 + > osinfo/osinfo_variant.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++ > osinfo/osinfo_variant.h | 81 +++++++++++++++++++++++++ > po/POTFILES.in | 1 + > 6 files changed, 247 insertions(+) > create mode 100644 osinfo/osinfo_variant.c > create mode 100644 osinfo/osinfo_variant.h > > diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am > index fc87123..17e1964 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_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_variant.c \ > ignore-value.h \ > $(NULL) > > diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms > index fa5be4e..a6f6cc6 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_variant_get_type; > + osinfo_variant_get_name; > + osinfo_variant_new; > } LIBOSINFO_0.2.8; > > /* Symbols in next release... > diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h > index 0d0f3d2..e06094e 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_variant.h> > > #endif > /* > diff --git a/osinfo/osinfo_variant.c b/osinfo/osinfo_variant.c > new file mode 100644 > index 0000000..3a7230a > --- /dev/null > +++ b/osinfo/osinfo_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 (OsinfoVariant, osinfo_variant, OSINFO_TYPE_ENTITY); > + > +#define OSINFO_VARIANT_GET_PRIVATE(obj) \ > + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ > + OSINFO_TYPE_VARIANT, \ > + OsinfoVariantPrivate)) > + > +/** > + * SECTION:osinfo_variant > + * @short_description: A variant of an OS > + * @see_also: #OsinfoOs > + * > + * #OsinfoVariant is an entity representing a variant of an operating system. > + */ > +struct _OsinfoVariantPrivate > +{ > + guint64 _unused; > +}; > + > +enum { > + PROP_0, > + > + PROP_NAME > +}; > + > +static void > +osinfo_variant_get_property (GObject *object, > + guint property_id, > + GValue *value, > + GParamSpec *pspec) > +{ > + OsinfoVariant *variant = OSINFO_VARIANT (object); > + > + switch (property_id) { > + case PROP_NAME: > + g_value_set_string (value, > + osinfo_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_variant_set_property(GObject *object, > + guint property_id, > + const GValue *value, > + GParamSpec *pspec) > +{ > + OsinfoVariant *variant = OSINFO_VARIANT (object); > + > + switch (property_id) { > + case PROP_NAME: > + osinfo_entity_set_param (OSINFO_ENTITY(variant), > + OSINFO_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_variant_class_init (OsinfoVariantClass *klass) > +{ > + GObjectClass *g_klass = G_OBJECT_CLASS (klass); > + GParamSpec *pspec; > + > + g_klass->get_property = osinfo_variant_get_property; > + g_klass->set_property = osinfo_variant_set_property; > + g_type_class_add_private (klass, sizeof (OsinfoVariantPrivate)); > + > + /** > + * OsinfoVariant: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_variant_init (OsinfoVariant *variant) > +{ > + variant->priv = OSINFO_VARIANT_GET_PRIVATE(variant); > +} > + > +OsinfoVariant *osinfo_variant_new(const gchar *id) > +{ > + OsinfoVariant *variant; > + > + variant = g_object_new(OSINFO_TYPE_VARIANT, > + "id", id, > + NULL); > + > + return variant; > +} > + > +/** > + * osinfo_variant_get_name: > + * @variant: an #OsinfoVariant instance > + * > + * The name of the @variant > + * > + * Returns: (transfer none): the name, or NULL > + */ > +const gchar *osinfo_variant_get_name(OsinfoVariant *variant) > +{ > + return osinfo_entity_get_param_value(OSINFO_ENTITY(variant), > + OSINFO_VARIANT_PROP_NAME); > +} > +/* > + * Local variables: > + * indent-tabs-mode: nil > + * c-indent-level: 4 > + * c-basic-offset: 4 > + * End: > + */ > diff --git a/osinfo/osinfo_variant.h b/osinfo/osinfo_variant.h > new file mode 100644 > index 0000000..1c9aff4 > --- /dev/null > +++ b/osinfo/osinfo_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_VARIANT_H__ > +#define __OSINFO_VARIANT_H__ > + > +/* > + * Type macros. > + */ > +#define OSINFO_TYPE_VARIANT (osinfo_variant_get_type ()) > +#define OSINFO_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_VARIANT, OsinfoVariant)) > +#define OSINFO_IS_VARIANT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_VARIANT)) > +#define OSINFO_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_VARIANT, OsinfoVariantClass)) > +#define OSINFO_IS_VARIANT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_VARIANT)) > +#define OSINFO_VARIANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_VARIANT, OsinfoVariantClass)) > + > +typedef struct _OsinfoVariant OsinfoVariant; > + > +typedef struct _OsinfoVariantClass OsinfoVariantClass; > + > +typedef struct _OsinfoVariantPrivate OsinfoVariantPrivate; > + > +#define OSINFO_VARIANT_PROP_NAME "name" > + > +/* object */ > +struct _OsinfoVariant > +{ > + OsinfoEntity parent_instance; > + > + /* public */ > + > + /* private */ > + OsinfoVariantPrivate *priv; > +}; > + > +/* class */ > +struct _OsinfoVariantClass > +{ > + /*< private >*/ > + OsinfoEntityClass parent_class; > + > + /* class members */ > +}; > + > +GType osinfo_variant_get_type(void); > + > +OsinfoVariant *osinfo_variant_new(const gchar *id); > +const gchar *osinfo_variant_get_name(OsinfoVariant *variant); > + > +#endif /* __OSINFO_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..f928bc6 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_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:
pgpWrjy4Fk7fF.pgp
Description: PGP signature
_______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo