summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2023-12-05 16:32:52 +0100
committerRobert Griebl <robert.griebl@qt.io>2023-12-06 13:55:04 +0100
commit449f519c53ca00a806de4cfb53725fc81605be13 (patch)
tree4921ad5f7213422fe4b80b7023cd3c4390e3adcb
parent14ac678dfd2eb23b111a38db56685798e2f04fd4 (diff)
Replace AM_.. defines with checks for Qt features where possible
Also got rid of hard to read double negated checks (!disabled) Change-Id: I93b0665ccdf60e30a473692167fde5c6d719dfa9 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
-rw-r--r--src/application-main-lib/applicationmain.h2
-rw-r--r--src/common-lib/configure.cmake13
-rw-r--r--src/common-lib/crashhandler.cpp19
-rw-r--r--src/common-lib/logging.cpp28
-rw-r--r--src/main-lib/main.cpp191
-rw-r--r--src/main-lib/main.h7
-rw-r--r--src/manager-lib/intentaminterface.cpp8
-rw-r--r--src/manager-lib/intentaminterface.h4
-rw-r--r--src/manager-lib/nativeruntime.cpp4
-rw-r--r--src/manager-lib/packagemanager.cpp72
-rw-r--r--src/manager-lib/packagemanager_p.h9
-rw-r--r--src/window-lib/systemframetimerimpl.cpp6
-rw-r--r--src/window-lib/systemframetimerimpl.h2
-rw-r--r--src/window-lib/waylandcompositor.h4
-rw-r--r--src/window-lib/waylandwindow.cpp4
-rw-r--r--src/window-lib/waylandwindow.h4
-rw-r--r--src/window-lib/windowitem.cpp20
-rw-r--r--src/window-lib/windowitem.h8
-rw-r--r--src/window-lib/windowmanager.cpp22
-rw-r--r--src/window-lib/windowmanager.h4
-rw-r--r--src/window-lib/windowmanager_p.h2
21 files changed, 207 insertions, 226 deletions
diff --git a/src/application-main-lib/applicationmain.h b/src/application-main-lib/applicationmain.h
index 4f271a9f..6f3773fe 100644
--- a/src/application-main-lib/applicationmain.h
+++ b/src/application-main-lib/applicationmain.h
@@ -10,7 +10,7 @@
#include <QtCore/QVector>
#include <QtAppManCommon/global.h>
#include <QtAppManSharedMain/sharedmain.h>
-#if defined(AM_WIDGETS_SUPPORT)
+#if QT_CONFIG(am_widgets_support)
# include <QtWidgets/QApplication>
using ApplicationMainBase = QApplication;
#else
diff --git a/src/common-lib/configure.cmake b/src/common-lib/configure.cmake
index d88d9da5..d276801f 100644
--- a/src/common-lib/configure.cmake
+++ b/src/common-lib/configure.cmake
@@ -46,15 +46,13 @@ qt_feature("am-multi-process" PUBLIC
ENABLE INPUT_force_mode STREQUAL 'multi'
DISABLE INPUT_force_mode STREQUAL 'single'
)
-qt_feature_definition("am-multi-process" "AM_MULTI_PROCESS")
-qt_feature("am-installer" PRIVATE
+qt_feature("am-installer" PUBLIC
LABEL "Enable the installer component"
CONDITION QT_FEATURE_ssl AND NOT IOS
ENABLE INPUT_installer STREQUAL 'yes'
DISABLE INPUT_installer STREQUAL 'no'
)
-qt_feature_definition("am-installer" "AM_DISABLE_INSTALLER" NEGATE)
qt_feature("am-external-dbus-interfaces" PRIVATE
LABEL "Enable external DBus interfaces"
@@ -62,7 +60,6 @@ qt_feature("am-external-dbus-interfaces" PRIVATE
ENABLE INPUT_external_dbus_interfaces STREQUAL 'yes'
DISABLE INPUT_external_dbus_interfaces STREQUAL 'no'
)
-qt_feature_definition("am-external-dbus-interfaces" "AM_DISABLE_EXTERNAL_DBUS_INTERFACES" NEGATE)
qt_feature("am-package-server" PRIVATE
LABEL "Build the package-server"
@@ -84,7 +81,6 @@ qt_feature("am-dltlogging" PRIVATE
ENABLE INPUT_dltlogging STREQUAL 'yes'
DISABLE INPUT_dltlogging STREQUAL 'no'
)
-qt_feature_definition("am-dltlogging" "AM_USE_DLTLOGGING")
qt_feature("am-libbacktrace" PRIVATE
LABEL "Enable support for libbacktrace"
@@ -93,7 +89,6 @@ qt_feature("am-libbacktrace" PRIVATE
ENABLE INPUT_libbacktrace STREQUAL 'yes'
DISABLE INPUT_libbacktrace STREQUAL 'no'
)
-qt_feature_definition("am-libbacktrace" "AM_USE_LIBBACKTRACE")
qt_feature("am-stackwalker" PRIVATE
LABEL "Enable support for StackWalker"
@@ -102,22 +97,20 @@ qt_feature("am-stackwalker" PRIVATE
ENABLE INPUT_stackwalker STREQUAL 'yes'
DISABLE INPUT_stackwalker STREQUAL 'no'
)
-qt_feature_definition("am-stackwalker" "AM_USE_STACKWALKER")
qt_feature("am-has-hardware-id" PRIVATE
LABEL "Hardware-id for the installer"
CONDITION ON
DISABLE INPUT_hardware_id STREQUAL ''
)
-qt_feature_definition("am-has-hardware-id" "AM_HARDWARE_ID" VALUE "\"${INPUT_hardware_id}\"")
+qt_feature_definition("am-has-hardware-id" "QT_AM_HARDWARE_ID" VALUE "\"${INPUT_hardware_id}\"")
-qt_feature("am-widgets-support" PRIVATE PUBLIC
+qt_feature("am-widgets-support" PUBLIC
LABEL "Enable support for Qt widgets"
CONDITION TARGET Qt::Widgets
ENABLE INPUT_widgets_support STREQUAL 'yes'
DISABLE INPUT_widgets_support STREQUAL 'no'
)
-qt_feature_definition("am-widgets-support" "AM_WIDGETS_SUPPORT")
qt_configure_add_summary_section(NAME "Qt Application Manager")
qt_configure_add_summary_entry(ARGS "am-system-libyaml")
diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp
index 38efd9c7..8af4a45d 100644
--- a/src/common-lib/crashhandler.cpp
+++ b/src/common-lib/crashhandler.cpp
@@ -20,6 +20,7 @@
#include "logging.h"
#include "console.h"
#include "colorprint.h"
+#include "qtappman_common-config_p.h"
#if defined(Q_OS_UNIX)
# include<unistd.h>
@@ -268,7 +269,7 @@ QT_END_NAMESPACE_AM
# include <cstdio>
# include <cstdlib>
-# if defined(AM_USE_LIBBACKTRACE)
+# if QT_CONFIG(am_libbacktrace)
# include <libbacktrace/backtrace.h>
# include <libbacktrace/backtrace-supported.h>
# endif
@@ -397,7 +398,7 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
# endif
}
-# if defined(AM_USE_LIBBACKTRACE) && defined(BACKTRACE_SUPPORTED)
+# if QT_CONFIG(am_libbacktrace) && defined(BACKTRACE_SUPPORTED)
struct btData
{
LogToDestination logTo;
@@ -469,7 +470,7 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
//backtrace_print(state, stackFramesToIgnore, stderr);
backtrace_simple(state, stackFramesToIgnore, simpleCallback, errorCallback, &data);
-# else // !defined(AM_USE_LIBBACKTRACE) && defined(BACKTRACE_SUPPORTED)
+# else // QT_CONFIG(am_libbacktrace) && defined(BACKTRACE_SUPPORTED)
Q_UNUSED(stackFramesToIgnore);
# if !defined(Q_OS_QNX)
void *addrArray[1024];
@@ -533,7 +534,7 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
logMsg(logTo, "\n > C++ backtrace:");
logMsg(logTo, out);
# endif
-# endif // defined(AM_USE_LIBBACKTRACE) && defined(BACKTRACE_SUPPORTED)
+# endif // QT_CONFIG(am_libbacktrace) && defined(BACKTRACE_SUPPORTED)
}
logQmlBacktrace(logTo);
}
@@ -600,7 +601,7 @@ QT_END_NAMESPACE_AM
# include <windows.h>
# include <dbghelp.h>
-# if defined(AM_USE_STACKWALKER)
+# if QT_CONFIG(am_stackwalker)
# include <stackwalker.h>
# endif
@@ -608,7 +609,7 @@ QT_BEGIN_NAMESPACE_AM
static DWORD mainThreadId = GetCurrentThreadId();
-# if defined(AM_USE_STACKWALKER)
+# if QT_CONFIG(am_stackwalker)
class AMStackWalker : public StackWalker
{
@@ -653,7 +654,7 @@ private:
int ignoreUpToLevel = 0;
};
-# endif // defined(AM_USE_STACKWALKER)
+# endif // QT_CONFIG(am_stackwalker)
static void logCrashInfo(LogToDestination logTo, const char *why, int stackFramesToIgnore, CONTEXT *context)
{
@@ -691,7 +692,7 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
logMsgF(logTo, "\n > where: %S thread, TID: %lu", threadName, tid);
if (chg()->printBacktrace && context) {
-# if defined(AM_USE_STACKWALKER)
+# if QT_CONFIG(am_stackwalker)
logMsg(logTo, "\n > C++ backtrace:");
AMStackWalker sw(logTo, stackFramesToIgnore);
sw.ShowCallstack(GetCurrentThread(), context);
@@ -705,7 +706,7 @@ static void logCrashInfo(LogToDestination logTo, const char *why, int stackFrame
);
Q_UNUSED(context)
Q_UNUSED(stackFramesToIgnore)
-# endif // defined(AM_USE_STACKWALKER)
+# endif // QT_CONFIG(am_stackwalker)
}
logQmlBacktrace(logTo);
}
diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp
index 9dfeed8e..3d3ae236 100644
--- a/src/common-lib/logging.cpp
+++ b/src/common-lib/logging.cpp
@@ -14,6 +14,7 @@
#include "logging.h"
#include "console.h"
#include "colorprint.h"
+#include "qtappman_common-config_p.h"
#include <cstdio>
@@ -24,7 +25,7 @@
# include <android/log.h>
#endif
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
# include <QtDltLogging/QtDlt>
# include <QtDltLogging/QDltRegistration>
#else
@@ -39,7 +40,7 @@
QT_BEGIN_NAMESPACE_AM
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
static constexpr const char *s_defaultSystemUiDltId = "QTAM";
static constexpr const char *s_defaultSystemUiDltDescription = "Qt Application Manager";
#endif
@@ -141,12 +142,7 @@ struct DeferredMessage
struct LoggingGlobal
{
- bool dltEnabled =
-#if defined(AM_USE_DLTLOGGING)
- true;
-#else
- false;
-#endif
+ bool dltEnabled = QT_CONFIG(am_dltlogging);
bool messagePatternDefined = false;
bool useAMConsoleLogger = false;
bool noCustomLogging = false;
@@ -372,7 +368,7 @@ static void colorLogToStderr(QtMsgType msgType, const QMessageLogContext &contex
void Logging::messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
{
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
if (lg()->dltEnabled)
QDltRegistration::messageHandler(msgType, context, message);
#endif
@@ -439,10 +435,8 @@ void Logging::setFilterRules(const QStringList &rules)
{
lg()->rules = rules;
QString rulesStr = rules.join(qL1C('\n'));
-#if defined(AM_USE_DLTLOGGING)
- if (lg()->dltEnabled)
+ if (QT_CONFIG(am_dltlogging) && lg()->dltEnabled)
rulesStr += qSL("\ngeneral=true");
-#endif
QLoggingCategory::setFilterRules(rulesStr);
}
@@ -514,7 +508,7 @@ void Logging::setDltEnabled(bool enabled)
void Logging::registerUnregisteredDltContexts()
{
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
if (lg()->dltEnabled)
globalDltRegistration()->registerUnregisteredContexts();
#endif
@@ -522,7 +516,7 @@ void Logging::registerUnregisteredDltContexts()
void Logging::setSystemUiDltId(const QByteArray &dltAppId, const QByteArray &dltAppDescription)
{
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
if (lg()->dltEnabled) {
const QByteArray id = dltAppId.isEmpty() ? QByteArray(s_defaultSystemUiDltId) : dltAppId;
const QByteArray description = dltAppDescription.isEmpty() ? QByteArray(s_defaultSystemUiDltDescription)
@@ -537,7 +531,7 @@ void Logging::setSystemUiDltId(const QByteArray &dltAppId, const QByteArray &dlt
void Logging::setDltApplicationId(const QByteArray &dltAppId, const QByteArray &dltAppDescription)
{
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
if (lg()->dltEnabled)
globalDltRegistration()->registerApplication(dltAppId, dltAppDescription);
#else
@@ -558,7 +552,7 @@ void Logging::setDltLongMessageBehavior(const QString &behaviorString)
lg()->dltLongMessageBehavior = behaviorString;
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
QDltRegistration::LongMessageBehavior behavior = QDltRegistration::LongMessageBehavior::Truncate;
if (behaviorString == qL1S("split"))
behavior = QDltRegistration::LongMessageBehavior::Split;
@@ -571,7 +565,7 @@ void Logging::setDltLongMessageBehavior(const QString &behaviorString)
void Logging::logToDlt(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
{
-#if defined(AM_USE_DLTLOGGING)
+#if QT_CONFIG(am_dltlogging)
if (lg()->dltEnabled)
QDltRegistration::messageHandler(msgType, context, message);
#else
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index b43d2ddd..94261568 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -7,7 +7,9 @@
#include <cstdlib>
#include <qglobal.h>
-#if defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
+#include "qtappman_common-config_p.h"
+
+#if defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
# include <QDBusConnection>
# include <QDBusAbstractAdaptor>
# include "dbusdaemon.h"
@@ -53,13 +55,13 @@
#include "installationreport.h"
#include "yamlpackagescanner.h"
#include "sudo.h"
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
# include "packageutilities.h"
#endif
#include "runtimefactory.h"
#include "containerfactory.h"
#include "quicklauncher.h"
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
# include "processcontainer.h"
# include "nativeruntime.h"
#endif
@@ -101,6 +103,88 @@ AM_QML_REGISTER_TYPES(QtApplicationManager_Application)
QT_BEGIN_NAMESPACE_AM
+
+#if defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
+
+static void registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, const char *serviceName,
+ const char *interfaceName, const char *path,
+ const QString &instanceId) Q_DECL_NOEXCEPT_EXPR(false)
+{
+ QString dbusAddress;
+ QDBusConnection conn((QString()));
+
+ if (dbusName.isEmpty()) {
+ return;
+ } else if (dbusName == qL1S("system")) {
+ dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SYSTEM_BUS_ADDRESS"));
+# if defined(Q_OS_LINUX)
+ if (dbusAddress.isEmpty())
+ dbusAddress = qL1S("unix:path=/var/run/dbus/system_bus_socket");
+# endif
+ conn = QDBusConnection::systemBus();
+ } else if (dbusName == qL1S("session")) {
+ dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS"));
+ conn = QDBusConnection::sessionBus();
+ } else if (dbusName == qL1S("auto")) {
+ dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS"));
+ // we cannot be using QDBusConnection::sessionBus() here, because some plugin
+ // might have called that function before we could spawn our own session bus. In
+ // this case, Qt has cached the bus name and we would get the old one back.
+ conn = QDBusConnection::connectToBus(dbusAddress, qSL("qtam_session"));
+ if (!conn.isConnected())
+ return;
+ dbusName = qL1S("session");
+ } else {
+ dbusAddress = dbusName;
+ conn = QDBusConnection::connectToBus(dbusAddress, qSL("custom"));
+ }
+
+ if (!conn.isConnected()) {
+ throw Exception("could not connect to D-Bus (%1): %2")
+ .arg(dbusAddress.isEmpty() ? dbusName : dbusAddress).arg(conn.lastError().message());
+ }
+
+ if (adaptor->parent() && adaptor->parent()->parent()) {
+ // we need this information later on to tell apps where services are listening
+ adaptor->parent()->parent()->setProperty("_am_dbus_name", dbusName);
+ adaptor->parent()->parent()->setProperty("_am_dbus_address", dbusAddress);
+ }
+
+ if (!conn.registerObject(qL1S(path), adaptor->parent(), QDBusConnection::ExportAdaptors)) {
+ throw Exception("could not register object %1 on D-Bus (%2): %3")
+ .arg(qL1S(path)).arg(dbusName).arg(conn.lastError().message());
+ }
+
+ if (!conn.registerService(qL1S(serviceName))) {
+ throw Exception("could not register service %1 on D-Bus (%2): %3")
+ .arg(qL1S(serviceName)).arg(dbusName).arg(conn.lastError().message());
+ }
+
+ qCDebug(LogSystem).nospace().noquote() << " * " << serviceName << path << " [on bus: " << dbusName << "]";
+
+ if (QByteArray::fromRawData(interfaceName, int(qstrlen(interfaceName))).startsWith("io.qt.")) {
+ // Write the bus address of the interface to a file in /tmp. This is needed for the
+ // controller tool, which does not even have a session bus, when started via ssh.
+
+ QString fileName = qL1S(interfaceName) % qSL(".dbus");
+ if (!instanceId.isEmpty())
+ fileName = instanceId % u'-' % fileName;
+
+ QFile f(QDir::temp().absoluteFilePath(fileName));
+ QByteArray dbusUtf8 = dbusAddress.isEmpty() ? dbusName.toUtf8() : dbusAddress.toUtf8();
+ if (!f.open(QFile::WriteOnly | QFile::Truncate) || (f.write(dbusUtf8) != dbusUtf8.size()))
+ throw Exception(f, "Could not write D-Bus address of interface %1").arg(qL1S(interfaceName));
+
+ static QStringList filesToDelete;
+ if (filesToDelete.isEmpty())
+ atexit([]() { for (const QString &ftd : std::as_const(filesToDelete)) QFile::remove(ftd); });
+ filesToDelete << f.fileName();
+ }
+}
+
+#endif // defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
+
+
// We need to do some things BEFORE the Q*Application constructor runs, so we're using this
// old trick to do this hooking transparently for the user of the class.
int &Main::preConstructor(int &argc, char **argv, InitFlags initFlags)
@@ -113,7 +197,7 @@ int &Main::preConstructor(int &argc, char **argv, InitFlags initFlags)
Sudo::forkServer(Sudo::DropPrivilegesPermanently);
StartupTimer::instance()->checkpoint("after sudo server fork");
}
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
// try to set a reasonable locale - we later verify with checkCorrectLocale() if we succeeded
PackageUtilities::ensureCorrectLocale();
#endif
@@ -161,7 +245,7 @@ Main::~Main()
delete ContainerFactory::instance();
delete StartupTimer::instance();
-#if defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
+#if defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
delete DBusPolicy::instance();
#endif
}
@@ -378,7 +462,7 @@ void Main::setupSingleOrMultiProcess(bool forceSingleProcess, bool forceMultiPro
if (forceMultiProcess && m_isSingleProcessMode)
throw Exception("You cannot enforce multi- and single-process mode at the same time.");
-#if !defined(AM_MULTI_PROCESS)
+#if !QT_CONFIG(am_multi_process)
if (forceMultiProcess)
throw Exception("This application manager build is not multi-process capable.");
m_isSingleProcessMode = true;
@@ -397,7 +481,7 @@ void Main::setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations,
RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("qml")));
} else {
RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager());
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager());
RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager(qSL("qml")));
@@ -520,7 +604,7 @@ void Main::setupQuickLauncher(int quickLaunchRuntimesPerContainer, qreal quickLa
void Main::setupInstaller(bool allowUnsigned, const QStringList &caCertificatePaths) Q_DECL_NOEXCEPT_EXPR(false)
{
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
if (Q_UNLIKELY(!PackageUtilities::checkCorrectLocale())) {
// we should really throw here, but so many embedded systems are badly set up
qCWarning(LogDeployment) << "The appman installer needs a UTF-8 locale to work correctly: "
@@ -572,7 +656,7 @@ void Main::setupInstaller(bool allowUnsigned, const QStringList &caCertificatePa
#else
Q_UNUSED(allowUnsigned)
Q_UNUSED(caCertificatePaths)
-#endif // AM_DISABLE_INSTALLER
+#endif // QT_CONFIG(am_installer)
}
void Main::registerPackages()
@@ -833,92 +917,11 @@ void Main::showWindow(bool showFullscreen)
}
}
-#if defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
-
-void Main::registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, const char *serviceName,
- const char *interfaceName, const char *path,
- const QString &instanceId) Q_DECL_NOEXCEPT_EXPR(false)
-{
- QString dbusAddress;
- QDBusConnection conn((QString()));
-
- if (dbusName.isEmpty()) {
- return;
- } else if (dbusName == qL1S("system")) {
- dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SYSTEM_BUS_ADDRESS"));
-# if defined(Q_OS_LINUX)
- if (dbusAddress.isEmpty())
- dbusAddress = qL1S("unix:path=/var/run/dbus/system_bus_socket");
-# endif
- conn = QDBusConnection::systemBus();
- } else if (dbusName == qL1S("session")) {
- dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS"));
- conn = QDBusConnection::sessionBus();
- } else if (dbusName == qL1S("auto")) {
- dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS"));
- // we cannot be using QDBusConnection::sessionBus() here, because some plugin
- // might have called that function before we could spawn our own session bus. In
- // this case, Qt has cached the bus name and we would get the old one back.
- conn = QDBusConnection::connectToBus(dbusAddress, qSL("qtam_session"));
- if (!conn.isConnected())
- return;
- dbusName = qL1S("session");
- } else {
- dbusAddress = dbusName;
- conn = QDBusConnection::connectToBus(dbusAddress, qSL("custom"));
- }
-
- if (!conn.isConnected()) {
- throw Exception("could not connect to D-Bus (%1): %2")
- .arg(dbusAddress.isEmpty() ? dbusName : dbusAddress).arg(conn.lastError().message());
- }
-
- if (adaptor->parent() && adaptor->parent()->parent()) {
- // we need this information later on to tell apps where services are listening
- adaptor->parent()->parent()->setProperty("_am_dbus_name", dbusName);
- adaptor->parent()->parent()->setProperty("_am_dbus_address", dbusAddress);
- }
-
- if (!conn.registerObject(qL1S(path), adaptor->parent(), QDBusConnection::ExportAdaptors)) {
- throw Exception("could not register object %1 on D-Bus (%2): %3")
- .arg(qL1S(path)).arg(dbusName).arg(conn.lastError().message());
- }
-
- if (!conn.registerService(qL1S(serviceName))) {
- throw Exception("could not register service %1 on D-Bus (%2): %3")
- .arg(qL1S(serviceName)).arg(dbusName).arg(conn.lastError().message());
- }
-
- qCDebug(LogSystem).nospace().noquote() << " * " << serviceName << path << " [on bus: " << dbusName << "]";
-
- if (QByteArray::fromRawData(interfaceName, int(qstrlen(interfaceName))).startsWith("io.qt.")) {
- // Write the bus address of the interface to a file in /tmp. This is needed for the
- // controller tool, which does not even have a session bus, when started via ssh.
-
- QString fileName = qL1S(interfaceName) % qSL(".dbus");
- if (!instanceId.isEmpty())
- fileName = instanceId % u'-' % fileName;
-
- QFile f(QDir::temp().absoluteFilePath(fileName));
- QByteArray dbusUtf8 = dbusAddress.isEmpty() ? dbusName.toUtf8() : dbusAddress.toUtf8();
- if (!f.open(QFile::WriteOnly | QFile::Truncate) || (f.write(dbusUtf8) != dbusUtf8.size()))
- throw Exception(f, "Could not write D-Bus address of interface %1").arg(qL1S(interfaceName));
-
- static QStringList filesToDelete;
- if (filesToDelete.isEmpty())
- atexit([]() { for (const QString &ftd : std::as_const(filesToDelete)) QFile::remove(ftd); });
- filesToDelete << f.fileName();
- }
-}
-
-#endif // defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
-
-
void Main::setupDBus(const std::function<QString(const char *)> &busForInterface,
const std::function<QVariantMap(const char *)> &policyForInterface,
const QString &instanceId)
{
-#if defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
+#if defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
registerDBusTypes();
DBusPolicy::createInstance([](qint64 pid) { return ApplicationManager::instance()->identifyAllApplications(pid); },
@@ -1000,15 +1003,15 @@ void Main::setupDBus(const std::function<QString(const char *)> &busForInterface
Q_UNUSED(busForInterface)
Q_UNUSED(policyForInterface)
Q_UNUSED(instanceId)
-#endif // defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
+#endif // defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces)
}
QString Main::hardwareId() const
{
static QString hardwareId;
if (hardwareId.isEmpty()) {
-#if defined(AM_HARDWARE_ID)
- hardwareId = QString::fromLocal8Bit(AM_HARDWARE_ID);
+#if defined(QT_AM_HARDWARE_ID)
+ hardwareId = QString::fromLocal8Bit(QT_AM_HARDWARE_ID);
if (hardwareId.startsWith(qL1C('@'))) {
QFile f(hardwareId.mid(1));
hardwareId.clear();
diff --git a/src/main-lib/main.h b/src/main-lib/main.h
index 1329c0ad..94213e18 100644
--- a/src/main-lib/main.h
+++ b/src/main-lib/main.h
@@ -12,7 +12,7 @@
#include <QtAppManCommon/logging.h>
#include <QtAppManManager/sudo.h>
-#if defined(AM_WIDGETS_SUPPORT)
+#if QT_CONFIG(am_widgets_support)
# include <QtWidgets/QApplication>
# include <QtGui/QSurfaceFormat>
QT_BEGIN_NAMESPACE_AM
@@ -112,11 +112,6 @@ protected:
QString hardwareId() const;
private:
-#if defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES)
- void registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, const char *serviceName,
- const char *interfaceName, const char *path,
- const QString &instanceId) Q_DECL_NOEXCEPT_EXPR(false);
-#endif
static int &preConstructor(int &argc, char **argv, InitFlags initFlags);
private:
diff --git a/src/manager-lib/intentaminterface.cpp b/src/manager-lib/intentaminterface.cpp
index 05454b4b..59ff126c 100644
--- a/src/manager-lib/intentaminterface.cpp
+++ b/src/manager-lib/intentaminterface.cpp
@@ -4,7 +4,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "global.h"
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
# include <QDBusMessage>
# include <QDBusConnection>
# include <QDBusPendingCallWatcher>
@@ -146,7 +146,7 @@ void IntentServerAMImplementation::initialize(IntentServer *server)
// wire it up to both interfaces from the outside
connect(AbstractRuntime::signaler(), &RuntimeSignaler::aboutToStart,
intentServer(), [this](AbstractRuntime *runtime) {
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (NativeRuntime *nativeRuntime = qobject_cast<NativeRuntime *>(runtime)) {
connect(nativeRuntime, &NativeRuntime::applicationConnectedToPeerDBus,
intentServer(), [this](const QDBusConnection &connection, Application *application) {
@@ -411,7 +411,7 @@ void IntentServerInProcessIpcConnection::replyFromSystem(IntentServerRequest *is
//////////////////////////////////////////////////////////////////////////
// vvv IntentServerDBusIpcConnection vvv
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
IntentServerDBusIpcConnection::IntentServerDBusIpcConnection(QDBusConnection connection,
Application *application,
@@ -506,7 +506,7 @@ void IntentServerDBusIpcConnection::replyFromApplication(const QString &requestI
QT_END_NAMESPACE_AM
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
IntentInterfaceAdaptor::IntentInterfaceAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
diff --git a/src/manager-lib/intentaminterface.h b/src/manager-lib/intentaminterface.h
index ea1777b2..78b7be0f 100644
--- a/src/manager-lib/intentaminterface.h
+++ b/src/manager-lib/intentaminterface.h
@@ -13,7 +13,7 @@
#include <QtCore/QUrl>
#include <QtAppManCommon/global.h>
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
# include <QtDBus/QDBusConnection>
# include <QtDBus/QDBusContext>
#endif
@@ -131,7 +131,7 @@ private:
bool m_isSystemUi = false;
};
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
// ... derived for P2P DBus clients
class IntentServerDBusIpcConnection : public IntentServerIpcConnection, public QDBusContext
diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp
index 6ee18abc..f0f418dd 100644
--- a/src/manager-lib/nativeruntime.cpp
+++ b/src/manager-lib/nativeruntime.cpp
@@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE_AM
// #define EXPORT_P2PBUS_OBJECTS_TO_SESSION_BUS 1
-#if defined(AM_MULTI_PROCESS) && defined(Q_OS_LINUX)
+#if QT_CONFIG(am_multi_process) && defined(Q_OS_LINUX)
QT_END_NAMESPACE_AM
# include <dlfcn.h>
# include <sys/socket.h>
@@ -83,7 +83,7 @@ NativeRuntime::NativeRuntime(AbstractContainer *container, Application *app, Nat
connect(m_applicationInterfaceServer, &QDBusServer::newConnection,
this, [this](const QDBusConnection &connection) {
-#if defined(AM_MULTI_PROCESS) && defined(Q_OS_LINUX)
+#if QT_CONFIG(am_multi_process) && defined(Q_OS_LINUX)
qint64 pid = getDBusPeerPid(connection);
if (pid <= 0) {
QDBusConnection::disconnectFromPeer(connection.name());
diff --git a/src/manager-lib/packagemanager.cpp b/src/manager-lib/packagemanager.cpp
index 82b8e87c..bd406a0c 100644
--- a/src/manager-lib/packagemanager.cpp
+++ b/src/manager-lib/packagemanager.cpp
@@ -19,7 +19,7 @@
#include "exception.h"
#include "sudo.h"
#include "utilities.h"
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
# include "installationtask.h"
# include "deinstallationtask.h"
#endif
@@ -302,9 +302,7 @@ PackageManager *PackageManager::instance()
void PackageManager::enableInstaller()
{
-#if !defined(AM_DISABLE_INSTALLER)
- d->disableInstaller = false;
-#endif
+ d->enableInstaller = QT_CONFIG(am_installer);
}
void PackageManager::registerPackages()
@@ -360,7 +358,7 @@ void PackageManager::registerPackages()
emit readyChanged(d->cleanupBrokenInstallationsDone);
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
// something might have been queued already before the cleanup had finished
triggerExecuteNextTask();
#endif
@@ -828,7 +826,7 @@ QVariantMap PackageManager::documentLocation() const
bool PackageManager::isPackageInstallationActive(const QString &packageId) const
{
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
for (const auto *t : std::as_const(d->installationTaskList)) {
if (t->packageId() == packageId)
return true;
@@ -844,7 +842,7 @@ void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false)
if (d->cleanupBrokenInstallationsDone)
return;
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
// Check that everything in the app-db is available
// -> if not, remove from app-db
@@ -927,7 +925,7 @@ void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false)
}
}
}
-#endif // !defined(AM_DISABLE_INSTALLER)
+#endif // QT_CONFIG(am_installer)
d->cleanupBrokenInstallationsDone = true;
}
@@ -1020,8 +1018,8 @@ QString PackageManager::startPackageInstallation(const QUrl &sourceUrl)
{
AM_TRACE(LogInstaller, sourceUrl)
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller)
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller)
return enqueueTask(new InstallationTask(d->installationPath, d->documentPath, sourceUrl));
#endif
return QString();
@@ -1069,8 +1067,8 @@ void PackageManager::acknowledgePackageInstallation(const QString &taskId)
{
AM_TRACE(LogInstaller, taskId)
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
const auto allTasks = d->allTasks();
for (AsynchronousTask *task : allTasks) {
@@ -1103,8 +1101,8 @@ QString PackageManager::removePackage(const QString &packageId, bool keepDocumen
{
AM_TRACE(LogInstaller, packageId, keepDocuments, force)
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
if (fromId(packageId)) {
return enqueueTask(new DeinstallationTask(packageId, d->installationPath,
d->documentPath, force, keepDocuments));
@@ -1125,8 +1123,8 @@ QString PackageManager::removePackage(const QString &packageId, bool keepDocumen
*/
AsynchronousTask::TaskState PackageManager::taskState(const QString &taskId) const
{
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
const auto allTasks = d->allTasks();
for (const AsynchronousTask *task : allTasks) {
@@ -1152,8 +1150,8 @@ AsynchronousTask::TaskState PackageManager::taskState(const QString &taskId) con
*/
QString PackageManager::taskPackageId(const QString &taskId) const
{
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
const auto allTasks = d->allTasks();
for (const AsynchronousTask *task : allTasks) {
@@ -1175,8 +1173,8 @@ QString PackageManager::taskPackageId(const QString &taskId) const
QStringList PackageManager::activeTaskIds() const
{
QStringList result;
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
const auto allTasks = d->allTasks();
for (const AsynchronousTask *task : allTasks)
@@ -1197,8 +1195,8 @@ bool PackageManager::cancelTask(const QString &taskId)
{
AM_TRACE(LogInstaller, taskId)
-#if !defined(AM_DISABLE_INSTALLER)
- if (!d->disableInstaller) {
+#if QT_CONFIG(am_installer)
+ if (d->enableInstaller) {
// incoming tasks can be forcefully canceled right away
for (AsynchronousTask *task : std::as_const(d->incomingTaskList)) {
if (task->id() == taskId) {
@@ -1229,32 +1227,30 @@ bool PackageManager::cancelTask(const QString &taskId)
QString PackageManager::enqueueTask(AsynchronousTask *task)
{
-#if defined(AM_DISABLE_INSTALLER)
- Q_UNUSED(task)
- Q_ASSERT_X(false, "PackageManager::enqueueTask", "Installer is disabled");
- return { };
-#else
+#if QT_CONFIG(am_installer)
d->incomingTaskList.append(task);
triggerExecuteNextTask();
return task->id();
+#else
+ Q_UNUSED(task)
+ Q_ASSERT_X(false, "PackageManager::enqueueTask", "Installer is disabled");
+ return { };
#endif
}
void PackageManager::triggerExecuteNextTask()
{
-#if defined(AM_DISABLE_INSTALLER)
- Q_ASSERT_X(false, "PackageManager::triggerExecuteNextTask", "Installer is disabled");
-#else
+#if QT_CONFIG(am_installer)
if (!QMetaObject::invokeMethod(this, &PackageManager::executeNextTask, Qt::QueuedConnection))
qCCritical(LogSystem) << "ERROR: failed to invoke method checkQueue";
+#else
+ Q_ASSERT_X(false, "PackageManager::triggerExecuteNextTask", "Installer is disabled");
#endif
}
void PackageManager::executeNextTask()
{
-#if defined(AM_DISABLE_INSTALLER)
- Q_ASSERT_X(false, "PackageManager::executeNextTask", "Installer is disabled");
-#else
+#if QT_CONFIG(am_installer)
if (!d->cleanupBrokenInstallationsDone || d->activeTask || d->incomingTaskList.isEmpty())
return;
@@ -1327,17 +1323,19 @@ void PackageManager::executeNextTask()
d->activeTask = task;
task->setState(AsynchronousTask::Executing);
task->start();
+#else
+ Q_ASSERT_X(false, "PackageManager::executeNextTask", "Installer is disabled");
#endif
}
void PackageManager::handleFailure(AsynchronousTask *task)
{
-#if defined(AM_DISABLE_INSTALLER)
- Q_UNUSED(task)
- Q_ASSERT_X(false, "PackageManager::handleFailure", "Installer is disabled");
-#else
+#if QT_CONFIG(am_installer)
qCDebug(LogInstaller) << "emit failed" << task->id() << task->errorCode() << task->errorString();
emit taskFailed(task->id(), int(task->errorCode()), task->errorString());
+#else
+ Q_UNUSED(task)
+ Q_ASSERT_X(false, "PackageManager::handleFailure", "Installer is disabled");
#endif
}
diff --git a/src/manager-lib/packagemanager_p.h b/src/manager-lib/packagemanager_p.h
index 65a4f35e..8bff5175 100644
--- a/src/manager-lib/packagemanager_p.h
+++ b/src/manager-lib/packagemanager_p.h
@@ -14,6 +14,7 @@
#include <QtAppManApplication/packagedatabase.h>
#include <QtAppManManager/asynchronoustask.h>
#include <QtAppManCommon/global.h>
+#include <QtAppManCommon/private/qtappman_common-config_p.h>
QT_BEGIN_NAMESPACE_AM
@@ -27,11 +28,7 @@ public:
QMap<Package *, PackageInfo *> pendingPackageInfoUpdates;
-#if defined(AM_DISABLE_INSTALLER)
- static constexpr
-#endif
- bool disableInstaller = true;
-
+ bool enableInstaller = false;
bool developmentMode = false;
bool allowInstallationOfUnsignedPackages = false;
@@ -44,7 +41,7 @@ public:
QList<QByteArray> chainOfTrust;
bool cleanupBrokenInstallationsDone = false;
-#if !defined(AM_DISABLE_INSTALLER)
+#if QT_CONFIG(am_installer)
QList<AsynchronousTask *> incomingTaskList; // incoming queue
QList<AsynchronousTask *> installationTaskList; // installation jobs in state >= AwaitingAcknowledge
AsynchronousTask *activeTask = nullptr; // currently active
diff --git a/src/window-lib/systemframetimerimpl.cpp b/src/window-lib/systemframetimerimpl.cpp
index a042c678..8ab8c559 100644
--- a/src/window-lib/systemframetimerimpl.cpp
+++ b/src/window-lib/systemframetimerimpl.cpp
@@ -8,7 +8,7 @@
#include "applicationmanagerwindow.h"
#include "frametimer.h"
#include "inprocesswindow.h"
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
# include "waylandwindow.h"
#endif
@@ -26,7 +26,7 @@ bool SystemFrameTimerImpl::connectToSystemWindow(QObject *window)
" FrameTimer won't operate with the given window.";
return true;
}
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (auto *wlwin = qobject_cast<WaylandWindow *>(window)) {
auto connectToWaylandSurface = [this](WaylandWindow *waylandWindow) {
if (m_redrawConnection) {
@@ -54,7 +54,7 @@ bool SystemFrameTimerImpl::connectToSystemWindow(QObject *window)
void SystemFrameTimerImpl::disconnectFromSystemWindow(QObject *window)
{
Q_UNUSED(window)
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (m_redrawConnection) {
QObject::disconnect(m_redrawConnection);
m_redrawConnection = { };
diff --git a/src/window-lib/systemframetimerimpl.h b/src/window-lib/systemframetimerimpl.h
index a4c36041..4cfe507b 100644
--- a/src/window-lib/systemframetimerimpl.h
+++ b/src/window-lib/systemframetimerimpl.h
@@ -23,7 +23,7 @@ public:
void disconnectFromSystemWindow(QObject *window) override;
private:
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
QMetaObject::Connection m_surfaceChangeConnection;
QMetaObject::Connection m_redrawConnection;
#endif
diff --git a/src/window-lib/waylandcompositor.h b/src/window-lib/waylandcompositor.h
index 68f0db80..68c0b73c 100644
--- a/src/window-lib/waylandcompositor.h
+++ b/src/window-lib/waylandcompositor.h
@@ -8,7 +8,7 @@
#include <QtAppManCommon/global.h>
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
#include <QtWaylandCompositor/QWaylandQuickCompositor>
@@ -122,4 +122,4 @@ protected:
QT_END_NAMESPACE_AM
-#endif // AM_MULTIPROCESS
+#endif // QT_CONFIG(am_multi_process)
diff --git a/src/window-lib/waylandwindow.cpp b/src/window-lib/waylandwindow.cpp
index e6fc4285..af488f81 100644
--- a/src/window-lib/waylandwindow.cpp
+++ b/src/window-lib/waylandwindow.cpp
@@ -5,7 +5,7 @@
#include "global.h"
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
#include "logging.h"
#include "applicationmanager.h"
#include "application.h"
@@ -198,6 +198,6 @@ void WaylandWindow::close()
QT_END_NAMESPACE_AM
-#endif // AM_MULTI_PROCESS
+#endif // QT_CONFIG(am_multi_process)
#include "moc_waylandwindow.cpp"
diff --git a/src/window-lib/waylandwindow.h b/src/window-lib/waylandwindow.h
index e0834aed..c8f69b83 100644
--- a/src/window-lib/waylandwindow.h
+++ b/src/window-lib/waylandwindow.h
@@ -7,7 +7,7 @@
#include <QtAppManWindow/window.h>
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
#include <QtWaylandCompositor/QWaylandQuickSurface>
#include <QtWaylandCompositor/QWaylandXdgShell>
@@ -71,4 +71,4 @@ private:
QT_END_NAMESPACE_AM
-#endif // AM_MULTI_PROCESS
+#endif // QT_CONFIG(am_multi_process)
diff --git a/src/window-lib/windowitem.cpp b/src/window-lib/windowitem.cpp
index 932016f3..d1fef2db 100644
--- a/src/window-lib/windowitem.cpp
+++ b/src/window-lib/windowitem.cpp
@@ -6,11 +6,11 @@
#include "windowitem.h"
#include "window.h"
-#if defined(AM_MULTI_PROCESS)
-#include <QWaylandQuickItem>
-#include "waylandcompositor.h"
-#include "waylandwindow.h"
-#endif // AM_MULTI_PROCESS
+#if QT_CONFIG(am_multi_process)
+# include <QWaylandQuickItem>
+# include "waylandcompositor.h"
+# include "waylandwindow.h"
+#endif
#include "applicationmanager.h"
#include "inprocesswindow.h"
@@ -172,7 +172,7 @@ Window *WindowItem::window() const
void WindowItem::createImpl(bool inProcess)
{
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (inProcess) {
if (m_impl && !m_impl->isInProcess()) {
delete m_impl;
@@ -188,11 +188,11 @@ void WindowItem::createImpl(bool inProcess)
if (!m_impl)
m_impl = new WaylandImpl(this);
}
-#else // AM_MULTI_PROCESS
+#else
Q_ASSERT(inProcess);
if (!m_impl)
m_impl = new InProcessImpl(this);
-#endif // AM_MULTI_PROCESS
+#endif
}
void WindowItem::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -407,7 +407,7 @@ QQuickItem *WindowItem::InProcessImpl::backingItem()
// WindowItem::WaylandImpl
///////////////////////////////////////////////////////////////////////////////////////////////////
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
// Wayland has no concept of clients ignoring/accepting key events, but even if it did, we'd get
// back the response far too late to be useful. In order to give the sys-ui a chance to handle
@@ -525,7 +525,7 @@ void WindowItem::WaylandImpl::setupSecondaryView()
m_waylandItem->setTouchEventsEnabled(false);
}
-#endif // AM_MULTI_PROCESS
+#endif // QT_CONFIG(am_multi_process)
QT_END_NAMESPACE_AM
diff --git a/src/window-lib/windowitem.h b/src/window-lib/windowitem.h
index e42c1044..0f994597 100644
--- a/src/window-lib/windowitem.h
+++ b/src/window-lib/windowitem.h
@@ -17,10 +17,10 @@ QT_BEGIN_NAMESPACE_AM
class Window;
class InProcessWindow;
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
class WaylandWindow;
class WaylandQuickIgnoreKeyItem;
-#endif // AM_MULTI_PROCESS
+#endif
class WindowItem : public QQuickFocusScope
@@ -114,7 +114,7 @@ private:
QQuickItem *m_shaderEffectSource{nullptr};
};
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
struct WaylandImpl : public Impl {
WaylandImpl(WindowItem *windowItem) : Impl(windowItem) {}
~WaylandImpl();
@@ -134,7 +134,7 @@ private:
WaylandWindow *m_waylandWindow{nullptr};
WaylandQuickIgnoreKeyItem *m_waylandItem{nullptr};
};
-#endif // AM_MULTI_PROCESS
+#endif // QT_CONFIG(am_multi_process)
Impl *m_impl{nullptr};
bool m_objectFollowsItemSize{true};
diff --git a/src/window-lib/windowmanager.cpp b/src/window-lib/windowmanager.cpp
index 1023089e..57a6888a 100644
--- a/src/window-lib/windowmanager.cpp
+++ b/src/window-lib/windowmanager.cpp
@@ -17,7 +17,7 @@
#include <QLocalServer>
#include "global.h"
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
# include "waylandcompositor.h"
# include <private/qwaylandcompositor_p.h>
#endif
@@ -351,7 +351,7 @@ WindowManager::WindowManager(QQmlEngine *qmlEngine, const QString &waylandSocket
: QAbstractListModel()
, d(new WindowManagerPrivate())
{
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
d->waylandSocketName = waylandSocketName;
#else
Q_UNUSED(waylandSocketName)
@@ -374,7 +374,7 @@ WindowManager::~WindowManager()
{
qApp->removeEventFilter(this);
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
delete d->waylandCompositor;
#endif
delete d;
@@ -383,7 +383,7 @@ WindowManager::~WindowManager()
void WindowManager::enableWatchdog(bool enable)
{
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
WaylandWindow::m_watchdogEnabled = enable;
#else
Q_UNUSED(enable);
@@ -392,7 +392,7 @@ void WindowManager::enableWatchdog(bool enable)
bool WindowManager::addWaylandSocket(QLocalServer *waylandSocket)
{
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (d->waylandCompositor) {
qCWarning(LogGraphics) << "Cannot add extra Wayland sockets after the compositor has been created"
" (tried to add:" << waylandSocket->fullServerName() << ").";
@@ -566,7 +566,7 @@ int WindowManager::indexOfWindow(Window *window) const
*/
QObject *WindowManager::addExtension(QQmlComponent *component) const
{
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (!component || ApplicationManager::instance()->isSingleProcess())
return nullptr;
@@ -664,7 +664,7 @@ void WindowManager::registerCompositorView(QQuickWindow *view)
updateViewSlowMode(view);
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
if (!ApplicationManager::instance()->isSingleProcess()) {
if (!d->waylandCompositor) {
// this will trigger the creation of extra sockets in main.cpp
@@ -783,7 +783,7 @@ void WindowManager::setupWindow(Window *window)
}
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
void WindowManager::waylandSurfaceCreated(QWaylandSurface *surface)
{
@@ -835,7 +835,7 @@ void WindowManager::waylandSurfaceMapped(WindowSurface *surface)
}
}
-#endif // defined(AM_MULTI_PROCESS)
+#endif // QT_CONFIG(am_multi_process)
/*!
\qmlsignal WindowManager::windowPropertyChanged(WindowObject window, string name, var value)
@@ -1041,7 +1041,7 @@ QList<QQuickWindow *> WindowManager::compositorViews() const
return d->views;
}
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
int WindowManagerPrivate::findWindowByWaylandSurface(QWaylandSurface *waylandSurface) const
{
@@ -1068,7 +1068,7 @@ QString WindowManagerPrivate::applicationId(Application *app, WindowSurface *win
return qSL("<unknown client>");
}
-#endif // defined(AM_MULTI_PROCESS)
+#endif // QT_CONFIG(am_multi_process)
bool WindowManager::eventFilter(QObject *watched, QEvent *event)
{
diff --git a/src/window-lib/windowmanager.h b/src/window-lib/windowmanager.h
index 6ddb722f..eb93699c 100644
--- a/src/window-lib/windowmanager.h
+++ b/src/window-lib/windowmanager.h
@@ -10,7 +10,7 @@
#include <QtAppManCommon/global.h>
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
QT_FORWARD_DECLARE_CLASS(QWaylandSurface)
#endif
@@ -112,7 +112,7 @@ public:
// evil hook to support in-process runtimes
void setupInProcessRuntime(QtAM::AbstractRuntime *runtime);
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
private slots:
void waylandSurfaceCreated(QWaylandSurface *surface);
void waylandSurfaceMapped(QtAM::WindowSurface *surface);
diff --git a/src/window-lib/windowmanager_p.h b/src/window-lib/windowmanager_p.h
index 473ab07a..517c5b52 100644
--- a/src/window-lib/windowmanager_p.h
+++ b/src/window-lib/windowmanager_p.h
@@ -20,7 +20,7 @@ class WindowManagerPrivate
public:
int findWindowBySurfaceItem(QQuickItem *quickItem) const;
-#if defined(AM_MULTI_PROCESS)
+#if QT_CONFIG(am_multi_process)
int findWindowByWaylandSurface(QWaylandSurface *waylandSurface) const;
WaylandCompositor *waylandCompositor = nullptr;