From 201df59cb7c5b3ccc285d55f601c1514aabb0a82 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 26 Mar 2025 09:48:37 -0400 Subject: [PATCH] remove Use of libnotify and wintoast --- .../actions/install-dependencies/action.yml | 14 ++-- cmake/Libraries.cmake | 11 +-- deploy/linux/arch/PKGBUILD.in | 1 - src/lib/client/ServerProxy.cpp | 16 +--- src/lib/deskflow/CMakeLists.txt | 15 +--- src/lib/deskflow/IAppUtil.h | 1 - src/lib/deskflow/unix/AppUtilUnix.cpp | 34 --------- src/lib/deskflow/unix/AppUtilUnix.h | 1 - src/lib/deskflow/win32/AppUtilWindows.cpp | 73 ------------------- src/lib/deskflow/win32/AppUtilWindows.h | 1 - src/lib/server/PrimaryClient.cpp | 14 +--- vcpkg.json | 1 - 12 files changed, 9 insertions(+), 173 deletions(-) diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index 486351c33..e727b8801 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -37,15 +37,13 @@ runs: apt update -qqq > /dev/null apt install -qqq cmake build-essential ninja-build \ xorg-dev libx11-dev libxtst-dev libssl-dev \ - libglib2.0-dev libnotify-dev \ - libxkbfile-dev qt6-base-dev qt6-tools-dev \ + libglib2.0-dev libxkbfile-dev qt6-base-dev qt6-tools-dev \ libgtk-3-dev libgtest-dev libgmock-dev \ libei-dev libportal-dev libtomlplusplus-dev libcli11-dev -y >/dev/null elif [ ${{inputs.like}} == "fedora" ]; then dnf install -y cmake make ninja-build gcc-c++ \ rpm-build openssl-devel glib2-devel \ - libXtst-devel libnotify-devel \ - libxkbfile-devel qt6-qtbase-devel qt6-qttools-devel \ + libXtst-devel libxkbfile-devel qt6-qtbase-devel qt6-qttools-devel \ gtk3-devel gtest-devel gmock-devel \ libei-devel libportal-devel tomlplusplus-devel \ cli11-devel @@ -53,14 +51,12 @@ runs: zypper refresh zypper install -y --force-resolution \ cmake make ninja gcc-c++ rpm-build libopenssl-devel \ - glib2-devel libXtst-devel libnotify-devel \ - libxkbfile-devel qt6-base-devel qt6-tools-devel gtk3-devel \ + glib2-devel libXtst-devel libxkbfile-devel qt6-base-devel qt6-tools-devel gtk3-devel \ googletest-devel googlemock-devel libei-devel \ libportal-devel tomlplusplus-devel cli11-devel elif [ ${{ inputs.like }} == "arch" ]; then pacman -Syu --noconfirm base-devel cmake ninja \ - gcc openssl glib2 libxtst libnotify \ - libxkbfile gtest libei libportal \ + gcc openssl glib2 libxtst libxkbfile gtest libei libportal \ qt6-base qt6-tools gtk3 tomlplusplus cli11 else echo "Unknown like" @@ -91,7 +87,7 @@ runs: id: vcpkg uses: johnwason/vcpkg-action@v6 with: - pkgs: wintoast gtest pkgconf openssl + pkgs: gtest pkgconf openssl extra-args: --classic triplet: x64-windows-release token: ${{ github.token }} diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index 23ca36de0..998e32894 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -149,7 +149,7 @@ macro(configure_unix_libs) configure_xorg_libs() include(FindPkgConfig) - + find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(LIBXKBCOMMON REQUIRED xkbcommon) pkg_check_modules(GLIB2 REQUIRED glib-2.0) @@ -159,15 +159,6 @@ macro(configure_unix_libs) else() message(WARNING "pkg-config not found, skipping wayland libraries") endif() - - find_package(PkgConfig) - if(PKG_CONFIG_FOUND) - pkg_check_modules(lib_glib REQUIRED IMPORTED_TARGET glib-2.0) - pkg_check_modules(lib_notify REQUIRED IMPORTED_TARGET libnotify) - add_definitions(-DHAVE_LIBNOTIFY=1) - else() - message(WARNING "pkg-config not found, skipping libnotify") - endif() endif() # For config.h, set some static values; it may be a good idea to make these diff --git a/deploy/linux/arch/PKGBUILD.in b/deploy/linux/arch/PKGBUILD.in index 3a2cc7720..375e77e21 100644 --- a/deploy/linux/arch/PKGBUILD.in +++ b/deploy/linux/arch/PKGBUILD.in @@ -22,7 +22,6 @@ depends=( 'libxtst' 'libxinerama' 'libxkbcommon-x11' - 'libnotify' 'hicolor-icon-theme' 'qt6-base' 'qt6-tools' diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index c5ac90ecd..d23edd8ba 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -861,21 +861,7 @@ void ServerProxy::secureInputNotification() { std::string app; ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app); - - // display this notification on the client - if (app != "unknown") { - AppUtil::instance().showNotification( - "The keyboard may stop working.", "'Secure input' enabled by " + app + - " on the server. " - "To fix the keyboard, " + - app + " must be closed." - ); - } else { - AppUtil::instance().showNotification( - "The keyboard may stop working.", "'Secure input' enabled by an application on the server. " - "To fix the keyboard, the application must be closed." - ); - } + LOG((CLOG_INFO "application \"%s\" is blocking the keyboard", app.c_str())); } void ServerProxy::setServerLanguages() diff --git a/src/lib/deskflow/CMakeLists.txt b/src/lib/deskflow/CMakeLists.txt index 359095211..3a1922d58 100644 --- a/src/lib/deskflow/CMakeLists.txt +++ b/src/lib/deskflow/CMakeLists.txt @@ -41,11 +41,6 @@ else() message(STATUS "tomlplusplus INC DIR: ${tomlPP_inc_dir}") endif() -if (WIN32) - find_package(unofficial-wintoast CONFIG REQUIRED) - set(wintoast-lib unofficial::wintoast::wintoast) -endif() - ####################Start Making Library######################### set(lib_name app) @@ -150,8 +145,7 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE} target_link_libraries(${lib_name} PUBLIC Qt6::Core Qt6::Network) if(WIN32) - target_compile_definitions(${lib_name} PUBLIC HAVE_WINTOAST) - target_link_libraries(${lib_name} PRIVATE ${cli11_lib} ${tomlPP_lib} ${wintoast-lib}) + target_link_libraries(${lib_name} PRIVATE ${cli11_lib} ${tomlPP_lib}) endif() target_include_directories( @@ -178,12 +172,5 @@ if(UNIX) if(NOT APPLE) target_link_libraries(${lib_name} PRIVATE Qt6::Xml) - - find_package(PkgConfig) - if(PKG_CONFIG_FOUND) - target_link_libraries(${lib_name} - PRIVATE - PkgConfig::lib_glib PkgConfig::lib_notify) - endif() endif() endif() diff --git a/src/lib/deskflow/IAppUtil.h b/src/lib/deskflow/IAppUtil.h index 933b27039..a3d8ccdf0 100644 --- a/src/lib/deskflow/IAppUtil.h +++ b/src/lib/deskflow/IAppUtil.h @@ -22,5 +22,4 @@ public: virtual void startNode() = 0; virtual std::vector getKeyboardLayoutList() = 0; virtual std::string getCurrentLanguageCode() = 0; - virtual void showNotification(const std::string &title, const std::string &text) const = 0; }; diff --git a/src/lib/deskflow/unix/AppUtilUnix.cpp b/src/lib/deskflow/unix/AppUtilUnix.cpp index 9b5f61d81..df76a0f0a 100644 --- a/src/lib/deskflow/unix/AppUtilUnix.cpp +++ b/src/lib/deskflow/unix/AppUtilUnix.cpp @@ -23,10 +23,6 @@ #include "base/LogOutputters.h" #include "common/Constants.h" -#if HAVE_LIBNOTIFY -#include -#endif - AppUtilUnix::AppUtilUnix(IEventQueue *events) { } @@ -159,33 +155,3 @@ std::string AppUtilUnix::getCurrentLanguageCode() #endif return result; } - -void AppUtilUnix::showNotification(const std::string &title, const std::string &text) const -{ -#if HAVE_LIBNOTIFY - LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str())); - if (!notify_init(kAppName)) { - LOG((CLOG_WARN "failed to initialize libnotify")); - return; - } - - auto notification = notify_notification_new(title.c_str(), text.c_str(), nullptr); - if (notification == nullptr) { - LOG((CLOG_WARN "failed to create notification")); - return; - } - notify_notification_set_timeout(notification, 10000); - - if (!notify_notification_show(notification, nullptr)) { - LOG((CLOG_WARN "failed to show notification")); - } - - g_object_unref(G_OBJECT(notification)); - notify_uninit(); - -#elif WINAPI_CARBON - // server and client processes are not allowed to show notifications. - // MacOS instead ask main deskflow process to show them instead. - LOG((CLOG_INFO "mac notification: %s|%s", title.c_str(), text.c_str())); -#endif -} diff --git a/src/lib/deskflow/unix/AppUtilUnix.h b/src/lib/deskflow/unix/AppUtilUnix.h index 54b9dd732..3a9bd26f6 100644 --- a/src/lib/deskflow/unix/AppUtilUnix.h +++ b/src/lib/deskflow/unix/AppUtilUnix.h @@ -23,6 +23,5 @@ public: void startNode() override; std::vector getKeyboardLayoutList() override; std::string getCurrentLanguageCode() override; - void showNotification(const std::string &title, const std::string &text) const override; std::string m_evdev; }; diff --git a/src/lib/deskflow/win32/AppUtilWindows.cpp b/src/lib/deskflow/win32/AppUtilWindows.cpp index eda02ff1c..ee86463ef 100644 --- a/src/lib/deskflow/win32/AppUtilWindows.cpp +++ b/src/lib/deskflow/win32/AppUtilWindows.cpp @@ -25,10 +25,6 @@ #include #include -#if HAVE_WINTOAST -#include "wintoastlib.h" -#endif - AppUtilWindows::AppUtilWindows(IEventQueue *events) : m_events(events), m_exitMode(kExitModeNormal) { if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE) { @@ -190,75 +186,6 @@ HKL AppUtilWindows::getCurrentKeyboardLayout() const return layout; } -#if HAVE_WINTOAST -class WinToastHandler : public WinToastLib::IWinToastHandler -{ -public: - WinToastHandler() - { - } - // Public interfaces - void toastActivated() const override - { - } - void toastActivated(int actionIndex) const override - { - } - void toastDismissed(WinToastDismissalReason state) const override - { - } - void toastFailed() const override - { - } -}; -#endif - -void AppUtilWindows::showNotification(const std::string &title, const std::string &text) const -{ -#if HAVE_WINTOAST - LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str())); - if (!WinToastLib::WinToast::isCompatible()) { - LOG((CLOG_INFO "this system does not support toast notifications")); - return; - } - if (!WinToastLib::WinToast::instance()->isInitialized()) { - WinToastLib::WinToast::instance()->setAppName( - L"" - "Deskflow" - ); - const auto aumi = WinToastLib::WinToast::configureAUMI( - L"" - "Deskflow Developers", - L"" - "Deskflow", - L"" - "Deskflow", - L"1.14.1+" - ); - WinToastLib::WinToast::instance()->setAppUserModelId(aumi); - - if (!WinToastLib::WinToast::instance()->initialize()) { - LOG((CLOG_WARN "failed to initialize toast notifications")); - return; - } - } - - WinToastLib::WinToast::WinToastError error; - auto handler = std::make_unique(); - WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02); - templ.setTextField(std::wstring(title.begin(), title.end()), WinToastLib::WinToastTemplate::FirstLine); - templ.setTextField(std::wstring(text.begin(), text.end()), WinToastLib::WinToastTemplate::SecondLine); - - const bool launched = WinToastLib::WinToast::instance()->showToast(templ, handler.get(), &error); - if (!launched) { - LOG((CLOG_WARN "failed to show toast notification, error code: %d", error)); - return; - } -#else - LOG((CLOG_INFO "toast notifications are not supported")); -#endif -} - void AppUtilWindows::eventLoop() { HANDLE hCloseEvent = CreateEventA(nullptr, TRUE, FALSE, kCloseEventName); diff --git a/src/lib/deskflow/win32/AppUtilWindows.h b/src/lib/deskflow/win32/AppUtilWindows.h index 839cbff1b..05dbe7999 100644 --- a/src/lib/deskflow/win32/AppUtilWindows.h +++ b/src/lib/deskflow/win32/AppUtilWindows.h @@ -42,7 +42,6 @@ public: std::vector getKeyboardLayoutList() override; std::string getCurrentLanguageCode() override; HKL getCurrentKeyboardLayout() const; - void showNotification(const std::string &title, const std::string &text) const override; private: AppExitMode m_exitMode; diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp index 3a6809aae..727b09bea 100644 --- a/src/lib/server/PrimaryClient.cpp +++ b/src/lib/server/PrimaryClient.cpp @@ -224,19 +224,7 @@ std::string PrimaryClient::getSecureInputApp() const void PrimaryClient::secureInputNotification(const std::string &app) const { - if (app != "unknown") { - AppUtil::instance().showNotification( - "The client keyboards may stop working.", "'Secure input' enabled by " + app + - ". " - "Close " + - app + " to continue using keyboards on the clients." - ); - } else { - AppUtil::instance().showNotification( - "The client keyboards may stop working.", "'Secure input' enabled by an application. " - "Close the application to continue using keyboards on the clients." - ); - } + LOG((CLOG_INFO "application \"%s\" is blocking the keyboard", app.c_str())); } void PrimaryClient::resetOptions() diff --git a/vcpkg.json b/vcpkg.json index b95234a3a..fa6ac7952 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,7 +2,6 @@ "dependencies": [ "qttranslations", "qtsvg", - "wintoast", "gtest", "pkgconf", "openssl"