Qt6 support (#1363)

* Initial Qt6 config

* Change Package order to reingfence missing packages

* Update to QT 6.2.0

* Qt 6.2.0 updates

* macOS fix

* Simplify handling QT5 & Qt6 in parallel

* Updates for Windows

* Fix macos build

* macOS linker fix

* General support of QTDIR, update docu

* MaxOS add default qt directories

* Fix merge typo

* Update default CMakeSettings.json with installation path options

* Add additional libs required by Qt6 to CompileHowTo

* Fix Qt5 items

Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2021-11-16 17:12:56 +00:00
committed by GitHub
parent 3b1ca20b10
commit 25d79a9f3f
76 changed files with 645 additions and 541 deletions

View File

@@ -29,7 +29,7 @@ endif(ENABLE_DX)
target_link_libraries(hyperion-api
hyperion
hyperion-utils
Qt5::Core
Qt5::Gui
Qt5::Network
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Network
)

View File

@@ -181,7 +181,7 @@ void JsonCB::doCallback(const QString& cmd, const QVariant& data)
QJsonObject obj;
obj["command"] = cmd;
if(data.userType() == QMetaType::QJsonArray)
if (data.userType() == QMetaType::QJsonArray)
obj["data"] = data.toJsonArray();
else
obj["data"] = data.toJsonObject();

View File

@@ -128,8 +128,8 @@ void BoblightClientConnection::socketClosed()
void BoblightClientConnection::handleMessage(const QString& message)
{
//std::cout << "boblight message: " << message.toStdString() << std::endl;
const QVector<QStringRef> messageParts = QStringUtils::splitRef(message, ' ', QStringUtils::SplitBehavior::SkipEmptyParts);
if (messageParts.size() > 0)
QStringList messageParts = QStringUtils::split(message, ' ', QStringUtils::SplitBehavior::SkipEmptyParts);
if (!messageParts.isEmpty())
{
if (messageParts[0] == "hello")
{
@@ -259,7 +259,7 @@ const float ipows[] = {
1.0f / 10000000.0f,
1.0f / 100000000.0f };
float BoblightClientConnection::parseFloat(const QStringRef& s, bool* ok) const
float BoblightClientConnection::parseFloat(const QString& s, bool *ok) const
{
// We parse radix 10
const char MIN_DIGIT = '0';
@@ -340,7 +340,7 @@ float BoblightClientConnection::parseFloat(const QStringRef& s, bool* ok) const
return f;
}
unsigned BoblightClientConnection::parseUInt(const QStringRef& s, bool* ok) const
unsigned BoblightClientConnection::parseUInt(const QString& s, bool *ok) const
{
// We parse radix 10
const char MIN_DIGIT = '0';
@@ -372,7 +372,7 @@ unsigned BoblightClientConnection::parseUInt(const QStringRef& s, bool* ok) cons
return n;
}
uint8_t BoblightClientConnection::parseByte(const QStringRef& s, bool* ok) const
uint8_t BoblightClientConnection::parseByte(const QString& s, bool *ok) const
{
const int LO = 0;
const int HI = 255;

View File

@@ -81,7 +81,7 @@ private:
/// @param ok whether the result is ok
/// @return the parsed byte value in range 0 to 255, or 0
///
uint8_t parseByte(const QStringRef& s, bool *ok = nullptr) const;
uint8_t parseByte(const QString& s, bool *ok = nullptr) const;
///
/// Parse the given QString as unsigned int value.
@@ -90,7 +90,7 @@ private:
/// @param ok whether the result is ok
/// @return the parsed unsigned int value
///
unsigned parseUInt(const QStringRef& s, bool *ok = nullptr) const;
unsigned parseUInt(const QString& s, bool *ok = nullptr) const;
///
/// Parse the given QString as float value, e.g. the 16-bit (wide char) QString "1" shall represent 1, "0.5" is 0.5 and so on.
@@ -99,7 +99,7 @@ private:
/// @param ok whether the result is ok
/// @return the parsed float value, or 0
///
float parseFloat(const QStringRef& s, bool *ok = nullptr) const;
float parseFloat(const QString& s, bool *ok = nullptr) const;
///
/// Read an incoming boblight message as QString

View File

@@ -10,7 +10,7 @@ add_library(bonjour ${Bonjour_SOURCES} )
target_link_libraries(bonjour
hyperion
hyperion-utils
Qt5::Network
Qt${QT_VERSION_MAJOR}::Network
)
IF (NOT APPLE)

View File

@@ -12,6 +12,6 @@ include_directories(${CEC_INCLUDE_DIRS})
target_link_libraries(cechandler
dl
${CEC_LIBRARIES}
Qt5::Core
Qt${QT_VERSION_MAJOR}::Core
)

View File

@@ -8,5 +8,5 @@ add_library(commandline ${Parser_SOURCES} )
target_link_libraries(commandline
hyperion
Qt5::Gui
Qt${QT_VERSION_MAJOR}::Gui
)

View File

@@ -1,5 +1,3 @@
find_package(Qt5 COMPONENTS Sql REQUIRED)
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/db)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/db)
@@ -13,6 +11,6 @@ add_library(database
target_link_libraries(database
hyperion
hyperion-utils
Qt5::Core
Qt5::Sql
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Sql
)

View File

@@ -139,8 +139,8 @@ bool DBManager::recordExists(const VectorPair& conditions) const
int entry = 0;
while (query.next()) {
entry++;
}
entry++;
}
if(entry)
return true;
@@ -422,7 +422,7 @@ void DBManager::doAddBindValue(QSqlQuery& query, const QVariantList& variants) c
{
for(const auto& variant : variants)
{
QVariant::Type t = variant.type();
auto t = variant.userType();
switch(t)
{
case QVariant::UInt:

View File

@@ -36,8 +36,8 @@ add_library(effectengine
target_link_libraries(effectengine
hyperion
python
Qt5::Core
Qt5::Gui
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
)
if (NOT CMAKE_VERSION VERSION_LESS "3.12")

View File

@@ -10,28 +10,6 @@
#include <QMap>
#include <QByteArray>
// createEffect helper
struct find_schema : std::unary_function<EffectSchema, bool>
{
QString pyFile;
find_schema(QString pyFile) :pyFile(std::move(pyFile)) { }
bool operator()(EffectSchema const& schema) const
{
return schema.pyFile == pyFile;
}
};
// deleteEffect helper
struct find_effect : std::unary_function<EffectDefinition, bool>
{
QString effectName;
find_effect(QString effectName) :effectName(std::move(effectName)) { }
bool operator()(EffectDefinition const& effectDefinition) const
{
return effectDefinition.name == effectName;
}
};
EffectFileHandler* EffectFileHandler::efhInstance;
EffectFileHandler::EffectFileHandler(const QString& rootPath, const QJsonDocument& effectConfig, QObject* parent)
@@ -61,7 +39,9 @@ QString EffectFileHandler::deleteEffect(const QString& effectName)
{
QString resultMsg;
std::list<EffectDefinition> effectsDefinition = getEffects();
std::list<EffectDefinition>::iterator it = std::find_if(effectsDefinition.begin(), effectsDefinition.end(), find_effect(effectName));
std::list<EffectDefinition>::iterator it = std::find_if(effectsDefinition.begin(), effectsDefinition.end(),
[&effectName](const EffectDefinition& effectDefinition) {return effectDefinition.name == effectName; }
);
if (it != effectsDefinition.end())
{
@@ -117,7 +97,9 @@ QString EffectFileHandler::saveEffect(const QJsonObject& message)
QString scriptName = message["script"].toString();
std::list<EffectSchema> effectsSchemas = getEffectSchemas();
std::list<EffectSchema>::iterator it = std::find_if(effectsSchemas.begin(), effectsSchemas.end(), find_schema(scriptName));
std::list<EffectSchema>::iterator it = std::find_if(effectsSchemas.begin(), effectsSchemas.end(),
[&scriptName](const EffectSchema& schema) {return schema.pyFile == scriptName; }
);
if (it != effectsSchemas.end())
{
@@ -132,17 +114,20 @@ QString EffectFileHandler::saveEffect(const QJsonObject& message)
if (!effectArray.empty())
{
if (message["name"].toString().trimmed().isEmpty() || message["name"].toString().trimmed().startsWith(":"))
QString effectName = message["name"].toString();
if (effectName.trimmed().isEmpty() || effectName.trimmed().startsWith(":"))
{
return "Can't save new effect. Effect name is empty or begins with a dot.";
}
effectJson["name"] = message["name"].toString();
effectJson["name"] = effectName;
effectJson["script"] = message["script"].toString();
effectJson["args"] = message["args"].toObject();
std::list<EffectDefinition> availableEffects = getEffects();
std::list<EffectDefinition>::iterator iter = std::find_if(availableEffects.begin(), availableEffects.end(), find_effect(message["name"].toString()));
std::list<EffectDefinition>::iterator iter = std::find_if(availableEffects.begin(), availableEffects.end(),
[&effectName](const EffectDefinition& effectDefinition) {return effectDefinition.name == effectName; }
);
QFileInfo newFileName;
if (iter != availableEffects.end())
@@ -150,12 +135,12 @@ QString EffectFileHandler::saveEffect(const QJsonObject& message)
newFileName.setFile(iter->file);
if (newFileName.absoluteFilePath().startsWith(':'))
{
return "The effect name '" + message["name"].toString() + "' is assigned to an internal effect. Please rename your effect.";
return "The effect name '" + effectName + "' is assigned to an internal effect. Please rename your effect.";
}
}
else
{
QString f = effectArray[0].toString().replace("$ROOT", _rootPath) + '/' + message["name"].toString().replace(QString(" "), QString("")) + QString(".json");
QString f = effectArray[0].toString().replace("$ROOT", _rootPath) + '/' + effectName.replace(QString(" "), QString("")) + QString(".json");
newFileName.setFile(f);
}

View File

@@ -36,6 +36,6 @@ add_library(flatbufserver
target_link_libraries(flatbufserver
hyperion-utils
flatbuffers
Qt5::Network
Qt5::Core
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Core
)

View File

@@ -236,7 +236,7 @@ QJsonObject AmlogicGrabber::discover(const QJsonObject& params)
QSize screenSize = _fbGrabber.getScreenSize();
if ( !screenSize.isEmpty() )
{
int fbIdx = _fbGrabber.getPath().rightRef(1).toInt();
int fbIdx = _fbGrabber.getPath().right(1).toInt();
DebugIf(verbose, _log, "FB device [%s] found with resolution: %dx%d", QSTRING_CSTR(_fbGrabber.getPath()), screenSize.width(), screenSize.height());
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30};

View File

@@ -6,7 +6,7 @@
// Constants
namespace {
const bool verbose = true;
const bool verbose = false;
} //End of constants
DirectXGrabber::DirectXGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom)

View File

@@ -208,7 +208,7 @@ QJsonObject FramebufferFrameGrabber::discover(const QJsonObject& params)
QFileInfoList::const_iterator deviceFileIterator;
for (deviceFileIterator = deviceFiles.constBegin(); deviceFileIterator != deviceFiles.constEnd(); ++deviceFileIterator)
{
fbIdx = (*deviceFileIterator).fileName().rightRef(1).toInt();
fbIdx = (*deviceFileIterator).fileName().right(1).toInt();
QString device = (*deviceFileIterator).absoluteFilePath();
DebugIf(verbose, _log, "FB device [%s] found", QSTRING_CSTR(device));

View File

@@ -2,9 +2,6 @@
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/qt)
find_package(Qt5Widgets REQUIRED)
include_directories( ${X11_INCLUDES} )
FILE ( GLOB QT_GRAB_SOURCES "${CURRENT_HEADER_DIR}/Qt*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
@@ -12,5 +9,5 @@ add_library(qt-grabber ${QT_GRAB_SOURCES} )
target_link_libraries(qt-grabber
hyperion
Qt5::Widgets
${QT_LIBRARIES}
)

View File

@@ -5,7 +5,6 @@
#include <QPixmap>
#include <QWindow>
#include <QGuiApplication>
#include <QWidget>
#include <QScreen>
#include <QJsonObject>
#include <QJsonArray>

View File

@@ -172,7 +172,6 @@ bool MFGrabber::init()
}
}
return _initialized;
}
@@ -194,6 +193,7 @@ HRESULT MFGrabber::init_device(QString deviceName, DeviceProperties props)
IMFAttributes* deviceAttributes = nullptr, *sourceReaderAttributes = nullptr;
IMFMediaType* type = nullptr;
HRESULT hr = S_OK;
IAMVideoProcAmp* pProcAmp = nullptr;
Debug(_log, "Init %s, %d x %d @ %d fps (%s)", QSTRING_CSTR(deviceName), props.width, props.height, props.fps, QSTRING_CSTR(pixelFormatToString(pixelformat)));
DebugIf (verbose, _log, "Symbolic link: %s", QSTRING_CSTR(props.symlink));
@@ -233,7 +233,6 @@ HRESULT MFGrabber::init_device(QString deviceName, DeviceProperties props)
else
Debug(_log, "Device opened");
IAMVideoProcAmp *pProcAmp = nullptr;
if (SUCCEEDED(device->QueryInterface(IID_PPV_ARGS(&pProcAmp))))
{
for (auto control : _deviceControls[deviceName])
@@ -402,7 +401,7 @@ void MFGrabber::enumVideoCaptureDevices()
if (SUCCEEDED(devices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &symlink, &length)))
{
QList<DeviceProperties> devicePropertyList;
QString dev = QString::fromUtf16((const ushort*)name);
QString dev = QString::fromUtf16((const char16_t*)name);
IMFMediaSource *pSource = nullptr;
if (SUCCEEDED(devices[i]->ActivateObject(IID_PPV_ARGS(&pSource))))
@@ -429,7 +428,7 @@ void MFGrabber::enumVideoCaptureDevices()
if (pixelformat != PixelFormat::NO_CHANGE)
{
DeviceProperties properties;
properties.symlink = QString::fromUtf16((const ushort*)symlink);
properties.symlink = QString::fromUtf16((const char16_t*)symlink);
properties.width = width;
properties.height = height;
properties.fps = numerator / denominator;
@@ -462,7 +461,7 @@ void MFGrabber::enumVideoCaptureDevices()
control.minValue = minVal;
control.maxValue = maxVal;
control.step = stepVal;
control.default = defaultVal;
control.def = defaultVal;
long currentVal;
if (SUCCEEDED(videoProcAmp->Get(it.key(), &currentVal, &flag)))
@@ -515,7 +514,9 @@ void MFGrabber::start_capturing()
{
HRESULT hr = _sourceReader->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, NULL, NULL, NULL);
if (!SUCCEEDED(hr))
{
Error(_log, "ReadSample (%i)", hr);
}
}
}
@@ -784,7 +785,7 @@ QJsonArray MFGrabber::discover(const QJsonObject& params)
property["step"] = control.step;
property["current"] = control.currentValue;
controls[control.property] = property;
controls_default[control.property] = control.default;
controls_default[control.property] = control.def;
}
device["properties"] = controls;

View File

@@ -124,12 +124,15 @@ public:
// Variables declaration
IMFMediaBuffer* buffer = nullptr;
BYTE* data = nullptr;
DWORD maxLength = 0, currentLength = 0;
if (FAILED(hrStatus))
{
_hrStatus = hrStatus;
_com_error error(_hrStatus);
Error(_grabber->_log, "%s", error.ErrorMessage());
Error(_grabber->_log, "0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -145,18 +148,15 @@ public:
_hrStatus = pSample->ConvertToContiguousBuffer(&buffer);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Buffer conversion failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Buffer conversion failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
BYTE* data = nullptr;
DWORD maxLength = 0, currentLength = 0;
_hrStatus = buffer->Lock(&data, &maxLength, &currentLength);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Access to the buffer memory failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Access to the buffer memory failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -165,8 +165,7 @@ public:
_hrStatus = buffer->Unlock();
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Unlocking the buffer memory failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Unlocking the buffer memory failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
}
done:
@@ -183,7 +182,7 @@ public:
return _hrStatus;
}
HRESULT SourceReaderCB::InitializeVideoEncoder(IMFMediaType* type, PixelFormat format)
HRESULT InitializeVideoEncoder(IMFMediaType* type, PixelFormat format)
{
_pixelformat = format;
if (format == PixelFormat::MJPEG || format == PixelFormat::BGR24 || format == PixelFormat::NO_CHANGE)
@@ -198,8 +197,7 @@ public:
_hrStatus = CoCreateInstance(CLSID_CColorConvertDMO, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (void**)&_transform);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Creation of the Color Converter failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Creation of the Color Converter failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -207,8 +205,7 @@ public:
_hrStatus = _transform->SetInputType(0, type, 0);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Setting the input media type failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Setting the input media type failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -216,8 +213,7 @@ public:
_hrStatus = MFCreateMediaType(&output);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Creating a new media type failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Creating a new media type failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -225,8 +221,7 @@ public:
_hrStatus = type->CopyAllItems(output);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Copying of all attributes from input to output media type failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Copying of all attributes from input to output media type failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -253,8 +248,7 @@ public:
_hrStatus = _transform->SetOutputType(0, output, 0);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Setting the output media type failed => %s", error.ErrorMessage());
Error(_grabber->_log, "Setting the output media type failed => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -262,8 +256,7 @@ public:
_hrStatus = _transform->GetInputStatus(0, &mftStatus);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to query the input stream for more data => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to query the input stream for more data => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -283,7 +276,7 @@ public:
return _hrStatus;
}
BOOL SourceReaderCB::isBusy()
BOOL isBusy()
{
EnterCriticalSection(&_critsec);
BOOL result = _isBusy;
@@ -310,18 +303,18 @@ private:
DeleteCriticalSection(&_critsec);
}
IMFSample* SourceReaderCB::TransformSample(IMFTransform* transform, IMFSample* in_sample)
IMFSample* TransformSample(IMFTransform* transform, IMFSample* in_sample)
{
IMFSample* result = nullptr;
IMFMediaBuffer* out_buffer = nullptr;
MFT_OUTPUT_DATA_BUFFER outputDataBuffer = { 0 };
DWORD status = 0;
// Process the input sample
_hrStatus = transform->ProcessInput(0, in_sample, 0);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to process the input sample => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to process the input sample => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -330,8 +323,7 @@ private:
_hrStatus = transform->GetOutputStreamInfo(0, &streamInfo);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to retrieve buffer requirement for output current => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to retrieve buffer requirement for output current => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -339,8 +331,7 @@ private:
_hrStatus = MFCreateMemoryBuffer(streamInfo.cbSize, &out_buffer);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to create an output media buffer => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to create an output media buffer => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -348,8 +339,7 @@ private:
_hrStatus = MFCreateSample(&result);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to create an empty media sample => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to create an empty media sampl => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -357,8 +347,7 @@ private:
_hrStatus = result->AddBuffer(out_buffer);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to add the output media buffer to the media sample => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to add the output media buffer to the media sample => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
goto done;
}
@@ -369,14 +358,11 @@ private:
outputDataBuffer.pEvents = nullptr;
outputDataBuffer.pSample = result;
DWORD status = 0;
// Generate the output sample
_hrStatus = transform->ProcessOutput(0, 1, &outputDataBuffer, &status);
if (FAILED(_hrStatus))
{
_com_error error(_hrStatus);
Error(_grabber->_log, "Failed to generate the output sample => %s", error.ErrorMessage());
Error(_grabber->_log, "Failed to generate the output sample => 0x%08x: %s", _hrStatus, std::system_category().message(_hrStatus).c_str());
}
else
{

View File

@@ -4,7 +4,6 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/x11)
# Find X11
find_package(X11 REQUIRED)
find_package(Qt5Widgets REQUIRED)
include_directories( ${X11_INCLUDES} )
@@ -21,5 +20,5 @@ target_link_libraries(x11-grabber
${X11_LIBRARIES}
${X11_Xrandr_LIB}
${X11_Xrender_LIB}
Qt5::Widgets
${QT_LIBRARIES}
)

View File

@@ -90,7 +90,7 @@ void X11Grabber::setupResources()
if (_XRenderAvailable)
{
_useImageResampler = false;
_useImageResampler = false;
_imageResampler.setHorizontalPixelDecimation(1);
_imageResampler.setVerticalPixelDecimation(1);
@@ -111,7 +111,7 @@ void X11Grabber::setupResources()
}
else
{
_useImageResampler = true;
_useImageResampler = true;
_imageResampler.setHorizontalPixelDecimation(_pixelDecimation);
_imageResampler.setVerticalPixelDecimation(_pixelDecimation);
}
@@ -378,7 +378,11 @@ void X11Grabber::setCropping(int cropLeft, int cropRight, int cropTop, int cropB
}
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool X11Grabber::nativeEventFilter(const QByteArray & eventType, void * message, qintptr * /*result*/)
#else
bool X11Grabber::nativeEventFilter(const QByteArray & eventType, void * message, long int * /*result*/)
#endif
{
if (!_XRandRAvailable || eventType != "xcb_generic_event_t") {
return false;

View File

@@ -3,11 +3,6 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/xcb)
find_package(XCB COMPONENTS SHM IMAGE RENDER RANDR REQUIRED)
find_package(Qt5Widgets REQUIRED)
if (NOT APPLE)
find_package(Qt5X11Extras REQUIRED)
endif()
include_directories(${XCB_INCLUDE_DIRS})
@@ -17,11 +12,12 @@ add_library(xcb-grabber ${XCB_SOURCES})
target_link_libraries(xcb-grabber
hyperion
Qt5::X11Extras
Qt5::Widgets
${XCB_LIBRARIES}
${QT_LIBRARIES}
)
if (NOT APPLE)
target_link_libraries(xcb-grabber Qt5::X11Extras)
target_link_libraries(
xcb-grabber
)
endif()

View File

@@ -8,10 +8,6 @@
#include <QCoreApplication>
#ifndef __APPLE__
#include <QX11Info>
#endif
#include <memory>
// Constants
@@ -454,7 +450,11 @@ void XcbGrabber::setCropping(int cropLeft, int cropRight, int cropTop, int cropB
updateScreenDimensions(true);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
bool XcbGrabber::nativeEventFilter(const QByteArray & eventType, void * message, qintptr * /*result*/)
#else
bool XcbGrabber::nativeEventFilter(const QByteArray & eventType, void * message, long int * /*result*/)
#endif
{
if (!_XcbRandRAvailable || eventType != "xcb_generic_event_t" || _XcbRandREventBase == -1)
return false;
@@ -477,7 +477,7 @@ xcb_render_pictformat_t XcbGrabber::findFormatForVisual(xcb_visualid_t visual) c
#ifdef __APPLE__
int screen = 0;
#else
int screen = QX11Info::appScreen();
int screen = _screen_num;
#endif
xcb_render_pictscreen_iterator_t sit =
xcb_render_query_pict_formats_screens_iterator(formats.get());

View File

@@ -10,6 +10,6 @@ add_library(jsonserver ${JsonServer_SOURCES} )
target_link_libraries(jsonserver
hyperion-api
hyperion
Qt5::Network
Qt5::Gui
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Gui
)

View File

@@ -3,7 +3,7 @@
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/leddevice)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/leddevice)
find_package(Qt5 COMPONENTS Network SerialPort REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network SerialPort REQUIRED)
include_directories(
dev_hid
@@ -85,8 +85,8 @@ target_link_libraries(leddevice
hyperion
hyperion-utils
${CMAKE_THREAD_LIBS_INIT}
Qt5::Network
Qt5::SerialPort
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::SerialPort
ssdp
)

View File

@@ -16,7 +16,12 @@
#include <QDir>
LedDeviceRegistry LedDeviceWrapper::_ledDeviceMap {};
QMutex LedDeviceWrapper::_ledDeviceMapLock {QMutex::Recursive};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QRecursiveMutex LedDeviceWrapper::_ledDeviceMapLock;
#else
QMutex LedDeviceWrapper::_ledDeviceMapLock{ QMutex::Recursive };
#endif
LedDeviceWrapper::LedDeviceWrapper(Hyperion* hyperion)
: QObject(hyperion)

View File

@@ -325,8 +325,7 @@ QJsonObject LedDeviceAtmoOrb::discover(const QJsonObject& params)
close();
}
QMap<int, QHostAddress>::iterator i;
for (i = _services.begin(); i != _services.end(); ++i)
for (auto i = _services.begin(); i != _services.end(); ++i)
{
QJsonObject obj;

View File

@@ -600,8 +600,7 @@ QJsonArray LedDeviceCololight::discover()
}
QJsonArray deviceList;
QMap<QString, QMap <QString, QString>>::iterator i;
for (i = _services.begin(); i != _services.end(); ++i)
for (auto i = _services.begin(); i != _services.end(); ++i)
{
QJsonObject obj;

View File

@@ -250,12 +250,12 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
QJsonObject jsonLayout = jsonPanelLayout[PANEL_LAYOUT].toObject();
int panelNum = jsonLayout[PANEL_NUM].toInt();
QJsonArray positionData = jsonLayout[PANEL_POSITIONDATA].toArray();
const QJsonArray positionData = jsonLayout[PANEL_POSITIONDATA].toArray();
std::map<int, std::map<int, int>> panelMap;
// Loop over all children.
foreach(const QJsonValue & value, positionData)
for(const QJsonValue & value : positionData)
{
QJsonObject panelObj = value.toObject();

View File

@@ -1020,7 +1020,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig)
if ( deviceConfig[ CONFIG_COLOR_MODEL ].isString() )
{
_outputColorModel = deviceConfig[ CONFIG_COLOR_MODEL ].toString(QString(MODEL_RGB)).toInt();
_outputColorModel = deviceConfig[ CONFIG_COLOR_MODEL ].toString(QString(QChar(MODEL_RGB))).toInt();
}
else
{
@@ -1029,7 +1029,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig)
if ( deviceConfig[ CONFIG_TRANS_EFFECT ].isString() )
{
_transitionEffect = static_cast<YeelightLight::API_EFFECT>( deviceConfig[ CONFIG_TRANS_EFFECT ].toString(QString(YeelightLight::API_EFFECT_SMOOTH)).toInt() );
_transitionEffect = static_cast<YeelightLight::API_EFFECT>( deviceConfig[ CONFIG_TRANS_EFFECT ].toString(QString(QChar(YeelightLight::API_EFFECT_SMOOTH))).toInt() );
}
else
{

View File

@@ -252,7 +252,7 @@ httpResponse ProviderRestApi::getResponse(QNetworkReply* const &reply)
default:
break;
}
errorReason = QString ("[%3 %4] - %5").arg(QString(httpStatusCode) , httpReason, advise);
errorReason = QString ("[%3 %4] - %5").arg(httpStatusCode).arg(httpReason, advise);
}
else {

View File

@@ -286,7 +286,7 @@ QString ProviderRs232::discoverFirst()
// take first available USB serial port - currently no probing!
for (auto & port : QSerialPortInfo::availablePorts())
{
if (!port.isNull() && !port.isBusy())
if (!port.isNull())
{
Info(_log, "found serial device: %s", QSTRING_CSTR(port.portName()));
return port.portName();

View File

@@ -33,12 +33,12 @@ target_link_libraries(protoclient
hyperion
hyperion-utils
protobuf
Qt5::Gui
Qt${QT_VERSION_MAJOR}::Gui
)
target_link_libraries(protoserver
hyperion
hyperion-utils
protoclient
Qt5::Gui
Qt${QT_VERSION_MAJOR}::Gui
)

View File

@@ -9,6 +9,6 @@ add_library(ssdp
)
target_link_libraries(ssdp
Qt5::Network
Qt${QT_VERSION_MAJOR}::Network
webserver
)

View File

@@ -17,10 +17,10 @@ namespace {
// as per upnp spec 1.1, section 1.2.2.
const QString UPNP_DISCOVER_MESSAGE = "M-SEARCH * HTTP/1.1\r\n"
"HOST: %1:%2\r\n"
"MAN: \"ssdp:discover\"\r\n"
"MAN: \"ssdp:discover\"\r\n"
"MX: %3\r\n"
"ST: %4\r\n"
"\r\n";
"\r\n";
} //End of constants
SSDPDiscover::SSDPDiscover(QObject* parent)
@@ -300,7 +300,7 @@ QJsonArray SSDPDiscover::getServicesDiscoveredJson() const
{
QJsonArray result;
QMap<QString, SSDPService>::const_iterator i;
QMultiMap<QString, SSDPService>::const_iterator i;
for (i = _services.begin(); i != _services.end(); ++i)
{
//Debug(_log, "Device discovered at [%s]", QSTRING_CSTR( i.key() ));

View File

@@ -7,7 +7,9 @@
#include <hyperion/AuthManager.h>
#include <QNetworkInterface>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfigurationManager>
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator>
@@ -19,7 +21,9 @@ SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 prot
: SSDPServer(parent)
, _webserver(webserver)
, _localAddress()
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, _NCA(nullptr)
#endif
{
setFlatBufPort(flatBufPort);
setProtoBufPort(protoBufPort);
@@ -45,14 +49,15 @@ void SSDPHandler::initServer()
// prep server
SSDPServer::initServer();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
_NCA = new QNetworkConfigurationManager(this);
connect(_NCA, &QNetworkConfigurationManager::configurationChanged, this, &SSDPHandler::handleNetworkConfigurationChanged);
#endif
// listen for mSearchRequestes
connect(this, &SSDPServer::msearchRequestReceived, this, &SSDPHandler::handleMSearchRequest);
connect(_NCA, &QNetworkConfigurationManager::configurationChanged, this, &SSDPHandler::handleNetworkConfigurationChanged);
// get localAddress from interface
if(!getLocalAddress().isEmpty())
{
@@ -138,6 +143,7 @@ void SSDPHandler::handleWebServerStateChange(bool newState)
}
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration &config)
{
// get localAddress from interface
@@ -154,6 +160,7 @@ void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration
sendAnnounceList(true);
}
}
#endif
QString SSDPHandler::getLocalAddress() const
{

View File

@@ -28,7 +28,7 @@ add_library(hyperion-utils
target_link_libraries(hyperion-utils
hyperion
python
Qt5::Core
Qt5::Gui
Qt5::Network
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Network
)

View File

@@ -10,7 +10,11 @@ inline uint8_t clamp(int x)
void ColorSys::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance)
{
QColor color(red,green,blue);
qreal h,s,l;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
float h, s, l;
#else
qreal h, s, l;
#endif
color.getHslF(&h,&s,&l);
hue = h;
saturation = s;

View File

@@ -17,7 +17,12 @@
#include <QThreadStorage>
#include <time.h>
QMutex Logger::MapLock { QMutex::Recursive };
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QRecursiveMutex Logger::MapLock;
#else
QMutex Logger::MapLock{ QMutex::Recursive };
#endif
QMap<QString,Logger*> Logger::LoggerMap { };
QAtomicInteger<int> Logger::GLOBAL_MIN_LOG_LEVEL { static_cast<int>(Logger::UNSET)};
@@ -39,24 +44,25 @@ QThreadStorage<Logger::T_LOG_MESSAGE> RepeatMessage;
QString getApplicationName()
{
#ifdef __GLIBC__
const char* _appname_char = program_invocation_short_name;
#elif !defined(_WIN32)
const char* _appname_char = getprogname();
#else
char fileName[MAX_PATH];
char *_appname_char;
HINSTANCE hinst = GetModuleHandle(NULL);
if (GetModuleFileNameA(hinst, fileName, sizeof(fileName)))
{
_appname_char = PathFindFileName(fileName);
*(PathFindExtension(fileName)) = 0;
}
else
_appname_char = "unknown";
#endif
return QString(_appname_char).toLower();
//#ifdef __GLIBC__
// const char* _appname_char = program_invocation_short_name;
//#elif !defined(_WIN32)
// const char* _appname_char = getprogname();
//#else
// char fileName[MAX_PATH];
// char *_appname_char;
// HINSTANCE hinst = GetModuleHandle(NULL);
// if (GetModuleFileNameA(hinst, fileName, sizeof(fileName)))
// {
// _appname_char = PathFindFileName(fileName);
// *(PathFindExtension(fileName)) = 0;
// }
// else
// _appname_char = "unknown";
//#endif
// return QString(_appname_char).toLower();
//
return "";
}
} // namespace

View File

@@ -7,7 +7,10 @@
#include <utils/jsonschema/QJsonSchemaChecker.h>
#include <utils/jsonschema/QJsonUtils.h>
QJsonSchemaChecker::QJsonSchemaChecker()
QJsonSchemaChecker::QJsonSchemaChecker() :
_ignoreRequired(false),
_error(false),
_schemaError(false)
{
// empty
}
@@ -17,7 +20,7 @@ QJsonSchemaChecker::~QJsonSchemaChecker()
// empty
}
bool QJsonSchemaChecker::setSchema(const QJsonObject & schema)
bool QJsonSchemaChecker::setSchema(const QJsonObject& schema)
{
_qSchema = schema;
@@ -26,7 +29,17 @@ bool QJsonSchemaChecker::setSchema(const QJsonObject & schema)
return true;
}
QPair<bool, bool> QJsonSchemaChecker::validate(const QJsonObject & value, bool ignoreRequired)
void QJsonSchemaChecker::setMessage(const QString& message)
{
_messages.append(_currentPath.join("") + ": " + message);
}
QStringList QJsonSchemaChecker::getMessages() const
{
return _messages;
}
QPair<bool, bool> QJsonSchemaChecker::validate(const QJsonObject& value, bool ignoreRequired)
{
// initialize state
_ignoreRequired = ignoreRequired;
@@ -51,7 +64,7 @@ QJsonObject QJsonSchemaChecker::getAutoCorrectedConfig(const QJsonObject& value,
_messages.clear();
_autoCorrected = value;
for(const QString &correct : sequence)
for (const QString& correct : sequence)
{
_correct = correct;
_currentPath.clear();
@@ -62,18 +75,18 @@ QJsonObject QJsonSchemaChecker::getAutoCorrectedConfig(const QJsonObject& value,
return _autoCorrected;
}
void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &schema)
void QJsonSchemaChecker::validate(const QJsonValue& value, const QJsonObject& schema)
{
// check the current json value
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
{
QString attribute = i.key();
const QJsonValue & attributeValue = *i;
const QJsonValue& attributeValue = *i;
QJsonObject::const_iterator defaultValue = schema.find("default");
if (attribute == "type")
checkType(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkType(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "properties")
{
if (value.isObject())
@@ -103,7 +116,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
// ignore the properties which are handled by the properties attribute (if present)
QStringList ignoredProperties;
if (schema.contains("properties")) {
const QJsonObject & props = schema["properties"].toObject();
const QJsonObject& props = schema["properties"].toObject();
ignoredProperties = props.keys();
}
@@ -117,13 +130,13 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
}
}
else if (attribute == "minimum")
checkMinimum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMinimum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "maximum")
checkMaximum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMaximum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "minLength")
checkMinLength(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMinLength(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "maxLength")
checkMaxLength(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMaxLength(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "items")
{
if (value.isArray())
@@ -136,21 +149,21 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
}
}
else if (attribute == "minItems")
checkMinItems(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMinItems(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "maxItems")
checkMaxItems(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
checkMaxItems(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "uniqueItems")
checkUniqueItems(value, attributeValue);
else if (attribute == "enum")
checkEnum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue::Null));
else if (attribute == "required")
; // nothing to do. value is present so always oke
else if (attribute == "id")
; // references have already been collected
else if (attribute == "title" || attribute == "description" || attribute == "default" || attribute == "format"
checkEnum(value, attributeValue, (defaultValue != schema.end() ? *defaultValue : QJsonValue(QJsonValue::Null)));
else if (attribute == "required")
; // nothing to do. value is present so always oke
else if (attribute == "id")
; // references have already been collected
else if (attribute == "title" || attribute == "description" || attribute == "default" || attribute == "format"
|| attribute == "defaultProperties" || attribute == "propertyOrder" || attribute == "append" || attribute == "step"
|| attribute == "access" || attribute == "options" || attribute == "script" || attribute == "allowEmptyArray" || attribute == "comment")
; // nothing to do.
; // nothing to do.
else
{
// no check function defined for this attribute
@@ -161,17 +174,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
}
}
void QJsonSchemaChecker::setMessage(const QString & message)
{
_messages.append(_currentPath.join("") +": "+message);
}
QStringList QJsonSchemaChecker::getMessages() const
{
return _messages;
}
void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkType(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
QString type = schema.toString();
@@ -215,13 +218,13 @@ void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue &
}
}
void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonObject & schema)
void QJsonSchemaChecker::checkProperties(const QJsonObject& value, const QJsonObject& schema)
{
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
{
QString property = i.key();
const QJsonValue & propertyValue = *i;
const QJsonValue& propertyValue = *i;
_currentPath.append("." + property);
QJsonObject::const_iterator required = propertyValue.toObject().find("required");
@@ -230,49 +233,71 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO
{
validate(value[property], propertyValue.toObject());
}
else if (verifyDeps(property, value, schema))
{
}
else if (required != propertyValue.toObject().end() && propertyValue.toObject().find("required").value().toBool() && !_ignoreRequired)
{
_error = true;
if (_correct == "create")
{
QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property);
setMessage("Create property: "+property+" with value: "+QJsonUtils::getDefaultValue(propertyValue));
QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property);
setMessage("Create property: " + property + " with value: " + QJsonUtils::getDefaultValue(propertyValue));
}
if (_correct == "")
setMessage("missing member");
}
else if (_correct == "create" && _ignoreRequired)
QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property);
QJsonUtils::modify(_autoCorrected, _currentPath, QJsonUtils::create(propertyValue, _ignoreRequired), property);
_currentPath.removeLast();
}
}
void QJsonSchemaChecker::checkDependencies(const QJsonObject & value, const QJsonObject & schema)
bool QJsonSchemaChecker::verifyDeps(const QString& property, const QJsonObject& value, const QJsonObject& schema)
{
if (schema[property].toObject().contains("options") && (schema[property].toObject())["options"].toObject().contains("dependencies"))
{
const QJsonObject& depends = ((schema[property].toObject())["options"].toObject())["dependencies"].toObject();
if (depends.keys().size() > 0)
{
QString firstName = depends.keys().first();
if (value.contains(firstName))
{
if (value[firstName] != depends[firstName])
return true;
}
}
}
return false;
}
void QJsonSchemaChecker::checkDependencies(const QJsonObject& value, const QJsonObject& schema)
{
for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i)
{
QString property = i.key();
const QJsonValue & propertyValue = *i;
const QJsonValue& propertyValue = *i;
if (propertyValue.toObject().contains("properties"))
{
_currentPath.append("." + property);
const QJsonObject & dependencies = propertyValue.toObject()["properties"].toObject();
const QJsonObject& dependencies = propertyValue.toObject()["properties"].toObject();
bool valid = false;
for (QJsonObject::const_iterator d = dependencies.begin(); d != dependencies.end(); ++d)
{
QString dependency = d.key();
const QJsonValue & dependencyValue = *d;
const QJsonValue& dependencyValue = *d;
if (dependencyValue.toObject()["enum"].isArray())
{
QJsonArray jArray = dependencyValue.toObject()["enum"].toArray();
for(int a = 0; a < jArray.size(); ++a)
for (int a = 0; a < jArray.size(); ++a)
{
if (value[dependency] == jArray[a])
{
@@ -294,7 +319,7 @@ void QJsonSchemaChecker::checkDependencies(const QJsonObject & value, const QJso
if (_correct == "remove")
{
QJsonUtils::modify(_autoCorrected, _currentPath);
setMessage("Removed property: "+property);
setMessage("Removed property: " + property);
}
if (_correct == "")
@@ -306,7 +331,7 @@ void QJsonSchemaChecker::checkDependencies(const QJsonObject & value, const QJso
}
}
void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, const QJsonValue & schema, const QStringList & ignoredProperties)
void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject& value, const QJsonValue& schema, const QStringList& ignoredProperties)
{
for (QJsonObject::const_iterator i = value.begin(); i != value.end(); ++i)
{
@@ -324,7 +349,7 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co
if (_correct == "remove")
{
QJsonUtils::modify(_autoCorrected, _currentPath);
setMessage("Removed property: "+property);
setMessage("Removed property: " + property);
}
if (_correct == "")
@@ -340,7 +365,7 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co
}
}
void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMinimum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isDouble())
{
@@ -357,9 +382,9 @@ void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too small value: "+QString::number(value.toDouble())+" to: "+QString::number(defaultValue.toDouble()));
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too small value: " + QString::number(value.toDouble()) + " to: " + QString::number(defaultValue.toDouble()));
}
if (_correct == "")
@@ -367,7 +392,7 @@ void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue
}
}
void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMaximum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isDouble())
{
@@ -384,9 +409,9 @@ void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too large value: "+QString::number(value.toDouble())+" to: "+QString::number(defaultValue.toDouble()));
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too large value: " + QString::number(value.toDouble()) + " to: " + QString::number(defaultValue.toDouble()));
}
if (_correct == "")
@@ -394,7 +419,7 @@ void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue
}
}
void QJsonSchemaChecker::checkMinLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMinLength(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isString())
{
@@ -411,16 +436,16 @@ void QJsonSchemaChecker::checkMinLength(const QJsonValue & value, const QJsonVal
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too short value: "+value.toString()+" to: "+defaultValue.toString());
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too short value: " + value.toString() + " to: " + defaultValue.toString());
}
if (_correct == "")
setMessage("value is too short (minLength=" + QString::number(schema.toInt()) + ")");
}
}
void QJsonSchemaChecker::checkMaxLength(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMaxLength(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isString())
{
@@ -437,16 +462,16 @@ void QJsonSchemaChecker::checkMaxLength(const QJsonValue & value, const QJsonVal
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too long value: "+value.toString()+" to: "+defaultValue.toString());
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct too long value: " + value.toString() + " to: " + defaultValue.toString());
}
if (_correct == "")
setMessage("value is too long (maxLength=" + QString::number(schema.toInt()) + ")");
}
}
void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject & schema)
void QJsonSchemaChecker::checkItems(const QJsonValue& value, const QJsonObject& schema)
{
if (!value.isArray())
{
@@ -465,7 +490,7 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject
setMessage("Remove empty array");
}
for(int i = 0; i < jArray.size(); ++i)
for (int i = 0; i < jArray.size(); ++i)
{
// validate each item
_currentPath.append("[" + QString::number(i) + "]");
@@ -474,7 +499,7 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject
}
}
void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMinItems(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isArray())
{
@@ -492,9 +517,9 @@ void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValu
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct minItems: "+QString::number(jArray.size())+" to: "+QString::number(defaultValue.toArray().size()));
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct minItems: " + QString::number(jArray.size()) + " to: " + QString::number(defaultValue.toArray().size()));
}
if (_correct == "")
@@ -502,7 +527,7 @@ void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValu
}
}
void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkMaxItems(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (!value.isArray())
{
@@ -520,9 +545,9 @@ void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValu
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct maxItems: "+QString::number(jArray.size())+" to: "+QString::number(defaultValue.toArray().size()));
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema);
setMessage("Correct maxItems: " + QString::number(jArray.size()) + " to: " + QString::number(defaultValue.toArray().size()));
}
if (_correct == "")
@@ -530,7 +555,7 @@ void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValu
}
}
void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonValue & schema)
void QJsonSchemaChecker::checkUniqueItems(const QJsonValue& value, const QJsonValue& schema)
{
if (!value.isArray())
{
@@ -547,9 +572,9 @@ void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonV
bool removeDuplicates = false;
QJsonArray jArray = value.toArray();
for(int i = 0; i < jArray.size(); ++i)
for (int i = 0; i < jArray.size(); ++i)
{
for (int j = i+1; j < jArray.size(); ++j)
for (int j = i + 1; j < jArray.size(); ++j)
{
if (jArray[i] == jArray[j])
{
@@ -567,7 +592,7 @@ void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonV
{
QJsonArray uniqueItemsArray;
for(int i = 0; i < jArray.size(); ++i)
for (int i = 0; i < jArray.size(); ++i)
if (!uniqueItemsArray.contains(jArray[i]))
uniqueItemsArray.append(jArray[i]);
@@ -576,12 +601,12 @@ void QJsonSchemaChecker::checkUniqueItems(const QJsonValue & value, const QJsonV
}
}
void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue)
void QJsonSchemaChecker::checkEnum(const QJsonValue& value, const QJsonValue& schema, const QJsonValue& defaultValue)
{
if (schema.isArray())
{
QJsonArray jArray = schema.toArray();
for(int i = 0; i < jArray.size(); ++i)
for (int i = 0; i < jArray.size(); ++i)
{
if (jArray[i] == value)
{
@@ -597,15 +622,15 @@ void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue &
if (_correct == "modify")
{
(defaultValue != QJsonValue::Null) ?
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema.toArray().first());
setMessage("Correct unknown enum value: "+value.toString()+" to: "+defaultValue.toString());
QJsonUtils::modify(_autoCorrected, _currentPath, defaultValue) :
QJsonUtils::modify(_autoCorrected, _currentPath, schema.toArray().first());
setMessage("Correct unknown enum value: " + value.toString() + " to: " + defaultValue.toString());
}
if (_correct == "")
{
QJsonDocument doc(schema.toArray());
QString strJson(doc.toJson(QJsonDocument::Compact));
setMessage("Unknown enum value (allowed values are: " + strJson+ ")");
setMessage("Unknown enum value (allowed values are: " + strJson + ")");
}
}

View File

@@ -8,8 +8,8 @@ FILE ( GLOB_RECURSE webFiles RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/a
FILE ( RELATIVE_PATH webConfigPath ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/assets/webconfig)
FOREACH( f ${webFiles} )
STRING ( REPLACE "${webConfigPath}/" "" fname ${f})
SET(HYPERION_WEBCONFIG_RES "${HYPERION_WEBCONFIG_RES}\n\t\t<file alias=\"/webconfig/${fname}\">${f}</file>")
STRING ( REPLACE "${webConfigPath}/" "" fname ${f})
SET(HYPERION_WEBCONFIG_RES "${HYPERION_WEBCONFIG_RES}\n\t\t<file alias=\"/webconfig/${fname}\">${f}</file>")
ENDFOREACH()
CONFIGURE_FILE(${CURRENT_SOURCE_DIR}/WebConfig.qrc.in ${CMAKE_BINARY_DIR}/WebConfig.qrc )
SET(WebConfig_RESOURCES ${CMAKE_BINARY_DIR}/WebConfig.qrc)
@@ -23,5 +23,5 @@ target_link_libraries(webserver
hyperion
hyperion-utils
hyperion-api
Qt5::Network
Qt${QT_VERSION_MAJOR}::Network
)

View File

@@ -36,7 +36,7 @@ void QtHttpServerWrapper::incomingConnection (qintptr handle)
QtHttpServer::QtHttpServer (QObject * parent)
: QObject (parent)
, m_useSsl (false)
, m_serverName (QStringLiteral ("The Qt5 HTTP Server"))
, m_serverName (QStringLiteral ("The Qt6 HTTP Server"))
, m_netOrigin (NetOrigin::getInstance())
{
m_sockServer = new QtHttpServerWrapper (this);