From bc8b7494905a0099aac113f30ad0e974beb32c1b Mon Sep 17 00:00:00 2001 From: Max Qian Date: Sat, 4 Nov 2023 11:47:15 +0800 Subject: [PATCH] stage --- CMakeLists.txt | 325 +++++++++++++------------------ locale/lithium.pot | 259 ------------------------ locale/po/en_US.UTF-8/lithium.po | 78 ++++---- src/modules/system/system.cpp | 54 ++--- 4 files changed, 188 insertions(+), 528 deletions(-) delete mode 100644 locale/lithium.pot diff --git a/CMakeLists.txt b/CMakeLists.txt index c2ca7cd2..aac9f1df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ endif() # root directory of the project set(Lithium_PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR}) set(lithium_src_dir ${Lithium_PROJECT_ROOT_DIR}/src) +set(lithium_module_dir ${Lithium_PROJECT_ROOT_DIR}/src/modules) add_custom_target(CmakeAdditionalFiles SOURCES @@ -70,11 +71,6 @@ set(LITHIUM_SOVERSION ${CMAKE_LITHIUM_VERSION_MAJOR}) set(CMAKE_LITHIUM_VERSION_STRING "${CMAKE_LITHIUM_VERSION_MAJOR}.${CMAKE_LITHIUM_VERSION_MINOR}.${CMAKE_LITHIUM_VERSION_RELEASE}") set(LITHIUM_VERSION ${CMAKE_LITHIUM_VERSION_MAJOR}.${CMAKE_LITHIUM_VERSION_MINOR}.${CMAKE_LITHIUM_VERSION_RELEASE}) -# ####################################### Paths ################################################### -set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/indi/") -set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin") -set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include") - if(APPLE) set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") endif(APPLE) @@ -113,42 +109,6 @@ elseif(LINUX) set(CMAKE_INSTALL_PREFIX "/usr/lithium") endif() -################################################################################# -# -# main project -# this should appear after setting the architecture -project(Lithium) - -include_directories(${CMAKE_SOURCE_DIR}/libs/) -include_directories(${lithium_src_dir}) -include_directories(${lithium_src_dir}/modules) -include_directories(${CMAKE_SOURCE_DIR}/src/) -include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp) -include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-swagger) -include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-websocket) - -# TODO : 更好的构建系统,不需要这样引用 -include_directories(${lithium_src_dir}/) -include_directories(${lithium_src_dir}/core) -include_directories(${lithium_src_dir}/core/image) -include_directories(${lithium_src_dir}/core/base) -include_directories(${lithium_src_dir}/core/property) - -add_subdirectory(libs/) - -# 所有的工具组件 -add_subdirectory(tools) - -# 内置的模组 -include_directories(modules) -add_subdirectory(modules/hydrogen_client) - -# 构建Lithium内核 -add_subdirectory(${lithium_src_dir}/core) -if(NOT WIN32) -add_subdirectory(${lithium_src_dir}/modules/deviceloader) -endif() - set(api_module ${lithium_src_dir}/client/astap.cpp ${lithium_src_dir}/client/astap.hpp @@ -159,33 +119,33 @@ set(api_module ${lithium_src_dir}/client/phd2client.cpp ${lithium_src_dir}/client/phd2client.hpp - ${lithium_src_dir}/modules/client/indiclient.cpp - ${lithium_src_dir}/modules/client/indiclient.hpp + ${lithium_module_dir}/client/indiclient.cpp + ${lithium_module_dir}/client/indiclient.hpp ${lithium_src_dir}/client/hydrogen/hydrogencamera.cpp ${lithium_src_dir}/client/hydrogen/hydrogencamera.hpp ) set(config_module - ${lithium_src_dir}/modules/config/configor.cpp - ${lithium_src_dir}/modules/config/configor.hpp + ${lithium_module_dir}/config/configor.cpp + ${lithium_module_dir}/config/configor.hpp ) set(device_module - ${lithium_src_dir}/modules/device/device_manager.cpp - ${lithium_src_dir}/modules/device/device_manager.hpp + ${lithium_module_dir}/device/device_manager.cpp + ${lithium_module_dir}/device/device_manager.hpp - ${lithium_src_dir}/modules/device/indidevice_manager.cpp - ${lithium_src_dir}/modules/device/indidevice_manager.hpp + ${lithium_module_dir}/device/indidevice_manager.cpp + ${lithium_module_dir}/device/indidevice_manager.hpp - ${lithium_src_dir}/modules/device/device_utils.cpp - ${lithium_src_dir}/modules/device/device_utils.hpp + ${lithium_module_dir}/device/device_utils.cpp + ${lithium_module_dir}/device/device_utils.hpp - ${lithium_src_dir}/modules/device/indi_device.cpp - ${lithium_src_dir}/modules/device/indi_device.hpp + ${lithium_module_dir}/device/indi_device.cpp + ${lithium_module_dir}/device/indi_device.hpp - ${lithium_src_dir}/modules/device/hydrogen_device.cpp - ${lithium_src_dir}/modules/device/hydrogen_device.hpp + ${lithium_module_dir}/device/hydrogen_device.cpp + ${lithium_module_dir}/device/hydrogen_device.hpp ) set(image_module @@ -196,16 +156,16 @@ set(image_module ) set(io_module - ${lithium_src_dir}/modules/io/compress.cpp - ${lithium_src_dir}/modules/io/compress.hpp + ${lithium_module_dir}/io/compress.cpp + ${lithium_module_dir}/io/compress.hpp - ${lithium_src_dir}/modules/io/file.cpp - ${lithium_src_dir}/modules/io/file.hpp + ${lithium_module_dir}/io/file.cpp + ${lithium_module_dir}/io/file.hpp - ${lithium_src_dir}/modules/io/glob.hpp + ${lithium_module_dir}/io/glob.hpp - ${lithium_src_dir}/modules/io/io.cpp - ${lithium_src_dir}/modules/io/io.hpp + ${lithium_module_dir}/io/io.cpp + ${lithium_module_dir}/io/io.hpp ) set(launcher_module @@ -214,46 +174,46 @@ set(launcher_module ) set(module_module - ${lithium_src_dir}/modules/module/modloader.cpp - ${lithium_src_dir}/modules/module/modloader.hpp + ${lithium_module_dir}/module/modloader.cpp + ${lithium_module_dir}/module/modloader.hpp - ${lithium_src_dir}/modules/plugin/plugin.cpp - ${lithium_src_dir}/modules/plugin/plugin.hpp + ${lithium_module_dir}/plugin/plugin.cpp + ${lithium_module_dir}/plugin/plugin.hpp - ${lithium_src_dir}/modules/plugin/exe_plugin.cpp - ${lithium_src_dir}/modules/plugin/exe_plugin.hpp + ${lithium_module_dir}/plugin/exe_plugin.cpp + ${lithium_module_dir}/plugin/exe_plugin.hpp - ${lithium_src_dir}/modules/plugin/script_plugin.cpp - ${lithium_src_dir}/modules/plugin/script_plugin.hpp + ${lithium_module_dir}/plugin/script_plugin.cpp + ${lithium_module_dir}/plugin/script_plugin.hpp - ${lithium_src_dir}/modules/plugin/plugin_manager.cpp - ${lithium_src_dir}/modules/plugin/plugin_manager.hpp + ${lithium_module_dir}/plugin/plugin_manager.cpp + ${lithium_module_dir}/plugin/plugin_manager.hpp - ${lithium_src_dir}/modules/module/compiler.cpp - ${lithium_src_dir}/modules/module/compiler.hpp + ${lithium_module_dir}/module/compiler.cpp + ${lithium_module_dir}/module/compiler.hpp ) set(network_module - ${lithium_src_dir}/modules/web/downloader.cpp - ${lithium_src_dir}/modules/web/downloader.hpp + ${lithium_module_dir}/web/downloader.cpp + ${lithium_module_dir}/web/downloader.hpp - ${lithium_src_dir}/modules/web/httpclient.cpp - ${lithium_src_dir}/modules/web/httpclient.hpp + ${lithium_module_dir}/web/httpclient.cpp + ${lithium_module_dir}/web/httpclient.hpp - ${lithium_src_dir}/modules/web/utils.cpp - ${lithium_src_dir}/modules/web/utils.hpp + ${lithium_module_dir}/web/utils.cpp + ${lithium_module_dir}/web/utils.hpp # ${lithium_src_dir}/network/time.cpp # ${lithium_src_dir}/network/time.hpp ) set(server_module - ${lithium_src_dir}/modules/server/commander.hpp - ${lithium_src_dir}/modules/server/message_bus.hpp - ${lithium_src_dir}/modules/server/message_queue.hpp + ${lithium_module_dir}/server/commander.hpp + ${lithium_module_dir}/server/message_bus.hpp + ${lithium_module_dir}/server/message_queue.hpp - ${lithium_src_dir}/modules/server/serialize.cpp - ${lithium_src_dir}/modules/server/serialize.hpp + ${lithium_module_dir}/server/serialize.cpp + ${lithium_module_dir}/server/serialize.hpp ${lithium_src_dir}/websocket/WebSocketServer.cpp ${lithium_src_dir}/websocket/WebSocketServer.hpp @@ -282,47 +242,47 @@ set(server_module ) set(script_module - ${lithium_src_dir}/modules/script/script_manager.cpp - ${lithium_src_dir}/modules/script/script_manager.hpp + ${lithium_module_dir}/script/script_manager.cpp + ${lithium_module_dir}/script/script_manager.hpp ) set(task_module - ${lithium_src_dir}/modules/task/task_manager.cpp - ${lithium_src_dir}/modules/task/task_manager.hpp + ${lithium_module_dir}/task/task_manager.cpp + ${lithium_module_dir}/task/task_manager.hpp - ${lithium_src_dir}/modules/task/task_stack.cpp - ${lithium_src_dir}/modules/task/task_stack.hpp + ${lithium_module_dir}/task/task_stack.cpp + ${lithium_module_dir}/task/task_stack.hpp - ${lithium_src_dir}/modules/task/task_generator.cpp - ${lithium_src_dir}/modules/task/task_generator.hpp + ${lithium_module_dir}/task/task_generator.cpp + ${lithium_module_dir}/task/task_generator.hpp ) set(thread_module - ${lithium_src_dir}/modules/thread/thread.cpp - ${lithium_src_dir}/modules/thread/thread.hpp + ${lithium_module_dir}/thread/thread.cpp + ${lithium_module_dir}/thread/thread.hpp ) set(system_module - ${lithium_src_dir}/modules/system/system.cpp - ${lithium_src_dir}/modules/system/system.hpp + ${lithium_module_dir}/system/system.cpp + ${lithium_module_dir}/system/system.hpp - ${lithium_src_dir}/modules/system/crash.cpp - ${lithium_src_dir}/modules/system/crash.hpp + ${lithium_module_dir}/system/crash.cpp + ${lithium_module_dir}/system/crash.hpp - ${lithium_src_dir}/modules/system/process.cpp - ${lithium_src_dir}/modules/system/process.hpp + ${lithium_module_dir}/system/process.cpp + ${lithium_module_dir}/system/process.hpp - ${lithium_src_dir}/modules/system/pid.cpp - ${lithium_src_dir}/modules/system/pid.hpp + ${lithium_module_dir}/system/pid.cpp + ${lithium_module_dir}/system/pid.hpp - ${lithium_src_dir}/modules/system/pidw.cpp - ${lithium_src_dir}/modules/system/pidw.cpp + ${lithium_module_dir}/system/pidw.cpp + ${lithium_module_dir}/system/pidw.cpp ) set(utils_module - ${lithium_src_dir}/modules/utils/time.cpp - ${lithium_src_dir}/modules/utils/string.cpp - ${lithium_src_dir}/modules/utils/switch.cpp + ${lithium_module_dir}/utils/time.cpp + ${lithium_module_dir}/utils/string.cpp + ${lithium_module_dir}/utils/switch.cpp ) set(Lithium_module @@ -338,7 +298,7 @@ set(Lithium_module find_package(OpenSSL REQUIRED) if(OpenSSL_FOUND) - message("-- Using OpenSSL ${OPENSSL_VERSION}") + message("-- Found OpenSSL ${OPENSSL_VERSION}: ${OPENSSL_LIBRARIES}") else() message("-- OpenSSL Not Found") endif() @@ -364,107 +324,86 @@ configure_gettext( find_package(Intl REQUIRED) +################################################################################# +# Main -if(WIN32) - #add_executable(lithium_server ${api_module} ${config_module} ${database_module} ${debug_module} - #${image_module} ${logger_module} ${module_module} - # ${server_module} ${task_module} ${thread_module} ${Lithium_module}) - - add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${network_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${Lithium_module}) - - target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs) - - target_link_libraries(lithium_server pdh iphlpapi winmm crypt32 wsock32 ws2_32) - - target_link_libraries(lithium_server oatpp oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib) - - target_link_libraries(lithium_server loguru) - - target_link_libraries(lithium_server libzippp) - - target_link_libraries(lithium_server lithiumcorestatic) - - target_link_libraries(lithium_server hydrogencore) +project(Lithium) - find_package(dlfcn-win32 REQUIRED) - target_link_libraries(lithium_server dlfcn-win32::dl) +include_directories(${CMAKE_SOURCE_DIR}/libs/) +include_directories(${lithium_src_dir}) +include_directories(${lithium_module_dir}) +include_directories(${CMAKE_SOURCE_DIR}/src/) +include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp) +include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-swagger) +include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-websocket) - CHECK_INCLUDE_FILE(format HAS_STD_FORMAT) +# TODO : 更好的构建系统,不需要这样引用 +include_directories(${lithium_src_dir}/) +include_directories(${lithium_src_dir}/core) +include_directories(${lithium_src_dir}/core/base) +include_directories(${lithium_src_dir}/core/property) - if(NOT HAS_STD_FORMAT) - find_package(fmt REQUIRED) - target_link_libraries(lithium_server fmt::fmt) - endif() +add_subdirectory(libs/) - target_link_libraries(lithium_server ${CFITSIO_LIBRARIES}) - target_link_libraries(lithium_server OpenSSL::SSL OpenSSL::Crypto) - target_link_libraries(lithium_server ${ZLIB_LIBRARIES}) - target_link_libraries(lithium_server libzip::zip) - target_link_libraries(lithium_server pugixml-static) - target_link_libraries(lithium_server sqlite3) - target_link_libraries(lithium_server cpp_httplib) - target_link_libraries(lithium_server backward) - - find_package(libuv REQUIRED) - - target_link_libraries(lithium_server ${Libintl_LIBRARY}) - target_include_directories(lithium_server PUBLIC ${Libintl_INCLUDE_DIRS}) - add_dependencies(lithium_server lithium-gettext) - - # Set output name for Lithium executable - set_target_properties( - lithium_server - PROPERTIES - OUTPUT_NAME lithium_server - ) - - install(TARGETS lithium_server) - install(TARGETS oatpp) - install(TARGETS oatpp-zlib) - install(TARGETS oatpp-openssl) - install(TARGETS oatpp-websocket) -elseif(UNIX OR LINUX OR APPLE) - - add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${network_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${utils_module} ${Lithium_module}) +# 所有的工具组件 +add_subdirectory(tools) - target_link_libraries(lithium_server oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib oatpp) +# 内置的模组 +include_directories(modules) +add_subdirectory(modules/hydrogen_client) - target_link_libraries(lithium_server loguru) +# 构建Lithium内核 +add_subdirectory(${lithium_src_dir}/core) +if(NOT WIN32) +add_subdirectory(${lithium_module_dir}/deviceloader) +endif() - target_link_libraries(lithium_server libzippp) +add_executable(lithium_server ${api_module} ${config_module} ${io_module} ${module_module} ${network_module} ${device_module} ${thread_module} ${task_module} ${server_module} ${script_module} ${system_module} ${utils_module} ${Lithium_module}) - target_link_libraries(lithium_server lithiumcorestatic) +target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs) - target_link_libraries(lithium_server hydrogencore) +target_link_libraries(lithium_server oatpp oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib) +target_link_libraries(lithium_server loguru) +target_link_libraries(lithium_server libzippp) - target_link_libraries(lithium_server hydrogenclientstatic) +target_link_libraries(lithium_server lithiumcorestatic) +target_link_libraries(lithium_server hydrogencore) +target_link_libraries(lithium_server hydrogenclientstatic) - target_link_libraries(lithium_server asan) +CHECK_INCLUDE_FILE(format HAS_STD_FORMAT) +if(NOT HAS_STD_FORMAT) + find_package(fmt REQUIRED) + target_link_libraries(lithium_server fmt::fmt) +endif() - CHECK_INCLUDE_FILE(format HAS_STD_FORMAT) +target_link_libraries(lithium_server ${CFITSIO_LIBRARIES}) +target_link_libraries(lithium_server OpenSSL::SSL OpenSSL::Crypto) +target_link_libraries(lithium_server ${ZLIB_LIBRARIES}) +target_link_libraries(lithium_server libzip::zip) +target_link_libraries(lithium_server pugixml-static) +target_link_libraries(lithium_server sqlite3) +target_link_libraries(lithium_server cpp_httplib) +target_link_libraries(lithium_server backward) - if(NOT HAS_STD_FORMAT) - find_package(fmt REQUIRED) - target_link_libraries(lithium_server fmt::fmt) - endif() +target_link_libraries(lithium_server asan) - target_link_libraries(lithium_server ${CFITSIO_LIBRARIES}) - target_link_libraries(lithium_server OpenSSL::SSL OpenSSL::Crypto) - target_link_libraries(lithium_server ${ZLIB_LIBRARIES}) - target_link_libraries(lithium_server libzip::zip) - target_link_libraries(lithium_server pugixml-static) - target_link_libraries(lithium_server sqlite3) - target_link_libraries(lithium_server cpp_httplib) - target_link_libraries(lithium_server backward) +target_link_libraries(lithium_server ${Libintl_LIBRARY}) +target_include_directories(lithium_server PUBLIC ${Libintl_INCLUDE_DIRS}) +add_dependencies(lithium_server lithium-gettext) +if(WIN32) + target_link_libraries(lithium_server pdh iphlpapi winmm crypt32 wsock32 ws2_32) + find_package(dlfcn-win32 REQUIRED) + target_link_libraries(lithium_server dlfcn-win32::dl) +elseif(UNIX OR LINUX OR APPLE) target_link_libraries(lithium_server dl) - - set_target_properties( - lithium_server - PROPERTIES - OUTPUT_NAME lithium_server - ) - else() message(FATAL_ERROR "Unsupported platform") endif() + +# Set output name for Lithium executable +set_target_properties( + lithium_server + PROPERTIES + OUTPUT_NAME lithium_server +) diff --git a/locale/lithium.pot b/locale/lithium.pot deleted file mode 100644 index 64179c4b..00000000 --- a/locale/lithium.pot +++ /dev/null @@ -1,259 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Max Qian -# This file is distributed under the same license as the Lithium package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: Lithium \n" -"Report-Msgid-Bugs-To: astro_air@126.com\n" -"POT-Creation-Date: 2023-11-03 13:19+0000\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: /workspaces/Lithium/src/modules/device/device_manager.cpp:161 -msgid "A device with name {} already exists, please choose a different name" -msgstr "" - -#: /workspaces/Lithium/src/modules/device/indidevice_manager.cpp:266 -msgid "Failed to run command: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:63 -msgid "Failed to destroy ThreadManager: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:82 -msgid "Thread manager has stopped, cannot add new thread" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:100 -#: /workspaces/Lithium/src/modules/thread/thread.cpp:122 -msgid "Unhandled exception in thread: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:128 -msgid "Added thread: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:133 -msgid "Failed to add thread {}: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:149 -msgid "All threads joined" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:153 -msgid "Failed to join all threads: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:163 -#: /workspaces/Lithium/src/modules/thread/thread.cpp:180 -#: /workspaces/Lithium/src/modules/thread/thread.cpp:194 -#: /workspaces/Lithium/src/modules/thread/thread.cpp:205 -msgid "Thread {} not found" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:172 -msgid "Thread {} joined" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:184 -msgid "Failed to join thread {}: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/thread/thread.cpp:210 -msgid "Failed to check if thread {} is running: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:76 -msgid "Failed to create PowerShell process" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:86 -msgid "Running command: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:103 -#: /workspaces/Lithium/src/modules/system/process.cpp:127 -#: /workspaces/Lithium/src/modules/system/process.cpp:148 -msgid "Failed to create process" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:113 -#: /workspaces/Lithium/src/modules/system/process.cpp:158 -msgid "Process created: {} (PID: {})" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:137 -msgid "Running script: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:175 -#: /workspaces/Lithium/src/modules/system/process.cpp:187 -msgid "Process terminated: {} (PID: {})" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:179 -msgid "Failed to terminate process" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:195 -#: /workspaces/Lithium/src/modules/system/process.cpp:240 -msgid "Process not found" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:210 -msgid "Process not found by name: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:255 -msgid "Process completed: {} (PID: {})" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:259 -msgid "Failed to wait for process completion" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:265 -#, c-format -msgid "Process completed: %s (PID: %d)" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:270 -msgid "All processes completed." -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:281 -msgid "Failed to create process snapshot" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:322 -msgid "Failed to open /proc directory" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:351 -msgid "Failed to get process path" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:372 -msgid "Failed to get process info length" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:379 -msgid "Failed to allocate memory" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/process.cpp:385 -msgid "Failed to get process info" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:94 -msgid "CreateToolhelp32Snapshot failed." -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:113 -msgid "Watching process with PID: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:124 -msgid "Process exited with code: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:133 -msgid "GetExitCodeProcess failed." -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:143 -msgid "OpenProcess failed." -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:170 -msgid "Process exited with status: {}" -msgstr "" - -#: /workspaces/Lithium/src/modules/system/pid.cpp:179 -msgid "Process terminated by signal: {}" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:226 -msgid "port the server running on" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:227 -msgid "host the server running on" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:228 -msgid "path to the config file" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:229 -msgid "path to the modules directory" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:230 -msgid "web panel" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:231 -msgid "path to log file" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:233 -msgid "Lithium Command Line Interface:" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:234 -msgid "End." -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:242 -#, c-format -msgid "Failed to parser command line : %s" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:263 -#, c-format -msgid "Command line server port : %d" -msgstr "" - -#: /workspaces/Lithium/src/App.cpp:269 -#, c-format -msgid "Set server port to %d" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:81 -msgid "Failed to load Lithium App , error : {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:93 -msgid "Get config value: {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:99 -msgid "Set {} to {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:286 -msgid "Failed to run chai command : {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:304 -msgid "Failed to run chai multi command {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:317 -msgid "Failed to load chaiscript file {}" -msgstr "" - -#: /workspaces/Lithium/src/LithiumApp.cpp:330 -msgid "Failed to run chai script {}" -msgstr "" diff --git a/locale/po/en_US.UTF-8/lithium.po b/locale/po/en_US.UTF-8/lithium.po index 95eb5d2b..61f477e7 100644 --- a/locale/po/en_US.UTF-8/lithium.po +++ b/locale/po/en_US.UTF-8/lithium.po @@ -54,93 +54,85 @@ msgstr "" msgid "Failed to check if thread {} is running: {}" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:75 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:76 msgid "Failed to create PowerShell process" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:85 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:86 msgid "Running command: {}" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:98 -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:122 -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:143 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:103 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:127 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:148 msgid "Failed to create process" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:108 -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:153 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:113 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:158 msgid "Process created: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:132 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:137 msgid "Running script: {}" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:170 -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:182 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:175 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:187 msgid "Process terminated: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:174 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:179 msgid "Failed to terminate process" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:190 -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:246 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:195 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:240 msgid "Process not found" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:205 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:210 msgid "Process not found by name: {}" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:212 -msgid "Currently running processes:" -msgstr "" - -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:216 -msgid "{} (PID: {})" -msgstr "" - -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:261 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:255 msgid "Process completed: {} (PID: {})" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:265 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:259 msgid "Failed to wait for process completion" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:271 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:265 #, c-format msgid "Process completed: %s (PID: %d)" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:276 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:270 msgid "All processes completed." msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:287 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:281 msgid "Failed to create process snapshot" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:328 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:322 msgid "Failed to open /proc directory" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:357 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:351 msgid "Failed to get process path" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:378 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:372 msgid "Failed to get process info length" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:385 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:379 msgid "Failed to allocate memory" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:391 +#: E:/msys64/home/Qrm/OpenAPT/src/modules/system/process.cpp:385 msgid "Failed to get process info" msgstr "" @@ -172,49 +164,49 @@ msgstr "" msgid "Process terminated by signal: {}" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:223 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:226 msgid "port the server running on" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:224 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:227 msgid "host the server running on" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:225 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:228 msgid "path to the config file" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:226 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:229 msgid "path to the modules directory" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:227 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:230 msgid "web panel" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:228 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:231 msgid "path to log file" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:230 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:233 msgid "Lithium Command Line Interface:" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:231 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:234 msgid "End." msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:239 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:242 #, c-format msgid "Failed to parser command line : %s" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:260 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:263 #, c-format msgid "Command line server port : %d" msgstr "" -#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:266 +#: E:/msys64/home/Qrm/OpenAPT/src/App.cpp:269 #, c-format msgid "Set server port to %d" msgstr "" diff --git a/src/modules/system/system.cpp b/src/modules/system/system.cpp index cc0aab89..11a2751d 100644 --- a/src/modules/system/system.cpp +++ b/src/modules/system/system.cpp @@ -69,47 +69,35 @@ namespace Lithium::System bool CheckSoftwareInstalled(const std::string &software_name) { bool is_installed = false; - #if defined(_WIN32) HKEY hKey; - const std::string uninstall_key = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall)"; - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, uninstall_key.c_str(), 0, KEY_READ, &hKey) != ERROR_SUCCESS) - { - // // spdlog::error("Failed to open registry key."); - return false; - } - - // 遍历注册表键值,查找指定软件名 - TCHAR subkey[1024]; - DWORD index = 0; - while (RegEnumKeyExA(hKey, index++, subkey, nullptr, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) + std::string regPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regPath.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - HKEY subkey_handle; - std::string subkey_path = uninstall_key + "\\" + subkey; - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, subkey_path.c_str(), 0, KEY_READ, &subkey_handle) != ERROR_SUCCESS) - { - continue; - } - - // 获取 DisplayName 值 - TCHAR display_name[1024]; - DWORD display_name_size = sizeof(display_name); - if (RegGetValueA(subkey_handle, nullptr, "DisplayName", RRF_RT_REG_SZ, nullptr, display_name, &display_name_size) == ERROR_SUCCESS) + char subKeyName[255]; + DWORD subKeyNameSize = 255; + for (DWORD i = 0; RegEnumKeyEx(hKey, i, subKeyName, &subKeyNameSize, NULL, NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS; i++) { - if (software_name == display_name) + HKEY hSubKey; + if (RegOpenKeyEx(hKey, subKeyName, 0, KEY_READ, &hSubKey) == ERROR_SUCCESS) { - RegCloseKey(subkey_handle); - RegCloseKey(hKey); - is_installed = true; - // DLOG_F(INFO,"Software '{}' is installed.", software_name); // 记录日志 - break; + char displayName[255]; + DWORD displayNameSize = 255; + if (RegQueryValueEx(hSubKey, "DisplayName", NULL, NULL, reinterpret_cast(displayName), &displayNameSize) == ERROR_SUCCESS) + { + if (softwareName == displayName) + { + RegCloseKey(hSubKey); + RegCloseKey(hKey); + is_installed = true; + } + } + RegCloseKey(hSubKey); } + subKeyNameSize = 255; } - - RegCloseKey(subkey_handle); + RegCloseKey(hKey); } - - RegCloseKey(hKey); #elif defined(__APPLE__) std::string command = "mdfind \"kMDItemKind == 'Application' && kMDItemFSName == '*" + software_name + "*.app'\""; FILE *pipe = popen(command.c_str(), "r");