mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
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).
This commit is contained in:
parent
a2f823113c
commit
48d96b21f9
@ -3361,6 +3361,7 @@ uwp_package_cb (gpointer user_data,
|
|||||||
gchar *app_user_model_id_u8_folded;
|
gchar *app_user_model_id_u8_folded;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
GWin32AppInfoHandler *ext;
|
GWin32AppInfoHandler *ext;
|
||||||
|
GWin32AppInfoHandler *url;
|
||||||
|
|
||||||
if (!g_utf16_to_utf8_and_fold (app_user_model_id,
|
if (!g_utf16_to_utf8_and_fold (app_user_model_id,
|
||||||
-1,
|
-1,
|
||||||
@ -3414,6 +3415,9 @@ uwp_package_cb (gpointer user_data,
|
|||||||
g_object_ref (handler_rec));
|
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
|
/* This is somewhat wasteful, but for 100% correct handling
|
||||||
* we need to remember which extensions (handlers) support
|
* we need to remember which extensions (handlers) support
|
||||||
* which verbs, and each handler gets its own copy of the
|
* which verbs, and each handler gets its own copy of the
|
||||||
@ -3499,17 +3503,51 @@ uwp_package_cb (gpointer user_data,
|
|||||||
NULL,
|
NULL,
|
||||||
app_user_model_id,
|
app_user_model_id,
|
||||||
app_user_model_id);
|
app_user_model_id);
|
||||||
/* UWP URL handlers do not need any verbs */
|
|
||||||
g_hash_table_insert (schema_rec->handlers,
|
g_hash_table_insert (schema_rec->handlers,
|
||||||
g_strdup (app_user_model_id_u8_folded),
|
g_strdup (app_user_model_id_u8_folded),
|
||||||
g_object_ref (handler_rec));
|
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_hash_table_insert (app->supported_urls,
|
||||||
g_steal_pointer (&proto_u8_folded),
|
g_steal_pointer (&proto_u8_folded),
|
||||||
g_object_ref (handler_rec));
|
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);
|
||||||
g_free (app_user_model_id_u8_folded);
|
g_free (app_user_model_id_u8_folded);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user