[gnome-software/wip/ubuntu-3-22: 14/14] Handle snap URLs
- From: Jeremy Bicha <jbicha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-3-22: 14/14] Handle snap URLs
- Date: Wed, 8 Mar 2017 16:30:19 +0000 (UTC)
commit d867792967bf139833eb7073197ee9c570dc8dc6
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Feb 2 15:09:06 2017 +1300
Handle snap URLs
src/gs-application.c | 55 +++++++++++++++++-------------------
src/org.gnome.Software.desktop.in | 2 +-
src/plugins/gs-plugin-snap.c | 9 ++++--
3 files changed, 33 insertions(+), 33 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index c079d38..508e1cc 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -619,12 +619,17 @@ details_pkg_activated (GSimpleAction *action,
gpointer data)
{
GsApplication *app = GS_APPLICATION (data);
+ const gchar *name;
+ const gchar *plugin;
g_autoptr (GsApp) a = NULL;
initialize_ui_and_present_window (app, NULL);
+ g_variant_get (parameter, "(&s&s)", &name, &plugin);
a = gs_app_new (NULL);
- gs_app_add_source (a, g_variant_get_string (parameter, NULL));
+ gs_app_add_source (a, name);
+ if (strcmp (plugin, "") != 0)
+ gs_app_set_management_plugin (a, plugin);
gs_shell_show_app (app->shell, a);
}
@@ -728,7 +733,7 @@ static GActionEntry actions[] = {
{ "set-mode", set_mode_activated, "s", NULL, NULL },
{ "search", search_activated, "s", NULL, NULL },
{ "details", details_activated, "(ss)", NULL, NULL },
- { "details-pkg", details_pkg_activated, "s", NULL, NULL },
+ { "details-pkg", details_pkg_activated, "(ss)", NULL, NULL },
{ "filename", filename_activated, "(s)", NULL, NULL },
{ "launch", launch_activated, "s", NULL, NULL },
{ "show-offline-update-error", show_offline_updates_error, NULL, NULL, NULL },
@@ -920,7 +925,7 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
} else if (g_variant_dict_lookup (options, "details-pkg", "&s", &pkgname)) {
g_action_group_activate_action (G_ACTION_GROUP (app),
"details-pkg",
- g_variant_new_string (pkgname));
+ g_variant_new ("(ss)", pkgname, ""));
return 0;
} else if (g_variant_dict_lookup (options, "local-filename", "^&ay", &local_filename)) {
g_action_group_activate_action (G_ACTION_GROUP (app),
@@ -944,44 +949,36 @@ gs_application_open (GApplication *application,
for (i = 0; i < n_files; i++) {
g_autofree gchar *str = g_file_get_uri (files[i]);
g_autoptr(SoupURI) uri = NULL;
+ const gchar *host;
+ const gchar *path;
uri = soup_uri_new (str);
if (!SOUP_URI_IS_VALID (uri))
continue;
- if (g_strcmp0 (soup_uri_get_scheme (uri), "appstream") == 0) {
- const gchar *host = soup_uri_get_host (uri);
- const gchar *path = soup_uri_get_path (uri);
-
- /* appstream://foo -> scheme: appstream, host: foo, path: / */
- /* appstream:foo -> scheme: appstream, host: (empty string), path: /foo */
- if (host != NULL && (strlen (host) > 0))
- path = host;
+ /* foo://bar -> scheme: foo, host: bar, path: / */
+ /* foo:bar -> scheme: foo, host: (empty string), path: /bar */
+ host = soup_uri_get_host (uri);
+ path = soup_uri_get_path (uri);
+ if (host != NULL && (strlen (host) > 0))
+ path = host;
- /* trim any leading slashes */
- while (*path == '/')
- path++;
+ /* trim any leading slashes */
+ while (*path == '/')
+ path++;
+ if (g_strcmp0 (soup_uri_get_scheme (uri), "appstream") == 0) {
g_action_group_activate_action (G_ACTION_GROUP (app),
"details",
g_variant_new ("(ss)", path, ""));
- }
- if (g_strcmp0 (soup_uri_get_scheme (uri), "apt") == 0) {
- const gchar *host = soup_uri_get_host (uri);
- const gchar *path = soup_uri_get_path (uri);
-
- /* trim any leading slashes */
- while (*path == '/')
- path++;
-
- /* apt://foo -> scheme: apt, host: foo, path: / */
- /* apt:foo -> scheme: apt, host: (empty string), path: /foo */
- if (host != NULL && (strlen (host) > 0))
- path = host;
-
+ } else if (g_strcmp0 (soup_uri_get_scheme (uri), "apt") == 0) {
g_action_group_activate_action (G_ACTION_GROUP (app),
"details-pkg",
- g_variant_new_string (path));
+ g_variant_new ("(ss)", path, "apt"));
+ } else if (g_strcmp0 (soup_uri_get_scheme (uri), "snap") == 0) {
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "details-pkg",
+ g_variant_new ("(ss)", path, "snap"));
}
}
}
diff --git a/src/org.gnome.Software.desktop.in b/src/org.gnome.Software.desktop.in
index 7dc05f2..79dfd1a 100644
--- a/src/org.gnome.Software.desktop.in
+++ b/src/org.gnome.Software.desktop.in
@@ -8,7 +8,7 @@ Type=Application
Categories=GNOME;GTK;System;PackageManager;
_Keywords=Updates;Upgrade;Sources;Repositories;Preferences;Install;Uninstall;Program;Software;App;Store;
StartupNotify=true
-MimeType=x-scheme-handler/appstream;x-scheme-handler/apt;
+MimeType=x-scheme-handler/appstream;x-scheme-handler/apt;x-scheme-handler/snap;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-software
X-GNOME-Bugzilla-Component=gnome-software
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index 7310c9f..c7bb750 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -109,6 +109,7 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package, gboolean from_sea
get_macaroon (plugin, &macaroon, &discharges);
+ gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
status = json_object_get_string_member (package, "status");
if (g_strcmp0 (status, "installed") == 0 || g_strcmp0 (status, "active") == 0) {
const gchar *update_available;
@@ -262,7 +263,6 @@ gs_plugin_add_installed (GsPlugin *plugin,
gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
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);
refine_app (plugin, app, package, TRUE, cancellable);
gs_app_list_add (list, app);
@@ -299,7 +299,6 @@ gs_plugin_add_search (GsPlugin *plugin,
gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
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);
refine_app (plugin, app, package, TRUE, cancellable);
gs_app_list_add (list, app);
@@ -318,6 +317,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
g_autofree gchar *macaroon = NULL;
g_auto(GStrv) discharges = NULL;
g_autoptr(JsonObject) result = NULL;
+ const gchar *id;
/* not us */
if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
@@ -325,7 +325,10 @@ gs_plugin_refine_app (GsPlugin *plugin,
get_macaroon (plugin, &macaroon, &discharges);
- result = gs_snapd_list_one (macaroon, discharges, gs_app_get_id (app), cancellable, error);
+ id = gs_app_get_id (app);
+ if (id == NULL)
+ id = gs_app_get_source_default (app);
+ result = gs_snapd_list_one (macaroon, discharges, id, cancellable, error);
if (result == NULL)
return FALSE;
refine_app (plugin, app, result, FALSE, cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]