mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
* Refactor to fix #1671 * Add GUI/NonGUI mode to info page * Do not show lock config, if in non-UI mode * Updae Changelog * Correct includes * Remove unused variable * use ninja generator under macos --------- Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
parent
3f2375deaf
commit
cdd59ffc87
@ -52,6 +52,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
|
|||||||
- Fixed that the Matrix effect finds its image - Thanks @lsellens
|
- Fixed that the Matrix effect finds its image - Thanks @lsellens
|
||||||
- MDNSBrower - Fixed, if timeout while resolving host occurs
|
- MDNSBrower - Fixed, if timeout while resolving host occurs
|
||||||
- Non image updates ignored blacklisted LEDs (#1634)
|
- Non image updates ignored blacklisted LEDs (#1634)
|
||||||
|
- Fixed that Windows OsEvents failed in non-GUI mode (#1671)
|
||||||
|
|
||||||
##### LED-Devices
|
##### LED-Devices
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
performTranslation();
|
performTranslation();
|
||||||
|
|
||||||
|
let isGuiMode = window.sysInfo.hyperion.isGuiMode;
|
||||||
const CEC_ENABLED = (jQuery.inArray("cec", window.serverInfo.services) !== -1);
|
const CEC_ENABLED = (jQuery.inArray("cec", window.serverInfo.services) !== -1);
|
||||||
|
|
||||||
let conf_editor_osEvents = null;
|
let conf_editor_osEvents = null;
|
||||||
@ -76,6 +77,12 @@ $(document).ready(function () {
|
|||||||
osEvents: window.schema.osEvents
|
osEvents: window.schema.osEvents
|
||||||
}, true, true);
|
}, true, true);
|
||||||
|
|
||||||
|
conf_editor_osEvents.on('ready', function () {
|
||||||
|
if (!isGuiMode) {
|
||||||
|
showInputOptionsForKey(conf_editor_osEvents, "osEvents", "suspendEnable", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
conf_editor_osEvents.on('change', function () {
|
conf_editor_osEvents.on('change', function () {
|
||||||
conf_editor_osEvents.validate().length || window.readOnlyMode ? $('#btn_submit_os_events').prop('disabled', true) : $('#btn_submit_os_events').prop('disabled', false);
|
conf_editor_osEvents.validate().length || window.readOnlyMode ? $('#btn_submit_os_events').prop('disabled', true) : $('#btn_submit_os_events').prop('disabled', false);
|
||||||
});
|
});
|
||||||
|
@ -1224,6 +1224,7 @@ function getSystemInfo() {
|
|||||||
info += '- Avail Services: ' + window.serverInfo.services + '\n';
|
info += '- Avail Services: ' + window.serverInfo.services + '\n';
|
||||||
info += '- Config path: ' + shy.rootPath + '\n';
|
info += '- Config path: ' + shy.rootPath + '\n';
|
||||||
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
|
info += '- Database: ' + (shy.readOnlyMode ? "ready-only" : "read/write") + '\n';
|
||||||
|
info += '- Mode: ' + (shy.isGuiMode ? "GUI" : "Non-GUI") + '\n';
|
||||||
|
|
||||||
info += '\n';
|
info += '\n';
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <powrprof.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <utils/settings.h>
|
#include <utils/settings.h>
|
||||||
@ -21,8 +22,9 @@ class OsEventHandlerBase : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OsEventHandlerBase();
|
OsEventHandlerBase();
|
||||||
~OsEventHandlerBase() override;
|
virtual ~OsEventHandlerBase();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void suspend(bool sleep);
|
void suspend(bool sleep);
|
||||||
@ -46,6 +48,8 @@ protected:
|
|||||||
bool _isSuspendRegistered;
|
bool _isSuspendRegistered;
|
||||||
bool _isLockRegistered;
|
bool _isLockRegistered;
|
||||||
|
|
||||||
|
bool _isService;
|
||||||
|
|
||||||
Logger* _log{};
|
Logger* _log{};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,10 +57,11 @@ protected:
|
|||||||
|
|
||||||
class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter
|
class OsEventHandlerWindows : public OsEventHandlerBase, public QAbstractNativeEventFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OsEventHandlerWindows();
|
OsEventHandlerWindows();
|
||||||
~OsEventHandlerWindows() override;
|
~OsEventHandlerWindows();
|
||||||
|
|
||||||
|
void handleSuspendResumeEvent(bool sleep);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
@ -65,13 +70,17 @@ protected:
|
|||||||
bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) override;
|
bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
bool registerOsEventHandler() override;
|
bool registerOsEventHandler() override;
|
||||||
void unregisterOsEventHandler() override;
|
void unregisterOsEventHandler() override;
|
||||||
bool registerLockHandler() override;
|
bool registerLockHandler() override;
|
||||||
void unregisterLockHandler() override;
|
void unregisterLockHandler() override;
|
||||||
|
|
||||||
QWidget _widget;
|
private:
|
||||||
|
static OsEventHandlerWindows* getInstance();
|
||||||
|
|
||||||
|
static DEVICE_NOTIFY_CALLBACK_ROUTINE handlePowerNotifications;
|
||||||
|
|
||||||
|
QWidget* _widget;
|
||||||
HPOWERNOTIFY _notifyHandle;
|
HPOWERNOTIFY _notifyHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
// hyperion includes
|
// hyperion includes
|
||||||
#include <leddevice/LedDeviceWrapper.h>
|
#include <leddevice/LedDeviceWrapper.h>
|
||||||
@ -389,6 +391,9 @@ void JsonAPI::handleSysInfoCommand(const QJsonObject &, const QString &command,
|
|||||||
hyperion["rootPath"] = _instanceManager->getRootPath();
|
hyperion["rootPath"] = _instanceManager->getRootPath();
|
||||||
hyperion["readOnlyMode"] = _hyperion->getReadOnlyMode();
|
hyperion["readOnlyMode"] = _hyperion->getReadOnlyMode();
|
||||||
|
|
||||||
|
QCoreApplication* app = QCoreApplication::instance();
|
||||||
|
hyperion["isGuiMode"] = qobject_cast<QApplication*>(app) ? true : false;
|
||||||
|
|
||||||
info["hyperion"] = hyperion;
|
info["hyperion"] = hyperion;
|
||||||
|
|
||||||
// send the result
|
// send the result
|
||||||
|
@ -3,19 +3,22 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include <events/EventHandler.h>
|
#include <events/EventHandler.h>
|
||||||
#include <utils/Logger.h>
|
#include <utils/Logger.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wtsapi32.h>
|
#include <wtsapi32.h>
|
||||||
|
#include <powerbase.h>
|
||||||
|
|
||||||
#pragma comment( lib, "wtsapi32.lib" )
|
#pragma comment( lib, "wtsapi32.lib" )
|
||||||
|
#pragma comment(lib, "PowrProf.lib")
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
#endif
|
#endif
|
||||||
@ -26,10 +29,16 @@ OsEventHandlerBase::OsEventHandlerBase()
|
|||||||
, _isSuspendOnLock(false)
|
, _isSuspendOnLock(false)
|
||||||
, _isSuspendRegistered(false)
|
, _isSuspendRegistered(false)
|
||||||
, _isLockRegistered(false)
|
, _isLockRegistered(false)
|
||||||
|
, _isService(false)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Event>("Event");
|
qRegisterMetaType<Event>("Event");
|
||||||
_log = Logger::getInstance("EVENTS-OS");
|
_log = Logger::getInstance("EVENTS-OS");
|
||||||
|
|
||||||
|
QCoreApplication* app = QCoreApplication::instance();
|
||||||
|
if (!qobject_cast<QApplication*>(app))
|
||||||
|
{
|
||||||
|
_isService = true;
|
||||||
|
}
|
||||||
QObject::connect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent);
|
QObject::connect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +74,8 @@ void OsEventHandlerBase::handleSettingsUpdate(settings::type type, const QJsonDo
|
|||||||
unregisterOsEventHandler();
|
unregisterOsEventHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_isService)
|
||||||
|
{
|
||||||
_isLockEnabled = obj["lockEnable"].toBool(true);
|
_isLockEnabled = obj["lockEnable"].toBool(true);
|
||||||
if (_isLockEnabled || _isSuspendOnLock != prevIsSuspendOnLock)
|
if (_isLockEnabled || _isSuspendOnLock != prevIsSuspendOnLock)
|
||||||
{
|
{
|
||||||
@ -77,6 +88,7 @@ void OsEventHandlerBase::handleSettingsUpdate(settings::type type, const QJsonDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OsEventHandlerBase::suspend(bool sleep)
|
void OsEventHandlerBase::suspend(bool sleep)
|
||||||
{
|
{
|
||||||
@ -118,8 +130,15 @@ void OsEventHandlerBase::lock(bool isLocked)
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
|
OsEventHandlerWindows* OsEventHandlerWindows::getInstance()
|
||||||
|
{
|
||||||
|
static OsEventHandlerWindows instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
OsEventHandlerWindows::OsEventHandlerWindows()
|
OsEventHandlerWindows::OsEventHandlerWindows()
|
||||||
: _notifyHandle(NULL)
|
: _notifyHandle(NULL),
|
||||||
|
_widget(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +146,8 @@ OsEventHandlerWindows::~OsEventHandlerWindows()
|
|||||||
{
|
{
|
||||||
unregisterLockHandler();
|
unregisterLockHandler();
|
||||||
unregisterOsEventHandler();
|
unregisterOsEventHandler();
|
||||||
|
|
||||||
|
delete _widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
@ -135,8 +156,8 @@ bool OsEventHandlerWindows::nativeEventFilter(const QByteArray& eventType, void*
|
|||||||
bool OsEventHandlerWindows::nativeEventFilter(const QByteArray& eventType, void* message, long int* /*result*/)
|
bool OsEventHandlerWindows::nativeEventFilter(const QByteArray& eventType, void* message, long int* /*result*/)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
MSG* msg = static_cast<MSG*>(message);
|
|
||||||
|
|
||||||
|
MSG* msg = static_cast<MSG*>(message);
|
||||||
switch (msg->message)
|
switch (msg->message)
|
||||||
{
|
{
|
||||||
case WM_WTSSESSION_CHANGE:
|
case WM_WTSSESSION_CHANGE:
|
||||||
@ -152,34 +173,45 @@ bool OsEventHandlerWindows::nativeEventFilter(const QByteArray& eventType, void*
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_POWERBROADCAST:
|
|
||||||
switch (msg->wParam)
|
|
||||||
{
|
|
||||||
case PBT_APMRESUMESUSPEND:
|
|
||||||
emit suspend(false);
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
case PBT_APMSUSPEND:
|
|
||||||
emit suspend(true);
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsEventHandlerWindows::handleSuspendResumeEvent(bool sleep)
|
||||||
|
{
|
||||||
|
if (sleep)
|
||||||
|
{
|
||||||
|
suspend(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
suspend(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG OsEventHandlerWindows::handlePowerNotifications(PVOID Context, ULONG Type, PVOID Setting)
|
||||||
|
{
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case PBT_APMRESUMESUSPEND:
|
||||||
|
getInstance()->handleSuspendResumeEvent(false);
|
||||||
|
break;
|
||||||
|
case PBT_APMSUSPEND:
|
||||||
|
getInstance()->handleSuspendResumeEvent(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
bool OsEventHandlerWindows::registerOsEventHandler()
|
bool OsEventHandlerWindows::registerOsEventHandler()
|
||||||
{
|
{
|
||||||
bool isRegistered{ _isSuspendRegistered };
|
bool isRegistered{ _isSuspendRegistered };
|
||||||
if (!_isSuspendRegistered)
|
if (!_isSuspendRegistered)
|
||||||
{
|
{
|
||||||
auto handle = reinterpret_cast<HWND> (_widget.winId());
|
DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS notificationsParameters = { handlePowerNotifications, NULL };
|
||||||
_notifyHandle = RegisterSuspendResumeNotification(handle, DEVICE_NOTIFY_WINDOW_HANDLE);
|
if (PowerRegisterSuspendResumeNotification(DEVICE_NOTIFY_CALLBACK, (HANDLE)¬ificationsParameters, &_notifyHandle) == ERROR_SUCCESS)
|
||||||
if (_notifyHandle != NULL)
|
|
||||||
{
|
{
|
||||||
QCoreApplication::instance()->installNativeEventFilter(this);
|
isRegistered = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -200,8 +232,7 @@ void OsEventHandlerWindows::unregisterOsEventHandler()
|
|||||||
{
|
{
|
||||||
if (_notifyHandle != NULL)
|
if (_notifyHandle != NULL)
|
||||||
{
|
{
|
||||||
QCoreApplication::instance()->removeNativeEventFilter(this);
|
PowerUnregisterSuspendResumeNotification(_notifyHandle);
|
||||||
UnregisterSuspendResumeNotification(_notifyHandle);
|
|
||||||
}
|
}
|
||||||
_notifyHandle = NULL;
|
_notifyHandle = NULL;
|
||||||
_isSuspendRegistered = false;
|
_isSuspendRegistered = false;
|
||||||
@ -213,17 +244,23 @@ bool OsEventHandlerWindows::registerLockHandler()
|
|||||||
bool isRegistered{ _isLockRegistered };
|
bool isRegistered{ _isLockRegistered };
|
||||||
if (!_isLockRegistered)
|
if (!_isLockRegistered)
|
||||||
{
|
{
|
||||||
auto handle = reinterpret_cast<HWND> (_widget.winId());
|
if (!_isService)
|
||||||
|
{
|
||||||
|
_widget = new QWidget();
|
||||||
|
if (_widget)
|
||||||
|
{
|
||||||
|
auto handle = reinterpret_cast<HWND> (_widget->winId());
|
||||||
if (WTSRegisterSessionNotification(handle, NOTIFY_FOR_THIS_SESSION))
|
if (WTSRegisterSessionNotification(handle, NOTIFY_FOR_THIS_SESSION))
|
||||||
{
|
{
|
||||||
|
QCoreApplication::instance()->installNativeEventFilter(this);
|
||||||
isRegistered = true;
|
isRegistered = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Error(_log, "Could not register for lock/unlock events!");
|
Error(_log, "Could not register for lock/unlock events!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRegistered)
|
if (isRegistered)
|
||||||
@ -237,11 +274,15 @@ void OsEventHandlerWindows::unregisterLockHandler()
|
|||||||
{
|
{
|
||||||
if (_isLockRegistered)
|
if (_isLockRegistered)
|
||||||
{
|
{
|
||||||
auto handle = reinterpret_cast<HWND> (_widget.winId());
|
if (!_isService)
|
||||||
|
{
|
||||||
|
auto handle = reinterpret_cast<HWND> (_widget->winId());
|
||||||
|
QCoreApplication::instance()->removeNativeEventFilter(this);
|
||||||
WTSUnRegisterSessionNotification(handle);
|
WTSUnRegisterSessionNotification(handle);
|
||||||
_isLockRegistered = false;
|
_isLockRegistered = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user