[Libosinfo] [PATCH 1/5] Add an optional 'is-pre-release' tag to OS entries

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Thu Nov 21 17:52:53 UTC 2013


Applications can use this to determine if an OS is just a pre-release.
For example, alpha and beta pre-releases of Fedora etc.

Co-author: Christophe Fergeau <cfergeau at redhat.com>
---
 data/schemas/libosinfo.rng |  5 +++++
 osinfo/libosinfo.syms      |  4 ++++
 osinfo/osinfo_loader.c     |  1 +
 osinfo/osinfo_os.c         | 17 +++++++++++++++++
 osinfo/osinfo_os.h         |  6 ++++--
 5 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index d491832..786fc3a 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -481,6 +481,11 @@
         <optional>
           <ref name='devices-rel'/>
         </optional>
+        <optional>
+          <element name='is-pre-release'>
+            <ref name='bool'/>
+          </element>
+        </optional>
         <zeroOrMore>
           <ref name='resources'/>
         </zeroOrMore>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index ccd7c30..5d620aa 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -444,6 +444,10 @@ LIBOSINFO_0.2.8 {
 	osinfo_product_get_release_date_string;
 } LIBOSINFO_0.2.7;
 
+LIBOSINFO_0.2.9 {
+	osinfo_os_get_is_pre_release;
+} LIBOSINFO_0.2.8;
+
 /* Symbols in next release...
 
   LIBOSINFO_0.0.2 {
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 9873cbd..1b0dad2 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1166,6 +1166,7 @@ static void osinfo_loader_os(OsinfoLoader *loader,
     const OsinfoEntityKey keys[] = {
         { OSINFO_OS_PROP_FAMILY, G_TYPE_STRING },
         { OSINFO_OS_PROP_DISTRO, G_TYPE_STRING },
+        { OSINFO_OS_PROP_IS_PRE_RELEASE, G_TYPE_BOOLEAN },
         { NULL, G_TYPE_INVALID }
     };
 
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 638d9c1..fe0bacd 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -402,6 +402,23 @@ const gchar *osinfo_os_get_distro(OsinfoOs *os)
 }
 
 /**
+ * osinfo_os_get_is_pre_release:
+ * @os: an #OsinfoOs
+ *
+ * Use this to determine if @os is just a pre-release. For example
+ * alpha and beta releases of Fedora etc.
+ *
+ * Returns: (transfer none): %TRUE if @os is a pre-release, %FALSE otherwise.
+ */
+gboolean osinfo_os_get_is_pre_release(OsinfoOs *os)
+{
+    g_return_val_if_fail(OSINFO_IS_OS(os), FALSE);
+
+    return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(os),
+                                                 "is-pre-release");
+}
+
+/**
  * osinfo_os_get_media_list:
  * @os: an operating system
  *
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index d667e3b..a7531f7 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -55,8 +55,9 @@ typedef struct _OsinfoOsClass   OsinfoOsClass;
 
 typedef struct _OsinfoOsPrivate OsinfoOsPrivate;
 
-#define OSINFO_OS_PROP_FAMILY    "family"
-#define OSINFO_OS_PROP_DISTRO    "distro"
+#define OSINFO_OS_PROP_FAMILY      "family"
+#define OSINFO_OS_PROP_DISTRO      "distro"
+#define OSINFO_OS_PROP_IS_PRE_RELEASE "is-pre-release"
 
 /* object */
 struct _OsinfoOs
@@ -93,6 +94,7 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil
 OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev);
 const gchar *osinfo_os_get_family(OsinfoOs *os);
 const gchar *osinfo_os_get_distro(OsinfoOs *os);
+gboolean osinfo_os_get_is_pre_release(OsinfoOs *os);
 OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
 void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
 OsinfoTreeList *osinfo_os_get_tree_list(OsinfoOs *os);
-- 
1.8.4.2




More information about the Libosinfo mailing list