unifi: Add Qt6 support

This commit is contained in:
Simon Stürz 2025-08-11 14:54:30 +02:00
parent 5cbb2db471
commit 673a25ef8d
3 changed files with 11 additions and 12 deletions

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -144,7 +144,7 @@ void IntegrationPluginUnifi::discoverThings(ThingDiscoveryInfo *info)
} else { } else {
QVariantList clients = response.value("data").toList(); QVariantList clients = response.value("data").toList();
foreach (const QVariant &clientVariant, clients) { foreach (const QVariant &clientVariant, clients) {
// qCDebug(dcUnifi()) << "client:" << qUtf8Printable(QJsonDocument::fromVariant(clientVariant).toJson()); // qCDebug(dcUnifi()) << "client:" << qUtf8Printable(QJsonDocument::fromVariant(clientVariant).toJson());
QString name = clientVariant.toMap().value("name").toString(); QString name = clientVariant.toMap().value("name").toString();
if (name.isEmpty()) { if (name.isEmpty()) {
@ -262,7 +262,7 @@ void IntegrationPluginUnifi::setupThing(ThingSetupInfo *info)
QNetworkReply *reply = hardwareManager()->networkManager()->post(request, QJsonDocument::fromVariant(login).toJson()); QNetworkReply *reply = hardwareManager()->networkManager()->post(request, QJsonDocument::fromVariant(login).toJson());
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
connect(reply, &QNetworkReply::finished, info, [this, info, reply](){ connect(reply, &QNetworkReply::finished, info, [info, reply](){
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
qCWarning(dcUnifi()) << "SetupThing: Network request error:" << reply->error() << reply->errorString(); qCWarning(dcUnifi()) << "SetupThing: Network request error:" << reply->error() << reply->errorString();
info->finish(Thing::ThingErrorHardwareFailure); info->finish(Thing::ThingErrorHardwareFailure);
@ -348,7 +348,7 @@ void IntegrationPluginUnifi::postSetupThing(Thing *thing)
return; return;
} }
// qCDebug(dcUnifi()) << "Client is present reply" << qUtf8Printable(jsonDoc.toJson()); // qCDebug(dcUnifi()) << "Client is present reply" << qUtf8Printable(jsonDoc.toJson());
QVariantList clientEntries = jsonDoc.toVariant().toMap().value("data").toList(); QVariantList clientEntries = jsonDoc.toVariant().toMap().value("data").toList();
if (clientEntries.count() != 1) { if (clientEntries.count() != 1) {
qCWarning(dcUnifi()) << "Client data not found in controller reply"; qCWarning(dcUnifi()) << "Client data not found in controller reply";

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -33,7 +33,7 @@
#include <QObject> #include <QObject>
#include "integrations/integrationplugin.h" #include <integrations/integrationplugin.h>
#include <QNetworkRequest> #include <QNetworkRequest>
@ -56,7 +56,6 @@ public:
void setupThing(ThingSetupInfo *info) override; void setupThing(ThingSetupInfo *info) override;
void postSetupThing(Thing *thing) override; void postSetupThing(Thing *thing) override;
void thingRemoved(Thing *thing) override; void thingRemoved(Thing *thing) override;
// void executeAction(ThingActionInfo *info) override;
private: private:
QNetworkRequest createRequest(const QString &address, uint port, const QString &path, const QString &prefix = QString()); QNetworkRequest createRequest(const QString &address, uint port, const QString &path, const QString &prefix = QString());
@ -64,8 +63,8 @@ private:
void markOffline(Thing *thing); void markOffline(Thing *thing);
private: private:
QHash<ThingDiscoveryInfo*, Things> m_pendingDiscoveries; QHash<ThingDiscoveryInfo *, Things> m_pendingDiscoveries;
QHash<Thing*, QStringList> m_pendingSiteDiscoveries; QHash<Thing *, QStringList> m_pendingSiteDiscoveries;
PluginTimer *m_loginTimer = nullptr; PluginTimer *m_loginTimer = nullptr;
PluginTimer *m_pollTimer = nullptr; PluginTimer *m_pollTimer = nullptr;

View File

@ -1,11 +1,11 @@
include(../plugins.pri) include(../plugins.pri)
QT += network QT *= network
HEADERS += \ HEADERS += \
integrationpluginunifi.h \ integrationpluginunifi.h
SOURCES += \ SOURCES += \
integrationpluginunifi.cpp \ integrationpluginunifi.cpp