Skip to content

Commit

Permalink
Various Fixes/Updates (hyperion-project#1549)
Browse files Browse the repository at this point in the history
* Update FindWindowsSDK.cmake

* cmake support libcec without version

* Ensure Light-Ids are strings

* Fix type - do not have dbus as requried

* Fixing hyperion-project#1544

* Cleanup

* CleanupFix hyperion-project#1551

* Consistently return instance number with JSON replies (hyperion-project#1504)

* hyperion-remote- Fix extracting reply for configGet request

* Qt 6.6 - Fix iterator finds

* Fix test_image2ledsmap

* Ensure window.currentHyperionInstanceName is set, cleanup system/log clipboard report

* Address protobuf cmake warning

* Update License

* Update ChangeLog

* Address CodeQL and clang findings
  • Loading branch information
Lord-Grey authored and asturel committed Feb 11, 2023
1 parent d77cde4 commit aeb2c52
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 102 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Restart correctly, if running as service (#1368)
- Hue-Wizard: In case auto discovery failed, port 80 was not used as default (#1544)
- Send only one reply per Start Instance request (#1551)
- Add instance# in JSON-API replies (aligning to Add instance in websocket response to a subscription #1504 behaviour)
- hyperion-remote: Extracting reply for a configGet request correctly (#1555)

### Technical
- Add CodeQL for GitHub code scanning
- Update to Protocol Buffers 3.21.12
- cmake support of libcec without version in lib-name
- Qt6 alignments
- Refactor for Python 3.11 deprecated functions

## Removed

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2014-2022 Hyperion Project
Copyright (c) 2014-2023 Hyperion Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 4 additions & 3 deletions assets/webconfig/js/content_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ $(document).ready(function () {
if (getStorage('lastSelectedInstance'))
removeStorage('lastSelectedInstance')

currentHyperionInstance = 0;
currentHyperionInstanceName = getInstanceNameByIndex(0);
window.currentHyperionInstance = 0;
window.currentHyperionInstanceName = getInstanceNameByIndex(0);

requestServerConfig();
setTimeout(requestServerInfo, 100)
setTimeout(requestTokenInfo, 200)
Expand All @@ -293,7 +294,7 @@ $(document).ready(function () {
$('#btn_hypinstanceswitch').toggle(false)

// update listing for button
updateUiOnInstance(currentHyperionInstance);
updateUiOnInstance(window.currentHyperionInstance);
updateHyperionInstanceListing();
});

Expand Down
46 changes: 31 additions & 15 deletions assets/webconfig/js/content_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,45 @@ $(document).ready(function () {
function infoSummary() {
var info = "";

info += 'Hyperion System Summary Report (' + window.serverConfig.general.name + '), Reported instance: ' + window.currentHyperionInstanceName + '\n';
info += 'Hyperion System Summary Report (' + window.serverConfig.general.name + ')\n';
info += 'Reported instance: [' + window.currentHyperionInstance + '] - ' + window.currentHyperionInstanceName + '\n';

info += "\n< ----- System information -------------------- >\n";
info += getSystemInfo() + '\n';

info += "\n< ----- Configured Instances ------------------ >\n";
var instances = window.serverInfo.instance;
for (var i = 0; i < instances.length; i++) {
info += instances[i].instance + ': ' + instances[i].friendly_name + ' Running: ' + instances[i].running + '\n';
info += instances[i].instance + ': ' + instances[i].friendly_name + ', Running: ' + instances[i].running + '\n';
}

info += "\n< ----- This instance's priorities ------------ >\n";
var prios = window.serverInfo.priorities;
for (var i = 0; i < prios.length; i++) {
info += prios[i].priority + ': ';
if (prios[i].visible) {
info += ' VISIBLE!';
}
else {
info += ' ';

if (prios.length > 0) {

for (var i = 0; i < prios.length; i++) {

var prio = prios[i].priority.toString().padStart(3, '0');

info += prio + ': ';
if (prios[i].visible) {
info += ' VISIBLE -';
}
else {
info += ' INVISIBLE -';
}
info += ' (' + prios[i].componentId + ')';
if (prios[i].owner) {
info += ' (Owner: ' + prios[i].owner + ')';
}
info += '\n';

}
info += ' (' + prios[i].componentId + ') Owner: ' + prios[i].owner + '\n';
} else {
info += 'The current priority list is empty!\n';
}
info += 'priorities_autoselect: ' + window.serverInfo.priorities_autoselect + '\n';
info += 'Autoselect: ' + window.serverInfo.priorities_autoselect + '\n';

info += "\n< ----- This instance components' status ------->\n";
var comps = window.serverInfo.components;
Expand All @@ -67,7 +82,7 @@ $(document).ready(function () {
}

info += "\n< ----- This instance's configuration --------- >\n";
info += JSON.stringify(window.serverConfig) + '\n';
info += JSON.stringify(window.serverConfig, null, 2) + '\n';

info += "\n< ----- Current Log --------------------------- >\n";
var logMsgs = document.getElementById("logmessages").textContent;
Expand Down Expand Up @@ -193,18 +208,19 @@ $(document).ready(function () {
});

// toggle fullscreen button in log output
$(".fullscreen-btn").mousedown(function(e) {
$(".fullscreen-btn").mousedown(function (e) {
e.preventDefault();
});

$(".fullscreen-btn").click(function(e) {
$(".fullscreen-btn").click(function (e) {
e.preventDefault();
$(this).children('i')
.toggleClass('fa-expand')
.toggleClass('fa-compress');
$('#conf_cont').toggle();
$('#logmessages').css('max-height', $('#logmessages').css('max-height') !== 'none' ? 'none' : '400px' );
$('#logmessages').css('max-height', $('#logmessages').css('max-height') !== 'none' ? 'none' : '400px');
});

removeOverlay();
});

4 changes: 4 additions & 0 deletions assets/webconfig/js/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function initLanguageSelection() {
}

function updateUiOnInstance(inst) {

window.currentHyperionInstance = inst;
window.currentHyperionInstanceName = getInstanceNameByIndex(inst);

$("#active_instance_friendly_name").text(getInstanceNameByIndex(inst));
if (window.serverInfo.instance.filter(entry => entry.running).length > 1) {
$('#btn_hypinstanceswitch').toggle(true);
Expand Down
22 changes: 17 additions & 5 deletions assets/webconfig/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,17 @@ function checkUserResult(reply, usr) {

function useGroupId(id) {
$('#groupId').val(id);
groupLights = hueGroups[id].lights;

//Ensure ligthIDs are strings
groupLights = hueGroups[id].lights.map(num => {
return String(num);
});

groupLightsLocations = hueGroups[id].locations;
get_hue_lights();
}


async function discover_hue_bridges() {
$('#wiz_hue_ipstate').html($.i18n('edt_dev_spec_devices_discovery_inprogress'));
$('#wiz_hue_discovered').html("")
Expand Down Expand Up @@ -1016,11 +1022,11 @@ function beginWizardHue() {
$('#host').val(host);

var port = eV("port");
if (port > 0) {
$('#port').val(port);
if (port == 0) {
$('#port').val(80);
}
else {
$('#port').val('');
$('#port').val(port);
}
hueIPs.unshift({ host: host, port: port });

Expand All @@ -1037,7 +1043,13 @@ function beginWizardHue() {

hueIPs = [];
hueIPsinc = 0;
hueIPs.push({ host: $('#host').val(), port: $('#port').val() });

var port = $('#port').val();
if (isNaN(port) || port < 1 || port > 65535) {
port = 80;
$('#port').val(80);
}
hueIPs.push({ host: $('#host').val(), port: port });
}
else {
discover_hue_bridges();
Expand Down
8 changes: 6 additions & 2 deletions cmake/FindWindowsSDK.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# - Find the Windows SDK aka Platform SDK
# - Find the Windows SDK aka Platform SDK (from https://github.com/rpavlik/cmake-modules)
#
# Relevant Wikipedia article: http://en.wikipedia.org/wiki/Microsoft_Windows_SDK
#
Expand Down Expand Up @@ -49,10 +49,11 @@
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2012.
# Copyright 2012, Iowa State University
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# SPDX-License-Identifier: BSL-1.0

set(_preferred_sdk_dirs) # pre-output
set(_win_sdk_dirs) # pre-output
Expand All @@ -76,6 +77,9 @@ endmacro()
# although version numbers listed on that page don't necessarily match the directory
# used by the installer.
set(_winsdk_win10vers
10.0.22000.0
10.0.20348.0
10.0.19041.0
10.0.18362.0 # Win10 1903 "19H1"
10.0.17763.0 # Win10 1809 "October 2018 Update"
10.0.17134.0 # Redstone 4 aka Win10 1803 "April 2018 Update"
Expand Down
2 changes: 1 addition & 1 deletion cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ endif()
# .deb files for apt
# https://cmake.org/cmake/help/latest/cpack_gen/deb.html
SET ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/package-scripts/preinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/package-scripts/prerm" )
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4" )
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "libcec6 | libcec4 | libcec (>= 4.0)" )
SET ( CPACK_DEBIAN_PACKAGE_SECTION "Miscellaneous" )

# .rpm for rpm
Expand Down
2 changes: 1 addition & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ if(ENABLE_PROTOBUF_SERVER)
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Build protobuf static")
endif()

add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/cmake")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf")

# define the include for the protobuf library
set(PROTOBUF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
Expand Down
19 changes: 1 addition & 18 deletions include/mdns/MdnsBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

// Utility includes
#include <utils/Logger.h>
#include <utils/WeakConnect.h>

namespace {
constexpr std::chrono::milliseconds DEFAULT_DISCOVER_TIMEOUT{ 500 };
Expand Down Expand Up @@ -103,24 +104,6 @@ private slots:
void onServiceRemoved(const QMdnsEngine::Service& service);

private:

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

/// The logger instance for mDNS-Service
Logger* _log;

Expand Down
2 changes: 1 addition & 1 deletion include/utils/NetUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace NetUtils {
{
if ((port <= 0 || port > MAX_PORT) && port != -1)
{
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [0 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
Error(log, "Invalid port [%d] for host: (%s)! - Port must be in range [1 - %d]", port, QSTRING_CSTR(host), MAX_PORT);
return false;
}
return true;
Expand Down
63 changes: 63 additions & 0 deletions include/utils/WeakConnect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef WEAKCONNECT_H
#define WEAKCONNECT_H

#include <type_traits>

// Qt includes
#include <QObject>

template <typename Func1, typename Func2, typename std::enable_if_t<std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, receiver, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
Func2 slot)
{
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

template <typename Func1, typename Func2, typename std::enable_if_t<!std::is_member_pointer<Func2>::value, int> = 0>
static inline QMetaObject::Connection weakConnect(typename QtPrivate::FunctionPointer<Func1>::Object* sender,
Func1 signal,
typename QtPrivate::FunctionPointer<Func2>::Object* receiver,
Func2 slot)
{
Q_UNUSED(receiver);
QMetaObject::Connection conn_normal = QObject::connect(sender, signal, slot);

QMetaObject::Connection* conn_delete = new QMetaObject::Connection();

*conn_delete = QObject::connect(sender, signal, [conn_normal, conn_delete]() {
QObject::disconnect(conn_normal);
QObject::disconnect(*conn_delete);
delete conn_delete;
});
return conn_normal;
}

#endif // WEAKCONNECT_H
Loading

0 comments on commit aeb2c52

Please sign in to comment.