[gnome-software/gnome-3-22] trivial: Move out some shared functionality for creating a GsApp from a AsApp
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] trivial: Move out some shared functionality for creating a GsApp from a AsApp
- Date: Mon, 7 Nov 2016 13:36:56 +0000 (UTC)
commit 111432abd75fc9e34e42ad7c0ec249a94bbcd525
Author: Richard Hughes <richard hughsie com>
Date: Tue Sep 13 16:38:03 2016 +0100
trivial: Move out some shared functionality for creating a GsApp from a AsApp
(cherry picked from commit 5ef1cc6d0e6d0acab23f0d91346aafb3ba876dcb)
src/plugins/gs-appstream.c | 14 ++++++++++++++
src/plugins/gs-appstream.h | 2 ++
src/plugins/gs-plugin-appstream.c | 26 ++++++--------------------
3 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 5850dd0..76a53a4 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -27,6 +27,20 @@
#define GS_APPSTREAM_MAX_SCREENSHOTS 5
+GsApp *
+gs_appstream_create_app (GsPlugin *plugin, AsApp *item)
+{
+ const gchar *unique_id = as_app_get_unique_id (item);
+ GsApp *app = gs_plugin_cache_lookup (plugin, unique_id);
+ if (app == NULL) {
+ app = gs_app_new (as_app_get_id (item));
+ gs_app_set_metadata (app, "GnomeSoftware::Creator",
+ gs_plugin_get_name (plugin));
+ gs_plugin_cache_add (plugin, unique_id, app);
+ }
+ return app;
+}
+
static AsIcon *
gs_appstream_get_icon_by_kind (AsApp *app, AsIconKind icon_kind)
{
diff --git a/src/plugins/gs-appstream.h b/src/plugins/gs-appstream.h
index 6e2a4d6..f17370d 100644
--- a/src/plugins/gs-appstream.h
+++ b/src/plugins/gs-appstream.h
@@ -26,6 +26,8 @@
G_BEGIN_DECLS
+GsApp *gs_appstream_create_app (GsPlugin *plugin,
+ AsApp *item);
gboolean gs_appstream_refine_app (GsPlugin *plugin,
GsApp *app,
AsApp *item,
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 77b005a..cc1b0e6 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -401,20 +401,6 @@ gs_plugin_refine_from_pkgname (GsPlugin *plugin,
return gs_appstream_refine_app (plugin, app, item, error);
}
-static GsApp *
-gs_plugin_appstream_create_app (GsPlugin *plugin, AsApp *item)
-{
- const gchar *unique_id = as_app_get_unique_id (item);
- GsApp *app = gs_plugin_cache_lookup (plugin, unique_id);
- if (app == NULL) {
- app = gs_app_new (as_app_get_id (item));
- gs_app_set_metadata (app, "GnomeSoftware::Creator",
- gs_plugin_get_name (plugin));
- gs_plugin_cache_add (plugin, unique_id, app);
- }
- return app;
-}
-
gboolean
gs_plugin_add_distro_upgrades (GsPlugin *plugin,
GsAppList *list,
@@ -435,7 +421,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
continue;
/* create */
- app = gs_plugin_appstream_create_app (plugin, item);
+ app = gs_appstream_create_app (plugin, item);
gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
if (!gs_appstream_refine_app (plugin, app, item, error))
@@ -504,7 +490,7 @@ gs_plugin_appstream_add_wildcards (GsPlugin *plugin,
/* new app */
g_debug ("found %s for wildcard %s",
as_app_get_id (item), id);
- new = gs_plugin_appstream_create_app (plugin, item);
+ new = gs_appstream_create_app (plugin, item);
if (!gs_appstream_refine_app (plugin, new, item, error))
return FALSE;
gs_app_list_add (list, new);
@@ -597,7 +583,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
continue;
/* add all the data we can */
- app = gs_plugin_appstream_create_app (plugin, item);
+ app = gs_appstream_create_app (plugin, item);
if (!gs_appstream_refine_app (plugin, app, item, error))
return FALSE;
gs_app_list_add (list, app);
@@ -693,7 +679,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
item = g_ptr_array_index (array, i);
if (as_app_get_state (item) == AS_APP_STATE_INSTALLED) {
g_autoptr(GsApp) app = NULL;
- app = gs_plugin_appstream_create_app (plugin, item);
+ app = gs_appstream_create_app (plugin, item);
if (!gs_appstream_refine_app (plugin, app, item, error))
return FALSE;
gs_app_list_add (list, app);
@@ -788,7 +774,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
continue;
if (!as_app_has_kudo (item, "GnomeSoftware::popular"))
continue;
- app = gs_plugin_appstream_create_app (plugin, item);
+ app = gs_appstream_create_app (plugin, item);
gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
gs_app_list_add (list, app);
}
@@ -819,7 +805,7 @@ gs_plugin_add_featured (GsPlugin *plugin,
continue;
if (as_app_get_metadata_item (item, "GnomeSoftware::FeatureTile-css") == NULL)
continue;
- app = gs_plugin_appstream_create_app (plugin, item);
+ app = gs_appstream_create_app (plugin, item);
if (!gs_appstream_refine_app (plugin, app, item, error))
return FALSE;
gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]