mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
* Refactor config API * Corrections * Test Qt 6.8 * Revert "Test Qt 6.8" This reverts commit eceebec49ecf1a3eda281a0630a9a7577b44ef0a. * Corrections 2 * Update Changelog * Add configFilter element for getconfig call * Do not create errors for DB updates when in read-only mode * Have configuration migration and validation before Hyperion starts * Correct Tests * Corrections * Add migration items * Correct windows build * Ensure that first instance as default one exists * Remove dependency between AuthManager and SSDPHandler * Correct typos * Address CodeQL findings * Replace CamkeSettings by Presets and provide debug scenarios
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
|
|
#include <db/MetaTable.h>
|
|
|
|
// qt
|
|
#include <QDateTime>
|
|
#include <QUuid>
|
|
#include <QNetworkInterface>
|
|
#include <QCryptographicHash>
|
|
|
|
MetaTable::MetaTable(QObject* parent)
|
|
: DBManager(parent)
|
|
{
|
|
setTable("meta");
|
|
createTable(QStringList()<<"uuid TEXT"<<"created_at TEXT");
|
|
};
|
|
|
|
QString MetaTable::getUUID() const
|
|
{
|
|
QVector<QVariantMap> results;
|
|
getRecords(results, QStringList() << "uuid");
|
|
|
|
for(const auto & entry : std::as_const(results))
|
|
{
|
|
if(!entry["uuid"].toString().isEmpty())
|
|
{
|
|
return entry["uuid"].toString();
|
|
}
|
|
}
|
|
|
|
// create new uuidv5 based on net adapter MAC, save to db and return
|
|
QString hash;
|
|
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
|
{
|
|
if (!(interface.flags() & QNetworkInterface::IsLoopBack))
|
|
{
|
|
hash = QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit(),QCryptographicHash::Sha1).toHex();
|
|
break;
|
|
}
|
|
}
|
|
const QString newUuid = QUuid::createUuidV5(QUuid(), hash).toString().mid(1, 36);
|
|
QVariantMap map;
|
|
map["created_at"] = QDateTime::currentDateTimeUtc().toString(Qt::ISODate);
|
|
|
|
createRecord({{"uuid",newUuid}}, map);
|
|
|
|
return newUuid;
|
|
}
|