Skip to content
Snippets Groups Projects
Commit c8636b27 authored by Ludovico de Nittis's avatar Ludovico de Nittis
Browse files

steam: Add support for the custom Steam URI handler in Flatpak


Do not report as an issue if the Flatpak version of Steam is the default
URI handler.

Also handle the special URI case when s-r-s-i is executed from inside a
Flatpak environment.

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent dc1dcb44
No related branches found
No related tags found
1 merge request!132steam: Add support for the custom Steam URI handler in Flatpak
Pipeline #4317 passed
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <glib.h> #include <glib.h>
#include <gio/gio.h> #include <gio/gio.h>
#include "steam-runtime-tools/desktop-entry-internal.h"
#include "steam-runtime-tools/enums.h" #include "steam-runtime-tools/enums.h"
#include "steam-runtime-tools/glib-compat.h" #include "steam-runtime-tools/glib-compat.h"
#include "steam-runtime-tools/utils.h" #include "steam-runtime-tools/utils.h"
...@@ -299,6 +300,7 @@ _srt_steam_check (const GStrv my_environ, ...@@ -299,6 +300,7 @@ _srt_steam_check (const GStrv my_environ,
const char *commandline = NULL; const char *commandline = NULL;
const char *executable = NULL; const char *executable = NULL;
const char *app_id = NULL; const char *app_id = NULL;
gboolean in_flatpak = FALSE;
GStrv env = NULL; GStrv env = NULL;
GError *error = NULL; GError *error = NULL;
...@@ -481,8 +483,39 @@ _srt_steam_check (const GStrv my_environ, ...@@ -481,8 +483,39 @@ _srt_steam_check (const GStrv my_environ,
if (default_app == NULL) if (default_app == NULL)
{ {
g_debug ("There isn't a default app that can handle `steam:` URLs"); GList *desktop_entries = _srt_list_steam_desktop_entries ();
issues |= SRT_STEAM_ISSUES_MISSING_STEAM_URI_HANDLER; /* If we are running from the Flatpak version of Steam we can't tell
* which one is the default `steam` URI handler.
* So we just list them all and check if we have the known
* "com.valvesoftware.Steam.desktop" that is used in the Flathub's
* version of Steam */
for (GList *iter = desktop_entries; iter != NULL; iter = iter->next)
{
if (g_strcmp0 (srt_desktop_entry_get_id (iter->data), "com.valvesoftware.Steam.desktop") != 0)
continue;
/* If we have the desktop entry "com.valvesoftware.Steam.desktop"
* with a commandline that starts with "/app/bin/" we are fairly
* sure to be inside a Flatpak environment. Otherwise report the
* issues about the missing and unexpected Steam URI handler */
commandline = srt_desktop_entry_get_commandline (iter->data);
if (g_str_has_prefix (commandline, "/app/bin/")
&& g_str_has_suffix (commandline, "%U"))
{
g_debug ("It seems like this is a Flatpak environment. The missing default app for `steam:` URLs is not an issue");
in_flatpak = TRUE;
}
else
{
issues |= SRT_STEAM_ISSUES_UNEXPECTED_STEAM_URI_HANDLER;
}
}
if (!in_flatpak)
{
g_debug ("There isn't a default app that can handle `steam:` URLs");
issues |= SRT_STEAM_ISSUES_MISSING_STEAM_URI_HANDLER;
}
} }
else else
{ {
...@@ -514,6 +547,18 @@ _srt_steam_check (const GStrv my_environ, ...@@ -514,6 +547,18 @@ _srt_steam_check (const GStrv my_environ,
g_debug ("Cannot parse \"Exec=%s\" like a shell would: %s", commandline, error->message); g_debug ("Cannot parse \"Exec=%s\" like a shell would: %s", commandline, error->message);
g_clear_error (&error); g_clear_error (&error);
} }
if (!found_expected_steam_uri_handler)
{
/* If we are running from the host system, do not flag the Flatpak
* version of Steam as unexpected URI handler */
if (g_str_has_prefix (commandline, executable)
&& g_str_has_suffix (commandline, "com.valvesoftware.Steam @@u %U @@")
&& g_pattern_match_simple ("* --command=/app/bin/*", commandline))
{
found_expected_steam_uri_handler = TRUE;
}
}
} }
/* Exclude the special case `/usr/bin/env steam %U` that we use in our unit tests */ /* Exclude the special case `/usr/bin/env steam %U` that we use in our unit tests */
...@@ -546,7 +591,9 @@ _srt_steam_check (const GStrv my_environ, ...@@ -546,7 +591,9 @@ _srt_steam_check (const GStrv my_environ,
} }
else else
{ {
if (g_strcmp0 (executable, steam_script) != 0) if (!in_flatpak
&& g_strcmp0 (executable, steam_script) != 0
&& g_strcmp0 (executable, "/usr/bin/flatpak") != 0)
{ {
g_debug ("Unexpectedly \"STEAMSCRIPT\" environment variable and the default Steam app " g_debug ("Unexpectedly \"STEAMSCRIPT\" environment variable and the default Steam app "
"executable point to different paths: \"%s\" and \"%s\"", steam_script, executable); "executable point to different paths: \"%s\" and \"%s\"", steam_script, executable);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment