[virt-tools-list] [[libosinfo V2]] API for getting product logo URLs

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Tue Aug 14 09:15:13 UTC 2012


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

While we will be able to neither ship any product logos nor provide URLs
to them for legal reasons, this patch simply adds API for easily fetch
URLs from *a* libosinfo database.
---
 osinfo/libosinfo.syms   |  5 +++++
 osinfo/osinfo_loader.c  |  3 ++-
 osinfo/osinfo_product.c | 24 +++++++++++++++++++++++-
 osinfo/osinfo_product.h |  2 ++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index dcf12ab..5ef304b 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -235,6 +235,11 @@ LIBOSINFO_0.1.0 {
 	osinfo_treelist_new_union;
 } LIBOSINFO_0.0.6;
 
+LIBOSINFO_0.1.3 {
+    global:
+	osinfo_product_get_logo;
+} LIBOSINFO_0.1.0;
+
 /* Symbols in next release...
 
   LIBOSINFO_0.0.2 {
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 21d9c7a..bc30241 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -33,6 +33,7 @@
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
 #include <libxml/xmlreader.h>
+#include <libxml/uri.h>
 
 G_DEFINE_TYPE (OsinfoLoader, osinfo_loader, G_TYPE_OBJECT);
 
@@ -373,6 +374,7 @@ static void osinfo_loader_product(OsinfoLoader *loader,
         OSINFO_PRODUCT_PROP_NAME,
         OSINFO_PRODUCT_PROP_VENDOR,
         OSINFO_PRODUCT_PROP_VERSION,
+        OSINFO_PRODUCT_PROP_LOGO,
         OSINFO_PRODUCT_PROP_SHORT_ID,
         OSINFO_PRODUCT_PROP_RELEASE_DATE,
         OSINFO_PRODUCT_PROP_EOL_DATE,
@@ -384,7 +386,6 @@ static void osinfo_loader_product(OsinfoLoader *loader,
     if (error_is_set(err))
         return;
 
-
     osinfo_loader_product_relshp(loader, product,
                                  OSINFO_PRODUCT_RELATIONSHIP_DERIVES_FROM,
                                  "./derives-from",
diff --git a/osinfo/osinfo_product.c b/osinfo/osinfo_product.c
index cc430c5..f330209 100644
--- a/osinfo/osinfo_product.c
+++ b/osinfo/osinfo_product.c
@@ -76,6 +76,7 @@ enum {
     PROP_VENDOR,
     PROP_VERSION,
     PROP_CODENAME,
+    PROP_LOGO,
 };
 
 static void osinfo_product_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED)
@@ -130,6 +131,9 @@ osinfo_product_get_property (GObject    *object,
     case PROP_CODENAME:
         g_value_set_string (value,
                             osinfo_product_get_codename (product));
+    case PROP_LOGO:
+        g_value_set_string (value,
+                            osinfo_product_get_logo (product));
         break;
 
     default:
@@ -224,6 +228,21 @@ osinfo_product_class_init (OsinfoProductClass *klass)
                                  G_PARAM_STATIC_NICK |
                                  G_PARAM_STATIC_BLURB);
     g_object_class_install_property (g_klass, PROP_NAME, pspec);
+
+    /**
+     * OsinfoProduct::logo:
+     *
+     * The URI of the logo of the product.
+     */
+    pspec = g_param_spec_string ("logo",
+                                 "Logo",
+                                 "URI of the logo",
+                                 NULL /* default value */,
+                                 G_PARAM_READABLE |
+                                 G_PARAM_STATIC_NAME |
+                                 G_PARAM_STATIC_NICK |
+                                 G_PARAM_STATIC_BLURB);
+    g_object_class_install_property (g_klass, PROP_LOGO, pspec);
 }
 
 static void
@@ -354,7 +373,10 @@ GDate *osinfo_product_get_eol_date(OsinfoProduct *prod)
     return date_from_string(str);
 }
 
-
+const gchar *osinfo_product_get_logo(OsinfoProduct *prod)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(prod), OSINFO_PRODUCT_PROP_LOGO);
+}
 
 /*
  * Local variables:
diff --git a/osinfo/osinfo_product.h b/osinfo/osinfo_product.h
index fa63877..57bd29b 100644
--- a/osinfo/osinfo_product.h
+++ b/osinfo/osinfo_product.h
@@ -51,6 +51,7 @@ typedef struct _OsinfoProductPrivate OsinfoProductPrivate;
 #define OSINFO_PRODUCT_PROP_RELEASE_DATE "release-date"
 #define OSINFO_PRODUCT_PROP_EOL_DATE     "eol-date"
 #define OSINFO_PRODUCT_PROP_CODENAME     "codename"
+#define OSINFO_PRODUCT_PROP_LOGO         "logo"
 
 /* object */
 struct _OsinfoProduct
@@ -94,6 +95,7 @@ const gchar *osinfo_product_get_release_date_string(OsinfoProduct *prod);
 const gchar *osinfo_product_get_eol_date_string(OsinfoProduct *prod);
 GDate *osinfo_product_get_release_date(OsinfoProduct *prod);
 GDate *osinfo_product_get_eol_date(OsinfoProduct *prod);
+const gchar *osinfo_product_get_logo(OsinfoProduct *prod);
 
 
 #endif /* __OSINFO_PRODUCT_H__ */
-- 
1.7.11.2




More information about the virt-tools-list mailing list