Skip to content

Commit fac9d28

Browse files
committed
Merge branch 'Refactor' of https://github.com/Lord-Grey/hyperion.ng into Refactor
2 parents 6a9ff04 + 6dd1d47 commit fac9d28

File tree

10 files changed

+47
-195
lines changed

10 files changed

+47
-195
lines changed

.github/workflows/qt5_6.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,18 @@ jobs:
153153
cmake --preset macos-${{ env.BUILD_TYPE }} ${{ steps.dependencies.outputs.cmakeArgs }}
154154
cmake --build --preset macos-${{ env.BUILD_TYPE }}
155155
# CPack workaround for macOS 13
156-
echo killing...; sudo pkill -9 XProtect >/dev/null || true;
157-
echo waiting...; while pgrep XProtect; do sleep 3; done;
158-
cd build; cpack
156+
attempt=0
157+
max_attempts=5
158+
while [ $attempt -lt $max_attempts ]; do
159+
if cd build && cpack; then
160+
echo "Package created successfully"
161+
break
162+
else
163+
echo "Failed to create package, retrying..."
164+
sleep 10
165+
fi
166+
attempt=$((attempt + 1))
167+
done
159168
env:
160169
BUILD_TYPE: ${{ inputs.event_name == 'pull_request' && 'debug' || 'release' }}
161170
HINT: ${{ steps.dependencies.outputs.cmakeArgs != '' && '(with pre-built dependencies)' || '(full build)' }}

assets/webconfig/js/content_network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ $(document).ready(function () {
266266
$("#conf_cont_tok").insertAfter("#conf_cont_network");
267267

268268
// Initial state check based on server config
269-
checkApiTokenState(window.serverConfig.network.internetAccessAPI || window.serverConfig.network.localApiAuth);
269+
checkApiTokenState(window.serverConfig.network.internetAccessAPI || window.serverConfig.network.localApiAuth || storedAccess === 'expert');
270270

271271
// Listen for changes on the Internet access API Auth toggle
272272
$('#root_network_internetAccessAPI').on("change", function () {

bin/compile.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

bin/copy_binaries_to_deploy.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

bin/create_all_releases.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

bin/create_release.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

include/forwarder/MessageForwarder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private slots:
142142
/// Flatbuffer connection for forwarding
143143
QList<TargetHost> _flatbufferTargets;
144144

145-
MessageForwarderFlatbufferClientsHelper* _messageForwarderFlatBufHelper;
145+
QSharedPointer<MessageForwarderFlatbufferClientsHelper> _messageForwarderFlatBufHelper;
146146

147147
QSharedPointer<MdnsBrowser> _mdnsBrowser = MdnsBrowser::getInstance();
148148
};

libsrc/api/JsonAPI.cpp

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ void JsonAPI::handleInstanceCommand(const JsonApiCommand& cmd, const QJsonObject
259259
{
260260
QJsonArray instances;
261261
const QJsonValue instanceElement = message.value("instance");
262+
263+
// Extract instance(s) from the message
262264
if (!(instanceElement.isUndefined() && instanceElement.isNull()))
263265
{
264266
if (instanceElement.isDouble())
@@ -270,79 +272,65 @@ void JsonAPI::handleInstanceCommand(const JsonApiCommand& cmd, const QJsonObject
270272
}
271273
}
272274

273-
InstanceCmd::MustRun isRunningInstanceRequired = cmd.getInstanceMustRun();
275+
InstanceCmd::MustRun const isRunningInstanceRequired = cmd.getInstanceMustRun();
274276
QSet const runningInstanceIds = _instanceManager->getRunningInstanceIdx();
275-
276277
QSet<quint8> instanceIds;
277278
QStringList errorDetails;
279+
280+
// Determine instance IDs, if not provided or "all" is given
278281
if (instanceElement.isUndefined() || instanceElement.isNull() || instances.contains("all"))
279282
{
280-
if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes)
281-
{
282-
instanceIds = runningInstanceIds;
283-
}
284-
else
285-
{
286-
instanceIds = _instanceManager->getInstanceIds();
287-
}
283+
instanceIds = (isRunningInstanceRequired == InstanceCmd::MustRun_Yes) ? runningInstanceIds : _instanceManager->getInstanceIds();
288284
}
289285
else
290286
{
291-
for (const auto &instance : std::as_const(instances)) {
287+
//Resolve instances provided and test, if they need to be running
288+
for (const auto &instance : std::as_const(instances))
289+
{
290+
if (!instance.isDouble())
291+
{
292+
errorDetails.append("Not a valid instance: " + instance.toVariant().toString());
293+
continue;
294+
}
292295

293296
quint8 const instanceId = static_cast<quint8>(instance.toInt());
294-
if (instance.isDouble())
297+
298+
if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes && !runningInstanceIds.contains(instanceId))
295299
{
296-
if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes)
297-
{
298-
if (runningInstanceIds.contains(instanceId))
299-
{
300-
instanceIds.insert(instanceId);
301-
}
302-
else
303-
{
304-
errorDetails.append(QString("Instance [%1] is not running, but the (sub-) command requires a running instance.").arg(instance.toVariant().toString()));
305-
}
306-
}
307-
else
308-
{
309-
instanceIds.insert(instanceId);
310-
}
300+
errorDetails.append(QString("Instance [%1] is not running, but the (sub-) command requires a running instance.").arg(instance.toVariant().toString()));
311301
}
312302
else
313303
{
314-
errorDetails.append("Not a valid instance: " + instance.toVariant().toString());
304+
instanceIds.insert(instanceId);
315305
}
316306
}
317307
}
318308

319-
if (instanceIds.isEmpty() && errorDetails.isEmpty() )
309+
// Handle cases where no valid instances are found
310+
if (instanceIds.isEmpty())
320311
{
321-
if (cmd.getInstanceCmdType() == InstanceCmd::No_or_Single || cmd.getInstanceCmdType() == InstanceCmd::No_or_Multi )
312+
if (errorDetails.isEmpty() && (cmd.getInstanceCmdType() == InstanceCmd::No_or_Single || cmd.getInstanceCmdType() == InstanceCmd::No_or_Multi) )
322313
{
323314
handleCommand(cmd, message);
324315
return;
325316
}
326-
else
327-
{
328-
errorDetails.append("No instance(s) provided, but required");
329-
}
317+
errorDetails.append("No instance(s) provided, but required");
330318
}
331319

332-
if (instanceIds.size() > 1)
320+
// Check if multiple instances are allowed
321+
if (instanceIds.size() > 1 && cmd.getInstanceCmdType() != InstanceCmd::Multi)
333322
{
334-
if (cmd.getInstanceCmdType() != InstanceCmd::Multi)
335-
{
336-
errorDetails.append("Command does not support multiple instances");
337-
}
323+
errorDetails.append("Command does not support multiple instances");
338324
}
339325

326+
// If there are errors, send a response and exit
340327
if ( !errorDetails.isEmpty() )
341328
{
342329
sendErrorReply("Errors for instance(s) given", errorDetails, cmd);
343330
return;
344331
}
345332

333+
// Execute the command for each valid instance
346334
for (const auto &instanceId : std::as_const(instanceIds))
347335
{
348336
if (isRunningInstanceRequired == InstanceCmd::MustRun_Yes)

libsrc/forwarder/MessageForwarder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ int MessageForwarder::startFlatbufferTargets(const QJsonObject& config)
519519
{
520520
if (!config["flatbuffer"].isNull())
521521
{
522-
if (_messageForwarderFlatBufHelper == nullptr)
522+
if (_messageForwarderFlatBufHelper.isNull())
523523
{
524-
_messageForwarderFlatBufHelper = new MessageForwarderFlatbufferClientsHelper();
524+
_messageForwarderFlatBufHelper = QSharedPointer<MessageForwarderFlatbufferClientsHelper>::create();
525525
}
526526
else
527527
{
@@ -598,13 +598,13 @@ void MessageForwarder::forwardJsonMessage(const QJsonObject& message, quint8 ins
598598

599599
void MessageForwarder::forwardFlatbufferMessage(const QString& /*name*/, const Image<ColorRgb>& image)
600600
{
601-
if (_messageForwarderFlatBufHelper != nullptr)
601+
if (_messageForwarderFlatBufHelper)
602602
{
603603
bool const isfree = _messageForwarderFlatBufHelper->isFree();
604604

605605
if (isfree && _isActive)
606606
{
607-
QMetaObject::invokeMethod(_messageForwarderFlatBufHelper, "forwardImage", Qt::QueuedConnection, Q_ARG(Image<ColorRgb>, image));
607+
QMetaObject::invokeMethod(_messageForwarderFlatBufHelper.get(), "forwardImage", Qt::QueuedConnection, Q_ARG(Image<ColorRgb>, image));
608608
}
609609
}
610610
}

src/hyperion-remote/JsonConnection.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ void JsonConnection::setImage(const QImage& image, int priority, int duration, c
112112
// ensure the image has RGB888 format
113113
QImage imageARGB32 = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
114114
QByteArray binaryImage;
115-
binaryImage.reserve(imageARGB32.width() * imageARGB32.height() * 3);
115+
binaryImage.reserve(static_cast<qsizetype>(imageARGB32.width()) *
116+
static_cast<qsizetype>(imageARGB32.height()) * 3);
116117
for (int i = 0; i < imageARGB32.height(); ++i)
117118
{
118119
const QRgb * scanline = reinterpret_cast<const QRgb *>(imageARGB32.scanLine(i));

0 commit comments

Comments
 (0)