From 88fc05d2a83e2d5588d4f39e9bba0cb7abeb07de Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Sun, 8 Oct 2023 20:22:44 +0200
Subject: [PATCH] Adjust to build with AppStream 1.0 as well as 0.16.x

---
 lib/gs-app.c                             |  4 ++
 lib/gs-appstream.c                       | 61 +++++++++++++++++++-----
 lib/gs-utils.c                           |  8 ++--
 meson.build                              | 22 +--------
 plugins/core/gs-plugin-appstream.c       |  8 ----
 plugins/fwupd/gs-fwupd-app.c             |  8 ++++
 plugins/fwupd/gs-plugin-fwupd.c          |  4 ++
 src/gs-hardware-support-context-dialog.c |  6 +++
 src/gs-repos-dialog.c                    |  4 ++
 src/gs-screenshot-carousel.c             |  4 +-
 src/gs-screenshot-image.c                | 41 ++++++++++++----
 src/gs-screenshot-image.h                |  7 +++
 subprojects/appstream.wrap               |  2 +-
 13 files changed, 122 insertions(+), 57 deletions(-)

diff --git a/lib/gs-app.c b/lib/gs-app.c
index 2308de504d..ea348f8c01 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -609,7 +609,11 @@ gs_app_to_string_append (GsApp *app, GString *str)
 		AsScreenshot *ss = g_ptr_array_index (priv->screenshots, i);
 		g_autofree gchar *key = NULL;
 		tmp = as_screenshot_get_caption (ss);
+#if AS_CHECK_VERSION(1, 0, 0)
+		im = as_screenshot_get_image (ss, 0, 0, 1);
+#else
 		im = as_screenshot_get_image (ss, 0, 0);
+#endif
 		if (im == NULL)
 			continue;
 		key = g_strdup_printf ("screenshot-%02u", i);
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index deca176dcf..6504d6f25e 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1011,8 +1011,11 @@ gs_appstream_refine_app_relation (GsApp           *app,
 			as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_CONTROL);
 			as_relation_set_value_control_kind (relation, as_control_kind_from_string (xb_node_get_text (child)));
 		} else if (g_str_equal (item_kind, "display_length")) {
-			AsDisplayLengthKind display_length_kind;
 			const gchar *compare;
+			const gchar *side;
+#if !AS_CHECK_VERSION(1, 0, 0)
+			AsDisplayLengthKind display_length_kind;
+#endif
 
 			/* https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-relations-display_length */
 			as_relation_set_item_kind (relation, AS_RELATION_ITEM_KIND_DISPLAY_LENGTH);
@@ -1020,15 +1023,21 @@ gs_appstream_refine_app_relation (GsApp           *app,
 			compare = xb_node_get_attr (child, "compare");
 			as_relation_set_compare (relation, (compare != NULL) ? as_relation_compare_from_string (compare) : AS_RELATION_COMPARE_GE);
 
+#if AS_CHECK_VERSION(1, 0, 0)
+			side = xb_node_get_attr (child, "side");
+			as_relation_set_display_side_kind (relation, (side != NULL) ? as_display_side_kind_from_string (side) : AS_DISPLAY_SIDE_KIND_SHORTEST);
+			as_relation_set_value_px (relation, xb_node_get_text_as_uint (child));
+#else
 			display_length_kind = as_display_length_kind_from_string (xb_node_get_text (child));
 			if (display_length_kind != AS_DISPLAY_LENGTH_KIND_UNKNOWN) {
 				/* Ignore the `side` attribute */
 				as_relation_set_value_display_length_kind (relation, display_length_kind);
 			} else {
-				const gchar *side = xb_node_get_attr (child, "side");
+				side = xb_node_get_attr (child, "side");
 				as_relation_set_display_side_kind (relation, (side != NULL) ? as_display_side_kind_from_string (side) : AS_DISPLAY_SIDE_KIND_SHORTEST);
 				as_relation_set_value_px (relation, xb_node_get_text_as_uint (child));
 			}
+#endif
 		} else {
 			g_debug ("Relation type ‘%s’ not currently supported for %s; ignoring",
 				 item_kind, gs_app_get_id (app));
@@ -1472,7 +1481,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
 }
 
 typedef struct {
-	AsSearchTokenMatch	 match_value;
+	guint16			 match_value;
 	XbQuery			*query;
 } GsAppstreamSearchHelper;
 
@@ -1522,7 +1531,7 @@ gs_appstream_silo_search_component (GPtrArray *array, XbNode *component, const g
 }
 
 typedef struct {
-	AsSearchTokenMatch	match_value;
+	guint16			match_value;
 	const gchar		*xpath;
 } Query;
 
@@ -1539,6 +1548,11 @@ gs_appstream_do_search (GsPlugin *plugin,
 	g_autoptr(GPtrArray) array = g_ptr_array_new_with_free_func ((GDestroyNotify) gs_appstream_search_helper_free);
 	g_autoptr(GPtrArray) components = NULL;
 	g_autoptr(GTimer) timer = g_timer_new ();
+#if AS_CHECK_VERSION(1, 0, 0)
+	const guint16 component_id_weight = as_utils_get_tag_search_weight ("id");
+#else
+	const guint16 component_id_weight = AS_SEARCH_TOKEN_MATCH_ID;
+#endif
 
 	g_return_val_if_fail (GS_IS_PLUGIN (plugin), FALSE);
 	g_return_val_if_fail (XB_IS_SILO (silo), FALSE);
@@ -1585,7 +1599,7 @@ gs_appstream_do_search (GsPlugin *plugin,
 			 * Drop the ID token from it as it’s the highest
 			 * numeric value but isn’t visible to the user in the
 			 * UI, which leads to confusing results ordering. */
-			gs_app_set_match_value (app, match_value & (~AS_SEARCH_TOKEN_MATCH_ID));
+			gs_app_set_match_value (app, match_value & (~component_id_weight));
 			gs_app_list_add (list, app);
 
 			if (gs_app_get_kind (app) == AS_COMPONENT_KIND_ADDON) {
@@ -1624,18 +1638,32 @@ gs_appstream_search (GsPlugin *plugin,
 		     GCancellable *cancellable,
 		     GError **error)
 {
+#if AS_CHECK_VERSION(1, 0, 0)
+	guint16 pkgname_weight = as_utils_get_tag_search_weight ("pkgname");
+	guint16 name_weight = as_utils_get_tag_search_weight ("name");
+	guint16 id_weight = as_utils_get_tag_search_weight ("id");
 	const Query queries[] = {
-		#ifdef HAVE_AS_SEARCH_TOKEN_MATCH_MEDIATYPE
-		{ AS_SEARCH_TOKEN_MATCH_MEDIATYPE,	"mimetypes/mimetype[text()~=stem(?)]" },
-		#else
-		{ AS_SEARCH_TOKEN_MATCH_MIMETYPE,	"mimetypes/mimetype[text()~=stem(?)]" },
-		#endif
+		{ as_utils_get_tag_search_weight ("mediatype"),	"provides/mediatype[text()~=stem(?)]" },
 		/* Search once with a tokenize-and-casefold operator (`~=`) to support casefolded
 		 * full-text search, then again using substring matching (`contains()`), to
 		 * support prefix matching. Only do the prefix matches on a few fields, and at a
 		 * lower priority, otherwise things will get confusing.
-		 * 
+		 *
 		 * See https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2277 */
+		{ pkgname_weight,				"pkgname[text()~=stem(?)]" },
+		{ pkgname_weight / 2,				"pkgname[contains(text(),stem(?))]" },
+		{ as_utils_get_tag_search_weight ("summary"),	"summary[text()~=stem(?)]" },
+		{ name_weight,					"name[text()~=stem(?)]" },
+		{ name_weight / 2,				"name[contains(text(),stem(?))]" },
+		{ as_utils_get_tag_search_weight ("keyword"),	"keywords/keyword[text()~=stem(?)]" },
+		{ id_weight,					"id[text()~=stem(?)]" },
+		{ id_weight,					"launchable[text()~=stem(?)]" },
+		{ as_utils_get_tag_search_weight ("origin"),	"../components[@origin~=stem(?)]" },
+		{ 0,						NULL }
+	};
+#else
+	const Query queries[] = {
+		{ AS_SEARCH_TOKEN_MATCH_MEDIATYPE,	"mimetypes/mimetype[text()~=stem(?)]" },
 		{ AS_SEARCH_TOKEN_MATCH_PKGNAME,	"pkgname[text()~=stem(?)]" },
 		{ AS_SEARCH_TOKEN_MATCH_PKGNAME / 2,	"pkgname[contains(text(),stem(?))]" },
 		{ AS_SEARCH_TOKEN_MATCH_SUMMARY,	"summary[text()~=stem(?)]" },
@@ -1647,6 +1675,7 @@ gs_appstream_search (GsPlugin *plugin,
 		{ AS_SEARCH_TOKEN_MATCH_ORIGIN,		"../components[@origin~=stem(?)]" },
 		{ AS_SEARCH_TOKEN_MATCH_NONE,		NULL }
 	};
+#endif
 
 	return gs_appstream_do_search (plugin, silo, values, queries, list, cancellable, error);
 }
@@ -1659,11 +1688,21 @@ gs_appstream_search_developer_apps (GsPlugin *plugin,
 				    GCancellable *cancellable,
 				    GError **error)
 {
+#if AS_CHECK_VERSION(1, 0, 0)
+	const Query queries[] = {
+		{ as_utils_get_tag_search_weight ("pkgname"), "developer/name[text()~=stem(?)]" },
+		{ as_utils_get_tag_search_weight ("summary"), "project_group[text()~=stem(?)]" },
+		/* for legacy support */
+		{ as_utils_get_tag_search_weight ("pkgname"), "developer_name[text()~=stem(?)]" },
+		{ 0,					      NULL }
+	};
+#else
 	const Query queries[] = {
 		{ AS_SEARCH_TOKEN_MATCH_PKGNAME,	"developer_name[text()~=stem(?)]" },
 		{ AS_SEARCH_TOKEN_MATCH_SUMMARY,	"project_group[text()~=stem(?)]" },
 		{ AS_SEARCH_TOKEN_MATCH_NONE,		NULL }
 	};
+#endif
 
 	return gs_appstream_do_search (plugin, silo, values, queries, list, cancellable, error);
 }
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index cf9073025f..19e6ebd046 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1694,9 +1694,9 @@ gs_utils_gstring_replace (GString *str,
 			  const gchar *find,
 			  const gchar *replace)
 {
-	#ifdef HAVE_AS_GSTRING_REPLACE_WITH_FOUR_ARGS
+#if AS_CHECK_VERSION(1, 0, 0)
 	as_gstring_replace (str, find, replace, 0);
-	#else
-	as_gstring_replace (str, find, replace);
-	#endif
+#else
+	as_gstring_replace2 (str, find, replace, 0);
+#endif
 }
diff --git a/meson.build b/meson.build
index bc19669dd5..8c82464cdb 100644
--- a/meson.build
+++ b/meson.build
@@ -113,7 +113,7 @@ add_project_arguments('-D_GNU_SOURCE', language : 'c')
 conf.set('HAVE_LINUX_UNISTD_H', cc.has_header('linux/unistd.h'))
 
 appstream = dependency('appstream',
-  version : '>= 0.14.0',
+  version : '>= 0.16.4',
   fallback : ['appstream', 'appstream_dep'],
   default_options : [
     'docs=false',
@@ -121,26 +121,6 @@ appstream = dependency('appstream',
     'install-docs=false'
   ]
 )
-if appstream.type_name() == 'internal'
-else
-  if meson.get_compiler('c').has_header_symbol('appstream.h', 'AS_SEARCH_TOKEN_MATCH_MEDIATYPE', dependencies: appstream)
-    conf.set('HAVE_AS_SEARCH_TOKEN_MATCH_MEDIATYPE', '1')
-  endif
-  if meson.get_compiler('c').has_header_symbol('appstream.h', 'AS_FORMAT_STYLE_CATALOG', dependencies: appstream)
-    conf.set('HAVE_AS_FORMAT_STYLE_CATALOG', '1')
-  endif
-  if meson.get_compiler('c').has_function('as_metadata_components_to_catalog', prefix: '#include <appstream.h>', dependencies: appstream)
-    conf.set('HAVE_AS_METADATA_COMPONENTS_TO_CATALOG', '1')
-  endif
-  if meson.get_compiler('c').links('''#include <appstream.h>
-      int main (void)
-      {
-         as_gstring_replace (NULL, "a", "b", 0);
-         return 0;
-      }''', name: 'as_gstring_replace() has four arguments', dependencies: appstream)
-    conf.set('HAVE_AS_GSTRING_REPLACE_WITH_FOUR_ARGS', '1')
-  endif
-endif
 
 gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.32.0')
 libxmlb = dependency('xmlb', version : '>= 0.1.7', fallback : ['libxmlb', 'libxmlb_dep'])
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index cf9f3022b1..ef3226a591 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -414,11 +414,7 @@ gs_plugin_appstream_load_dep11_cb (XbBuilderSource *self,
 	if (bytes == NULL)
 		return NULL;
 
-	#ifdef HAVE_AS_FORMAT_STYLE_CATALOG
 	as_metadata_set_format_style (mdata, AS_FORMAT_STYLE_CATALOG);
-	#else
-	as_metadata_set_format_style (mdata, AS_FORMAT_STYLE_COLLECTION);
-	#endif
 	as_metadata_parse_bytes (mdata,
 				 bytes,
 				 AS_FORMAT_KIND_YAML,
@@ -428,11 +424,7 @@ gs_plugin_appstream_load_dep11_cb (XbBuilderSource *self,
 		return NULL;
 	}
 
-	#ifdef HAVE_AS_METADATA_COMPONENTS_TO_CATALOG
 	xml = as_metadata_components_to_catalog (mdata, AS_FORMAT_KIND_XML, &tmp_error);
-	#else
-	xml = as_metadata_components_to_collection (mdata, AS_FORMAT_KIND_XML, &tmp_error);
-	#endif
 	if (xml == NULL) {
 		// This API currently returns NULL if there is nothing to serialize, so we
 		// have to test if this is an error or not.
diff --git a/plugins/fwupd/gs-fwupd-app.c b/plugins/fwupd/gs-fwupd-app.c
index 6dcda6ee92..5d3254da59 100644
--- a/plugins/fwupd/gs-fwupd-app.c
+++ b/plugins/fwupd/gs-fwupd-app.c
@@ -164,7 +164,11 @@ gs_fwupd_app_set_from_device (GsApp *app,
 		gs_app_set_install_date (app, fwupd_device_get_created (dev));
 	if (fwupd_device_get_description (dev) != NULL) {
 		g_autofree gchar *tmp = NULL;
+#if AS_CHECK_VERSION(1, 0, 0)
+		tmp = as_markup_convert (fwupd_device_get_description (dev), AS_MARKUP_KIND_TEXT, NULL);
+#else
 		tmp = as_markup_convert_simple (fwupd_device_get_description (dev), NULL);
+#endif
 		if (tmp != NULL)
 			gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp);
 	}
@@ -402,7 +406,11 @@ gs_fwupd_app_set_from_release (GsApp *app, FwupdRelease *rel)
 	}
 	if (fwupd_release_get_description (rel) != NULL) {
 		g_autofree gchar *tmp = NULL;
+#if AS_CHECK_VERSION(1, 0, 0)
+		tmp = as_markup_convert (fwupd_release_get_description (rel), AS_MARKUP_KIND_TEXT, NULL);
+#else
 		tmp = as_markup_convert_simple (fwupd_release_get_description (rel), NULL);
+#endif
 		if (tmp != NULL)
 			gs_app_set_update_details_text (app, tmp);
 	}
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index d8c0cd2dd4..a9b05028a0 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -727,7 +727,11 @@ gs_plugin_add_updates (GsPlugin *plugin,
 				g_autofree gchar *desc = NULL;
 				if (fwupd_release_get_description (rel) == NULL)
 					continue;
+#if AS_CHECK_VERSION(1, 0, 0)
+				desc = as_markup_convert (fwupd_release_get_description (rel), AS_MARKUP_KIND_TEXT, NULL);
+#else
 				desc = as_markup_convert_simple (fwupd_release_get_description (rel), NULL);
+#endif
 				if (desc == NULL)
 					continue;
 				g_string_append_printf (update_desc,
diff --git a/src/gs-hardware-support-context-dialog.c b/src/gs-hardware-support-context-dialog.c
index 0e48c8c266..14653401de 100644
--- a/src/gs-hardware-support-context-dialog.c
+++ b/src/gs-hardware-support-context-dialog.c
@@ -461,6 +461,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor     *monitor,
 			AsRelationCompare comparator = as_relation_get_compare (relation);
 			Range current_display_comparand, relation_comparand;
 
+#if !AS_CHECK_VERSION(1, 0, 0)
 			/* From https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-requires-recommends-display_length */
 			Range display_lengths[] = {
 				[AS_DISPLAY_LENGTH_KIND_XSMALL] = { 0, 360 },
@@ -469,6 +470,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor     *monitor,
 				[AS_DISPLAY_LENGTH_KIND_LARGE] = { 1024, 3840 },
 				[AS_DISPLAY_LENGTH_KIND_XLARGE] = { 3840, G_MAXUINT },
 			};
+#endif
 
 			any_display_relations_set = TRUE;
 
@@ -485,11 +487,14 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor     *monitor,
 			case AS_DISPLAY_SIDE_KIND_LAST:
 			default:
 				current_display_comparand.min = current_display_comparand.max = MAX (current_screen_size.width, current_screen_size.height);
+#if !AS_CHECK_VERSION(1, 0, 0)
 				relation_comparand.min = display_lengths[as_relation_get_value_display_length_kind (relation)].min;
 				relation_comparand.max = display_lengths[as_relation_get_value_display_length_kind (relation)].max;
+#endif
 				break;
 			}
 
+#if !AS_CHECK_VERSION(1, 0, 0)
 			if (evaluate_display_comparison (display_lengths[AS_DISPLAY_LENGTH_KIND_SMALL], comparator, relation_comparand)) {
 				*mobile_relation_kind_out = max_relation_kind (*mobile_relation_kind_out, as_relation_get_kind (relation));
 				*mobile_match_out = TRUE;
@@ -499,6 +504,7 @@ gs_hardware_support_context_dialog_get_display_support (GdkMonitor     *monitor,
 				*desktop_relation_kind_out = max_relation_kind (*desktop_relation_kind_out, as_relation_get_kind (relation));
 				*desktop_match_out = TRUE;
 			}
+#endif
 
 			if (evaluate_display_comparison (current_display_comparand, comparator, relation_comparand)) {
 				*current_relation_kind_out = max_relation_kind (*current_relation_kind_out, as_relation_get_kind (relation));
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index c41c4944a1..7dac0416d9 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -154,7 +154,11 @@ enable_repo (GsReposDialog *dialog,
 		g_autoptr(GError) error = NULL;
 
 		/* convert from AppStream markup */
+#if AS_CHECK_VERSION(1, 0, 0)
+		message = as_markup_convert (gs_app_get_agreement (repo), AS_MARKUP_KIND_TEXT, &error);
+#else
 		message = as_markup_convert_simple (gs_app_get_agreement (repo), &error);
+#endif
 		if (message == NULL) {
 			/* failed, so just try and show the original markup */
 			message = g_strdup (gs_app_get_agreement (repo));
diff --git a/src/gs-screenshot-carousel.c b/src/gs-screenshot-carousel.c
index 04bbf86a1e..d269af6605 100644
--- a/src/gs-screenshot-carousel.c
+++ b/src/gs-screenshot-carousel.c
@@ -141,8 +141,8 @@ gs_screenshot_carousel_load_screenshots (GsScreenshotCarousel *self, GsApp *app,
 		gtk_widget_set_can_focus (gtk_widget_get_first_child (ssimg), FALSE);
 		gs_screenshot_image_set_screenshot (GS_SCREENSHOT_IMAGE (ssimg), ss);
 		gs_screenshot_image_set_size (GS_SCREENSHOT_IMAGE (ssimg),
-					      AS_IMAGE_NORMAL_WIDTH,
-					      AS_IMAGE_NORMAL_HEIGHT);
+					      GS_IMAGE_NORMAL_WIDTH,
+					      GS_IMAGE_NORMAL_HEIGHT);
 		gtk_widget_add_css_class (ssimg, "screenshot-image-main");
 		gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), cancellable);
 
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 93dba68f96..6b4db03d06 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -293,13 +293,13 @@ gs_screenshot_image_save_downloaded_img (GsScreenshotImage *ssimg,
 	if (images->len > 1)
 		return TRUE;
 
-	if (width == AS_IMAGE_THUMBNAIL_WIDTH &&
-	    height == AS_IMAGE_THUMBNAIL_HEIGHT) {
-		width = AS_IMAGE_NORMAL_WIDTH;
-		height = AS_IMAGE_NORMAL_HEIGHT;
+	if (width == GS_IMAGE_THUMBNAIL_WIDTH &&
+	    height == GS_IMAGE_THUMBNAIL_HEIGHT) {
+		width = GS_IMAGE_NORMAL_WIDTH;
+		height = GS_IMAGE_NORMAL_HEIGHT;
 	} else {
-		width = AS_IMAGE_THUMBNAIL_WIDTH;
-		height = AS_IMAGE_THUMBNAIL_HEIGHT;
+		width = GS_IMAGE_THUMBNAIL_WIDTH;
+		height = GS_IMAGE_THUMBNAIL_HEIGHT;
 	}
 
 	width *= ssimg->scale;
@@ -591,16 +591,30 @@ gs_screenshot_image_get_url (GsScreenshotImage *ssimg)
 	} else if (as_screenshot_get_media_kind (ssimg->screenshot) == AS_SCREENSHOT_MEDIA_KIND_IMAGE) {
 		AsImage *im;
 
+#if AS_CHECK_VERSION(1, 0, 0)
+		im = as_screenshot_get_image (ssimg->screenshot,
+					      ssimg->width,
+					      ssimg->height,
+					      ssimg->scale);
+#else
 		im = as_screenshot_get_image (ssimg->screenshot,
 					      ssimg->width * ssimg->scale,
 					      ssimg->height * ssimg->scale);
+#endif
 
 		/* if we've failed to load a HiDPI image, fallback to LoDPI */
 		if (im == NULL && ssimg->scale > 1) {
 			ssimg->scale = 1;
+#if AS_CHECK_VERSION(1, 0, 0)
+			im = as_screenshot_get_image (ssimg->screenshot,
+						      ssimg->width,
+						      ssimg->height,
+						      1);
+#else
 			im = as_screenshot_get_image (ssimg->screenshot,
 						      ssimg->width,
 						      ssimg->height);
+#endif
 		}
 
 		if (im)
@@ -707,15 +721,22 @@ gs_screenshot_image_load_async (GsScreenshotImage *ssimg,
 	 * smaller version of it straight away */
 	if (!ssimg->showing_image &&
 	    as_screenshot_get_media_kind (ssimg->screenshot) == AS_SCREENSHOT_MEDIA_KIND_IMAGE &&
-	    ssimg->width > AS_IMAGE_THUMBNAIL_WIDTH &&
-	    ssimg->height > AS_IMAGE_THUMBNAIL_HEIGHT) {
+	    ssimg->width > GS_IMAGE_THUMBNAIL_WIDTH &&
+	    ssimg->height > GS_IMAGE_THUMBNAIL_HEIGHT) {
 		const gchar *url_thumb;
 		g_autofree gchar *basename_thumb = NULL;
 		g_autofree gchar *cache_kind_thumb = NULL;
 		AsImage *im;
+#if AS_CHECK_VERSION(1, 0, 0)
 		im = as_screenshot_get_image (ssimg->screenshot,
-					      AS_IMAGE_THUMBNAIL_WIDTH * ssimg->scale,
-					      AS_IMAGE_THUMBNAIL_HEIGHT * ssimg->scale);
+					      GS_IMAGE_THUMBNAIL_WIDTH,
+					      GS_IMAGE_THUMBNAIL_HEIGHT,
+					      ssimg->scale);
+#else
+		im = as_screenshot_get_image (ssimg->screenshot,
+					      GS_IMAGE_THUMBNAIL_WIDTH * ssimg->scale,
+					      GS_IMAGE_THUMBNAIL_HEIGHT * ssimg->scale);
+#endif
 		url_thumb = as_image_get_url (im);
 		basename_thumb = gs_screenshot_get_cachefn_for_url (url_thumb);
 		cache_kind_thumb = g_build_filename ("screenshots", "112x63", NULL);
diff --git a/src/gs-screenshot-image.h b/src/gs-screenshot-image.h
index 1f6cf81ce6..6e45f5d20a 100644
--- a/src/gs-screenshot-image.h
+++ b/src/gs-screenshot-image.h
@@ -21,6 +21,13 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GsScreenshotImage, gs_screenshot_image, GS, SCREENSHOT_IMAGE, GtkWidget)
 
+#define GS_IMAGE_LARGE_HEIGHT		423
+#define GS_IMAGE_LARGE_WIDTH		752
+#define GS_IMAGE_NORMAL_HEIGHT		351
+#define GS_IMAGE_NORMAL_WIDTH		624
+#define GS_IMAGE_THUMBNAIL_HEIGHT	63
+#define GS_IMAGE_THUMBNAIL_WIDTH 	112
+
 GtkWidget	*gs_screenshot_image_new		(SoupSession		*session);
 
 AsScreenshot	*gs_screenshot_image_get_screenshot	(GsScreenshotImage	*ssimg);
diff --git a/subprojects/appstream.wrap b/subprojects/appstream.wrap
index 6f0beb0cbc..5763a32c64 100644
--- a/subprojects/appstream.wrap
+++ b/subprojects/appstream.wrap
@@ -1,5 +1,5 @@
 [wrap-git]
 directory = appstream
 url = https://github.com/ximion/appstream.git
-revision = v0.14.1
+revision = v0.16.3
 depth = 1
-- 
GitLab

