[gnome-software] trivial: Add gs_app_set_bundle_kind()
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Add gs_app_set_bundle_kind()
- Date: Tue, 9 Aug 2016 16:22:55 +0000 (UTC)
commit f3179dcbd7b7e88813a6c1e81a6462b17f952ab9
Author: Richard Hughes <richard hughsie com>
Date: Tue Aug 9 16:10:44 2016 +0100
trivial: Add gs_app_set_bundle_kind()
This allows us to auto-generate the unique-app automatically in most cases.
src/gs-app.c | 36 ++++++++++++++++++++++++++++-
src/gs-app.h | 3 ++
src/plugins/gs-flatpak.c | 1 +
src/plugins/gs-plugin-dummy.c | 2 +-
src/plugins/gs-plugin-limba.c | 12 +--------
src/plugins/gs-plugin-packagekit-refine.c | 2 +
src/plugins/gs-plugin-shell-extensions.c | 8 ------
src/plugins/gs-plugin-snap.c | 11 +-------
8 files changed, 46 insertions(+), 29 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 9568d4c..e8faf68 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -102,6 +102,7 @@ struct _GsApp
AsAppState state;
AsAppState state_recover;
AsAppScope scope;
+ AsBundleKind bundle_kind;
guint progress;
GHashTable *metadata;
GPtrArray *addons; /* of GsApp */
@@ -261,6 +262,10 @@ gs_app_to_string (GsApp *app)
gs_app_kv_lpad (str, "unique-id", app->unique_id);
if (app->scope != AS_APP_SCOPE_UNKNOWN)
gs_app_kv_lpad (str, "scope", as_app_scope_to_string (app->scope));
+ if (app->bundle_kind != AS_BUNDLE_KIND_UNKNOWN) {
+ gs_app_kv_lpad (str, "bundle-kind",
+ as_bundle_kind_to_string (app->bundle_kind));
+ }
if ((app->kudos & GS_APP_KUDO_MY_LANGUAGE) > 0)
gs_app_kv_lpad (str, "kudo", "my-language");
if ((app->kudos & GS_APP_KUDO_RECENT_RELEASE) > 0)
@@ -558,6 +563,35 @@ gs_app_set_scope (GsApp *app, AsAppScope scope)
}
/**
+ * gs_app_get_bundle_kind:
+ * @app: a #GsApp
+ *
+ * Gets the bundle kind of the application.
+ *
+ * Returns: the #AsAppScope, e.g. %AS_BUNDLE_KIND_FLATPAK
+ **/
+AsBundleKind
+gs_app_get_bundle_kind (GsApp *app)
+{
+ g_return_val_if_fail (GS_IS_APP (app), AS_BUNDLE_KIND_UNKNOWN);
+ return app->bundle_kind;
+}
+
+/**
+ * gs_app_set_bundle_kind:
+ * @app: a #GsApp
+ * @bundle_kind: a #AsAppScope, e.g. AS_BUNDLE_KIND_FLATPAK
+ *
+ * This sets the bundle kind of the application.
+ **/
+void
+gs_app_set_bundle_kind (GsApp *app, AsBundleKind bundle_kind)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ app->bundle_kind = bundle_kind;
+}
+
+/**
* gs_app_get_state:
* @app: a #GsApp
*
@@ -876,7 +910,7 @@ gs_app_get_unique_id (GsApp *app)
if (app->unique_id == NULL) {
g_debug ("autogenerating unique-id for %s", app->id);
app->unique_id = as_utils_unique_id_build (app->scope,
- AS_BUNDLE_KIND_UNKNOWN,
+ app->bundle_kind,
app->origin,
app->kind,
app->id,
diff --git a/src/gs-app.h b/src/gs-app.h
index 440a770..1842bad 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -112,6 +112,9 @@ void gs_app_set_state (GsApp *app,
AsAppScope gs_app_get_scope (GsApp *app);
void gs_app_set_scope (GsApp *app,
AsAppScope scope);
+AsBundleKind gs_app_get_bundle_kind (GsApp *app);
+void gs_app_set_bundle_kind (GsApp *app,
+ AsBundleKind bundle_kind);
void gs_app_set_state_recover (GsApp *app);
guint gs_app_get_progress (GsApp *app);
void gs_app_set_progress (GsApp *app,
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 14dce42..7a7d5e9 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -241,6 +241,7 @@ gs_plugin_refine_item_scope (GsFlatpak *self, GsApp *app)
static void
gs_flatpak_set_metadata (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
{
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
gs_app_set_management_plugin (app, gs_plugin_get_name (self->plugin));
gs_app_set_flatpak_kind (app, flatpak_ref_get_kind (xref));
gs_app_set_flatpak_name (app, flatpak_ref_get_name (xref));
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 21f7a0f..7e5ad95 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -306,7 +306,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
/* add again, this time with a prefix so it gets deduplicated */
app2 = gs_app_new ("zeus.desktop");
gs_app_set_scope (app2, AS_APP_SCOPE_USER);
- gs_app_set_unique_id (app2, "user/dummy/*/*/zeus.desktop/*");
+ gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_SNAP);
gs_app_set_metadata (app2, "GnomeSoftware::Creator",
gs_plugin_get_name (plugin));
gs_app_list_add (list, app2);
diff --git a/src/plugins/gs-plugin-limba.c b/src/plugins/gs-plugin-limba.c
index b7c5f09..c2ed583 100644
--- a/src/plugins/gs-plugin-limba.c
+++ b/src/plugins/gs-plugin-limba.c
@@ -282,7 +282,6 @@ gs_plugin_app_from_pki (LiPkgInfo *pki)
{
const gchar *cptkind_str;
GsApp *app;
- g_autofree gchar *unique_id = NULL;
cptkind_str = li_pkg_info_get_component_kind (pki);
if ((cptkind_str != NULL) && (g_strcmp0 (cptkind_str, "desktop") == 0)) {
@@ -298,17 +297,10 @@ gs_plugin_app_from_pki (LiPkgInfo *pki)
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
}
- /* create a unique ID for deduplication, TODO: scope?, branch?, arch? */
- unique_id = as_utils_unique_id_build (AS_APP_SCOPE_UNKNOWN,
- AS_BUNDLE_KIND_LIMBA,
- NULL, /* origin */
- AS_APP_KIND_UNKNOWN,
- id,
- NULL); /* branch */
-
- gs_app_set_unique_id (app, unique_id);
+ /* TODO: scope?, branch? */
gs_app_set_management_plugin (app, "limba");
gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_LIMBA);
gs_app_set_name (app,
GS_APP_QUALITY_LOWEST,
li_pkg_info_get_name (pki));
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 8397446..0f7658f 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -946,6 +946,8 @@ gs_plugin_refine_app (GsPlugin *plugin,
/* the scope is always system-wide */
if (gs_app_get_scope (app) == AS_APP_SCOPE_UNKNOWN)
gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
+ if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_UNKNOWN)
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
return TRUE;
}
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index 0539e22..2bf06df 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -120,19 +120,11 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
gchar *str;
GVariant *val;
g_autofree gchar *id = NULL;
- g_autofree gchar *unique_id = NULL;
g_autoptr(AsIcon) ic = NULL;
id = gs_plugin_shell_extensions_id_from_uuid (uuid);
- unique_id = as_utils_unique_id_build (AS_APP_SCOPE_USER,
- AS_BUNDLE_KIND_UNKNOWN,
- NULL, /* origin */
- AS_APP_KIND_SHELL_EXTENSION,
- id,
- NULL); /* branch */
gs_app_set_id (app, id);
gs_app_set_scope (app, AS_APP_SCOPE_USER);
- gs_app_set_unique_id (app, unique_id);
gs_app_set_metadata (app, "GnomeSoftware::Creator",
gs_plugin_get_name (plugin));
gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index 1f98bc2..ee60f85 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -327,7 +327,6 @@ get_apps (GsPlugin *plugin,
for (l = snaps; l != NULL; l = l->next) {
JsonObject *package = json_node_get_object (l->data);
g_autoptr(GsApp) app = NULL;
- g_autofree gchar *unique_id = NULL;
const gchar *id;
id = json_object_get_string_member (package, "name");
@@ -335,16 +334,10 @@ get_apps (GsPlugin *plugin,
if (filter_func != NULL && !filter_func (id, package, user_data))
continue;
- /* create a unique ID for deduplication, TODO: branch?, arch? */
- unique_id = as_utils_unique_id_build (AS_APP_SCOPE_SYSTEM,
- AS_BUNDLE_KIND_SNAP,
- NULL, /* origin */
- AS_APP_KIND_UNKNOWN,
- id,
- NULL); /* branch */
+ /* create a unique ID for deduplication, TODO: branch? */
app = gs_app_new (id);
gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
- gs_app_set_unique_id (app, unique_id);
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP);
gs_app_set_management_plugin (app, "snap");
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
gs_app_add_quirk (app, AS_APP_QUIRK_NOT_REVIEWABLE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]