From 37d333d610b7fe87c448d772d25d68bb572a4cc4 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Wed, 13 Dec 2023 00:56:51 +0100 Subject: [PATCH] Add Windows Implementation --- src/CMakeLists.txt | 2 +- src/gui/DatabaseOpenWidget.cpp | 11 +- src/gui/DatabaseOpenWidget.h | 3 +- src/gui/osutils/DeviceListener.cpp | 9 +- src/gui/osutils/DeviceListener.h | 11 +- src/gui/osutils/ScreenLockListener.cpp | 2 +- src/gui/osutils/ScreenLockListener.h | 4 +- src/gui/osutils/ScreenLockListenerPrivate.cpp | 4 +- src/gui/osutils/ScreenLockListenerPrivate.h | 6 +- .../osutils/macutils/DeviceListenerMac.cpp | 3 +- src/gui/osutils/macutils/DeviceListenerMac.h | 8 +- .../osutils/nixutils/DeviceListenerLibUsb.cpp | 4 +- .../osutils/nixutils/DeviceListenerLibUsb.h | 6 +- .../nixutils/ScreenLockListenerDBus.cpp | 2 +- .../osutils/nixutils/ScreenLockListenerDBus.h | 3 +- .../osutils/winutils/DeviceListenerWin.cpp | 103 ++++++++++++++++++ src/gui/osutils/winutils/DeviceListenerWin.h | 59 ++++++++++ .../winutils/ScreenLockListenerWin.cpp | 2 +- .../osutils/winutils/ScreenLockListenerWin.h | 6 +- 19 files changed, 211 insertions(+), 37 deletions(-) create mode 100644 src/gui/osutils/winutils/DeviceListenerWin.cpp create mode 100644 src/gui/osutils/winutils/DeviceListenerWin.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f2ffa02db..f06e7aa728 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -257,7 +257,7 @@ if(WITH_XC_YUBIKEY) elseif(UNIX) set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerLibUsb.cpp) elseif(WIN32) -# set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerWin.cpp.cpp) + set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/winutils/DeviceListenerWin.cpp) endif() endif() diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 2da00e3fa6..1d0c3fb5fd 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -57,6 +57,7 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent) : DialogyWidget(parent) , m_ui(new Ui::DatabaseOpenWidget()) , m_db(nullptr) + , m_deviceListener(new DeviceListener(this)) { m_ui->setupUi(this); @@ -90,7 +91,7 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent) connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject())); #ifdef WITH_XC_YUBIKEY - connect(&m_deviceListener, SIGNAL(devicePlugged(bool, void*, void*)), this, SLOT(pollHardwareKey())); + connect(m_deviceListener, SIGNAL(devicePlugged(bool, void*, void*)), this, SLOT(pollHardwareKey())); #endif m_ui->hardwareKeyLabelHelp->setIcon(icons()->icon("system-help").pixmap(QSize(12, 12))); @@ -147,7 +148,11 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event) #ifdef WITH_XC_YUBIKEY constexpr int vid = 0x1050; // Yubico vendor ID - m_deviceListener.registerHotplugCallback(true, true, vid); +#ifdef Q_OS_WIN + m_deviceListener->registerHotplugCallback(true, true, vid, DeviceListener::MATCH_ANY, &DeviceListenerWin::DEV_CLS_CCID); +#else + m_deviceListener->registerHotplugCallback(true, true, vid); +#endif #endif } @@ -161,7 +166,7 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event) } #ifdef WITH_XC_YUBIKEY - m_deviceListener.deregisterHotplugCallback(); + m_deviceListener->deregisterHotplugCallback(); #endif } diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 9c2f31183e..ad16ede2ac 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -19,6 +19,7 @@ #ifndef KEEPASSX_DATABASEOPENWIDGET_H #define KEEPASSX_DATABASEOPENWIDGET_H +#include #include #include @@ -83,7 +84,7 @@ private slots: private: #ifdef WITH_XC_YUBIKEY - DeviceListener m_deviceListener; + QPointer m_deviceListener; #endif bool m_pollingHardwareKey = false; bool m_blockQuickUnlock = false; diff --git a/src/gui/osutils/DeviceListener.cpp b/src/gui/osutils/DeviceListener.cpp index 1334133e90..bf07de6107 100644 --- a/src/gui/osutils/DeviceListener.cpp +++ b/src/gui/osutils/DeviceListener.cpp @@ -16,12 +16,11 @@ */ #include "DeviceListener.h" - #include -DeviceListener::DeviceListener(QObject* parent) +DeviceListener::DeviceListener(QWidget* parent) : QObject(parent) - , m_platformImpl(new DEVICELISTENER_IMPL()) + , m_platformImpl(new DEVICELISTENER_IMPL(parent)) { connect(impl(), &DEVICELISTENER_IMPL::devicePlugged, this, [&](bool state, void* ctx, void* device) { // Wait a few ms to prevent USB device access conflicts @@ -38,9 +37,9 @@ DEVICELISTENER_IMPL* DeviceListener::impl() return qobject_cast(m_platformImpl.data()); } -void DeviceListener::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId) +void DeviceListener::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId, const QUuid* deviceClass) { - impl()->registerHotplugCallback(arrived, left, vendorId, productId); + impl()->registerHotplugCallback(arrived, left, vendorId, productId, deviceClass); } void DeviceListener::deregisterHotplugCallback() diff --git a/src/gui/osutils/DeviceListener.h b/src/gui/osutils/DeviceListener.h index 7ac4d337d3..1221ed7135 100644 --- a/src/gui/osutils/DeviceListener.h +++ b/src/gui/osutils/DeviceListener.h @@ -18,17 +18,19 @@ #ifndef DEVICELISTENER_H #define DEVICELISTENER_H -#include #include +#include #if defined(Q_OS_WIN) -// TODO +#include "winutils/DeviceListenerWin.h" #elif defined(Q_OS_MACOS) #include "macutils/DeviceListenerMac.h" #elif defined(Q_OS_UNIX) #include "nixutils/DeviceListenerLibUsb.h" #endif +class QUuid; + class DeviceListener : public QObject { Q_OBJECT @@ -36,7 +38,7 @@ class DeviceListener : public QObject public: static constexpr int MATCH_ANY = -1; - explicit DeviceListener(QObject* parent = nullptr); + explicit DeviceListener(QWidget* parent); DeviceListener(const DeviceListener&) = delete; ~DeviceListener() override; @@ -51,9 +53,10 @@ class DeviceListener : public QObject * @param left listen for device unplug * @param vendorId vendor ID to listen for or DeviceListener::MATCH_ANY * @param productId product ID to listen for or DeviceListener::MATCH_ANY + * @param deviceClass device class GUID (Windows only) * @return callback handle */ - void registerHotplugCallback(bool arrived, bool left, int vendorId = MATCH_ANY, int productId = MATCH_ANY); + void registerHotplugCallback(bool arrived, bool left, int vendorId = MATCH_ANY, int productId = MATCH_ANY, const QUuid* deviceClass = nullptr); void deregisterHotplugCallback(); signals: diff --git a/src/gui/osutils/ScreenLockListener.cpp b/src/gui/osutils/ScreenLockListener.cpp index 2c77b6e08e..1e3e4e47ca 100644 --- a/src/gui/osutils/ScreenLockListener.cpp +++ b/src/gui/osutils/ScreenLockListener.cpp @@ -18,7 +18,7 @@ #include "ScreenLockListener.h" #include "ScreenLockListenerPrivate.h" -ScreenLockListener::ScreenLockListener(QObject* parent) +ScreenLockListener::ScreenLockListener(QWidget* parent) : QObject(parent) { m_listener = ScreenLockListenerPrivate::instance(parent); diff --git a/src/gui/osutils/ScreenLockListener.h b/src/gui/osutils/ScreenLockListener.h index 04e3758d3e..326bacd2ee 100644 --- a/src/gui/osutils/ScreenLockListener.h +++ b/src/gui/osutils/ScreenLockListener.h @@ -17,7 +17,7 @@ #ifndef SCREENLOCKLISTENER_H #define SCREENLOCKLISTENER_H -#include +#include class ScreenLockListenerPrivate; @@ -26,7 +26,7 @@ class ScreenLockListener : public QObject Q_OBJECT public: - explicit ScreenLockListener(QObject* parent = nullptr); + explicit ScreenLockListener(QWidget* parent); ~ScreenLockListener() override; signals: diff --git a/src/gui/osutils/ScreenLockListenerPrivate.cpp b/src/gui/osutils/ScreenLockListenerPrivate.cpp index 6b643cc1ff..76df0a914b 100644 --- a/src/gui/osutils/ScreenLockListenerPrivate.cpp +++ b/src/gui/osutils/ScreenLockListenerPrivate.cpp @@ -26,12 +26,12 @@ #include "winutils/ScreenLockListenerWin.h" #endif -ScreenLockListenerPrivate::ScreenLockListenerPrivate(QObject* parent) +ScreenLockListenerPrivate::ScreenLockListenerPrivate(QWidget* parent) : QObject(parent) { } -ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QObject* parent) +ScreenLockListenerPrivate* ScreenLockListenerPrivate::instance(QWidget* parent) { #if defined(Q_OS_MACOS) Q_UNUSED(parent); diff --git a/src/gui/osutils/ScreenLockListenerPrivate.h b/src/gui/osutils/ScreenLockListenerPrivate.h index 4e4bb7b0a2..34511f168a 100644 --- a/src/gui/osutils/ScreenLockListenerPrivate.h +++ b/src/gui/osutils/ScreenLockListenerPrivate.h @@ -17,16 +17,16 @@ #ifndef SCREENLOCKLISTENERPRIVATE_H #define SCREENLOCKLISTENERPRIVATE_H -#include +#include class ScreenLockListenerPrivate : public QObject { Q_OBJECT public: - static ScreenLockListenerPrivate* instance(QObject* parent = nullptr); + static ScreenLockListenerPrivate* instance(QWidget* parent = nullptr); protected: - explicit ScreenLockListenerPrivate(QObject* parent = nullptr); + explicit ScreenLockListenerPrivate(QWidget* parent = nullptr); signals: void screenLocked(); diff --git a/src/gui/osutils/macutils/DeviceListenerMac.cpp b/src/gui/osutils/macutils/DeviceListenerMac.cpp index 03672c2e86..2d417818de 100644 --- a/src/gui/osutils/macutils/DeviceListenerMac.cpp +++ b/src/gui/osutils/macutils/DeviceListenerMac.cpp @@ -19,6 +19,7 @@ #include #include +#include DeviceListenerMac::DeviceListenerMac(QObject* parent) : QObject(parent) @@ -35,7 +36,7 @@ DeviceListenerMac::~DeviceListenerMac() } } -void DeviceListenerMac::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId) +void DeviceListenerMac::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId, const QUuid*) { if (!m_mgr) { m_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDManagerOptionNone); diff --git a/src/gui/osutils/macutils/DeviceListenerMac.h b/src/gui/osutils/macutils/DeviceListenerMac.h index 32ed18b96f..fcb865142c 100644 --- a/src/gui/osutils/macutils/DeviceListenerMac.h +++ b/src/gui/osutils/macutils/DeviceListenerMac.h @@ -19,9 +19,9 @@ #define DEVICELISTENER_MAC_H #include -#include -#include +class IOHIDManagerRef; +class QUuid; #define DEVICELISTENER_IMPL DeviceListenerMac @@ -30,14 +30,14 @@ class DeviceListenerMac : public QObject Q_OBJECT public: - explicit DeviceListenerMac(QObject* parent = nullptr); + explicit DeviceListenerMac(QObject* parent); DeviceListenerMac(const DeviceListenerMac&) = delete; ~DeviceListenerMac() override; void registerHotplugCallback(bool arrived, bool left, int vendorId = -1, - int productId = -1); + int productId = -1, const QUuid* = nullptr); void deregisterHotplugCallback(); signals: diff --git a/src/gui/osutils/nixutils/DeviceListenerLibUsb.cpp b/src/gui/osutils/nixutils/DeviceListenerLibUsb.cpp index 141b2970ba..0f9bc4bf12 100644 --- a/src/gui/osutils/nixutils/DeviceListenerLibUsb.cpp +++ b/src/gui/osutils/nixutils/DeviceListenerLibUsb.cpp @@ -22,7 +22,7 @@ #include #include -DeviceListenerLibUsb::DeviceListenerLibUsb(QObject* parent) +DeviceListenerLibUsb::DeviceListenerLibUsb(QWidget* parent) : QObject(parent) , m_ctx(nullptr) , m_callbackRef(0) @@ -50,7 +50,7 @@ namespace } } // namespace -void DeviceListenerLibUsb::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId) +void DeviceListenerLibUsb::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId, const QUuid*) { if (!m_ctx) { if (libusb_init(reinterpret_cast(&m_ctx)) != LIBUSB_SUCCESS) { diff --git a/src/gui/osutils/nixutils/DeviceListenerLibUsb.h b/src/gui/osutils/nixutils/DeviceListenerLibUsb.h index c7c8688dee..54f0abedec 100644 --- a/src/gui/osutils/nixutils/DeviceListenerLibUsb.h +++ b/src/gui/osutils/nixutils/DeviceListenerLibUsb.h @@ -22,6 +22,8 @@ #include #include +class QUuid; + #define DEVICELISTENER_IMPL DeviceListenerLibUsb class DeviceListenerLibUsb : public QObject @@ -29,11 +31,11 @@ class DeviceListenerLibUsb : public QObject Q_OBJECT public: - explicit DeviceListenerLibUsb(QObject* parent = nullptr); + explicit DeviceListenerLibUsb(QWidget* parent); DeviceListenerLibUsb(const DeviceListenerLibUsb&) = delete; ~DeviceListenerLibUsb() override; - void registerHotplugCallback(bool arrived, bool left, int vendorId = -1, int productId = -1); + void registerHotplugCallback(bool arrived, bool left, int vendorId = -1, int productId = -1, const QUuid* = nullptr); void deregisterHotplugCallback(); signals: diff --git a/src/gui/osutils/nixutils/ScreenLockListenerDBus.cpp b/src/gui/osutils/nixutils/ScreenLockListenerDBus.cpp index cc3d2e4edd..1da87b9974 100644 --- a/src/gui/osutils/nixutils/ScreenLockListenerDBus.cpp +++ b/src/gui/osutils/nixutils/ScreenLockListenerDBus.cpp @@ -21,7 +21,7 @@ #include #include -ScreenLockListenerDBus::ScreenLockListenerDBus(QObject* parent) +ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget* parent) : ScreenLockListenerPrivate(parent) { QDBusConnection sessionBus = QDBusConnection::sessionBus(); diff --git a/src/gui/osutils/nixutils/ScreenLockListenerDBus.h b/src/gui/osutils/nixutils/ScreenLockListenerDBus.h index cbaa134ecc..4ece8134f5 100644 --- a/src/gui/osutils/nixutils/ScreenLockListenerDBus.h +++ b/src/gui/osutils/nixutils/ScreenLockListenerDBus.h @@ -17,6 +17,7 @@ #ifndef SCREENLOCKLISTENERDBUS_H #define SCREENLOCKLISTENERDBUS_H + #include "gui/osutils/ScreenLockListenerPrivate.h" #include @@ -24,7 +25,7 @@ class ScreenLockListenerDBus : public ScreenLockListenerPrivate { Q_OBJECT public: - explicit ScreenLockListenerDBus(QObject* parent = nullptr); + explicit ScreenLockListenerDBus(QWidget* parent); private slots: void gnomeSessionStatusChanged(uint status); diff --git a/src/gui/osutils/winutils/DeviceListenerWin.cpp b/src/gui/osutils/winutils/DeviceListenerWin.cpp new file mode 100644 index 0000000000..82b5f6905b --- /dev/null +++ b/src/gui/osutils/winutils/DeviceListenerWin.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2023 KeePassXC Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "DeviceListenerWin.h" + +#include + +#include +#include +#include + +DeviceListenerWin::DeviceListenerWin(QWidget* parent) + : QObject(parent) +{ + // Event listeners need a valid window reference + Q_ASSERT(parent); + QCoreApplication::instance()->installNativeEventFilter(this); +} + +DeviceListenerWin::~DeviceListenerWin() +{ + deregisterHotplugCallback(); +} + +void DeviceListenerWin::registerHotplugCallback(bool arrived, bool left, int vendorId, int productId, const QUuid* deviceClass) +{ + Q_ASSERT(deviceClass); + + if (m_deviceNotifyHandle) { + deregisterHotplugCallback(); + } + + m_deviceIdPrefix = R"(\\?\USB#)"; + if (vendorId > 0) { + m_deviceIdPrefix += QString("VID_%1&").arg(vendorId, 0, 16); + if (productId > 0) { + m_deviceIdPrefix += QString("PID_%1&").arg(productId, 0, 16); + } + } + + DEV_BROADCAST_DEVICEINTERFACE_W notificationFilter { + sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), + DBT_DEVTYP_DEVICEINTERFACE, + 0u, + *deviceClass, + {0x00} + }; + auto w = reinterpret_cast(qobject_cast(parent())->winId()); + m_deviceNotifyHandle = RegisterDeviceNotificationW(w, ¬ificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE); + if (!m_deviceNotifyHandle) { + qWarning("Failed to register device notification handle."); + return; + } + m_handleArrival = arrived; + m_handleRemoval = left; +} + +void DeviceListenerWin::deregisterHotplugCallback() +{ + if (m_deviceNotifyHandle) { + UnregisterDeviceNotification(m_deviceNotifyHandle); + m_deviceNotifyHandle = nullptr; + m_handleArrival = false; + m_handleRemoval = false; + } +} + +bool DeviceListenerWin::nativeEventFilter(const QByteArray& eventType, void* message, long*) +{ + if (eventType != "windows_generic_MSG") { + return false; + } + + const auto* m = static_cast(message); + if (m->message != WM_DEVICECHANGE) { + return false; + } + if ((m_handleArrival && m->wParam == DBT_DEVICEARRIVAL) || (m_handleRemoval && m->wParam == DBT_DEVICEREMOVECOMPLETE)) { + const auto pBrHdr = reinterpret_cast(m->lParam); + const auto pDevIface = reinterpret_cast(pBrHdr); + const auto name = QString::fromWCharArray(pDevIface->dbcc_name, pDevIface->dbcc_size); + if (name.startsWith(m_deviceIdPrefix)) { + emit devicePlugged(m->wParam == DBT_DEVICEARRIVAL, nullptr, pDevIface); + } + return true; + } + + return false; +} diff --git a/src/gui/osutils/winutils/DeviceListenerWin.h b/src/gui/osutils/winutils/DeviceListenerWin.h new file mode 100644 index 0000000000..94926726cf --- /dev/null +++ b/src/gui/osutils/winutils/DeviceListenerWin.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 KeePassXC Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DEVICELISTENER_WIN_H +#define DEVICELISTENER_WIN_H + +#include +#include +#include + +#define DEVICELISTENER_IMPL DeviceListenerWin + +class DeviceListenerWin : public QObject, public QAbstractNativeEventFilter +{ + Q_OBJECT + +public: + static constexpr QUuid DEV_CLS_CCID = QUuid(0x50dd5230L, 0xba8a, 0x11d1, 0xbf, 0x5d, 0x00, 0x00, 0xf8, 0x05, 0xf5, 0x30); + static constexpr QUuid DEV_CLS_HID = QUuid(0x745a17a0L, 0x74d3, 0x11d0, 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda); + static constexpr QUuid DEV_CLS_USB = QUuid(0x88bae032L, 0x5a81, 0x49f0, 0xbc, 0x3d, 0xa4, 0xff, 0x13, 0x82, 0x16, 0xd6); + + explicit DeviceListenerWin(QWidget* parent); + DeviceListenerWin(const DeviceListenerWin&) = delete; + ~DeviceListenerWin() override; + + void registerHotplugCallback(bool arrived, + bool left, + int vendorId = -1, + int productId = -1, + const QUuid* deviceClass = nullptr); + void deregisterHotplugCallback(); + + bool nativeEventFilter(const QByteArray &eventType, void *message, long*) override; + +signals: + void devicePlugged(bool state, void* ctx, void* device); + +private: + void* m_deviceNotifyHandle = nullptr; + bool m_handleArrival = false; + bool m_handleRemoval = false; + QString m_deviceIdPrefix; +}; + +#endif // DEVICELISTENER_WIN_H diff --git a/src/gui/osutils/winutils/ScreenLockListenerWin.cpp b/src/gui/osutils/winutils/ScreenLockListenerWin.cpp index d0db5f2a0b..05d01f4ccd 100644 --- a/src/gui/osutils/winutils/ScreenLockListenerWin.cpp +++ b/src/gui/osutils/winutils/ScreenLockListenerWin.cpp @@ -25,7 +25,7 @@ * See https://msdn.microsoft.com/en-us/library/aa383841(v=vs.85).aspx * See https://blogs.msdn.microsoft.com/oldnewthing/20060104-50/?p=32783 */ -ScreenLockListenerWin::ScreenLockListenerWin(QObject* parent) +ScreenLockListenerWin::ScreenLockListenerWin(QWidget* parent) : ScreenLockListenerPrivate(parent) , QAbstractNativeEventFilter() { diff --git a/src/gui/osutils/winutils/ScreenLockListenerWin.h b/src/gui/osutils/winutils/ScreenLockListenerWin.h index 29cc7620c7..31449b8e3a 100644 --- a/src/gui/osutils/winutils/ScreenLockListenerWin.h +++ b/src/gui/osutils/winutils/ScreenLockListenerWin.h @@ -17,8 +17,8 @@ #ifndef SCREENLOCKLISTENERWIN_H #define SCREENLOCKLISTENERWIN_H + #include -#include #include #include "gui/osutils/ScreenLockListenerPrivate.h" @@ -27,9 +27,9 @@ class ScreenLockListenerWin : public ScreenLockListenerPrivate, public QAbstract { Q_OBJECT public: - explicit ScreenLockListenerWin(QObject* parent = nullptr); + explicit ScreenLockListenerWin(QWidget* parent); ~ScreenLockListenerWin(); - bool nativeEventFilter(const QByteArray& eventType, void* message, long*) override; + virtual bool nativeEventFilter(const QByteArray &eventType, void* message, long* result) override; private: void* m_powerNotificationHandle;