remove Use of libnotify and wintoast

This commit is contained in:
sithlord48 2025-03-26 09:48:37 -04:00 committed by Nick Bolton
parent bcfc77fde6
commit 201df59cb7
12 changed files with 9 additions and 173 deletions

View file

@ -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 }}

View file

@ -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

View file

@ -22,7 +22,6 @@ depends=(
'libxtst'
'libxinerama'
'libxkbcommon-x11'
'libnotify'
'hicolor-icon-theme'
'qt6-base'
'qt6-tools'

View file

@ -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()

View file

@ -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()

View file

@ -22,5 +22,4 @@ public:
virtual void startNode() = 0;
virtual std::vector<std::string> getKeyboardLayoutList() = 0;
virtual std::string getCurrentLanguageCode() = 0;
virtual void showNotification(const std::string &title, const std::string &text) const = 0;
};

View file

@ -23,10 +23,6 @@
#include "base/LogOutputters.h"
#include "common/Constants.h"
#if HAVE_LIBNOTIFY
#include <libnotify/notify.h>
#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
}

View file

@ -23,6 +23,5 @@ public:
void startNode() override;
std::vector<std::string> getKeyboardLayoutList() override;
std::string getCurrentLanguageCode() override;
void showNotification(const std::string &title, const std::string &text) const override;
std::string m_evdev;
};

View file

@ -25,10 +25,6 @@
#include <conio.h>
#include <memory>
#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<WinToastHandler>();
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);

View file

@ -42,7 +42,6 @@ public:
std::vector<std::string> 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;

View file

@ -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()

View file

@ -2,7 +2,6 @@
"dependencies": [
"qttranslations",
"qtsvg",
"wintoast",
"gtest",
"pkgconf",
"openssl"