mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
fix mess
This commit is contained in:
parent
e2ca9bcaa5
commit
a7f72a7bf2
@ -1,11 +1,9 @@
|
|||||||
// qt includes
|
// qt includes
|
||||||
#include <QDebug>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QEventLoop>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
// hyperion includes
|
// hyperion includes
|
||||||
@ -22,13 +20,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
Logger* _log;
|
Logger* _log;
|
||||||
QString _hash = "";
|
QString _hash = "";
|
||||||
|
QByteArray _ba;
|
||||||
|
QNetworkRequest _req;
|
||||||
QNetworkAccessManager _mgr;
|
QNetworkAccessManager _mgr;
|
||||||
|
|
||||||
bool trigger(bool set = false);
|
bool trigger(bool set = false);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendHTTP(bool put = false);
|
void sendHTTP();
|
||||||
|
void sendHTTPp();
|
||||||
void resolveReply(QNetworkReply *reply);
|
void resolveReply(QNetworkReply *reply);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ void EffectEngine::readEffects()
|
|||||||
Warning(_log, "Failed to create Effect path \"%s\", please check permissions",path.toUtf8().constData() );
|
Warning(_log, "Failed to create Effect path \"%s\", please check permissions",path.toUtf8().constData() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (directory.exists(path))
|
else
|
||||||
{
|
{
|
||||||
int efxCount = 0;
|
int efxCount = 0;
|
||||||
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||||
@ -336,10 +336,6 @@ void EffectEngine::readEffects()
|
|||||||
if (efxCount > 0)
|
if (efxCount > 0)
|
||||||
Info(_log, "%d effect schemas loaded from directory %s", efxCount, (path + "schema/").toUtf8().constData());
|
Info(_log, "%d effect schemas loaded from directory %s", efxCount, (path + "schema/").toUtf8().constData());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Warning(_log, "Effect path \"%s\" does not exist",path.toUtf8().constData() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(auto item, availableEffects)
|
foreach(auto item, availableEffects)
|
||||||
|
@ -19,7 +19,6 @@ Stats::Stats()
|
|||||||
, _log(Logger::getInstance("STATS"))
|
, _log(Logger::getInstance("STATS"))
|
||||||
{
|
{
|
||||||
// generate hash
|
// generate hash
|
||||||
QString hash;
|
|
||||||
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
||||||
{
|
{
|
||||||
if (!(interface.flags() & QNetworkInterface::IsLoopBack))
|
if (!(interface.flags() & QNetworkInterface::IsLoopBack))
|
||||||
@ -36,35 +35,12 @@ Stats::Stats()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(&_mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(resolveReply(QNetworkReply*)));
|
// prepare content
|
||||||
|
|
||||||
// 7 days interval
|
|
||||||
QTimer *timer = new QTimer(this);
|
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(sendHTTP()));
|
|
||||||
timer->start(604800000);
|
|
||||||
|
|
||||||
// check instant execution required
|
|
||||||
if(trigger())
|
|
||||||
{
|
|
||||||
QTimer::singleShot(0, this, [=]() {
|
|
||||||
sendHTTP();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Stats::~Stats()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stats::sendHTTP(bool put)
|
|
||||||
{
|
|
||||||
QJsonObject config = Hyperion::getInstance()->getConfig();
|
QJsonObject config = Hyperion::getInstance()->getConfig();
|
||||||
SysInfo::HyperionSysInfo data = SysInfo::get();
|
SysInfo::HyperionSysInfo data = SysInfo::get();
|
||||||
|
|
||||||
QJsonObject system;
|
QJsonObject system;
|
||||||
system["kType" ] = data.kernelType;
|
system["kType" ] = data.kernelType;
|
||||||
//system["kernelVersion" ] = data.kernelVersion;
|
|
||||||
system["arch" ] = data.architecture;
|
system["arch" ] = data.architecture;
|
||||||
system["pType" ] = data.productType;
|
system["pType" ] = data.productType;
|
||||||
system["pVersion" ] = data.productVersion;
|
system["pVersion" ] = data.productVersion;
|
||||||
@ -82,24 +58,43 @@ void Stats::sendHTTP(bool put)
|
|||||||
system["comp_uc" ] = config["grabberV4L2"].toArray().at(0).toObject().take("enable");
|
system["comp_uc" ] = config["grabberV4L2"].toArray().at(0).toObject().take("enable");
|
||||||
|
|
||||||
QJsonDocument doc(system);
|
QJsonDocument doc(system);
|
||||||
QByteArray ba = doc.toJson();
|
_ba = doc.toJson();
|
||||||
|
|
||||||
QNetworkRequest req;
|
// QNetworkRequest Header
|
||||||
req.setRawHeader("Content-Type", "application/json");
|
_req.setRawHeader("Content-Type", "application/json");
|
||||||
req.setRawHeader("Authorization", "Basic SHlwZXJpb25YbDQ5MlZrcXA6ZDQxZDhjZDk4ZjAwYjIw");
|
_req.setRawHeader("Authorization", "Basic SHlwZXJpb25YbDQ5MlZrcXA6ZDQxZDhjZDk4ZjAwYjIw");
|
||||||
|
|
||||||
if(put)
|
connect(&_mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(resolveReply(QNetworkReply*)));
|
||||||
|
|
||||||
|
// 7 days interval
|
||||||
|
QTimer *timer = new QTimer(this);
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(sendHTTP()));
|
||||||
|
timer->start(604800000);
|
||||||
|
|
||||||
|
// check instant execution required
|
||||||
|
if(trigger())
|
||||||
{
|
{
|
||||||
req.setUrl(QUrl("https://api.hyperion-project.org/api/stats/"+_hash));
|
QTimer::singleShot(0,this, SLOT(sendHTTP()));
|
||||||
_mgr.put(req,ba);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
req.setUrl(QUrl("https://api.hyperion-project.org/api/stats"));
|
|
||||||
_mgr.post(req,ba);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stats::~Stats()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stats::sendHTTP()
|
||||||
|
{
|
||||||
|
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats"));
|
||||||
|
_mgr.post(_req,_ba);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stats::sendHTTPp()
|
||||||
|
{
|
||||||
|
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats/"+_hash));
|
||||||
|
_mgr.put(_req,_ba);
|
||||||
|
}
|
||||||
|
|
||||||
void Stats::resolveReply(QNetworkReply *reply)
|
void Stats::resolveReply(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
if (reply->error() == QNetworkReply::NoError)
|
if (reply->error() == QNetworkReply::NoError)
|
||||||
@ -109,10 +104,7 @@ void Stats::resolveReply(QNetworkReply *reply)
|
|||||||
// already created, update entry
|
// already created, update entry
|
||||||
if(reply->readAll().startsWith("null"))
|
if(reply->readAll().startsWith("null"))
|
||||||
{
|
{
|
||||||
//bool put = true;
|
QTimer::singleShot(0, this, SLOT(sendHTTPp()));
|
||||||
QTimer::singleShot(0, this, [=]() {
|
|
||||||
sendHTTP(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user