Update the entire Qt6 code to new signal slot connections

Update logging cathegories and allign coding style
This commit is contained in:
Simon Stürz 2025-08-12 08:50:44 +02:00
parent 2f0077a5d1
commit 2acf7784a6
39 changed files with 220 additions and 148 deletions

View File

@ -112,15 +112,27 @@ void DebugReportGenerator::generateReport()
QProcess *pingProcess = new QProcess(this); QProcess *pingProcess = new QProcess(this);
pingProcess->setProcessChannelMode(QProcess::MergedChannels); pingProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(pingProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onPingProcessFinished(int,QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(pingProcess, &QProcess::finished, this, &DebugReportGenerator::onPingProcessFinished);
#else
connect(pingProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onPingProcessFinished(int,QProcess::ExitStatus)));
#endif
QProcess *digProcess = new QProcess(this); QProcess *digProcess = new QProcess(this);
digProcess->setProcessChannelMode(QProcess::MergedChannels); digProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(digProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onDigProcessFinished(int,QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(digProcess, &QProcess::finished, this, &DebugReportGenerator::onDigProcessFinished);
#else
connect(digProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onDigProcessFinished(int,QProcess::ExitStatus)));
#endif
QProcess *tracePathProcess = new QProcess(this); QProcess *tracePathProcess = new QProcess(this);
tracePathProcess->setProcessChannelMode(QProcess::MergedChannels); tracePathProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(tracePathProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onTracePathProcessFinished(int,QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(tracePathProcess, &QProcess::finished, this, &DebugReportGenerator::onTracePathProcessFinished);
#else
connect(tracePathProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onTracePathProcessFinished(int,QProcess::ExitStatus)));
#endif
m_runningProcesses.append(pingProcess); m_runningProcesses.append(pingProcess);
m_runningProcesses.append(digProcess); m_runningProcesses.append(digProcess);
@ -151,7 +163,11 @@ void DebugReportGenerator::verifyRunningProcessesFinished()
m_compressProcess = new QProcess(this); m_compressProcess = new QProcess(this);
m_compressProcess->setProcessChannelMode(QProcess::MergedChannels); m_compressProcess->setProcessChannelMode(QProcess::MergedChannels);
m_compressProcess->setWorkingDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); m_compressProcess->setWorkingDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
connect(m_compressProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onCompressProcessFinished(int, QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(m_compressProcess, &QProcess::finished, this, &DebugReportGenerator::onCompressProcessFinished);
#else
connect(m_compressProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onCompressProcessFinished(int,QProcess::ExitStatus)));
#endif
m_compressProcess->start("tar", { "-zcf", m_reportFileName, "-C", QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/", m_reportDirectory.dirName() } ); m_compressProcess->start("tar", { "-zcf", m_reportFileName, "-C", QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/", m_reportDirectory.dirName() } );
qCDebug(dcDebugServer()) << "Execut command" << m_compressProcess->program() << m_compressProcess->arguments(); qCDebug(dcDebugServer()) << "Execut command" << m_compressProcess->program() << m_compressProcess->arguments();
} }

View File

@ -29,13 +29,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "nymeacore.h" #include "nymeacore.h"
#include "servers/httprequest.h"
#include "servers/httpreply.h" #include "servers/httpreply.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#include "loggingcategories.h" #include "loggingcategories.h"
#include "debugserverhandler.h" #include "debugserverhandler.h"
#include "nymeaconfiguration.h" #include "nymeaconfiguration.h"
#include "stdio.h"
#include "version.h" #include "version.h"
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
@ -321,7 +319,12 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
qCDebug(dcDebugServer()) << "Start ping nymea.io process"; qCDebug(dcDebugServer()) << "Start ping nymea.io process";
m_pingProcess = new QProcess(this); m_pingProcess = new QProcess(this);
m_pingProcess->setProcessChannelMode(QProcess::MergedChannels); m_pingProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(m_pingProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onPingProcessFinished(int,QProcess::ExitStatus)));
#if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(m_pingProcess, &QProcess::finished, this, &DebugServerHandler::onPingProcessFinished);
#else
connect(m_pingProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onPingProcessFinished(int,QProcess::ExitStatus)));
#endif
m_pingProcess->start("ping", { "-c", "4", "nymea.io" } ); m_pingProcess->start("ping", { "-c", "4", "nymea.io" } );
m_pingReply = HttpReply::createAsyncReply(); m_pingReply = HttpReply::createAsyncReply();
@ -339,7 +342,11 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
qCDebug(dcDebugServer()) << "Start dig nymea.io process"; qCDebug(dcDebugServer()) << "Start dig nymea.io process";
m_digProcess = new QProcess(this); m_digProcess = new QProcess(this);
m_digProcess->setProcessChannelMode(QProcess::MergedChannels); m_digProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(m_digProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onDigProcessFinished(int,QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(m_digProcess, &QProcess::finished, this, &DebugServerHandler::onDigProcessFinished);
#else
connect(m_digProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onDigProcessFinished(int,QProcess::ExitStatus)));
#endif
m_digProcess->start("dig", { "nymea.io" } ); m_digProcess->start("dig", { "nymea.io" } );
m_digReply = HttpReply::createAsyncReply(); m_digReply = HttpReply::createAsyncReply();
@ -357,7 +364,11 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
qCDebug(dcDebugServer()) << "Start tracepath nymea.io process"; qCDebug(dcDebugServer()) << "Start tracepath nymea.io process";
m_tracePathProcess = new QProcess(this); m_tracePathProcess = new QProcess(this);
m_tracePathProcess->setProcessChannelMode(QProcess::MergedChannels); m_tracePathProcess->setProcessChannelMode(QProcess::MergedChannels);
connect(m_tracePathProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onTracePathProcessFinished(int,QProcess::ExitStatus))); #if QT_VERSION > QT_VERSION_CHECK(6,0,0)
connect(m_tracePathProcess, &QProcess::finished, this, &DebugServerHandler::onTracePathProcessFinished);
#else
connect(m_tracePathProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(onTracePathProcessFinished(int,QProcess::ExitStatus)));
#endif
m_tracePathProcess->start("tracepath", { "nymea.io" } ); m_tracePathProcess->start("tracepath", { "nymea.io" } );
m_tracePathReply = HttpReply::createAsyncReply(); m_tracePathReply = HttpReply::createAsyncReply();
@ -448,7 +459,7 @@ HttpReply *DebugServerHandler::processDebugRequest(const QString &requestPath, c
loggingRules << "*.debug=false"; loggingRules << "*.debug=false";
// Load the rules from nymead.conf file and append them to the rules // Load the rules from nymead.conf file and append them to the rules
foreach (const QString &category, settings.childKeys()) { foreach (const QString &category, settings.childKeys()) {
loggingRules << QString("%1=%2").arg(category).arg(settings.value(category, "false").toString()); loggingRules << QString("%1=%2").arg(category, settings.value(category, "false").toString());
} }
settings.endGroup(); settings.endGroup();
QLoggingCategory::setFilterRules(loggingRules.join('\n')); QLoggingCategory::setFilterRules(loggingRules.join('\n'));
@ -542,19 +553,19 @@ void DebugServerHandler::logMessageHandler(QtMsgType type, const QMessageLogCont
QString finalMessage; QString finalMessage;
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
finalMessage = QString(" I | %1: %2\n").arg(context.category).arg(message); finalMessage = QString(" I | %1: %2\n").arg(context.category, message);
break; break;
case QtInfoMsg: case QtInfoMsg:
finalMessage = QString(" I | %1: %2\n").arg(context.category).arg(message); finalMessage = QString(" I | %1: %2\n").arg(context.category, message);
break; break;
case QtWarningMsg: case QtWarningMsg:
finalMessage = QString(" W | %1: %2\n").arg(context.category).arg(message); finalMessage = QString(" W | %1: %2\n").arg(context.category, message);
break; break;
case QtCriticalMsg: case QtCriticalMsg:
finalMessage = QString(" C | %1: %2\n").arg(context.category).arg(message); finalMessage = QString(" C | %1: %2\n").arg(context.category, message);
break; break;
case QtFatalMsg: case QtFatalMsg:
finalMessage = QString(" F | %1: %2\n").arg(context.category).arg(message); finalMessage = QString(" F | %1: %2\n").arg(context.category, message);
break; break;
} }
@ -646,7 +657,11 @@ void DebugServerHandler::onWebsocketClientConnected()
s_websocketClients.append(client); s_websocketClients.append(client);
qCDebug(dcDebugServer()) << "New websocket client connected:" << client->peerAddress().toString(); qCDebug(dcDebugServer()) << "New websocket client connected:" << client->peerAddress().toString();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(client, &QWebSocket::errorOccurred, this, &DebugServerHandler::onWebsocketClientError);
#else
connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onWebsocketClientError(QAbstractSocket::SocketError))); connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onWebsocketClientError(QAbstractSocket::SocketError)));
#endif
connect(client, &QWebSocket::disconnected, this, &DebugServerHandler::onWebsocketClientDisconnected); connect(client, &QWebSocket::disconnected, this, &DebugServerHandler::onWebsocketClientDisconnected);
} }
@ -678,7 +693,7 @@ void DebugServerHandler::onPingProcessFinished(int exitCode, QProcess::ExitStatu
if (m_pingReply) { if (m_pingReply) {
m_pingReply->setPayload(processOutput); m_pingReply->setPayload(processOutput);
m_pingReply->setHttpStatusCode(HttpReply::Ok); m_pingReply->setHttpStatusCode(HttpReply::Ok);
m_pingReply->finished(); emit m_pingReply->finished();
m_pingReply = nullptr; m_pingReply = nullptr;
} }
@ -695,7 +710,7 @@ void DebugServerHandler::onDigProcessFinished(int exitCode, QProcess::ExitStatus
if (m_digReply) { if (m_digReply) {
m_digReply->setPayload(processOutput); m_digReply->setPayload(processOutput);
m_digReply->setHttpStatusCode(HttpReply::Ok); m_digReply->setHttpStatusCode(HttpReply::Ok);
m_digReply->finished(); emit m_digReply->finished();
m_digReply = nullptr; m_digReply = nullptr;
} }
@ -712,7 +727,7 @@ void DebugServerHandler::onTracePathProcessFinished(int exitCode, QProcess::Exit
if (m_tracePathReply) { if (m_tracePathReply) {
m_tracePathReply->setPayload(processOutput); m_tracePathReply->setPayload(processOutput);
m_tracePathReply->setHttpStatusCode(HttpReply::Ok); m_tracePathReply->setHttpStatusCode(HttpReply::Ok);
m_tracePathReply->finished(); emit m_tracePathReply->finished();
m_tracePathReply = nullptr; m_tracePathReply = nullptr;
} }
@ -982,7 +997,12 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeStartElement("tr"); writer.writeStartElement("tr");
//: The language description in the server infromation section of the debug interface //: The language description in the server infromation section of the debug interface
writer.writeTextElement("th", tr("Language")); writer.writeTextElement("th", tr("Language"));
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
writer.writeTextElement("td", NymeaCore::instance()->configuration()->locale().name() + " (" + NymeaCore::instance()->configuration()->locale().nativeTerritoryName() + " - " + NymeaCore::instance()->configuration()->locale().nativeLanguageName() + ")");
#else
writer.writeTextElement("td", NymeaCore::instance()->configuration()->locale().name() + " (" + NymeaCore::instance()->configuration()->locale().nativeCountryName() + " - " + NymeaCore::instance()->configuration()->locale().nativeLanguageName() + ")"); writer.writeTextElement("td", NymeaCore::instance()->configuration()->locale().name() + " (" + NymeaCore::instance()->configuration()->locale().nativeCountryName() + " - " + NymeaCore::instance()->configuration()->locale().nativeLanguageName() + ")");
#endif
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
writer.writeStartElement("tr"); writer.writeStartElement("tr");
@ -1033,7 +1053,7 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeTextElement("td", qVersion()); writer.writeTextElement("td", qVersion());
writer.writeEndElement(); // tr writer.writeEndElement(); // tr
if (!qgetenv("SNAP").isEmpty()) { if (!qEnvironmentVariableIsEmpty("SNAP")) {
// Note: http://snapcraft.io/docs/reference/env // Note: http://snapcraft.io/docs/reference/env
writer.writeStartElement("tr"); writer.writeStartElement("tr");

View File

@ -48,7 +48,7 @@ BluetoothLowEnergyManagerImplementation::BluetoothLowEnergyManagerImplementation
// ourselves if bluez is registered on D-Bus. // ourselves if bluez is registered on D-Bus.
QDBusReply<QStringList> reply = QDBusConnection::systemBus().interface()->registeredServiceNames(); QDBusReply<QStringList> reply = QDBusConnection::systemBus().interface()->registeredServiceNames();
if (!reply.isValid()) { if (!reply.isValid()) {
qWarning(dcBluetooth()) << "Unable to query D-Bus for bluez:" << reply.error().message(); qCWarning(dcBluetooth()) << "Unable to query D-Bus for bluez:" << reply.error().message();
return; return;
} }
const QStringList services = reply.value(); const QStringList services = reply.value();
@ -112,7 +112,6 @@ BluetoothDiscoveryReply *BluetoothLowEnergyManagerImplementation::discoverDevice
qCDebug(dcBluetooth()) << "Discovery finished"; qCDebug(dcBluetooth()) << "Discovery finished";
reply->setFinished(); reply->setFinished();
}); });
// connect(discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(onDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
discoveryAgent->start(); discoveryAgent->start();
} }

View File

@ -272,7 +272,9 @@ void I2CManagerImplementation::nextCycle()
}); });
m_watcher.setFuture(future); m_watcher.setFuture(future);
connect(&m_watcher, SIGNAL(finished()), &m_pollTimer, SLOT(start())); connect(&m_watcher, &QFutureWatcher<void>::finished, this, [this](){
m_pollTimer.start();
});
} }
} }

View File

@ -662,7 +662,7 @@ void ConfigurationHandler::onTcpServerConfigurationChanged(const QString &id)
void ConfigurationHandler::onTcpServerConfigurationRemoved(const QString &id) void ConfigurationHandler::onTcpServerConfigurationRemoved(const QString &id)
{ {
qCDebug(dcJsonRpc) << "Notification: TCP server configuration removed"; qCDebug(dcJsonRpc()) << "Notification: TCP server configuration removed";
QVariantMap params; QVariantMap params;
params.insert("id", id); params.insert("id", id);
emit TcpServerConfigurationRemoved(params); emit TcpServerConfigurationRemoved(params);

View File

@ -159,7 +159,6 @@ JsonValidator::Result JsonValidator::validateMap(const QVariantMap &map, const Q
result.setErrorString(result.errorString()); result.setErrorString(result.errorString());
return result; return result;
} }
} }
return Result(true); return Result(true);

View File

@ -172,7 +172,7 @@ JsonReply *ScriptsHandler::GetScriptContent(const QVariantMap &params)
JsonReply* ScriptsHandler::AddScript(const QVariantMap &params) JsonReply* ScriptsHandler::AddScript(const QVariantMap &params)
{ {
qWarning() << "Script:" << params.value("content").toString(); qCDebug(dcJsonRpc()) << "Script:" << params.value("content").toString();
QVariantMap returns; QVariantMap returns;
ScriptEngine::AddScriptReply scriptReply = m_engine->addScript(params.value("name").toString(), params.value("content").toByteArray()); ScriptEngine::AddScriptReply scriptReply = m_engine->addScript(params.value("name").toString(), params.value("content").toByteArray());

View File

@ -57,7 +57,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
tmpId.insert(23, "-"); tmpId.insert(23, "-");
setServerUuid(QUuid(tmpId)); setServerUuid(QUuid(tmpId));
} else { } else {
qWarning(dcConfiguration()) << "Failed to open /etc/machine-id for reading. Generating a new UUID for this server instance."; qCWarning(dcConfiguration()) << "Failed to open /etc/machine-id for reading. Generating a new UUID for this server instance.";
setServerUuid(QUuid::createUuid()); setServerUuid(QUuid::createUuid());
} }
} }

View File

@ -35,7 +35,9 @@
#include "loggingcategories.h" #include "loggingcategories.h"
#include "nymeasettings.h" #include "nymeasettings.h"
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
#include <QColor> #include <QColor>
#endif
namespace nymeaserver { namespace nymeaserver {
@ -43,6 +45,7 @@ StateEvaluator::StateEvaluator(const StateDescriptor &stateDescriptor):
m_stateDescriptor(stateDescriptor), m_stateDescriptor(stateDescriptor),
m_operatorType(Types::StateOperatorAnd) m_operatorType(Types::StateOperatorAnd)
{ {
} }
StateEvaluator::StateEvaluator(QList<StateEvaluator> childEvaluators, Types::StateOperator stateOperator): StateEvaluator::StateEvaluator(QList<StateEvaluator> childEvaluators, Types::StateOperator stateOperator):

View File

@ -42,8 +42,10 @@ namespace scriptengine {
class ScriptThing : public QObject, public QQmlParserStatus class ScriptThing : public QObject, public QQmlParserStatus
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString thingId READ thingId WRITE setThingId NOTIFY thingIdChanged) Q_PROPERTY(QString thingId READ thingId WRITE setThingId NOTIFY thingIdChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged)
public: public:
Q_ENUM(Thing::ThingError) Q_ENUM(Thing::ThingError)

View File

@ -49,6 +49,7 @@ class ThingsModel;
class ScriptThings : public QSortFilterProxyModel, public QQmlParserStatus class ScriptThings : public QSortFilterProxyModel, public QQmlParserStatus
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged) Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(QString filterInterface READ filterInterface WRITE setFilterInterface NOTIFY filterInterfaceChanged) Q_PROPERTY(QString filterInterface READ filterInterface WRITE setFilterInterface NOTIFY filterInterfaceChanged)

View File

@ -76,7 +76,7 @@ bool BluetoothServer::hardwareAvailable()
// ourselves if bluez is registered on D-Bus. // ourselves if bluez is registered on D-Bus.
QDBusReply<QStringList> reply = QDBusConnection::systemBus().interface()->registeredServiceNames(); QDBusReply<QStringList> reply = QDBusConnection::systemBus().interface()->registeredServiceNames();
if (!reply.isValid()) { if (!reply.isValid()) {
qWarning(dcBluetoothServer()) << "Unable to query D-Bus for bluez:" << reply.error().message(); qCWarning(dcBluetoothServer()) << "Unable to query D-Bus for bluez:" << reply.error().message();
return false; return false;
} }
const QStringList services = reply.value(); const QStringList services = reply.value();
@ -138,10 +138,14 @@ void BluetoothServer::onClientConnected()
QUuid clientId = QUuid::createUuid(); QUuid clientId = QUuid::createUuid();
m_clientList.insert(clientId, client); m_clientList.insert(clientId, client);
connect(client, SIGNAL(readyRead()), this, SLOT(readData())); connect(client, &QBluetoothSocket::readyRead, this, &BluetoothServer::readData);
connect(client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected())); connect(client, &QBluetoothSocket::disconnected, this, &BluetoothServer::onClientDisconnected);
connect(client, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(onClientStateChanged(QBluetoothSocket::SocketState))); connect(client, &QBluetoothSocket::stateChanged, this, &BluetoothServer::onClientStateChanged);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(client, &QBluetoothSocket::errorOccurred, this, &BluetoothServer::onClientError);
#else
connect(client, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(onClientError(QBluetoothSocket::SocketError))); connect(client, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(onClientError(QBluetoothSocket::SocketError)));
#endif
emit clientConnected(clientId); emit clientConnected(clientId);
} }
@ -198,7 +202,7 @@ bool BluetoothServer::startServer()
// Init bluetooth server // Init bluetooth server
m_server = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); m_server = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
connect(m_server, SIGNAL(newConnection()), this, SLOT(onClientConnected())); connect(m_server, &QBluetoothServer::newConnection, this, &BluetoothServer::onClientConnected);
if (!m_server->listen(m_localDevice->address())) { if (!m_server->listen(m_localDevice->address())) {
qCWarning(dcBluetoothServer()) << "Could not listen on local device." << m_localDevice->name(); qCWarning(dcBluetoothServer()) << "Could not listen on local device." << m_localDevice->name();
delete m_localDevice; delete m_localDevice;

View File

@ -269,7 +269,7 @@ void WebServer::incomingConnection(qintptr socketDescriptor)
if (m_configuration.sslEnabled) { if (m_configuration.sslEnabled) {
// configure client connection // configure client connection
socket->setSslConfiguration(m_sslConfiguration); socket->setSslConfiguration(m_sslConfiguration);
connect(socket, SIGNAL(encrypted()), this, SLOT(onEncrypted())); connect(socket, &QSslSocket::encrypted, this, &WebServer::onEncrypted);
socket->startServerEncryption(); socket->startServerEncryption();
// wait for encrypted connection before continue with this client // wait for encrypted connection before continue with this client
return; return;
@ -425,7 +425,7 @@ void WebServer::readClient()
// Check if the webinterface dir does exist, otherwise a filerequest is not relevant // Check if the webinterface dir does exist, otherwise a filerequest is not relevant
// FIXME: return a default webpage containing server information // FIXME: return a default webpage containing server information
if (!QDir(m_configuration.publicFolder).exists()) { if (!QDir(m_configuration.publicFolder).exists()) {
qDebug(dcWebServer()) << "Webinterface folder" << m_configuration.publicFolder << "does not exist."; qCDebug(dcWebServer()) << "Webinterface folder" << m_configuration.publicFolder << "does not exist.";
HttpReply *reply = HttpReply::createErrorReply(HttpReply::NotFound); HttpReply *reply = HttpReply::createErrorReply(HttpReply::NotFound);
reply->setClientId(clientId); reply->setClientId(clientId);
sendHttpReply(reply); sendHttpReply(reply);

View File

@ -146,11 +146,15 @@ void WebSocketServer::onClientConnected()
// append the new client to the client list // append the new client to the client list
m_clientList.insert(clientId, client); m_clientList.insert(clientId, client);
connect(client, SIGNAL(pong(quint64,QByteArray)), this, SLOT(onPing(quint64,QByteArray))); connect(client, &QWebSocket::pong, this, &WebSocketServer::onPing);
connect(client, SIGNAL(binaryMessageReceived(QByteArray)), this, SLOT(onBinaryMessageReceived(QByteArray))); connect(client, &QWebSocket::binaryMessageReceived, this, &WebSocketServer::onBinaryMessageReceived);
connect(client, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessageReceived(QString))); connect(client, &QWebSocket::textMessageReceived, this, &WebSocketServer::onTextMessageReceived);
connect(client, &QWebSocket::disconnected, this, &WebSocketServer::onClientDisconnected);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(client, &QWebSocket::errorOccurred, this, &WebSocketServer::onClientError);
#else
connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onClientError(QAbstractSocket::SocketError))); connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onClientError(QAbstractSocket::SocketError)));
connect(client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected())); #endif
emit clientConnected(clientId); emit clientConnected(clientId);
} }

View File

@ -49,7 +49,7 @@
QObject(parent) QObject(parent)
{ {
Coap *coap = new Coap(this); Coap *coap = new Coap(this);
connect(coap, SIGNAL(replyFinished(CoapReply*)), this, SLOT(onReplyFinished(CoapReply*))); connect(coap, &Coap::replyFinished, this, &MyClass::onReplyFinished);
CoapRequest request(QUrl("coap://coap.me/hello")); CoapRequest request(QUrl("coap://coap.me/hello"));
coap->get(request); coap->get(request);
@ -96,7 +96,7 @@ Coap::Coap(QObject *parent, const quint16 &port) :
if (!m_socket->bind(QHostAddress::AnyIPv4, port, QAbstractSocket::ShareAddress)) if (!m_socket->bind(QHostAddress::AnyIPv4, port, QAbstractSocket::ShareAddress))
qCWarning(dcCoap) << "Could not bind to port" << port << m_socket->errorString(); qCWarning(dcCoap) << "Could not bind to port" << port << m_socket->errorString();
connect(m_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead())); connect(m_socket, &QUdpSocket::readyRead, this, &Coap::onReadyRead);
} }
/*! Performs a ping request to the CoAP server specified in the given \a request. /*! Performs a ping request to the CoAP server specified in the given \a request.

View File

@ -43,7 +43,7 @@
\code \code
Coap *coap = new Coap(this); Coap *coap = new Coap(this);
connect(coap, SIGNAL(replyFinished(CoapReply*)), this, SLOT(onReplyFinished(CoapReply*))); connect(coap, &Coap::replyFinished, this, &MyClass::onReplyFinished);
CoapRequest request(QUrl("coap://example.com/")); CoapRequest request(QUrl("coap://example.com/"));

View File

@ -40,6 +40,9 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QMetaObject> #include <QMetaObject>
#include <QMetaEnum> #include <QMetaEnum>
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
#include <QColor>
#endif
PluginMetadata::PluginMetadata() PluginMetadata::PluginMetadata()
{ {
@ -51,6 +54,10 @@ PluginMetadata::PluginMetadata(const QJsonObject &jsonObject, bool isBuiltIn, bo
m_isBuiltIn(isBuiltIn), m_isBuiltIn(isBuiltIn),
m_strictRun(strict) m_strictRun(strict)
{ {
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
qRegisterMetaType<QColor>("QColor");
#endif
parse(jsonObject); parse(jsonObject);
} }
@ -370,8 +377,11 @@ void PluginMetadata::parse(const QJsonObject &jsonObject)
hasError = true; hasError = true;
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QMetaType::Type t = static_cast<QMetaType::Type>(QMetaType::fromName(QByteArray(st.value("type").toString().toUtf8())).id());
#else
QMetaType::Type t = static_cast<QMetaType::Type>(QVariant::nameToType(st.value("type").toString().toLatin1().data())); QMetaType::Type t = static_cast<QMetaType::Type>(QVariant::nameToType(st.value("type").toString().toLatin1().data()));
#endif
if (t == QMetaType::UnknownType) { if (t == QMetaType::UnknownType) {
m_validationErrors.append("Thing class \"" + thingClass.name() + "\" state type \"" + stateTypeName + "\" has invalid type: \"" + st.value("type").toString() + "\""); m_validationErrors.append("Thing class \"" + thingClass.name() + "\" state type \"" + stateTypeName + "\" has invalid type: \"" + st.value("type").toString() + "\"");
hasError = true; hasError = true;

View File

@ -15,7 +15,6 @@
{ {
"name": "inputSource", "name": "inputSource",
"type": "QString", "type": "QString",
"allowedValues": "any",
"writable": true, "writable": true,
"optional": true "optional": true
}, },

View File

@ -231,7 +231,7 @@ void JsonHandler::registerObject(const QMetaObject &metaObject)
typeName = QString("$ref:%1").arg(QString(typeNameRaw).split("::").last().remove('<').remove('>')); typeName = QString("$ref:%1").arg(QString(typeNameRaw).split("::").last().remove('<').remove('>'));
} }
qCDebug(dcJsonRpc()) << typeNameRaw << propertyNameRaw << metaTypeNameRaw << typeName; // qCDebug(dcJsonRpc()) << typeNameRaw << propertyNameRaw << metaTypeNameRaw << typeName;
} }
} else if (metaProperty.isEnumType()) { } else if (metaProperty.isEnumType()) {
QString typeNameRaw = QString(metaProperty.typeName()); QString typeNameRaw = QString(metaProperty.typeName());

View File

@ -4,7 +4,13 @@ TARGET = nymea
TEMPLATE = lib TEMPLATE = lib
QT += network bluetooth dbus serialport sql QT += network bluetooth dbus serialport sql
QT -= gui
greaterThan(QT_MAJOR_VERSION, 5) {
# In Qt6 we need explictily add the gui module in order to have QColor available
QT += gui
} else {
QT -= gui
}
DEFINES += LIBNYMEA_LIBRARY DEFINES += LIBNYMEA_LIBRARY

View File

@ -19,7 +19,6 @@ greaterThan(QT_MAJOR_VERSION, 5) {
DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00 DEFINES += QT_DISABLE_DEPRECATED_UP_TO=0x050F00
} }
QMAKE_CXXFLAGS *= -Werror -g -Wno-deprecated-declarations QMAKE_CXXFLAGS *= -Werror -g -Wno-deprecated-declarations
top_srcdir=$$PWD top_srcdir=$$PWD
@ -92,7 +91,6 @@ asan: {
QMAKE_LFLAGS *= -fsanitize=address QMAKE_LFLAGS *= -fsanitize=address
} }
CONFIG(withoutpython) { CONFIG(withoutpython) {
message("Building without python support.") message("Building without python support.")
CONFIG -= python CONFIG -= python

View File

@ -66,9 +66,9 @@ void HttpDaemon::incomingConnection(qintptr socket)
// communication with the client is done over this QTcpSocket. QTcpSocket // communication with the client is done over this QTcpSocket. QTcpSocket
// works asynchronously, this means that all the communication is done // works asynchronously, this means that all the communication is done
// in the two slots readClient() and discardClient(). // in the two slots readClient() and discardClient().
QTcpSocket* s = new QTcpSocket(this); QTcpSocket *s = new QTcpSocket(this);
connect(s, SIGNAL(readyRead()), this, SLOT(readClient())); connect(s, &QTcpSocket::readyRead, this, &HttpDaemon::readClient);
connect(s, SIGNAL(disconnected()), this, SLOT(discardClient())); connect(s, &QTcpSocket::disconnected, this, &HttpDaemon::discardClient);
s->setSocketDescriptor(socket); s->setSocketDescriptor(socket);
} }

View File

@ -292,12 +292,12 @@
"name": "pressButton", "name": "pressButton",
"displayName": "Press button", "displayName": "Press button",
"paramTypes": [ "paramTypes": [
{ {
"id": "279e0157-78ea-4bb3-a756-b12fb46cf4fc", "id": "279e0157-78ea-4bb3-a756-b12fb46cf4fc",
"name": "buttonName", "name": "buttonName",
"displayName": "Button name", "displayName": "Button name",
"type": "QString" "type": "QString"
} }
] ]
} }
], ],

View File

@ -1,6 +1,6 @@
include(../plugins.pri) include(../plugins.pri)
QT+= network QT += network
TARGET = $$qtLibraryTarget(nymea_integrationpluginmock) TARGET = $$qtLibraryTarget(nymea_integrationpluginmock)

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
// check if there are local translations // check if there are local translations
if (!translator.load(QLocale::system(), application.applicationName(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm")) if (!translator.load(QLocale::system(), application.applicationName(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm"))
if (!translator.load(QLocale::system(), application.applicationName(), "-", NymeaSettings::translationsPath(), ".qm")) if (!translator.load(QLocale::system(), application.applicationName(), "-", NymeaSettings::translationsPath(), ".qm"))
qWarning(dcTranslations()) << "Could not find nymead translations for" << QLocale::system().name() << '\n' << (QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath()) << '\n' << NymeaSettings::translationsPath(); qCWarning(dcTranslations()) << "Could not find nymead translations for" << QLocale::system().name() << '\n' << (QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath()) << '\n' << NymeaSettings::translationsPath();

View File

@ -308,8 +308,8 @@ void QtServiceSysPrivate::incomingConnection(qintptr socketDescriptor)
{ {
QTcpSocket *s = new QTcpSocket(this); QTcpSocket *s = new QTcpSocket(this);
s->setSocketDescriptor(socketDescriptor); s->setSocketDescriptor(socketDescriptor);
connect(s, SIGNAL(readyRead()), this, SLOT(slotReady())); connect(s, &QTcpSocket::readyRead, this, &QtServiceSysPrivate::slotReady);
connect(s, SIGNAL(disconnected()), this, SLOT(slotClosed())); connect(s, &QTcpSocket::disconnected, this, &QtServiceSysPrivate::slotClosed);
} }
void QtServiceSysPrivate::slotReady() void QtServiceSysPrivate::slotReady()

View File

@ -101,7 +101,7 @@ void TestConfigurations::testServerName()
QString serverUuid = basicConfigurationMap.value("serverUuid").toString(); QString serverUuid = basicConfigurationMap.value("serverUuid").toString();
qDebug() << "Server name" << serverName << "(" << serverUuid << ")"; qDebug() << "Server name" << serverName << "(" << serverUuid << ")";
QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Set name unchanged // Set name unchanged
QVariantMap params; QVariant response; QVariantList configurationChangedNotifications; QVariantMap params; QVariant response; QVariantList configurationChangedNotifications;
@ -158,7 +158,7 @@ void TestConfigurations::testLanguages()
// Get current configurations // Get current configurations
QVariantMap basicConfigurationMap = loadBasicConfiguration(); QVariantMap basicConfigurationMap = loadBasicConfiguration();
QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Set language unchanged // Set language unchanged
QVariant response; QVariantMap params; QVariant response; QVariantMap params;
@ -175,12 +175,12 @@ void TestConfigurations::testLanguages()
response = injectAndWait("Configuration.GetAvailableLanguages"); response = injectAndWait("Configuration.GetAvailableLanguages");
QVERIFY2(response.toMap().value("params").toMap().contains("languages"), "Did not get list of languages"); QVERIFY2(response.toMap().value("params").toMap().contains("languages"), "Did not get list of languages");
QVariantMap responseMap = response.toMap().value("params").toMap(); QVariantMap responseMap = response.toMap().value("params").toMap();
QVERIFY2(responseMap.value("languages").toList().count() >= 2, "Available languages list to short: " + responseMap.value("languages").toList().count()); QVERIFY2(responseMap.value("languages").toList().size() >= 2, qPrintable(QString("Available languages list to short: %1").arg(responseMap.value("languages").toList().size())));
QVariantList languageVariantList = responseMap.value("languages").toList(); QVariantList languageVariantList = responseMap.value("languages").toList();
foreach (const QVariant &languageVariant, languageVariantList) { foreach (const QVariant &languageVariant, languageVariantList) {
// create a new spy for each run as we restart the server and kill the old one in this loop // create a new spy for each run as we restart the server and kill the old one in this loop
QSignalSpy notificationSpy2 (m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy2 (m_mockTcpServer, &MockTcpServer::outgoingData);
// Get current configurations // Get current configurations
basicConfigurationMap = loadBasicConfiguration(); basicConfigurationMap = loadBasicConfiguration();
@ -237,7 +237,7 @@ void TestConfigurations::testDebugServerConfiguration()
bool debugServerEnabled = basicConfigurationMap.value("debugServerEnabled").toBool(); bool debugServerEnabled = basicConfigurationMap.value("debugServerEnabled").toBool();
qCDebug(dcTests) << "Debug server enabled" << debugServerEnabled; qCDebug(dcTests) << "Debug server enabled" << debugServerEnabled;
QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Unchanged debug server // Unchanged debug server
QVariantMap params; QVariant response; QVariantList configurationChangedNotifications; QVariantMap params; QVariant response; QVariantList configurationChangedNotifications;
@ -295,10 +295,10 @@ void TestConfigurations::testDebugServerConfiguration()
// Webserver request // Webserver request
QNetworkAccessManager nam; QNetworkAccessManager nam;
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply* reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply* reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy namSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy namSpy(&nam, &QNetworkAccessManager::finished);
// Check if debug interface is reachable // Check if debug interface is reachable
QNetworkRequest request; QNetworkRequest request;

View File

@ -439,7 +439,7 @@ void TestIntegrations::thingAddedRemovedNotifications()
enableNotifications({"Integrations"}); enableNotifications({"Integrations"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// add thing and wait for notification // add thing and wait for notification
QVariantList thingParams; QVariantList thingParams;
@ -485,7 +485,7 @@ void TestIntegrations::thingChangedNotifications()
enableNotifications({"Integrations"}); enableNotifications({"Integrations"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// ADD // ADD
// add thing and wait for notification // add thing and wait for notification
@ -666,7 +666,7 @@ void TestIntegrations::stateCache()
Thing* thing = NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId).first(); Thing* thing = NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId).first();
int port = thing->paramValue(mockThingHttpportParamTypeId).toInt(); int port = thing->paramValue(mockThingHttpportParamTypeId).toInt();
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// First set the state values to something that is *not* the default // First set the state values to something that is *not* the default
@ -1570,7 +1570,7 @@ void TestIntegrations::reconfigureByDiscovery()
// check if the daemons are running // check if the daemons are running
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// check if old daemon is still running (should not) // check if old daemon is still running (should not)
QNetworkRequest request(QUrl(QString("http://localhost:%1").arg(55555))); QNetworkRequest request(QUrl(QString("http://localhost:%1").arg(55555)));
@ -1762,7 +1762,7 @@ void TestIntegrations::removeAutoThing()
{ {
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager *nam = new QNetworkAccessManager(this); QNetworkAccessManager *nam = new QNetworkAccessManager(this);
QSignalSpy spy(nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(nam, &QNetworkAccessManager::finished);
// First try to make a manually created device disappear. It must not go away // First try to make a manually created device disappear. It must not go away
@ -2068,7 +2068,7 @@ void TestIntegrations::executeAction()
// Fetch action execution history from mock device // Fetch action execution history from mock device
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(m_mockThing1Port))); QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(m_mockThing1Port)));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
@ -2205,7 +2205,7 @@ void TestIntegrations::dynamicMinMax()
QVERIFY2(things.count() > 0, "There needs to be at least one configured Mock for this test"); QVERIFY2(things.count() > 0, "There needs to be at least one configured Mock for this test");
Thing *thing = things.first(); Thing *thing = things.first();
QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager nam; QNetworkAccessManager nam;
@ -2284,7 +2284,7 @@ void TestIntegrations::asyncSetupEmitsSetupStatusUpdate()
restartServer(); restartServer();
enableNotifications({"Integrations"}); enableNotifications({"Integrations"});
QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy notificationSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
configuredDevices = injectAndWait("Integrations.GetThings").toMap(); configuredDevices = injectAndWait("Integrations.GetThings").toMap();
QList<QUuid> thingsWithSetupInProgress; QList<QUuid> thingsWithSetupInProgress;

View File

@ -203,7 +203,7 @@ void TestJSONRPC::testHandshake()
void TestJSONRPC::testHandshakeLocale() void TestJSONRPC::testHandshakeLocale()
{ {
// first test if the handshake message is auto-sent upon connecting // first test if the handshake message is auto-sent upon connecting
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Test withouth locale data // Test withouth locale data
QVariantMap handShake = injectAndWait("JSONRPC.Hello").toMap(); QVariantMap handShake = injectAndWait("JSONRPC.Hello").toMap();
@ -246,7 +246,7 @@ void TestJSONRPC::testInitialSetup()
QVERIFY(NymeaCore::instance()->userManager()->initRequired()); QVERIFY(NymeaCore::instance()->userManager()->initRequired());
QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0); QCOMPARE(NymeaCore::instance()->userManager()->users().count(), 0);
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, &MockTcpServer::outgoingData);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
QSignalSpy disconnectedSpy(m_mockTcpServer, &MockTcpServer::clientDisconnected); QSignalSpy disconnectedSpy(m_mockTcpServer, &MockTcpServer::clientDisconnected);
@ -620,7 +620,7 @@ void TestJSONRPC::testBasicCall()
QFETCH(bool, idValid); QFETCH(bool, idValid);
QFETCH(bool, valid); QFETCH(bool, valid);
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, &MockTcpServer::outgoingData);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
m_mockTcpServer->injectData(m_clientId, call); m_mockTcpServer->injectData(m_clientId, call);
@ -720,7 +720,7 @@ void TestJSONRPC::ruleAddedRemovedNotifications()
enableNotifications({"Rules"}); enableNotifications({"Rules"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Add rule and wait for notification // Add rule and wait for notification
// StateDescriptor // StateDescriptor
@ -838,7 +838,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
params.insert("stateEvaluator", stateEvaluator); params.insert("stateEvaluator", stateEvaluator);
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
response = injectAndWait("Rules.AddRule", params); response = injectAndWait("Rules.AddRule", params);
if (clientSpy.count() == 0) clientSpy.wait(); if (clientSpy.count() == 0) clientSpy.wait();
@ -857,13 +857,13 @@ void TestJSONRPC::ruleActiveChangedNotifications()
// set the rule active // set the rule active
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state state to 20 // state state to 20
qCDebug(dcTests) << "setting mock int state to 20"; qCDebug(dcTests) << "setting mock int state to 20";
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(20))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(20)));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater())); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
qCDebug(dcTests()) << "Waiting for RuleActiveChanged"; qCDebug(dcTests()) << "Waiting for RuleActiveChanged";
if (spy.count() == 0) spy.wait(); if (spy.count() == 0) spy.wait();
@ -879,7 +879,7 @@ void TestJSONRPC::ruleActiveChangedNotifications()
qCDebug(dcTests) << "setting mock int state to 42"; qCDebug(dcTests) << "setting mock int state to 42";
QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(42))); QNetworkRequest request2(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(42)));
QNetworkReply *reply2 = nam.get(request2); QNetworkReply *reply2 = nam.get(request2);
connect(reply2, SIGNAL(finished()), reply2, SLOT(deleteLater())); connect(reply2, &QNetworkReply::finished, reply2, &QNetworkReply::deleteLater);
// Waiting for notifications: // Waiting for notifications:
// Rules.RuleActiveChanged // Rules.RuleActiveChanged
@ -915,15 +915,15 @@ void TestJSONRPC::stateChangeEmitsNotifications()
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// trigger state change in mock device // trigger state change in mock device
int newVal = 38; int newVal = 38;
QUuid stateTypeId("80baec19-54de-4948-ac46-31eabfaceb83"); QUuid stateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(stateTypeId.toString()).arg(QString::number(newVal)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(stateTypeId.toString()).arg(QString::number(newVal))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater())); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
QSignalSpy replySpy(reply, SIGNAL(finished())); QSignalSpy replySpy(reply, &QNetworkReply::finished);
if (replySpy.count() == 0) replySpy.wait(); if (replySpy.count() == 0) replySpy.wait();
// Make sure the notification contains all the stuff we expect // Make sure the notification contains all the stuff we expect
@ -948,7 +948,7 @@ void TestJSONRPC::stateChangeEmitsNotifications()
newVal = 42; newVal = 42;
request.setUrl(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(stateTypeId.toString()).arg(newVal))); request.setUrl(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(stateTypeId.toString()).arg(newVal)));
reply = nam.get(request); reply = nam.get(request);
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater())); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
// Lets wait a max of 500ms for notifications // Lets wait a max of 500ms for notifications
clientSpy.wait(500); clientSpy.wait(500);
@ -966,7 +966,7 @@ void TestJSONRPC::stateChangeEmitsNotifications()
void TestJSONRPC::pluginConfigChangeEmitsNotification() void TestJSONRPC::pluginConfigChangeEmitsNotification()
{ {
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QVariantMap params; QVariantMap params;
params.insert("enabled", true); params.insert("enabled", true);
@ -1037,7 +1037,7 @@ void TestJSONRPC::testPushButtonAuthInterrupt()
if (responseSpy.count() == 0) responseSpy.wait(); if (responseSpy.count() == 0) responseSpy.wait();
// Snoop in on everything the TCP server sends to its clients. // Snoop in on everything the TCP server sends to its clients.
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// request push button auth for client 1 (alice) and check for OK reply // request push button auth for client 1 (alice) and check for OK reply
QVariantMap params; QVariantMap params;
@ -1313,7 +1313,7 @@ void TestJSONRPC::testDataFragmentation_data()
void TestJSONRPC::testDataFragmentation() void TestJSONRPC::testDataFragmentation()
{ {
QJsonDocument jsonDoc; QJsonDocument jsonDoc;
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, &MockTcpServer::outgoingData);
QFETCH(QList<QByteArray>, packets); QFETCH(QList<QByteArray>, packets);

View File

@ -216,7 +216,7 @@ void TestLogging::stateChangeLogs()
clearLoggingDatabase(logSourceName); clearLoggingDatabase(logSourceName);
enableNotifications({"Integrations"}); enableNotifications({"Integrations"});
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// trigger state change in mock device // trigger state change in mock device
request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(stateTypeId.toString()).arg(newValue.toString()))); request = QNetworkRequest(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(port).arg(stateTypeId.toString()).arg(newValue.toString())));
@ -263,7 +263,7 @@ void TestLogging::eventLog()
clearLoggingDatabase(logSourceName); clearLoggingDatabase(logSourceName);
enableNotifications({"Integrations"}); enableNotifications({"Integrations"});
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// trigger state change in mock device // trigger state change in mock device
QNetworkAccessManager nam; QNetworkAccessManager nam;
@ -319,7 +319,7 @@ void TestLogging::actionLog()
enableNotifications({"Logging"}); enableNotifications({"Logging"});
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// EXECUTE with params // EXECUTE with params
QVariant response = injectAndWait("Integrations.ExecuteAction", params); QVariant response = injectAndWait("Integrations.ExecuteAction", params);

View File

@ -142,7 +142,7 @@ private slots:
void TestRules::cleanupMockHistory() { void TestRules::cleanupMockHistory() {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -244,7 +244,7 @@ void TestRules::setWritableStateValue(const ThingId &thingId, const StateTypeId
QVariant currentStateValue = response.toMap().value("params").toMap().value("value"); QVariant currentStateValue = response.toMap().value("params").toMap().value("value");
bool shouldGetNotification = currentStateValue != value; bool shouldGetNotification = currentStateValue != value;
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy stateSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QVariantMap paramMap; QVariantMap paramMap;
paramMap.insert("paramTypeId", stateTypeId.toString()); paramMap.insert("paramTypeId", stateTypeId.toString());
@ -287,7 +287,7 @@ void TestRules::verifyRuleExecuted(const ActionTypeId &actionTypeId)
int i = 0; int i = 0;
while (!actionFound && i < 50) { while (!actionFound && i < 50) {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -307,7 +307,7 @@ void TestRules::verifyRuleExecuted(const ActionTypeId &actionTypeId)
void TestRules::verifyRuleNotExecuted() void TestRules::verifyRuleNotExecuted()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -394,7 +394,7 @@ void TestRules::generateEvent(const EventTypeId &eventTypeId)
{ {
// Trigger an event // Trigger an event
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// trigger event in mock // trigger event in mock
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(eventTypeId.toString()))); QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(eventTypeId.toString())));
@ -959,7 +959,7 @@ void TestRules::editRules()
} }
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
response.clear(); response.clear();
response = injectAndWait("Rules.EditRule", params); response = injectAndWait("Rules.EditRule", params);
verifyRuleError(response, error); verifyRuleError(response, error);
@ -1626,7 +1626,7 @@ void TestRules::evaluateEvent()
// Trigger an event // Trigger an event
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// trigger event in mock // trigger event in mock
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString()))); QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString())));
@ -1642,7 +1642,7 @@ void TestRules::evaluateEventParams()
{ {
// Init bool state to true // Init bool state to true
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBoolStateTypeId.toString()).arg("true"))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBoolStateTypeId.toString()).arg("true")));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -1735,7 +1735,7 @@ void TestRules::testStateChange() {
// Change the state // Change the state
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state state to 42 // state state to 42
qDebug() << "setting mock int state to 42"; qDebug() << "setting mock int state to 42";
@ -2093,7 +2093,7 @@ void TestRules::enableDisableRule()
// Trigger an event // Trigger an event
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// trigger event in mock // trigger event in mock
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString()))); QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString())));
@ -2189,7 +2189,7 @@ void TestRules::testEventBasedAction()
// Change the state // Change the state
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state state to 42 // state state to 42
qDebug() << "setting mock int state to 42"; qDebug() << "setting mock int state to 42";
@ -2206,7 +2206,7 @@ void TestRules::testEventBasedAction()
void TestRules::testEventBasedRuleWithExitAction() void TestRules::testEventBasedRuleWithExitAction()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// Init bool state to true // Init bool state to true
spy.clear(); spy.clear();
@ -2298,7 +2298,7 @@ void TestRules::testEventBasedRuleWithExitAction()
void TestRules::testStateBasedAction() void TestRules::testStateBasedAction()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// Init bool state to true // Init bool state to true
spy.clear(); spy.clear();
@ -2711,7 +2711,7 @@ void TestRules::testInitStatesActive()
void TestRules::testInterfaceBasedEventRule() void TestRules::testInterfaceBasedEventRule()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state battery critical state to false initially // state battery critical state to false initially
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBatteryCriticalStateTypeId.toString()).arg(false))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBatteryCriticalStateTypeId.toString()).arg(false)));
@ -2813,7 +2813,7 @@ void TestRules::testInterfaceBasedEventRule()
void TestRules::testInterfaceBasedStateRule() void TestRules::testInterfaceBasedStateRule()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state battery critical state to false initially // state battery critical state to false initially
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBatteryCriticalStateTypeId.toString()).arg(false))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBatteryCriticalStateTypeId.toString()).arg(false)));
@ -2882,7 +2882,7 @@ void TestRules::testInterfaceBasedStateRule()
void TestRules::testThingBasedAndThingValueStateDescriptor() void TestRules::testThingBasedAndThingValueStateDescriptor()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// set int state to 10 initially // set int state to 10 initially
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(10))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(10)));
@ -3073,7 +3073,7 @@ void TestRules::testScene()
NymeaCore::instance()->timeManager()->setTime(now); NymeaCore::instance()->timeManager()->setTime(now);
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
// state power state to false initially // state power state to false initially
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockPowerStateTypeId.toString()).arg(false))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockPowerStateTypeId.toString()).arg(false)));

View File

@ -111,7 +111,7 @@ void TestTags::addTag()
enableNotifications({"Tags"}); enableNotifications({"Tags"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// Create a tag; // Create a tag;
QVariantMap params; QVariantMap params;
@ -145,7 +145,7 @@ void TestTags::updateTagValue()
enableNotifications({"Tags"}); enableNotifications({"Tags"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QString thingId = m_mockThingId.toString(); QString thingId = m_mockThingId.toString();
QString appId = "testtags"; QString appId = "testtags";
@ -200,7 +200,7 @@ void TestTags::removeTag()
enableNotifications({"Tags"}); enableNotifications({"Tags"});
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QString thingId = m_mockThingId.toString(); QString thingId = m_mockThingId.toString();
QString appId = "testtags"; QString appId = "testtags";

View File

@ -2038,7 +2038,7 @@ void TestTimeManager::verifyRuleExecuted(const ActionTypeId &actionTypeId)
{ {
// Verify rule got executed // Verify rule got executed
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -2052,7 +2052,7 @@ void TestTimeManager::verifyRuleExecuted(const ActionTypeId &actionTypeId)
void TestTimeManager::verifyRuleNotExecuted() void TestTimeManager::verifyRuleNotExecuted()
{ {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/actionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -2065,7 +2065,7 @@ void TestTimeManager::verifyRuleNotExecuted()
void TestTimeManager::cleanupMockHistory() { void TestTimeManager::cleanupMockHistory() {
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(QString::number(m_mockThing1Port)))); QNetworkRequest request(QUrl(QString("http://localhost:%1/clearactionhistory").arg(QString::number(m_mockThing1Port))));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
spy.wait(); spy.wait();
@ -2100,8 +2100,8 @@ void TestTimeManager::setIntState(const int &value)
bool shouldGetNotification = currentStateValue != value; bool shouldGetNotification = currentStateValue != value;
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy stateSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
spy.clear(); spy.clear();
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(value))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(value)));
@ -2141,8 +2141,8 @@ void TestTimeManager::setBoolState(const bool &value)
bool shouldGetNotification = currentStateValue != value; bool shouldGetNotification = currentStateValue != value;
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QSignalSpy stateSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy stateSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBoolStateTypeId.toString()).arg(value))); QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockBoolStateTypeId.toString()).arg(value)));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
@ -2171,9 +2171,9 @@ void TestTimeManager::triggerMockEvent1()
qDebug() << "Trigger mock event 1"; qDebug() << "Trigger mock event 1";
QNetworkAccessManager nam; QNetworkAccessManager nam;
QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy spy(&nam, &QNetworkAccessManager::finished);
QSignalSpy eventSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy eventSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString()))); QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2").arg(m_mockThing1Port).arg(mockEvent1EventTypeId.toString())));
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);

View File

@ -226,7 +226,7 @@ void TestUsermanager::authenticatePushButton()
int transactionId = response.toMap().value("params").toMap().value("transactionId").toInt(); int transactionId = response.toMap().value("params").toMap().value("transactionId").toInt();
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
pushButtonAgent.sendButtonPressed(); pushButtonAgent.sendButtonPressed();
@ -264,7 +264,7 @@ void TestUsermanager::authenticatePushButtonAuthInterrupt()
if (responseSpy.count() == 0) responseSpy.wait(); if (responseSpy.count() == 0) responseSpy.wait();
// Snoop in on everything the TCP server sends to its clients. // Snoop in on everything the TCP server sends to its clients.
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, &MockTcpServer::outgoingData);
// request push button auth for client 1 (alice) and check for OK reply // request push button auth for client 1 (alice) and check for OK reply
QVariantMap params; QVariantMap params;

View File

@ -110,11 +110,11 @@ void TestWebserver::httpVersion()
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &); typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors); connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors);
socket->connectToHostEncrypted("127.0.0.1", 3333); socket->connectToHostEncrypted("127.0.0.1", 3333);
QSignalSpy encryptedSpy(socket, SIGNAL(encrypted())); QSignalSpy encryptedSpy(socket, &QSslSocket::encrypted);
bool encrypted = encryptedSpy.wait(); bool encrypted = encryptedSpy.wait();
QVERIFY2(encrypted, "could not created encrypted webserver connection."); QVERIFY2(encrypted, "could not created encrypted webserver connection.");
QSignalSpy clientSpy(socket, SIGNAL(readyRead())); QSignalSpy clientSpy(socket, &QSslSocket::readyRead);
QByteArray requestData; QByteArray requestData;
requestData.append("GET /hello/nymea HTTP/1\r\n"); requestData.append("GET /hello/nymea HTTP/1\r\n");
@ -150,11 +150,11 @@ void TestWebserver::multiPackageMessage()
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &); typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors); connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors);
socket->connectToHostEncrypted("127.0.0.1", 3333); socket->connectToHostEncrypted("127.0.0.1", 3333);
QSignalSpy encryptedSpy(socket, SIGNAL(encrypted())); QSignalSpy encryptedSpy(socket, &QSslSocket::encrypted);
bool encrypted = encryptedSpy.wait(); bool encrypted = encryptedSpy.wait();
QVERIFY2(encrypted, "could not created encrypte webserver connection."); QVERIFY2(encrypted, "could not created encrypte webserver connection.");
QSignalSpy clientSpy(socket, SIGNAL(readyRead())); QSignalSpy clientSpy(socket, &QSslSocket::readyRead);
QByteArray requestData; QByteArray requestData;
requestData.append("PUT / HTTP/1.1\r\n"); requestData.append("PUT / HTTP/1.1\r\n");
@ -220,7 +220,7 @@ void TestWebserver::checkAllowedMethodCall()
qCWarning(dcTests) << "SSL errors:" << errors; qCWarning(dcTests) << "SSL errors:" << errors;
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl("https://localhost:3333")); request.setUrl(QUrl("https://localhost:3333"));
@ -299,11 +299,11 @@ void TestWebserver::badRequests()
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &); typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors); connect(socket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TestWebserver::onSslErrors);
socket->connectToHostEncrypted("127.0.0.1", 3333); socket->connectToHostEncrypted("127.0.0.1", 3333);
QSignalSpy encryptedSpy(socket, SIGNAL(encrypted())); QSignalSpy encryptedSpy(socket, &QSslSocket::encrypted);
bool encrypted = encryptedSpy.wait(); bool encrypted = encryptedSpy.wait();
QVERIFY2(encrypted, "could not created encrypte webserver connection."); QVERIFY2(encrypted, "could not created encrypte webserver connection.");
QSignalSpy clientSpy(socket, SIGNAL(readyRead())); QSignalSpy clientSpy(socket, &QSslSocket::readyRead);
socket->write(request); socket->write(request);
bool filesWritten = socket->waitForBytesWritten(500); bool filesWritten = socket->waitForBytesWritten(500);
@ -352,7 +352,7 @@ void TestWebserver::getFiles()
connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl("https://localhost:3333" + query)); request.setUrl(QUrl("https://localhost:3333" + query));
@ -375,7 +375,7 @@ void TestWebserver::getServerDescription()
connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl("https://localhost:3333/server.xml")); request.setUrl(QUrl("https://localhost:3333/server.xml"));
@ -417,7 +417,7 @@ void TestWebserver::getIcons()
connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply* reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [this, &nam](QNetworkReply* reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl("https://localhost:3333" + query)); request.setUrl(QUrl("https://localhost:3333" + query));
@ -597,7 +597,7 @@ void TestWebserver::getDebugServer()
bool ok = false; bool ok = false;
int statusCode = 0; int statusCode = 0;
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply* reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });

View File

@ -97,7 +97,7 @@ void TestWebSocketServer::testHandshake()
socket->open(QUrl(QStringLiteral("wss://localhost:4444"))); socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
connectedSpy.wait(); connectedSpy.wait();
QSignalSpy spy(socket, SIGNAL(textMessageReceived(QString))); QSignalSpy spy(socket, &QWebSocket::textMessageReceived);
socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}"); socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}");
spy.wait(); spy.wait();
@ -118,12 +118,12 @@ void TestWebSocketServer::pingTest()
{ {
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13); QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors); connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
QSignalSpy spyConnection(socket, SIGNAL(connected())); QSignalSpy spyConnection(socket, &QWebSocket::connected);
socket->open(QUrl(QStringLiteral("wss://localhost:4444"))); socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
spyConnection.wait(); spyConnection.wait();
QVERIFY2(spyConnection.count() > 0, "not connected"); QVERIFY2(spyConnection.count() > 0, "not connected");
QSignalSpy spyPong(socket, SIGNAL(pong(quint64,QByteArray))); QSignalSpy spyPong(socket, &QWebSocket::pong);
socket->ping("hallo"); socket->ping("hallo");
spyPong.wait(); spyPong.wait();
QVERIFY2(spyPong.count() > 0, "no pong"); QVERIFY2(spyPong.count() > 0, "no pong");
@ -182,14 +182,14 @@ QVariant TestWebSocketServer::injectSocketAndWait(const QString &method, const Q
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13); QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors); connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
QSignalSpy spyConnection(socket, SIGNAL(connected())); QSignalSpy spyConnection(socket, &QWebSocket::connected);
socket->open(QUrl(QStringLiteral("wss://localhost:4444"))); socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
spyConnection.wait(); spyConnection.wait();
if (spyConnection.count() == 0) { if (spyConnection.count() == 0) {
return QVariant(); return QVariant();
} }
QSignalSpy spy(socket, SIGNAL(textMessageReceived(QString))); QSignalSpy spy(socket, &QWebSocket::textMessageReceived);
socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}"); socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}");
spy.wait(); spy.wait();
@ -227,14 +227,14 @@ QVariant TestWebSocketServer::injectSocketData(const QByteArray &data)
{ {
QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13); QWebSocket *socket = new QWebSocket("nymea tests", QWebSocketProtocol::Version13);
connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors); connect(socket, &QWebSocket::sslErrors, this, &TestWebSocketServer::sslErrors);
QSignalSpy spyConnection(socket, SIGNAL(connected())); QSignalSpy spyConnection(socket, &QWebSocket::connected);
socket->open(QUrl(QStringLiteral("wss://localhost:4444"))); socket->open(QUrl(QStringLiteral("wss://localhost:4444")));
spyConnection.wait(); spyConnection.wait();
if (spyConnection.count() == 0) { if (spyConnection.count() == 0) {
return QVariant(); return QVariant();
} }
QSignalSpy spy(socket, SIGNAL(textMessageReceived(QString))); QSignalSpy spy(socket, &QWebSocket::textMessageReceived);
socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}"); socket->sendTextMessage("{\"id\":0, \"method\": \"JSONRPC.Hello\"}");
spy.wait(); spy.wait();

View File

@ -90,7 +90,7 @@ void NymeaTestBase::initTestCase(const QString &loggingRules, bool disableLogEng
NymeaCore::instance()->init(QStringList(), m_disableLogEngine); NymeaCore::instance()->init(QStringList(), m_disableLogEngine);
// Wait unitl the server is initialized // Wait unitl the server is initialized
QSignalSpy coreInitializedSpy(NymeaCore::instance(), SIGNAL(initialized())); QSignalSpy coreInitializedSpy(NymeaCore::instance(), &NymeaCore::initialized);
QVERIFY(coreInitializedSpy.wait()); QVERIFY(coreInitializedSpy.wait());
qApp->processEvents(); qApp->processEvents();
qCDebug(dcTests()) << "Nymea core instance initialized. Creating dummy user."; qCDebug(dcTests()) << "Nymea core instance initialized. Creating dummy user.";
@ -151,7 +151,7 @@ QVariant NymeaTestBase::injectAndWait(const QString &method, const QVariantMap &
call.insert("token", tokenOverride == "default" ? m_apiToken : tokenOverride); call.insert("token", tokenOverride == "default" ? m_apiToken : tokenOverride);
QJsonDocument jsonDoc = QJsonDocument::fromVariant(call); QJsonDocument jsonDoc = QJsonDocument::fromVariant(call);
QSignalSpy spy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy spy(m_mockTcpServer, &MockTcpServer::outgoingData);
m_mockTcpServer->injectData(clientId.isNull() ? m_clientId : clientId, jsonDoc.toJson(QJsonDocument::Compact) + "\n"); m_mockTcpServer->injectData(clientId.isNull() ? m_clientId : clientId, jsonDoc.toJson(QJsonDocument::Compact) + "\n");
@ -237,7 +237,7 @@ QVariant NymeaTestBase::getAndWait(const QNetworkRequest &request, const int &ex
connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkReply *reply = nam.get(request); QNetworkReply *reply = nam.get(request);
@ -275,7 +275,7 @@ QVariant NymeaTestBase::deleteAndWait(const QNetworkRequest &request, const int
connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QNetworkReply *reply = nam.deleteResource(request); QNetworkReply *reply = nam.deleteResource(request);
@ -310,7 +310,7 @@ QVariant NymeaTestBase::postAndWait(const QNetworkRequest &request, const QVaria
connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QByteArray payload = QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact); QByteArray payload = QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact);
@ -350,7 +350,7 @@ QVariant NymeaTestBase::putAndWait(const QNetworkRequest &request, const QVarian
connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) { connect(&nam, &QNetworkAccessManager::sslErrors, [](QNetworkReply *reply, const QList<QSslError> &) {
reply->ignoreSslErrors(); reply->ignoreSslErrors();
}); });
QSignalSpy clientSpy(&nam, SIGNAL(finished(QNetworkReply*))); QSignalSpy clientSpy(&nam, &QNetworkAccessManager::finished);
QByteArray payload = QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact); QByteArray payload = QJsonDocument::fromVariant(params).toJson(QJsonDocument::Compact);
@ -437,7 +437,7 @@ void NymeaTestBase::restartServer()
NymeaCore::instance()->destroy(NymeaCore::ShutdownReasonRestart); NymeaCore::instance()->destroy(NymeaCore::ShutdownReasonRestart);
qCDebug(dcTests()) << "Restarting server instance"; qCDebug(dcTests()) << "Restarting server instance";
NymeaCore::instance()->init(QStringList(), m_disableLogEngine); NymeaCore::instance()->init(QStringList(), m_disableLogEngine);
QSignalSpy coreSpy(NymeaCore::instance(), SIGNAL(initialized())); QSignalSpy coreSpy(NymeaCore::instance(), &NymeaCore::initialized);
coreSpy.wait(); coreSpy.wait();
m_mockTcpServer = MockTcpServer::servers().first(); m_mockTcpServer = MockTcpServer::servers().first();
m_mockTcpServer->clientConnected(m_clientId); m_mockTcpServer->clientConnected(m_clientId);

View File

@ -39,7 +39,7 @@
InputWatcher::InputWatcher(QObject *parent) : QObject(parent) InputWatcher::InputWatcher(QObject *parent) : QObject(parent)
{ {
m_notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this); m_notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this);
connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readyRead())); connect(m_notifier, &QSocketNotifier::activated, this, &InputWatcher::readyRead);
} }
void InputWatcher::readyRead() void InputWatcher::readyRead()

View File

@ -1,8 +1,17 @@
QT -= gui include(../../nymea.pri)
CONFIG += c++11 console
greaterThan(QT_MAJOR_VERSION, 5) {
# In Qt6 we need explictily add the gui module
# in order to have QColor available
# Fixme: maybe integrate QColor directly to get rid of the dependency
QT += gui
} else {
QT -= gui
}
CONFIG += console
CONFIG -= app_bundle CONFIG -= app_bundle
include(../../nymea.pri)
INCLUDEPATH += $$top_srcdir/libnymea $$top_builddir INCLUDEPATH += $$top_srcdir/libnymea $$top_builddir
# FIXME: Rebuilding types here so that we can build the nymea-plugininfocompiler # FIXME: Rebuilding types here so that we can build the nymea-plugininfocompiler