[gnome-software] snap: Use ODRS for reviews
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] snap: Use ODRS for reviews
- Date: Wed, 18 Apr 2018 03:48:06 +0000 (UTC)
commit e54b31cc85ddef6f9579cb85bbdf53dbb9d9091d
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Feb 26 15:24:19 2018 +1300
snap: Use ODRS for reviews
plugins/snap/gs-plugin-snap.c | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 510a02a7..a890c0b1 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -279,23 +279,27 @@ static GsApp *
snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
+ g_autofree gchar *appstream_id = NULL;
g_autofree gchar *unique_id = NULL;
GsApp *cached_app;
g_autoptr(GsApp) app = NULL;
SnapdConfinement confinement;
+ /* generate an AppStream ID for this snap - when Snaps support an AppStream field we can override
this */
+ appstream_id = g_strdup_printf ("io.snapcraft.%s-%s", snapd_snap_get_name (snap), snapd_snap_get_id
(snap));
+
switch (snapd_snap_get_snap_type (snap)) {
case SNAPD_SNAP_TYPE_APP:
- unique_id = g_strdup_printf ("system/snap/*/desktop/%s/*", snapd_snap_get_name (snap));
+ unique_id = g_strdup_printf ("system/snap/*/desktop/%s/*", appstream_id);
break;
case SNAPD_SNAP_TYPE_KERNEL:
case SNAPD_SNAP_TYPE_GADGET:
case SNAPD_SNAP_TYPE_OS:
- unique_id = g_strdup_printf ("system/snap/*/runtime/%s/*", snapd_snap_get_name (snap));
+ unique_id = g_strdup_printf ("system/snap/*/runtime/%s/*", appstream_id);
break;
default:
case SNAPD_SNAP_TYPE_UNKNOWN:
- unique_id = g_strdup_printf ("system/snap/*/*/%s/*", snapd_snap_get_name (snap));
+ unique_id = g_strdup_printf ("system/snap/*/*/%s/*", appstream_id);
break;
}
@@ -303,13 +307,13 @@ snap_to_app (GsPlugin *plugin, SnapdSnap *snap)
if (cached_app == NULL) {
app = gs_app_new (NULL);
gs_app_set_from_unique_id (app, unique_id);
+ gs_app_set_metadata (app, "snap::name", snapd_snap_get_name (snap));
gs_plugin_cache_add (plugin, unique_id, app);
}
else
app = g_object_ref (cached_app);
gs_app_set_management_plugin (app, "snap");
- gs_app_add_quirk (app, AS_APP_QUIRK_NOT_REVIEWABLE);
if (gs_app_get_kind (app) != AS_APP_KIND_DESKTOP)
gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
if (gs_plugin_check_distro_id (plugin, "ubuntu"))
@@ -627,7 +631,7 @@ load_snap_icon (GsApp *app, SnapdClient *client, SnapdSnap *snap, GCancellable *
if (icon_url == NULL || strcmp (icon_url, "") == 0)
return FALSE;
- icon = snapd_client_get_icon_sync (client, snapd_snap_get_name (snap), cancellable, &error);
+ icon = snapd_client_get_icon_sync (client, gs_app_get_metadata_item (app, "snap::name"), cancellable,
&error);
if (icon == NULL) {
g_warning ("Failed to load snap icon: %s", error->message);
return FALSE;
@@ -758,7 +762,7 @@ load_icon (GsPlugin *plugin, SnapdClient *client, GsApp *app, const gchar *id, S
}
if (store_snap == NULL)
- store_snap = get_store_snap (plugin, id, cancellable, NULL);
+ store_snap = get_store_snap (plugin, gs_app_get_metadata_item (app, "snap::name"),
cancellable, NULL);
if (store_snap != NULL)
return load_store_icon (app, store_snap);
@@ -783,7 +787,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
{
GsPluginData *priv = gs_plugin_get_data (plugin);
g_autoptr(SnapdClient) client = NULL;
- const gchar *id, *name;
+ const gchar *name;
g_autoptr(SnapdSnap) local_snap = NULL;
g_autoptr(SnapdSnap) store_snap = NULL;
SnapdSnap *snap;
@@ -797,16 +801,10 @@ gs_plugin_refine_app (GsPlugin *plugin,
if (client == NULL)
return FALSE;
- id = gs_app_get_id (app);
- if (id == NULL)
- id = gs_app_get_source_default (app);
- if (id == NULL)
- return TRUE;
-
/* get information from local snaps and store */
- local_snap = snapd_client_list_one_sync (client, id, cancellable, NULL);
+ local_snap = snapd_client_list_one_sync (client, gs_app_get_metadata_item (app, "snap::name"),
cancellable, NULL);
if (local_snap == NULL || (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS) != 0)
- store_snap = get_store_snap (plugin, id, cancellable, NULL);
+ store_snap = get_store_snap (plugin, gs_app_get_metadata_item (app, "snap::name"),
cancellable, NULL);
if (local_snap == NULL && store_snap == NULL)
return TRUE;
@@ -885,7 +883,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
/* load icon if requested */
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON && gs_app_get_pixbuf (app) == NULL)
- load_icon (plugin, client, app, id, local_snap, store_snap, cancellable);
+ load_icon (plugin, client, app, gs_app_get_metadata_item (app, "snap::name"), local_snap,
store_snap, cancellable);
return TRUE;
}
@@ -928,7 +926,7 @@ gs_plugin_app_install (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_INSTALLING);
if (g_strcmp0 (gs_app_get_metadata_item (app, "snap::confinement"), "classic") == 0)
flags |= SNAPD_INSTALL_FLAGS_CLASSIC;
- if (!snapd_client_install2_sync (client, flags, gs_app_get_id (app), NULL, NULL, progress_cb, app,
cancellable, error)) {
+ if (!snapd_client_install2_sync (client, flags, gs_app_get_metadata_item (app, "snap::name"), NULL,
NULL, progress_cb, app, cancellable, error)) {
gs_app_set_state_recover (app);
snapd_error_convert (error);
return FALSE;
@@ -962,7 +960,7 @@ is_graphical (GsPlugin *plugin, GsApp *app, GCancellable *cancellable)
const gchar *interface;
// Only looks at the plugs for this snap
- if (g_strcmp0 (snapd_plug_get_snap (plug), gs_app_get_id (app)) != 0)
+ if (g_strcmp0 (snapd_plug_get_snap (plug), gs_app_get_metadata_item (app, "snap::name")) != 0)
continue;
interface = snapd_plug_get_interface (plug);
@@ -1001,10 +999,10 @@ gs_plugin_launch (GsPlugin *plugin,
g_autofree gchar *commandline = NULL;
GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE;
- if (g_strcmp0 (launch_name, gs_app_get_id (app)) == 0)
+ if (g_strcmp0 (launch_name, gs_app_get_metadata_item (app, "snap::name")) == 0)
commandline = g_strdup_printf ("snap run %s", launch_name);
else
- commandline = g_strdup_printf ("snap run %s.%s", gs_app_get_id (app), launch_name);
+ commandline = g_strdup_printf ("snap run %s.%s", gs_app_get_metadata_item (app,
"snap::name"), launch_name);
if (!is_graphical (plugin, app, cancellable))
flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL;
@@ -1034,7 +1032,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
return FALSE;
gs_app_set_state (app, AS_APP_STATE_REMOVING);
- if (!snapd_client_remove_sync (client, gs_app_get_id (app), progress_cb, app, cancellable, error)) {
+ if (!snapd_client_remove_sync (client, gs_app_get_metadata_item (app, "snap::name"), progress_cb,
app, cancellable, error)) {
gs_app_set_state_recover (app);
snapd_error_convert (error);
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]