[gnome-software] Support the new AppStreamGlib v0.5 API



commit 4de9bc66873f6bb054fe0b4d26f2b24079c8d354
Author: Richard Hughes <richard hughsie com>
Date:   Mon Aug 3 12:40:49 2015 +0100

    Support the new AppStreamGlib v0.5 API

 src/plugins/gs-plugin-appstream.c |   12 ++++++++++++
 src/plugins/gs-plugin-fwupd.c     |   19 +++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index d124da4..4444eaf 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -239,7 +239,11 @@ gs_plugin_startup (GsPlugin *plugin, GError **error)
                if (*perc < 10) {
                        g_debug ("Adding keyword '%s' to %s",
                                 origin, as_app_get_id (app));
+#if AS_CHECK_VERSION(0,5,0)
+                       as_app_add_keyword (app, NULL, origin);
+#else
                        as_app_add_keyword (app, NULL, origin, -1);
+#endif
                }
        }
 
@@ -558,7 +562,11 @@ gs_plugin_refine_item (GsPlugin *plugin,
        tmp = as_app_get_description (item, NULL);
        if (tmp != NULL) {
                _cleanup_free_ gchar *from_xml = NULL;
+#if AS_CHECK_VERSION(0,5,0)
+               from_xml = as_markup_convert_simple (tmp, error);
+#else
                from_xml = as_markup_convert_simple (tmp, -1, error);
+#endif
                if (from_xml == NULL) {
                        g_prefix_error (error, "trying to parse '%s': ", tmp);
                        return FALSE;
@@ -1045,7 +1053,11 @@ gs_plugin_add_categories_for_app (GList *list, AsApp *app)
                                gs_category_add_subcategory (parent, category);
                                g_object_unref (category);
                        }
+#if AS_CHECK_VERSION(0,5,0)
+                       as_app_add_category (app, gs_category_get_id (category));
+#else
                        as_app_add_category (app, gs_category_get_id (category), -1);
+#endif
                        gs_category_increment_size (category);
                }
        }
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index b58626b..fd14689 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -350,9 +350,15 @@ gs_plugin_add_update_app (GsPlugin *plugin,
        gs_app_set_metadata (app, "DataDir::desktop-icon", "application-x-firmware");
        if (update_desc != NULL) {
                _cleanup_free_ gchar *md = NULL;
+#if AS_CHECK_VERSION(0,5,0)
+               md = as_markup_convert (update_desc,
+                                       AS_MARKUP_CONVERT_FORMAT_MARKDOWN,
+                                       NULL);
+#else
                md = as_markup_convert (update_desc, -1,
                                        AS_MARKUP_CONVERT_FORMAT_MARKDOWN,
                                        NULL);
+#endif
                gs_app_set_update_details (app, md);
        }
        gs_plugin_add_app (list, app);
@@ -360,7 +366,11 @@ gs_plugin_add_update_app (GsPlugin *plugin,
        /* create icon */
        icon = as_icon_new ();
        as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+#if AS_CHECK_VERSION(0,5,0)
+       as_icon_set_name (icon, "application-x-firmware");
+#else
        as_icon_set_name (icon, "application-x-firmware", -1);
+#endif
        gs_app_set_icon (app, icon);
 
        return TRUE;
@@ -1052,8 +1062,13 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
                                            g_variant_get_string (variant, NULL));
                } else if (g_strcmp0 (key, "Description") == 0) {
                        _cleanup_free_ gchar *tmp = NULL;
+#if AS_CHECK_VERSION(0,5,0)
+                       tmp = as_markup_convert (g_variant_get_string (variant, NULL),
+                                                AS_MARKUP_CONVERT_FORMAT_SIMPLE, NULL);
+#else
                        tmp = as_markup_convert (g_variant_get_string (variant, NULL), -1,
                                                 AS_MARKUP_CONVERT_FORMAT_SIMPLE, NULL);
+#endif
                        if (tmp != NULL)
                                gs_app_set_description (app, GS_APP_QUALITY_HIGHEST, tmp);
                } else if (g_strcmp0 (key, "UrlHomepage") == 0) {
@@ -1070,7 +1085,11 @@ gs_plugin_filename_to_app (GsPlugin *plugin,
        /* create icon */
        icon = as_icon_new ();
        as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+#if AS_CHECK_VERSION(0,5,0)
+       as_icon_set_name (icon, "application-x-firmware");
+#else
        as_icon_set_name (icon, "application-x-firmware", -1);
+#endif
        gs_app_set_icon (app, icon);
 
        gs_plugin_add_app (list, app);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]