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/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. +
diff --git a/meson.build b/meson.build index 22a7ee9..e66a2e6 100644 --- a/meson.build +++ b/meson.build @@ -26,15 +26,16 @@ 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') +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 @@ -52,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') @@ -68,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 a393cc0..758c3bd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,3 +7,31 @@ option( ], value: 'default' ) + +option( + 'base_application_id', + type: 'string', + value: 'org.endlessos.Key', + description: 'Base application ID. When profile is "development", ".Devel" is appended' +) + +option( + 'base_object_path', + type: 'string', + value: '/org/endlessos/Key', + description: 'Base D-Bus object path. When profile is "development", "/Devel" is appended' +) + +option( + 'env_prefix', + type: 'string', + value: 'ENDLESS_KEY_', + description: 'Prefix for environment variables. When profile is "development", "DEVEL_" is appended' +) + +option( + 'uri_prefix', + type: 'string', + value: 'x-endless-key', + 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)