[gnome-software] Handle snap URLs
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Handle snap URLs
- Date: Thu, 2 Feb 2017 02:09:41 +0000 (UTC)
commit 21808f1ec3a2ff7f49724810eaed52726ffb4cd4
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 bbcb4cb..fb8e2c3 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -557,12 +557,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);
}
@@ -696,7 +701,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 },
{ "install", install_activated, "(su)", NULL, NULL },
{ "filename", filename_activated, "(s)", NULL, NULL },
{ "launch", launch_activated, "s", NULL, NULL },
@@ -872,7 +877,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, ""));
rc = 0;
} else if (g_variant_dict_lookup (options, "install", "&s", &id)) {
GsShellInteraction interaction = GS_SHELL_INTERACTION_FULL;
@@ -909,44 +914,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 ("(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_string (path));
+ g_variant_new ("(ss)", path, "snap"));
}
}
}
diff --git a/src/org.gnome.Software.desktop.in b/src/org.gnome.Software.desktop.in
index b50a1b1..dde6bad 100644
--- a/src/org.gnome.Software.desktop.in
+++ b/src/org.gnome.Software.desktop.in
@@ -10,7 +10,7 @@ Categories=GNOME;GTK;System;PackageManager;
# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list
MUST also end with a semicolon!
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 0ae92f9..101a6f5 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -112,6 +112,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;
@@ -265,7 +266,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);
@@ -302,7 +302,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);
@@ -321,6 +320,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)
@@ -328,7 +328,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]