diff --git a/CMakeLists.txt b/CMakeLists.txt index 51067f2..b2061d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,35 +16,11 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Qt6 REQUIRED COMPONENTS Core DBus Concurrent) find_package(Threads REQUIRED) -qt_add_dbus_adaptor(ApplicationManagerSource ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.xml applicationmanager1service.h ApplicationManager1Service) -add_library(ApplicationManager OBJECT ${ApplicationManagerSource}) -qt_add_dbus_adaptor(ApplicationSource ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.Application.xml applicationservice.h ApplicationService) -add_library(Application OBJECT ${ApplicationSource}) -qt_add_dbus_adaptor(InstnaceSource ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml instanceservice.h InstanceService) -add_library(Instance OBJECT ${InstnaceSource}) -qt_add_dbus_adaptor(JobManagerSource ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.JobManager1.xml jobmanager1service.h JobManager1Service) -add_library(JobManager OBJECT ${JobManagerSource}) -qt_add_dbus_adaptor(JobSource ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.JobManager1.Job.xml jobservice.h JobService) -add_library(Job OBJECT ${JobSource}) - -set(AdaptorLib) -list(APPEND AdaptorLib ApplicationManager Application Instance JobManager Job) - -foreach(obj IN LISTS AdaptorLib) - target_link_libraries(${obj} PUBLIC - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::DBus - Qt${QT_VERSION_MAJOR}::Concurrent - ) - - target_include_directories(${obj} PUBLIC - ${PROJECT_SOURCE_DIR}/src/include - ${PROJECT_SOURCE_DIR}/src/dbus - ) -endforeach() +set(APP_LAUNCH_HELPER_BIN app-launch-helper) add_subdirectory(src) -add_subdirectory(plugin) +add_subdirectory(plugins) +add_subdirectory(apps) # add_subdirectory(docs) include(CTest) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt new file mode 100644 index 0000000..4f1944a --- /dev/null +++ b/apps/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(dde-application-manager) +add_subdirectory(app-launch-helper) + diff --git a/apps/app-launch-helper/CMakeLists.txt b/apps/app-launch-helper/CMakeLists.txt new file mode 100644 index 0000000..febd4f0 --- /dev/null +++ b/apps/app-launch-helper/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/apps/app-launch-helper/src/CMakeLists.txt b/apps/app-launch-helper/src/CMakeLists.txt new file mode 100644 index 0000000..e3ab8a4 --- /dev/null +++ b/apps/app-launch-helper/src/CMakeLists.txt @@ -0,0 +1,10 @@ +find_package(PkgConfig REQUIRED) +pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) + +add_executable(${APP_LAUNCH_HELPER_BIN} main.cpp) +target_link_libraries(${APP_LAUNCH_HELPER_BIN} PRIVATE + PkgConfig::SYSTEMD +) + +include(GNUInstallDirs) +install(TARGETS ${APP_LAUNCH_HELPER_BIN} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager/) diff --git a/plugin/appLauncher/launcher.cpp b/apps/app-launch-helper/src/main.cpp similarity index 74% rename from plugin/appLauncher/launcher.cpp rename to apps/app-launch-helper/src/main.cpp index b2cbe59..af532da 100644 --- a/plugin/appLauncher/launcher.cpp +++ b/apps/app-launch-helper/src/main.cpp @@ -2,10 +2,12 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later +#include #include #include #include #include +#include #include #include #include @@ -62,7 +64,7 @@ static ExitCode fromString(const char *str) std::exit(static_cast(ret)); } -static int processExecStart(msg_ptr &msg, const std::vector &execArgs) +static int processExecStart(msg_ptr &msg, const std::deque &execArgs) { int ret; if (ret = sd_bus_message_append(msg, "s", "ExecStart"); ret < 0) { @@ -147,17 +149,20 @@ static int processKVPair(msg_ptr &msg, const std::map cmdLines) +static std::string cmdParse(msg_ptr &msg, std::deque &&cmdLines) { std::string serviceName{"internalError"}; std::map props; - for (auto str : cmdLines) { // avoid stl exception + while (!cmdLines.empty()) { // NOTE: avoid stl exception + auto str = cmdLines.front(); if (str.size() < 2) { sd_journal_print(LOG_WARNING, "invalid option %s.", str.data()); + cmdLines.pop_front(); continue; } if (str.substr(0, 2) != "--") { sd_journal_print(LOG_INFO, "unknown option %s.", str.data()); + cmdLines.pop_front(); continue; } @@ -166,92 +171,100 @@ static std::string cmdParse(msg_ptr &msg, const std::vector cm auto it = kvStr.cbegin(); if (it = std::find(it, kvStr.cend(), '='); it == kvStr.cend()) { sd_journal_print(LOG_WARNING, "invalid k-v pair: %s", kvStr.data()); + cmdLines.pop_front(); continue; } auto splitIndex = std::distance(kvStr.cbegin(), it); if (++it == kvStr.cend()) { sd_journal_print(LOG_WARNING, "invalid k-v pair: %s", kvStr.data()); + cmdLines.pop_front(); continue; } auto key = kvStr.substr(0, splitIndex); - if (key == "Type") { // type must be exec + if (key == "Type") { + // NOTE: + // Systemd service type must be "exec", + // this should not be configured in command line arguments. + cmdLines.pop_front(); continue; } props[key] = kvStr.substr(splitIndex + 1); + cmdLines.pop_front(); continue; } - // Processing of the binary file and its parameters that am want to launch - auto it = std::find(cmdLines.cbegin(), cmdLines.cend(), str); - std::vector execArgs(++it, cmdLines.cend()); - if (execArgs.empty()) { - sd_journal_print(LOG_ERR, "param exec is empty."); - serviceName = "invalidInput"; - return serviceName; - } - int ret; - if (props.find("unitName") == props.cend()) { - sd_journal_perror("unitName doesn't exists."); - serviceName = "invalidInput"; - return serviceName; - } - if (ret = sd_bus_message_append(msg, "s", props["unitName"].data()); ret < 0) { // unitName - sd_journal_perror("append unitName failed."); - return serviceName; - } else { - serviceName = props["unitName"]; - props.erase("unitName"); - } - - if (ret = sd_bus_message_append(msg, "s", "replace"); ret < 0) { // start mode - sd_journal_perror("append startMode failed."); - return serviceName; - } - - // process properties: a(sv) - if (ret = sd_bus_message_open_container(msg, SD_BUS_TYPE_ARRAY, "(sv)"); ret < 0) { - sd_journal_perror("open array failed."); - return serviceName; - } - - if (ret = sd_bus_message_append(msg, "(sv)", "Type", "s", "exec"); ret < 0) { - sd_journal_perror("append type failed."); - return serviceName; - } - - if (ret = sd_bus_message_open_container(msg, SD_BUS_TYPE_STRUCT, "sv"); ret < 0) { - sd_journal_perror("open struct failed."); - return serviceName; - } - - if (ret = processKVPair(msg, props); ret < 0) { // process props - serviceName = "invalidInput"; - return serviceName; - } - - if (ret = processExecStart(msg, execArgs); ret < 0) { - serviceName = "invalidInput"; - return serviceName; - } - - if (ret = sd_bus_message_close_container(msg); ret < 0) { - sd_journal_perror("close struct failed."); - return serviceName; - } - if (ret = sd_bus_message_close_container(msg); ret < 0) { - sd_journal_perror("close array failed."); - return serviceName; - } - - // append aux, it's unused for now - if (ret = sd_bus_message_append(msg, "a(sa(sv))", 0); ret < 0) { - sd_journal_perror("append aux failed."); - return serviceName; - } - + cmdLines.pop_front(); // NOTE: skip "--" break; } + + // Processing of the binary file and its parameters that am want to launch + auto &execArgs = cmdLines; + if (execArgs.empty()) { + sd_journal_print(LOG_ERR, "param exec is empty."); + serviceName = "invalidInput"; + return serviceName; + } + int ret; + if (props.find("unitName") == props.cend()) { + sd_journal_perror("unitName doesn't exists."); + serviceName = "invalidInput"; + return serviceName; + } + if (ret = sd_bus_message_append(msg, "s", props["unitName"].data()); ret < 0) { // unitName + sd_journal_perror("append unitName failed."); + return serviceName; + } else { + serviceName = props["unitName"]; + props.erase("unitName"); + } + + if (ret = sd_bus_message_append(msg, "s", "replace"); ret < 0) { // start mode + sd_journal_perror("append startMode failed."); + return serviceName; + } + + // process properties: a(sv) + if (ret = sd_bus_message_open_container(msg, SD_BUS_TYPE_ARRAY, "(sv)"); ret < 0) { + sd_journal_perror("open array failed."); + return serviceName; + } + + if (ret = sd_bus_message_append(msg, "(sv)", "Type", "s", "exec"); ret < 0) { + sd_journal_perror("append type failed."); + return serviceName; + } + + if (ret = sd_bus_message_open_container(msg, SD_BUS_TYPE_STRUCT, "sv"); ret < 0) { + sd_journal_perror("open struct failed."); + return serviceName; + } + + if (ret = processKVPair(msg, props); ret < 0) { // process props + serviceName = "invalidInput"; + return serviceName; + } + + if (ret = processExecStart(msg, execArgs); ret < 0) { + serviceName = "invalidInput"; + return serviceName; + } + + if (ret = sd_bus_message_close_container(msg); ret < 0) { + sd_journal_perror("close struct failed."); + return serviceName; + } + if (ret = sd_bus_message_close_container(msg); ret < 0) { + sd_journal_perror("close array failed."); + return serviceName; + } + + // append aux, it's unused for now + if (ret = sd_bus_message_append(msg, "a(sa(sv))", 0); ret < 0) { + sd_journal_perror("append aux failed."); + return serviceName; + } + return serviceName; } @@ -322,12 +335,12 @@ int main(int argc, const char *argv[]) releaseRes(error, msg, bus, ExitCode::InternalError); } - std::vector args; - for (std::size_t i = 1; i < argc; ++i) { + std::deque args; + for (int i = 1; i < argc; ++i) { args.emplace_back(argv[i]); } - serviceId = cmdParse(msg, args); + serviceId = cmdParse(msg, std::move(args)); if (serviceId == "internalError") { releaseRes(error, msg, bus, ExitCode::InternalError); } else if (serviceId == "invalidInput") { @@ -349,6 +362,8 @@ int main(int argc, const char *argv[]) sd_bus_error_get_errno(&error); sd_journal_print(LOG_ERR, "launch failed: [%s,%s]", error.name, error.message); releaseRes(error, msg, bus, ExitCode::InternalError); + } else { + sd_journal_print(LOG_INFO, "launch %s success.", serviceId.c_str()); } if (ret = sd_bus_message_read(reply, "o", &path); ret < 0) { diff --git a/apps/dde-application-manager/CMakeLists.txt b/apps/dde-application-manager/CMakeLists.txt new file mode 100644 index 0000000..febd4f0 --- /dev/null +++ b/apps/dde-application-manager/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/apps/dde-application-manager/src/CMakeLists.txt b/apps/dde-application-manager/src/CMakeLists.txt new file mode 100644 index 0000000..6376e59 --- /dev/null +++ b/apps/dde-application-manager/src/CMakeLists.txt @@ -0,0 +1,14 @@ +set(BIN_NAME dde-application-manager) + +add_executable(${BIN_NAME} main.cpp utils.cpp) + +target_link_libraries(${BIN_NAME} PRIVATE + dde_am_static +) + +target_include_directories(${BIN_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + +install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/main.cpp b/apps/dde-application-manager/src/main.cpp similarity index 97% rename from src/main.cpp rename to apps/dde-application-manager/src/main.cpp index 1ac8e8a..a751cf3 100644 --- a/src/main.cpp +++ b/apps/dde-application-manager/src/main.cpp @@ -6,7 +6,7 @@ #include #include #include -#include "applicationmanager1service.h" +#include "dbus/applicationmanager1service.h" #include "cgroupsidentifier.h" #include "global.h" diff --git a/src/utils.cpp b/apps/dde-application-manager/src/utils.cpp similarity index 100% rename from src/utils.cpp rename to apps/dde-application-manager/src/utils.cpp diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt deleted file mode 100644 index 4067e52..0000000 --- a/plugin/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(appLauncher) diff --git a/plugin/appLauncher/CMakeLists.txt b/plugin/appLauncher/CMakeLists.txt deleted file mode 100644 index bd33540..0000000 --- a/plugin/appLauncher/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -include(GNUInstallDirs) - -set(APP_LAUNCHER_BIN_NAME am-launcher) - -find_package(PkgConfig REQUIRED) -pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) - -add_executable(${APP_LAUNCHER_BIN_NAME} launcher.cpp) -target_link_libraries(${APP_LAUNCHER_BIN_NAME} PRIVATE - PkgConfig::SYSTEMD -) - -install(TARGETS ${APP_LAUNCHER_BIN_NAME} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager/) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1 @@ + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a12f538..ae68130 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,31 +1,21 @@ +add_subdirectory(dbus) + include(GNUInstallDirs) -set(BIN_NAME dde-application-manager) -set(LIB_NAME ddeam) +configure_file(config.h.in config.h) -file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_LIST_DIR}/*.cpp) +set(LIB_NAME dde_am_static) -list(REMOVE_ITEM SRCS "${PROJECT_SOURCE_DIR}/src/utils.cpp") +file(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/*.cpp ${CMAKE_CURRENT_LIST_DIR}/*.h) add_library(${LIB_NAME} ${SRCS}) target_include_directories(${LIB_NAME} PRIVATE - ${PROJECT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries(${LIB_NAME} PUBLIC Threads::Threads - ${AdaptorLib} + dde_am_dbus ) - -add_executable(${BIN_NAME} main.cpp utils.cpp) - -target_link_libraries(${BIN_NAME} PRIVATE - ${LIB_NAME} -) - -target_include_directories(${BIN_NAME} PRIVATE - ${PROJECT_BINARY_DIR} -) - -install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/include/cgroupsidentifier.h b/src/cgroupsidentifier.h similarity index 100% rename from src/include/cgroupsidentifier.h rename to src/cgroupsidentifier.h diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..18f08fa --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef CONFIG_H +#define CONFIG_H + +constexpr auto ApplicationLaunchHelperBinary = + u8"@CMAKE_INSTALL_FULL_LIBEXECDIR@/deepin/application-manager/@APP_LAUNCH_HELPER_BIN@"; + +#endif diff --git a/src/dbus/CMakeLists.txt b/src/dbus/CMakeLists.txt new file mode 100644 index 0000000..ae56a0b --- /dev/null +++ b/src/dbus/CMakeLists.txt @@ -0,0 +1,31 @@ +add_library(dde_am_dbus OBJECT) + +file( + GLOB_RECURSE dde_am_dbus_SOURCE + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/*.h +) + +qt_add_dbus_adaptor(dde_am_dbus_SOURCE ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.xml dbus/applicationmanager1service.h ApplicationManager1Service) +qt_add_dbus_adaptor(dde_am_dbus_SOURCE ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.Application.xml dbus/applicationservice.h ApplicationService) +qt_add_dbus_adaptor(dde_am_dbus_SOURCE ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.ApplicationManager1.Instance.xml dbus/instanceservice.h InstanceService) +qt_add_dbus_adaptor(dde_am_dbus_SOURCE ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.JobManager1.xml dbus/jobmanager1service.h JobManager1Service) +qt_add_dbus_adaptor(dde_am_dbus_SOURCE ${PROJECT_SOURCE_DIR}/api/dbus/org.desktopspec.JobManager1.Job.xml dbus/jobservice.h JobService) + + +target_sources(dde_am_dbus PRIVATE + ${dde_am_dbus_SOURCE} +) + +target_link_libraries( + dde_am_dbus PUBLIC + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::DBus + Qt${QT_VERSION_MAJOR}::Concurrent +) + +target_include_directories( + dde_am_dbus PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR}/.. +) diff --git a/src/dbus/applicationmanager1service.cpp b/src/dbus/applicationmanager1service.cpp index 7068a9c..dd99fed 100644 --- a/src/dbus/applicationmanager1service.cpp +++ b/src/dbus/applicationmanager1service.cpp @@ -1,8 +1,8 @@ // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "applicationmanager1service.h" -#include "applicationmanager1adaptor.h" +#include "dbus/applicationmanager1service.h" +#include "dbus/applicationmanager1adaptor.h" #include #include diff --git a/src/dbus/applicationmanager1service.h b/src/dbus/applicationmanager1service.h index 243b28c..a296dc5 100644 --- a/src/dbus/applicationmanager1service.h +++ b/src/dbus/applicationmanager1service.h @@ -12,9 +12,9 @@ #include #include #include -#include "jobmanager1service.h" -#include "applicationservice.h" -#include "applicationadaptor.h" +#include "dbus/jobmanager1service.h" +#include "dbus/applicationservice.h" +#include "dbus/applicationadaptor.h" #include "identifier.h" class ApplicationManager1Service final : public QObject diff --git a/src/dbus/applicationservice.cpp b/src/dbus/applicationservice.cpp index a5218cb..9be823d 100644 --- a/src/dbus/applicationservice.cpp +++ b/src/dbus/applicationservice.cpp @@ -2,9 +2,9 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "applicationservice.h" +#include "dbus/applicationservice.h" #include "applicationmanager1service.h" -#include "instanceadaptor.h" +#include "dbus/instanceadaptor.h" #include "pwd.h" #include #include @@ -162,7 +162,7 @@ QDBusObjectPath ApplicationService::Launch(QString action, QStringList fields, Q auto instanceRandomUUID = QUuid::createUuid().toString(QUuid::Id128); tmp.push_front(QString{R"(--unitName=DDE-%1@%2.service)"}.arg(this->id(), instanceRandomUUID)); QProcess process; - process.start(ApplicationLauncherBinary, tmp); + process.start(getApplicationLauncherBinary(), tmp); process.waitForFinished(); auto exitCode = process.exitCode(); if (exitCode != 0) { @@ -318,6 +318,10 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis } case 'u': { execList.removeAt(location); + if (fields.empty()) { + task.command.append(execList); + break; + } if (fields.count() > 1) { qDebug() << R"(fields count is greater than one, %u will only take first element.)"; } diff --git a/src/dbus/applicationservice.h b/src/dbus/applicationservice.h index 89ea3b9..56d8ec9 100644 --- a/src/dbus/applicationservice.h +++ b/src/dbus/applicationservice.h @@ -14,11 +14,11 @@ #include #include #include -#include "instanceservice.h" +#include "dbus/instanceservice.h" #include "global.h" #include "desktopentry.h" #include "desktopicons.h" -#include "jobmanager1service.h" +#include "dbus/jobmanager1service.h" class ApplicationService : public QObject { @@ -102,7 +102,7 @@ private: bool m_isPersistence; ApplicationManager1Service *m_parent{nullptr}; QDBusObjectPath m_applicationPath; - QString m_launcher{ApplicationLauncherBinary}; + QString m_launcher{getApplicationLauncherBinary()}; union DesktopSource { template , bool> = true> diff --git a/src/dbus/instanceservice.cpp b/src/dbus/instanceservice.cpp index 6c7ed6c..0032272 100644 --- a/src/dbus/instanceservice.cpp +++ b/src/dbus/instanceservice.cpp @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "instanceservice.h" +#include "dbus/instanceservice.h" InstanceService::InstanceService(QString instanceId, QString application, QString systemdUnitPath) : m_instanceId(std::move(instanceId)) diff --git a/src/dbus/jobmanager1service.cpp b/src/dbus/jobmanager1service.cpp index 3f8a2ce..ef3e7a2 100644 --- a/src/dbus/jobmanager1service.cpp +++ b/src/dbus/jobmanager1service.cpp @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "jobmanager1service.h" -#include "jobmanager1adaptor.h" +#include "dbus/jobmanager1service.h" +#include "dbus/jobmanager1adaptor.h" LaunchTask::LaunchTask() { diff --git a/src/dbus/jobmanager1service.h b/src/dbus/jobmanager1service.h index ce32aec..4f7fb7e 100644 --- a/src/dbus/jobmanager1service.h +++ b/src/dbus/jobmanager1service.h @@ -15,7 +15,7 @@ #include #include #include "global.h" -#include "jobadaptor.h" +#include "dbus/jobadaptor.h" class ApplicationManager1Service; diff --git a/src/dbus/jobservice.cpp b/src/dbus/jobservice.cpp index 839e062..e80368f 100644 --- a/src/dbus/jobservice.cpp +++ b/src/dbus/jobservice.cpp @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "jobservice.h" +#include "dbus/jobservice.h" JobService::JobService(const QFuture &job) : m_job(job) diff --git a/src/include/desktopentry.h b/src/desktopentry.h similarity index 100% rename from src/include/desktopentry.h rename to src/desktopentry.h diff --git a/src/include/desktopicons.h b/src/desktopicons.h similarity index 100% rename from src/include/desktopicons.h rename to src/desktopicons.h diff --git a/src/include/global.h b/src/global.h similarity index 93% rename from src/include/global.h rename to src/global.h index a678e77..5df6fc8 100644 --- a/src/include/global.h +++ b/src/global.h @@ -19,6 +19,8 @@ #include #include +#include "config.h" + using IconMap = QMap>>; constexpr auto DDEApplicationManager1ServiceName = u8"org.deepin.dde.ApplicationManager1"; @@ -29,8 +31,16 @@ constexpr auto DDEApplicationManager1JobManagerObjectPath = u8"/org/deepin/dde/A constexpr auto DDEApplicationManager1JobObjectPath = u8"/org/deepin/dde/ApplicationManager1/JobManager1/Job/"; constexpr auto DesktopFileEntryKey = u8"Desktop Entry"; constexpr auto DesktopFileActionKey = u8"Desktop Action "; -constexpr auto ApplicationLauncherBinary = - u8"/home/heyuming/workspace/dde-application-manager/build/plugin/appLauncher/am-launcher"; +inline QString getApplicationLauncherBinary() +{ + auto value = qgetenv("DEEPIN_APPLICATION_MANAGER_APP_LAUNCH_HELPER_BIN"); + if (value.isEmpty()) { + return ApplicationLaunchHelperBinary; + } else { + qWarning() << "Using app launch helper defined in environment variable DEEPIN_APPLICATION_MANAGER_APP_LAUNCH_HELPER_BIN."; + return value; + } +} constexpr auto ApplicationManagerDBusName = u8"deepin_application_manager_bus"; enum class DBusType { Session = QDBusConnection::SessionBus, System = QDBusConnection::SystemBus, Custom }; diff --git a/src/include/identifier.h b/src/identifier.h similarity index 100% rename from src/include/identifier.h rename to src/identifier.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 39db387..67f929b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,7 +19,7 @@ target_include_directories(${BIN_NAME} PRIVATE target_link_libraries(${BIN_NAME} PRIVATE GTest::gtest - ${AdaptorLib} + dde_am_static ) target_compile_options(${BIN_NAME} PRIVATE diff --git a/tests/ut_jobmanager.cpp b/tests/ut_jobmanager.cpp index d12cf77..7f09619 100644 --- a/tests/ut_jobmanager.cpp +++ b/tests/ut_jobmanager.cpp @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later -#include "jobmanager1service.h" +#include "dbus/jobmanager1service.h" #include class TestJobManager : public testing::Test