From 72258b452d2c9b318602ad9294b532cf5d8d69a4 Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Thu, 23 Nov 2023 12:06:06 -0800 Subject: [PATCH 1/4] Move app ID and prefixes to meson_options https://github.com/endlessm/endless-key-flatpak/issues/102 --- .../flatpak/org.endlessos.Key.Devel.json | 5 ++++- meson.build | 17 +++++++-------- meson_options.txt | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/build-aux/flatpak/org.endlessos.Key.Devel.json b/build-aux/flatpak/org.endlessos.Key.Devel.json index bb0dc3c..fd629bb 100644 --- a/build-aux/flatpak/org.endlessos.Key.Devel.json +++ b/build-aux/flatpak/org.endlessos.Key.Devel.json @@ -64,7 +64,10 @@ "builddir" : true, "run-tests" : true, "config-opts" : [ - "-Dprofile=development" + "-Dprofile=development", + "-Dbase_application_id=org.endlessos.Key", + "-Dbase_object_path=/org/endlessos/Key", + "-Denv_prefix=ENDLESS_KEY_" ], "sources" : [ { diff --git a/meson.build b/meson.build index 22a7ee9..28acd37 100644 --- a/meson.build +++ b/meson.build @@ -26,15 +26,14 @@ locale_dir = join_paths(get_option('prefix'), get_option('localedir')) datadir = join_paths(get_option('prefix'), get_option('datadir')) build_profile = get_option('profile') - -if build_profile == 'default' - base_application_id = 'org.endlessos.Key' - base_object_path = '/org/endlessos/Key' - profile_env_prefix = 'ENDLESS_KEY_' -elif build_profile == 'development' - base_application_id = 'org.endlessos.Key.Devel' - base_object_path = '/org/endlessos/Key/Devel' - profile_env_prefix = 'ENDLESS_KEY_DEVEL_' +base_application_id = get_option('base_application_id') +base_object_path = get_option('base_object_path') +profile_env_prefix = get_option('env_prefix') + +if build_profile == 'development' + base_application_id += '.Devel' + base_object_path += '/Devel' + profile_env_prefix += 'DEVEL_' endif frontend_application_id = base_application_id diff --git a/meson_options.txt b/meson_options.txt index a393cc0..f10edbd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,3 +7,24 @@ option( ], value: 'default' ) + +option( + 'base_application_id', + type: 'string', + value: 'org.learningequality.Kolibri', + description: 'Base application ID. When profile is "development", ".Devel" is appended' +) + +option( + 'base_object_path', + type: 'string', + value: '/org/learningequality/Kolibri', + description: 'Base D-Bus object path. When profile is "development", "/Devel" is appended' +) + +option( + 'env_prefix', + type: 'string', + value: 'KOLIBRI_', + description: 'Prefix for environment variables. When profile is "development", "DEVEL_" is appended' +) From e699a344ffb66bb27830b278ddcc511d7145b6ca Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Thu, 23 Nov 2023 13:55:52 -0800 Subject: [PATCH 2/4] Generate URI schemes from build configuration https://github.com/endlessm/endless-key-flatpak/issues/102 --- ...earningequality.Kolibri.Frontend.desktop.in.in | 2 +- ...g.learningequality.Kolibri.Launcher.desktop.in | 2 +- meson.build | 9 +++++++++ meson_options.txt | 7 +++++++ src/kolibri_app/config.py.in | 3 +++ src/kolibri_gnome/application.py | 4 +++- src/kolibri_gnome/kolibri_context.py | 15 +++++++++------ src/kolibri_gnome_launcher/application.py | 6 ++++-- .../kolibri-gnome-search-provider.c | 2 +- src/kolibri_gnome_search_provider/meson.build | 1 + 10 files changed, 39 insertions(+), 12 deletions(-) diff --git a/data/applications/org.learningequality.Kolibri.Frontend.desktop.in.in b/data/applications/org.learningequality.Kolibri.Frontend.desktop.in.in index 660ff24..27d8c6d 100644 --- a/data/applications/org.learningequality.Kolibri.Frontend.desktop.in.in +++ b/data/applications/org.learningequality.Kolibri.Frontend.desktop.in.in @@ -14,5 +14,5 @@ DBusActivatable=true # TRANSLATORS: This is an icon file name. # Do not translate or transliterate this text! Icon=@FRONTEND_APPLICATION_ID@ -MimeType=x-scheme-handler/kolibri;x-scheme-handler/x-kolibri-app; +MimeType=x-scheme-handler/kolibri;x-scheme-handler/@APP_URI_SCHEME@; X-Endless-LaunchMaximized=true diff --git a/data/applications/org.learningequality.Kolibri.Launcher.desktop.in b/data/applications/org.learningequality.Kolibri.Launcher.desktop.in index 2cd8c84..bd069ca 100644 --- a/data/applications/org.learningequality.Kolibri.Launcher.desktop.in +++ b/data/applications/org.learningequality.Kolibri.Launcher.desktop.in @@ -6,4 +6,4 @@ Exec=@KOLIBRI_APP_LIBEXECDIR@/kolibri-gnome-launcher %U NoDisplay=true StartupNotify=false DBusActivatable=true -MimeType=x-scheme-handler/x-kolibri-dispatch; +MimeType=x-scheme-handler/@DISPATCH_URI_SCHEME@; diff --git a/meson.build b/meson.build index 28acd37..e66a2e6 100644 --- a/meson.build +++ b/meson.build @@ -29,11 +29,13 @@ build_profile = get_option('profile') base_application_id = get_option('base_application_id') base_object_path = get_option('base_object_path') profile_env_prefix = get_option('env_prefix') +profile_uri_prefix = get_option('uri_prefix') if build_profile == 'development' base_application_id += '.Devel' base_object_path += '/Devel' profile_env_prefix += 'DEVEL_' + profile_uri_prefix += '-devel' endif frontend_application_id = base_application_id @@ -51,6 +53,10 @@ daemon_private_object_path = daemon_object_path + '/Private' search_provider_application_id = base_application_id + '.SearchProvider' search_provider_object_path = base_object_path + '/SearchProvider' +kolibri_uri_scheme = 'kolibri' +app_uri_scheme = profile_uri_prefix + '-app' +dispatch_uri_scheme = profile_uri_prefix + '-dispatch' + po_dir = join_paths(meson.project_source_root(), 'po') kolibri_app_libexecdir = join_paths(libexecdir, 'kolibri-app') @@ -67,6 +73,9 @@ kolibri_app_config.set('GETTEXT_PACKAGE', meson.project_name()) kolibri_app_config.set('LOCALE_DIR', locale_dir) kolibri_app_config.set('BUILD_PROFILE', build_profile) kolibri_app_config.set('PROFILE_ENV_PREFIX', profile_env_prefix) +kolibri_app_config.set('KOLIBRI_URI_SCHEME', kolibri_uri_scheme) +kolibri_app_config.set('APP_URI_SCHEME', app_uri_scheme) +kolibri_app_config.set('DISPATCH_URI_SCHEME', dispatch_uri_scheme) kolibri_app_config.set('KOLIBRI_APP_LIBEXECDIR', kolibri_app_libexecdir) kolibri_app_config.set('KOLIBRI_APP_DATA_DIR', kolibri_app_data_dir) kolibri_app_config.set('ENDLESS_KEY_DATA_DIR', endless_key_data_dir) diff --git a/meson_options.txt b/meson_options.txt index f10edbd..4060732 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -28,3 +28,10 @@ option( value: 'KOLIBRI_', description: 'Prefix for environment variables. When profile is "development", "DEVEL_" is appended' ) + +option( + 'uri_prefix', + type: 'string', + value: 'x-kolibri', + description: 'Prefix for custom URI schemes. When profile is "development", "-devel" is appended' +) diff --git a/src/kolibri_app/config.py.in b/src/kolibri_app/config.py.in index a048ac7..187d4dd 100644 --- a/src/kolibri_app/config.py.in +++ b/src/kolibri_app/config.py.in @@ -1,5 +1,8 @@ BUILD_PROFILE = "@BUILD_PROFILE@" PROFILE_ENV_PREFIX = "@PROFILE_ENV_PREFIX@" +KOLIBRI_URI_SCHEME = "@KOLIBRI_URI_SCHEME@" +APP_URI_SCHEME = "@APP_URI_SCHEME@" +DISPATCH_URI_SCHEME = "@DISPATCH_URI_SCHEME@" PROJECT_VERSION = "@PROJECT_VERSION@" BASE_OBJECT_PATH = "@BASE_OBJECT_PATH@" BASE_APPLICATION_ID = "@BASE_APPLICATION_ID@" diff --git a/src/kolibri_gnome/application.py b/src/kolibri_gnome/application.py index 6d3bd29..75fda4b 100644 --- a/src/kolibri_gnome/application.py +++ b/src/kolibri_gnome/application.py @@ -14,9 +14,11 @@ from gi.repository import GObject from gi.repository import Gtk from gi.repository import WebKit +from kolibri_app.config import APP_URI_SCHEME from kolibri_app.config import BASE_APPLICATION_ID from kolibri_app.config import BASE_OBJECT_PATH from kolibri_app.config import KOLIBRI_APP_DATA_DIR +from kolibri_app.config import KOLIBRI_URI_SCHEME from kolibri_app.globals import get_release_notes_version from kolibri_app.globals import get_version from kolibri_app.globals import XDG_CURRENT_DESKTOP @@ -246,7 +248,7 @@ def __window_on_open_new_window( return new_window.get_main_webview() if new_window else None def __handle_open_file_url(self, url: str): - valid_url_schemes = ("kolibri", "x-kolibri-app") + valid_url_schemes = (KOLIBRI_URI_SCHEME, APP_URI_SCHEME) url_tuple = urlsplit(url) diff --git a/src/kolibri_gnome/kolibri_context.py b/src/kolibri_gnome/kolibri_context.py index 768a378..1ecf798 100644 --- a/src/kolibri_gnome/kolibri_context.py +++ b/src/kolibri_gnome/kolibri_context.py @@ -13,9 +13,11 @@ from gi.repository import GLib from gi.repository import GObject from gi.repository import WebKit +from kolibri_app.config import APP_URI_SCHEME from kolibri_app.config import BUILD_PROFILE from kolibri_app.config import ENDLESS_KEY_DATA_DIR from kolibri_app.config import FRONTEND_APPLICATION_ID +from kolibri_app.config import KOLIBRI_URI_SCHEME from kolibri_app.config import PROJECT_VERSION from kolibri_app.config import VCS_TAG from kolibri_app.utils import get_app_modules_debug_info @@ -100,7 +102,7 @@ def kolibri_version(self) -> str: @property def default_url(self) -> str: - return "x-kolibri-app:/explore" + return f"{APP_URI_SCHEME}:/explore" @property def webkit_web_context(self) -> WebKit.WebContext: @@ -114,10 +116,10 @@ def shutdown(self): def get_absolute_url(self, url: str) -> typing.Optional[str]: url_tuple = urlsplit(url) - if url_tuple.scheme == "kolibri": + if url_tuple.scheme == KOLIBRI_URI_SCHEME: target_url = self.parse_kolibri_url_tuple(url_tuple) return self.__kolibri_daemon.get_absolute_url(target_url) - elif url_tuple.scheme == "x-kolibri-app": + elif url_tuple.scheme == APP_URI_SCHEME: target_url = self.parse_x_kolibri_app_url_tuple(url_tuple) return self.__kolibri_daemon.get_absolute_url(target_url) return url @@ -131,7 +133,8 @@ def kolibri_api_get_async(self, *args, **kwargs): def should_open_url(self, url: str) -> bool: return ( url == self.default_url - or urlsplit(url).scheme in ("kolibri", "x-kolibri-app", "about", "blob") + or urlsplit(url).scheme + in (KOLIBRI_URI_SCHEME, APP_URI_SCHEME, "about", "blob") or self.is_url_in_scope(url) ) @@ -230,7 +233,7 @@ def _get_kolibri_library_path(self, search: typing.Optional[str] = None) -> str: return f"{LEARN_PATH_PREFIX}home" def url_to_x_kolibri_app(self, url: str) -> str: - return urlsplit(url)._replace(scheme="x-kolibri-app", netloc="").geturl() + return urlsplit(url)._replace(scheme=APP_URI_SCHEME, netloc="").geturl() def parse_x_kolibri_app_url_tuple(self, url_tuple: SplitResult) -> str: """ @@ -399,7 +402,7 @@ def __init__(self, channel_id: str): @property def default_url(self) -> str: - return f"x-kolibri-app:{self.__default_path}" + return f"{APP_URI_SCHEME}:{self.__default_path}" @property def __default_path(self) -> str: diff --git a/src/kolibri_gnome_launcher/application.py b/src/kolibri_gnome_launcher/application.py index 3418ea8..76d5a55 100644 --- a/src/kolibri_gnome_launcher/application.py +++ b/src/kolibri_gnome_launcher/application.py @@ -4,6 +4,8 @@ from urllib.parse import urlunparse from gi.repository import Gio +from kolibri_app.config import DISPATCH_URI_SCHEME +from kolibri_app.config import KOLIBRI_URI_SCHEME from kolibri_app.config import LAUNCHER_APPLICATION_ID logger = logging.getLogger(__name__) @@ -41,7 +43,7 @@ def do_open(self, files: list, n_files: int, hint: str): def handle_uri(self, uri: str): url_tuple = urlsplit(uri) - if url_tuple.scheme == "x-kolibri-dispatch": + if url_tuple.scheme == DISPATCH_URI_SCHEME: channel_id = url_tuple.netloc node_path = url_tuple.path node_query = url_tuple.query @@ -59,7 +61,7 @@ def handle_uri(self, uri: str): if node_path or node_query: kolibri_node_url = urlunparse( - ("kolibri", node_path, "", None, node_query, None) + (KOLIBRI_URI_SCHEME, node_path, "", None, node_query, None) ) kolibri_gnome_args.append(kolibri_node_url) diff --git a/src/kolibri_gnome_search_provider/kolibri-gnome-search-provider.c b/src/kolibri_gnome_search_provider/kolibri-gnome-search-provider.c index ece1c7c..cbb28c6 100644 --- a/src/kolibri_gnome_search_provider/kolibri-gnome-search-provider.c +++ b/src/kolibri_gnome_search_provider/kolibri-gnome-search-provider.c @@ -266,7 +266,7 @@ build_kolibri_dispatch_uri(const gchar *channel_id, uri_path = g_strconcat("/", node_path, NULL); kolibri_uri = g_uri_build(G_URI_FLAGS_NONE, - "x-kolibri-dispatch", + DISPATCH_URI_SCHEME, NULL, channel_id, -1, diff --git a/src/kolibri_gnome_search_provider/meson.build b/src/kolibri_gnome_search_provider/meson.build index ddcd991..9f5a7c5 100644 --- a/src/kolibri_gnome_search_provider/meson.build +++ b/src/kolibri_gnome_search_provider/meson.build @@ -5,6 +5,7 @@ gobject_dep = dependency('gobject-2.0') _c_config = configuration_data() _c_config.set_quoted('PACKAGE_STRING', package_string) +_c_config.set_quoted('DISPATCH_URI_SCHEME', dispatch_uri_scheme) _c_config.set_quoted('FRONTEND_APPLICATION_ID', frontend_application_id) _c_config.set_quoted('FRONTEND_OBJECT_PATH', frontend_object_path) _c_config.set_quoted('FRONTEND_CHANNEL_APPLICATION_ID_PREFIX', frontend_channel_application_id_prefix) From d1ef58329f2d65d5861bff70af5dbd566beb6295 Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Thu, 23 Nov 2023 13:56:55 -0800 Subject: [PATCH 3/4] Use a custom URI prefix for Endless Key Sometimes, the application uses custom URI schemes to communicate with itself. In order to avoid conflicts with other versions of Endless Key or Kolibri, prefix those URIs with a specific string set at build time. https://github.com/endlessm/endless-key-flatpak/issues/102 --- build-aux/flatpak/org.endlessos.Key.Devel.json | 3 ++- data/metainfo/org.endlessos.Key.metainfo.xml.in.in | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build-aux/flatpak/org.endlessos.Key.Devel.json b/build-aux/flatpak/org.endlessos.Key.Devel.json index fd629bb..134ee45 100644 --- a/build-aux/flatpak/org.endlessos.Key.Devel.json +++ b/build-aux/flatpak/org.endlessos.Key.Devel.json @@ -67,7 +67,8 @@ "-Dprofile=development", "-Dbase_application_id=org.endlessos.Key", "-Dbase_object_path=/org/endlessos/Key", - "-Denv_prefix=ENDLESS_KEY_" + "-Denv_prefix=ENDLESS_KEY_", + "-Duri_prefix=x-endless-key" ], "sources" : [ { diff --git a/data/metainfo/org.endlessos.Key.metainfo.xml.in.in b/data/metainfo/org.endlessos.Key.metainfo.xml.in.in index 3d1c111..89dda3a 100644 --- a/data/metainfo/org.endlessos.Key.metainfo.xml.in.in +++ b/data/metainfo/org.endlessos.Key.metainfo.xml.in.in @@ -61,13 +61,17 @@ - +
  • Kolibri's debug mode can now be enabled with the KOLIBRI_DEBUG environment variable.
  • +
  • + The Endless Key app now uses its own set of URI schemes, so Kolibri + channel launchers will not try to open in Endless Key. +
From 12321922812b5fdc2132a1db6256b6a10686cb7f Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Thu, 23 Nov 2023 15:59:48 -0800 Subject: [PATCH 4/4] Replace default build options Instead of relying on build configuration, patch the default values in our downstream meson_options with an Endless Key-specific app ID, as well as environment variable and URI scheme prefixes. https://github.com/endlessm/endless-key-flatpak/issues/102 --- build-aux/flatpak/org.endlessos.Key.Devel.json | 6 +----- meson_options.txt | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/build-aux/flatpak/org.endlessos.Key.Devel.json b/build-aux/flatpak/org.endlessos.Key.Devel.json index 134ee45..bb0dc3c 100644 --- a/build-aux/flatpak/org.endlessos.Key.Devel.json +++ b/build-aux/flatpak/org.endlessos.Key.Devel.json @@ -64,11 +64,7 @@ "builddir" : true, "run-tests" : true, "config-opts" : [ - "-Dprofile=development", - "-Dbase_application_id=org.endlessos.Key", - "-Dbase_object_path=/org/endlessos/Key", - "-Denv_prefix=ENDLESS_KEY_", - "-Duri_prefix=x-endless-key" + "-Dprofile=development" ], "sources" : [ { diff --git a/meson_options.txt b/meson_options.txt index 4060732..758c3bd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -11,27 +11,27 @@ option( option( 'base_application_id', type: 'string', - value: 'org.learningequality.Kolibri', + value: 'org.endlessos.Key', description: 'Base application ID. When profile is "development", ".Devel" is appended' ) option( 'base_object_path', type: 'string', - value: '/org/learningequality/Kolibri', + value: '/org/endlessos/Key', description: 'Base D-Bus object path. When profile is "development", "/Devel" is appended' ) option( 'env_prefix', type: 'string', - value: 'KOLIBRI_', + value: 'ENDLESS_KEY_', description: 'Prefix for environment variables. When profile is "development", "DEVEL_" is appended' ) option( 'uri_prefix', type: 'string', - value: 'x-kolibri', + value: 'x-endless-key', description: 'Prefix for custom URI schemes. When profile is "development", "-devel" is appended' )