diff --git a/extension/extension.js b/extension/extension.js
--- a/extension/extension.js
+++ b/extension/extension.js
@@ -181,3 +181,7 @@
addRuntimeCallback("settings", "openKRunnerSettings", function () {
sendPortMessage("settings", "openKRunnerSettings");
});
+
+addRuntimeCallback("settings", "getSubsystemStatus", (message, sender, action) => {
+ return sendPortMessageWithReply("settings", "getSubsystemStatus");
+});
diff --git a/extension/options.html b/extension/options.html
--- a/extension/options.html
+++ b/extension/options.html
@@ -19,7 +19,7 @@
-
I18N
+
I18N
-
diff --git a/extension/options.css b/extension/options.css
--- a/extension/options.css
+++ b/extension/options.css
@@ -4,16 +4,20 @@
overflow: hidden;
}
-.not-supported-info {
+.os-not-supported-info {
display: none;
}
-body.not-supported .not-supported-info {
+body.os-not-supported .os-not-supported-info {
display: block;
}
-body.not-supported #extensions-selection {
+body.os-not-supported #extensions-selection {
display: none;
}
+.not-supported {
+ display: none !important;
+}
+
.tabbar {
display: block;
padding: 0;
diff --git a/extension/options.js b/extension/options.js
--- a/extension/options.js
+++ b/extension/options.js
@@ -182,7 +182,7 @@
// check whether the platform is supported before loading and activating settings
chrome.runtime.getPlatformInfo(function (info) {
if (!SUPPORTED_PLATFORMS.includes(info.os)) {
- document.body.classList.add("not-supported");
+ document.body.classList.add("os-not-supported");
return;
}
@@ -194,6 +194,41 @@
});
mprisEx.disabled = !mpris.checked;
});
+
+ // When getSubsystemStatus fails we assume it's an old host without any of the new features
+ // for which we added the requires-extension attributes. Disable all of them initially
+ // and then have the supported ones enabled below.
+ document.querySelectorAll("[data-requires-extension]").forEach((item) => {
+ item.classList.add("not-supported", "by-host");
+ });
+
+ sendMessage("settings", "getSubsystemStatus").then((status) => {
+ document.querySelectorAll("[data-requires-extension]").forEach((item) => {
+ let requiresExtension = item.dataset.requiresExtension;
+
+ if (requiresExtension && !status.hasOwnProperty(requiresExtension)) {
+ console.log("Extension", requiresExtension, "is not supported by this version of the host");
+ return; // continue
+ }
+
+ let requiresMinimumVersion = Number(item.dataset.requiresExtensionVersionMinimum);
+ if (requiresMinimumVersion) {
+ let runningVersion = status[requiresExtension].version;
+ if (runningVersion < requiresMinimumVersion) {
+ console.log("Extension", requiresExtension, "of version", requiresMinimumVersion, "is required but only", runningVersion, "is present in the host");
+ return; // continue
+ }
+ }
+
+ item.classList.remove("not-supported", "by-host");
+ });
+ }).catch((e) => {
+ // The host is most likely not working correctly
+ // If we run this against an older host which doesn't support message replies
+ // this handler is never entered, so we really encountered an error just now!
+ console.warn("Failed to determine subsystem status", e);
+ // TODO show helpful error message in UI
+ });
});
document.getElementById("open-krunner-settings").addEventListener("click", function (event) {
diff --git a/host/settings.h b/host/settings.h
--- a/host/settings.h
+++ b/host/settings.h
@@ -60,6 +60,7 @@
Q_ENUM(Environment)
void handleData(const QString &event, const QJsonObject &data) override;
+ QJsonObject handleData(int serial, const QString &event, const QJsonObject &data) override;
Environment environment() const;
QString environmentString() const; // dbus
diff --git a/host/settings.cpp b/host/settings.cpp
--- a/host/settings.cpp
+++ b/host/settings.cpp
@@ -136,6 +136,29 @@
}
}
+QJsonObject Settings::handleData(int serial, const QString &event, const QJsonObject &data)
+{
+ Q_UNUSED(serial)
+ Q_UNUSED(data)
+
+ QJsonObject ret;
+
+ if (event == QLatin1String("getSubsystemStatus")) {
+ // should we add a PluginManager::knownSubsystems() that returns a QList?
+ const QStringList subsystems = PluginManager::self().knownPluginSubsystems();
+ for (const QString &subsystem : subsystems) {
+ const AbstractBrowserPlugin *plugin = PluginManager::self().pluginForSubsystem(subsystem);
+ QJsonObject details{
+ {QStringLiteral("version"), plugin->protocolVersion()},
+ {QStringLiteral("loaded"), plugin->isLoaded()}
+ };
+ ret.insert(subsystem, details);
+ }
+ }
+
+ return ret;
+}
+
Settings::Environment Settings::environment() const
{
return m_environment;