coinmarketcap: Add Qt6 support

This commit is contained in:
Simon Stürz 2025-08-07 15:48:57 +02:00
parent f848502467
commit d212742a5a
3 changed files with 17 additions and 18 deletions

View File

@ -1,11 +1,9 @@
include(../plugins.pri) include(../plugins.pri)
QT += network QT *= network
TARGET = $$qtLibraryTarget(nymea_integrationplugincoinmarketcap)
SOURCES += \ SOURCES += \
integrationplugincoinmarketcap.cpp \ integrationplugincoinmarketcap.cpp
HEADERS += \ HEADERS += \
integrationplugincoinmarketcap.h \ integrationplugincoinmarketcap.h

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.
@ -29,9 +29,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationplugincoinmarketcap.h" #include "integrationplugincoinmarketcap.h"
#include "network/networkaccessmanager.h"
#include "plugininfo.h" #include "plugininfo.h"
#include <network/networkaccessmanager.h>
#include <QJsonDocument> #include <QJsonDocument>
IntegrationPluginCoinMarketCap::IntegrationPluginCoinMarketCap() IntegrationPluginCoinMarketCap::IntegrationPluginCoinMarketCap()
@ -44,7 +45,7 @@ void IntegrationPluginCoinMarketCap::startPairing(ThingPairingInfo *info)
NetworkAccessManager *network = hardwareManager()->networkManager(); NetworkAccessManager *network = hardwareManager()->networkManager();
QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://pro-api.coinmarketcap.com"))); QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://pro-api.coinmarketcap.com")));
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
connect(reply, &QNetworkReply::finished, this, [this, reply, info] { connect(reply, &QNetworkReply::finished, this, [reply, info] {
if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) { if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) {
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("CoinMarketCap server is not reachable.")); info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("CoinMarketCap server is not reachable."));
@ -175,31 +176,31 @@ void IntegrationPluginCoinMarketCap::onPriceCallFinished()
qCDebug(dcCoinMarketCap()) << "Name" << elementMap.value("name").toString(); qCDebug(dcCoinMarketCap()) << "Name" << elementMap.value("name").toString();
price = elementMap.value("quote").toMap().value(fiatCurrency).toMap().value("price").toDouble(); price = elementMap.value("quote").toMap().value(fiatCurrency).toMap().value("price").toDouble();
if (elementMap.value("name").toString() == "Bitcoin") { if (elementMap.value("name").toString() == "Bitcoin") {
qDebug(dcCoinMarketCap()) << "Bitcoin Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Bitcoin Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesBtcStateTypeId, price); thing->setStateValue(currentPricesBtcStateTypeId, price);
} else if (elementMap.value("name").toString() == "Ethereum") { } else if (elementMap.value("name").toString() == "Ethereum") {
qDebug(dcCoinMarketCap()) << "Etherium Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Etherium Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesEthStateTypeId, price); thing->setStateValue(currentPricesEthStateTypeId, price);
} else if (elementMap.value("name").toString() == "XRP") { } else if (elementMap.value("name").toString() == "XRP") {
qDebug(dcCoinMarketCap()) << "XRP Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "XRP Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesXrpStateTypeId, price); thing->setStateValue(currentPricesXrpStateTypeId, price);
} else if (elementMap.value("name").toString() == "Bitcoin Cash") { } else if (elementMap.value("name").toString() == "Bitcoin Cash") {
qDebug(dcCoinMarketCap()) << "Bitcoin-cash Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Bitcoin-cash Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesBchStateTypeId, price); thing->setStateValue(currentPricesBchStateTypeId, price);
} else if (elementMap.value("name").toString() == "Litecoin") { } else if (elementMap.value("name").toString() == "Litecoin") {
qDebug(dcCoinMarketCap()) << "Litecoin Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Litecoin Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesLtcStateTypeId, price); thing->setStateValue(currentPricesLtcStateTypeId, price);
} else if (elementMap.value("name").toString() == "NEM") { } else if (elementMap.value("name").toString() == "NEM") {
qDebug(dcCoinMarketCap()) << "Nem Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Nem Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesXemStateTypeId, price); thing->setStateValue(currentPricesXemStateTypeId, price);
} else if (elementMap.value("name").toString() == "Ethereum Classic") { } else if (elementMap.value("name").toString() == "Ethereum Classic") {
qDebug(dcCoinMarketCap()) << "Ethereum Classic Price in" << fiatCurrency << price; qCDebug(dcCoinMarketCap()) << "Ethereum Classic Price in" << fiatCurrency << price;
thing->setStateValue(currentPricesEtcStateTypeId, price); thing->setStateValue(currentPricesEtcStateTypeId, price);
} else if (elementMap.value("name").toString() == "Dash") { } else if (elementMap.value("name").toString() == "Dash") {

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.
@ -31,8 +31,8 @@
#ifndef INTEGRATIONPLUGINCOINMARKETCAP_H #ifndef INTEGRATIONPLUGINCOINMARKETCAP_H
#define INTEGRATIONPLUGINCOINMARKETCAP_H #define INTEGRATIONPLUGINCOINMARKETCAP_H
#include "integrations/integrationplugin.h" #include <integrations/integrationplugin.h>
#include "plugintimer.h" #include <plugintimer.h>
#include <QNetworkReply> #include <QNetworkReply>
#include <QHostInfo> #include <QHostInfo>