[gnome-software/wip/hughsie/unique_id: 2/5] Automatically set the unique ID when setting an ID with a prefix
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/unique_id: 2/5] Automatically set the unique ID when setting an ID with a prefix
- Date: Thu, 28 Jul 2016 16:42:36 +0000 (UTC)
commit eb1f3a722c8705c261343184010b379ff7a584b1
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 28 16:34:30 2016 +0100
Automatically set the unique ID when setting an ID with a prefix
This is added so we can port the plugins one at a time.
src/gs-app.c | 18 ++++++++++++++++--
src/gs-self-test.c | 6 +++---
src/plugins/gs-plugin-appstream.c | 4 +++-
src/plugins/gs-plugin-flatpak-system.c | 2 +-
src/plugins/gs-plugin-flatpak-user.c | 2 +-
5 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 11ebf0e..f6ad782 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -489,7 +489,7 @@ gs_app_queue_notify (GsApp *app, const gchar *property_name)
*
* Gets the application ID.
*
- * Returns: The whole ID, e.g. "gimp.desktop" or "flatpak:org.gnome.Gimp.desktop"
+ * Returns: The whole ID, e.g. "gimp.desktop"
**/
const gchar *
gs_app_get_id (GsApp *app)
@@ -529,7 +529,21 @@ gs_app_get_id_no_prefix (GsApp *app)
void
gs_app_set_id (GsApp *app, const gchar *id)
{
+ gchar *tmp;
g_return_if_fail (GS_IS_APP (app));
+
+ /* check for old-style prefix */
+ if (id != NULL) {
+ tmp = g_strrstr (id, ":");
+ if (tmp != NULL) {
+ g_debug ("FIXME: Fixing up %s legacy ID, use "
+ "gs_app_set_unique_id() and use the actual "
+ "desktop-style ID here instead!", id);
+ gs_app_set_unique_id (app, id);
+ id = tmp + 1;
+ }
+ }
+
g_free (app->id);
app->id = g_strdup (id);
}
@@ -3052,7 +3066,7 @@ gs_app_init (GsApp *app)
/**
* gs_app_new:
- * @id: an application ID, or %NULL, e.g. "flatpak:org.gnome.Software.desktop"
+ * @id: an application ID, or %NULL, e.g. "org.gnome.Software.desktop"
*
* Creates a new application object.
*
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 9065062..f5f9e43 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -169,7 +169,7 @@ gs_plugin_func (void)
g_assert_cmpint (gs_app_list_length (list), ==, 3);
gs_app_list_filter_duplicates (list, GS_APP_LIST_FILTER_FLAG_PRIORITY);
g_assert_cmpint (gs_app_list_length (list), ==, 1);
- g_assert_cmpstr (gs_app_get_id (gs_app_list_index (list, 0)), ==, "bar:e");
+ g_assert_cmpstr (gs_app_get_unique_id (gs_app_list_index (list, 0)), ==, "bar:e");
g_object_unref (list);
}
@@ -181,8 +181,8 @@ gs_app_func (void)
app = gs_app_new ("flatpak:gnome-software");
g_assert (GS_IS_APP (app));
- g_assert_cmpstr (gs_app_get_id (app), ==, "flatpak:gnome-software");
- g_assert_cmpstr (gs_app_get_id_no_prefix (app), ==, "gnome-software");
+ g_assert_cmpstr (gs_app_get_id (app), ==, "gnome-software");
+ g_assert_cmpstr (gs_app_get_unique_id (app), ==, "flatpak:gnome-software");
/* check we clean up the version, but not at the expense of having
* the same string as the update version */
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index ac91f96..1f3f54e 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -317,7 +317,9 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
return TRUE;
/* nothing found */
- item = as_store_get_app_by_id (priv->store, id);
+ item = as_store_get_app_by_id (priv->store, gs_app_get_unique_id (app));
+ if (item == NULL)
+ item = as_store_get_app_by_id (priv->store, id);
if (item == NULL)
return TRUE;
diff --git a/src/plugins/gs-plugin-flatpak-system.c b/src/plugins/gs-plugin-flatpak-system.c
index a1b629a..383fa3e 100644
--- a/src/plugins/gs-plugin-flatpak-system.c
+++ b/src/plugins/gs-plugin-flatpak-system.c
@@ -64,7 +64,7 @@ gs_plugin_destroy (GsPlugin *plugin)
void
gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
- const gchar *id = gs_app_get_id (app);
+ const gchar *id = gs_app_get_unique_id (app);
if (id != NULL && g_str_has_prefix (id, GS_FLATPAK_SYSTEM_PREFIX ":")) {
gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
diff --git a/src/plugins/gs-plugin-flatpak-user.c b/src/plugins/gs-plugin-flatpak-user.c
index 02d3b30..218ecaf 100644
--- a/src/plugins/gs-plugin-flatpak-user.c
+++ b/src/plugins/gs-plugin-flatpak-user.c
@@ -64,7 +64,7 @@ gs_plugin_destroy (GsPlugin *plugin)
void
gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
- const gchar *id = gs_app_get_id (app);
+ const gchar *id = gs_app_get_unique_id (app);
if (id != NULL && g_str_has_prefix (id, GS_FLATPAK_USER_PREFIX ":")) {
gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]