[glib: 16/19] GWin32AppInfo: enforce chosen handler on UWP apps, use URI verbs
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 16/19] GWin32AppInfo: enforce chosen handler on UWP apps, use URI verbs
- Date: Mon, 4 Jan 2021 12:56:00 +0000 (UTC)
commit 48d96b21f9cad208348869ce8f53b43c5585c59b
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Tue Dec 15 16:59:59 2020 +0000
GWin32AppInfo: enforce chosen handler on UWP apps, use URI verbs
* UWP apps that have low registry footprint might end up with chosen_handler == NULL.
Ensure that this doesn't happen.
* UWP apps don't need verbs for URIs, but we do need verbs to have a link to an app
(since handlers don't contain app fields). Work around this by adding an "open" verb
to each UWP URI handler.
* Duplicate the code that inserts extension handler verbs into the app to also insert
URI handler verbs. This allows URI-only apps to be used correctly later on (otherwise
GLib errors out, saying that the app has no verbs).
gio/gwin32appinfo.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
index f36905d5c..9e6b36c48 100644
--- a/gio/gwin32appinfo.c
+++ b/gio/gwin32appinfo.c
@@ -3361,6 +3361,7 @@ uwp_package_cb (gpointer user_data,
gchar *app_user_model_id_u8_folded;
GHashTableIter iter;
GWin32AppInfoHandler *ext;
+ GWin32AppInfoHandler *url;
if (!g_utf16_to_utf8_and_fold (app_user_model_id,
-1,
@@ -3414,6 +3415,9 @@ uwp_package_cb (gpointer user_data,
g_object_ref (handler_rec));
}
+ if (file_extn->chosen_handler == NULL)
+ g_set_object (&file_extn->chosen_handler, handler_rec);
+
/* This is somewhat wasteful, but for 100% correct handling
* we need to remember which extensions (handlers) support
* which verbs, and each handler gets its own copy of the
@@ -3499,17 +3503,51 @@ uwp_package_cb (gpointer user_data,
NULL,
app_user_model_id,
app_user_model_id);
- /* UWP URL handlers do not need any verbs */
+
g_hash_table_insert (schema_rec->handlers,
g_strdup (app_user_model_id_u8_folded),
g_object_ref (handler_rec));
}
+ if (schema_rec->chosen_handler == NULL)
+ g_set_object (&schema_rec->chosen_handler, handler_rec);
+
+ /* Technically, UWP apps don't use verbs for URIs,
+ * but we only store an app field in verbs,
+ * so each UWP URI handler has to have one.
+ * Let's call it "open".
+ */
+ uwp_handler_add_verb (handler_rec,
+ app,
+ L"open",
+ NULL,
+ TRUE);
+
g_hash_table_insert (app->supported_urls,
g_steal_pointer (&proto_u8_folded),
g_object_ref (handler_rec));
}
+ g_hash_table_iter_init (&iter, app->supported_urls);
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &url))
+ {
+ gint i_hverb;
+
+ if (!url)
+ continue;
+
+ for (i_hverb = 0; i_hverb < url->verbs->len; i_hverb++)
+ {
+ GWin32AppInfoShellVerb *handler_verb;
+
+ handler_verb = _verb_idx (url->verbs, i_hverb);
+ uwp_app_add_verb (app, handler_verb->verb_name, handler_verb->verb_displayname);
+ if (handler_verb->app == NULL && handler_verb->is_uwp)
+ handler_verb->app = g_object_ref (app);
+ }
+ }
+
g_free (app_user_model_id_u8);
g_free (app_user_model_id_u8_folded);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]