Skip to content

API Clean-up (2) & Fixes #1868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed: Python 3.12 crashes (#1747)
- osX Grabber: Use ScreenCaptureKit under macOS 15 and above
- Removed maximum LED number constraint from Matrix layout schema which was not synced with the UI behaviour (#1804)
- UI: Instance listings are sorted, enabled instances are high-lighted in drop-downs
- Fixed bespoke WebSocket implementation by using of QWebSockets (#1816, #1448, #1247, #1130)
- Fixed mDNS Browser deadlock, plus run in own thread now
- Fixed that LED Buffer and Layout might get out of sync.
Expand All @@ -72,7 +73,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Last update of an effect event is not removed in sources overview
- Fixed Removed stale _logger object
- Fixed Smoothing (#1863)
- UI: Instance listings are sorted, enabled instances are high-lighted in drop-downs
- Fixed Crash when XCB,X11 was configured and display manager changed to Wayland
- Fixed Target-directory not correctly build when exporting effects

**JSON-API**
- Refactored JSON-API to ensure consistent authorization behaviour across sessions and single requests with token authorization.
Expand Down
1 change: 0 additions & 1 deletion assets/webconfig/js/content_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ $(document).ready(function () {
$("#general_comp_" + componentName).bootstrapToggle(isInstanceEnabled ? "enable" : "disable");

$("#general_comp_" + componentName).change(function () {
const componentName = componentName;
const isChecked = $(this).prop('checked');
requestSetComponentState(componentName, isChecked);
});
Expand Down
8 changes: 4 additions & 4 deletions doc/development/JSON-API _Commands_Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ _http/s Support_
| instance | switchTo | Yes | No | No | Yes |
| instance-data | getImageSnapshot | Yes | Single | Yes | Yes |
| instance-data | getLedSnapshot | Yes | Single | Yes | Yes |
| ledcolors | imagestream-start | Yes | Single | Yes | Yes |
| ledcolors | imagestream-stop | Yes | Single | Yes | Yes |
| ledcolors | ledstream-start | Yes | Single | Yes | Yes |
| ledcolors | ledstream-stop | Yes | Single | Yes | Yes |
| ledcolors | imagestream-start | Yes | Single | Yes | No |
| ledcolors | imagestream-stop | Yes | Single | Yes | No |
| ledcolors | ledstream-start | Yes | Single | Yes | No |
| ledcolors | ledstream-stop | Yes | Single | Yes | No |
| leddevice | addAuthorization | Yes | Single | Yes | Yes |
| leddevice | discover | Yes | No | No | Yes |
| leddevice | getProperties | Yes | No | No | Yes |
Expand Down
8 changes: 4 additions & 4 deletions include/api/JsonApiCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ class ApiCommandRegister {
{ {"instance", "switchTo"}, { Command::Instance, SubCommand::SwitchTo, Authorization::Yes, InstanceCmd::No, InstanceCmd::MustRun_No, NoListenerCmd::Yes } },
{ {"instance-data", "getImageSnapshot"}, { Command::InstanceData, SubCommand::GetImageSnapshot, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"instance-data", "getLedSnapshot"}, { Command::InstanceData, SubCommand::GetLedSnapshot, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"ledcolors", "imagestream-start"}, { Command::LedColors, SubCommand::ImageStreamStart, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"ledcolors", "imagestream-stop"}, { Command::LedColors, SubCommand::ImageStreamStop, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"ledcolors", "ledstream-start"}, { Command::LedColors, SubCommand::LedStreamStart, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"ledcolors", "ledstream-stop"}, { Command::LedColors, SubCommand::LedStreamStop, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"ledcolors", "imagestream-start"}, { Command::LedColors, SubCommand::ImageStreamStart, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::No } },
{ {"ledcolors", "imagestream-stop"}, { Command::LedColors, SubCommand::ImageStreamStop, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::No } },
{ {"ledcolors", "ledstream-start"}, { Command::LedColors, SubCommand::LedStreamStart, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::No } },
{ {"ledcolors", "ledstream-stop"}, { Command::LedColors, SubCommand::LedStreamStop, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::No } },
{ {"leddevice", "addAuthorization"}, { Command::LedDevice, SubCommand::AddAuthorization, Authorization::Yes, InstanceCmd::Single, InstanceCmd::MustRun_Yes, NoListenerCmd::Yes } },
{ {"leddevice", "discover"}, { Command::LedDevice, SubCommand::Discover, Authorization::Yes, InstanceCmd::No, InstanceCmd::MustRun_No, NoListenerCmd::Yes } },
{ {"leddevice", "getProperties"}, { Command::LedDevice, SubCommand::GetProperties, Authorization::Yes, InstanceCmd::No, InstanceCmd::MustRun_No, NoListenerCmd::Yes } },
Expand Down
4 changes: 2 additions & 2 deletions include/api/JsonCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class JsonCallbacks : public QObject

///
/// @brief Subscribe to future data updates given by subscription list
/// @param type Array of subscriptionsm
/// @param type Array of subscriptions, an empty array subscribes to all updates
///
QStringList subscribe(const QJsonArray& subscriptions);

Expand All @@ -56,7 +56,7 @@ class JsonCallbacks : public QObject

///
/// @brief Unsubscribe to future data updates given by subscription list
/// @param type Array of subscriptions
/// @param type Array of subscriptions, an empty array will unsubcribe all current subscriptions
///
QStringList unsubscribe(const QJsonArray& subscriptions);

Expand Down
2 changes: 1 addition & 1 deletion include/grabber/dispmanx/DispmanxFrameGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DispmanxFrameGrabber : public Grabber
///
/// @return true, on success (i.e. library is present), else false
///
bool isAvailable() override;
bool isAvailable(bool logError = true) override;

///
/// @brief Opens the input device.
Expand Down
7 changes: 7 additions & 0 deletions include/grabber/qt/QtGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class QtGrabber : public Grabber
///
bool setupDisplay();

///
/// @brief Determine if the grabber is available.
///
/// @return true, on success (i.e. Window Manager is not Wayland), else false
///
bool isAvailable(bool logError = true) override;

///
/// @brief Opens the input device.
///
Expand Down
12 changes: 12 additions & 0 deletions include/grabber/qt/QtWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ class QtWrapper: public GrabberWrapper
///
QtWrapper(const QJsonDocument& grabberConfig = QJsonDocument());

///
/// @brief Determine if the grabber is available for usage on the platform
///
/// @return true, on success, else false
///
bool isAvailable() override;

///
/// Starts the grabber, if available
///
bool start() override;

///
/// Starts the grabber which produces led values with the specified update rate
///
Expand Down
8 changes: 7 additions & 1 deletion include/grabber/x11/X11Grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ class X11Grabber : public Grabber , public QAbstractNativeEventFilter

~X11Grabber() override;

bool open();
///
/// @brief Determine if the grabber is available.
///
/// @return true, on success (i.e. Window Manager is not Wayland), else false
///
bool isAvailable(bool logError = true) override;

bool open();
bool setupDisplay();

///
Expand Down
17 changes: 17 additions & 0 deletions include/grabber/x11/X11Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ class X11Wrapper: public GrabberWrapper
///
~X11Wrapper() override;

///
/// @brief Determine if the grabber is available for usage on the platform
///
/// @return true, on success, else false
///
bool isAvailable() override;

///
/// Starts the grabber, if available
///
bool start() override;

///
/// Starts the grabber which produces led values with the specified update rate
///
bool open() override;

public slots:
///
/// Performs a single frame grab and computes the led-colors
Expand Down
7 changes: 7 additions & 0 deletions include/grabber/xcb/XcbGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class XcbGrabber : public Grabber, public QAbstractNativeEventFilter

~XcbGrabber() override;

///
/// @brief Determine if the grabber is available.
///
/// @return true, on success (i.e. Window Manager is not Wayland), else false
///
bool isAvailable(bool logError = true) override;

bool open();
bool setupDisplay();

Expand Down
17 changes: 17 additions & 0 deletions include/grabber/xcb/XcbWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ class XcbWrapper: public GrabberWrapper

~XcbWrapper() override;

///
/// @brief Determine if the grabber is available for usage on the platform
///
/// @return true, on success, else false
///
bool isAvailable() override;

///
/// Starts the grabber, if available
///
bool start() override;

///
/// Starts the grabber which produces led values with the specified update rate
///
bool open() override;

public slots:
void action() override;

Expand Down
2 changes: 1 addition & 1 deletion include/hyperion/Grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Grabber : public QObject
///
/// @return true, on success (i.e. library is present), else false
///
virtual bool isAvailable() { return _isAvailable; }
virtual bool isAvailable(bool logError = true) { return _isAvailable; }

public slots:

Expand Down
3 changes: 0 additions & 3 deletions include/hyperion/GrabberWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ private slots:
/// Will start and stop grabber based on active listeners count
void handleSourceRequest(hyperion::Components component, int hyperionInd, bool listen);

///


protected:

///
Expand Down
3 changes: 1 addition & 2 deletions libsrc/api/JSONRPC_schema/schema-effect.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"minimum": 0,
"maximum": 254
},
"uniqueItems": true,
"minItems": 1
"uniqueItems": true
},
"tan" : {
"type" : "integer"
Expand Down
15 changes: 4 additions & 11 deletions libsrc/api/JSONRPC_schema/schema-serverinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
"minimum": 0,
"maximum": 254
},
"data": {
"type": ["null", "array"],
"properties": {
"subscriptions": {
"type": "array",
"items": {}
}
},
"additionalProperties": false
},
"subscribe" : {
"type" : "array"
"type" : "array",
"items": {
"type" : "string"
}
},
"tan" : {
"type" : "integer"
Expand Down
8 changes: 4 additions & 4 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,13 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const JsonApiC
case SubCommand::Subscribe:
case SubCommand::Unsubscribe:
{
const QJsonObject &params = message["data"].toObject();
const QJsonArray &subscriptions = params["subscriptions"].toArray();
if (subscriptions.isEmpty()) {
QJsonValue const subscriptionsValue = message["subscribe"];
if (subscriptionsValue.isUndefined())
{
sendErrorReply("Invalid params", {"No subscriptions provided"}, cmd);
return;
}

const QJsonArray &subscriptions = subscriptionsValue.toArray();
QStringList invaliCommands;
if (cmd.subCommand == SubCommand::Subscribe)
{
Expand Down
18 changes: 7 additions & 11 deletions libsrc/api/JsonCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ bool JsonCallbacks::subscribe(const QString& cmd)
QStringList JsonCallbacks::subscribe(const QJsonArray& subscriptions)
{
QJsonArray subsArr;
if (subscriptions.contains("all"))
if (subscriptions.isEmpty())
{
for (const auto& entry : getCommands(false))
{
Expand Down Expand Up @@ -229,7 +229,7 @@ bool JsonCallbacks::unsubscribe(const Subscription::Type cmd)

bool JsonCallbacks::unsubscribe(const QString& cmd)
{
JsonApiSubscription subscription = ApiSubscriptionRegister::getSubscriptionInfo(cmd);
JsonApiSubscription const subscription = ApiSubscriptionRegister::getSubscriptionInfo(cmd);
if (subscription.cmd == Subscription::Unknown)
{
return false;
Expand All @@ -240,18 +240,14 @@ bool JsonCallbacks::unsubscribe(const QString& cmd)
QStringList JsonCallbacks::unsubscribe(const QJsonArray& subscriptions)
{
QJsonArray subsArr;
if (subscriptions.contains("all"))
{
for (const auto& entry : getCommands(false))
{
subsArr.append(entry);
}
}
else
if (subscriptions.isEmpty())
{
subsArr = subscriptions;
resetSubscriptions();
return {};
}

subsArr = subscriptions;

QStringList invalidSubscriptions;
for (auto it = subsArr.begin(); it != subsArr.end(); ++it)
{
Expand Down
2 changes: 1 addition & 1 deletion libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DispmanxFrameGrabber::DispmanxFrameGrabber()
_useImageResampler = true;
}

bool DispmanxFrameGrabber::isAvailable()
bool DispmanxFrameGrabber::isAvailable(bool logError)
{
#ifdef BCM_FOUND
void* bcm_host = dlopen(std::string("" BCM_LIBRARY).c_str(), RTLD_LAZY | RTLD_GLOBAL);
Expand Down
36 changes: 18 additions & 18 deletions libsrc/grabber/qt/QtGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ void QtGrabber::freeResources()
// Qt seems to hold the ownership of the QScreen pointers
}

bool QtGrabber::open()
bool QtGrabber::isAvailable(bool logError)
{
bool rc = false;

#ifndef _WIN32
#ifndef _WIN32
if (getenv("WAYLAND_DISPLAY") != nullptr)
{
ErrorIf(logError, _log, "Grabber does not work under Wayland!");
_isWayland = true;
}
else
#endif
{
rc = true;
}
return rc;
#endif

_isAvailable = !_isWayland;
return _isAvailable;
}

bool QtGrabber::open()
{
return _isAvailable;
}

bool QtGrabber::setupDisplay()
{
bool result = false;
if (!open())
if (!_isAvailable)
{
if (_isWayland)
{
Error(_log, "Grabber does not work under Wayland!");
}
return false;
}
else

bool result = false;
if (open())
{
// cleanup last screen
freeResources();
Expand Down Expand Up @@ -385,7 +385,7 @@ QJsonObject QtGrabber::discover(const QJsonObject& params)
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());

QJsonObject inputsDiscovered;
if (open())
if (isAvailable(false) && open())
{
QList<QScreen*> screens = QGuiApplication::screens();
if (!screens.isEmpty())
Expand Down
Loading
Loading