MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / getUUID

Method getUUID

sources/db/MetaTable.cpp:14–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12};
13
14QString MetaTable::getUUID() const
15{
16 QVector<QVariantMap> results;
17 getRecords(results, QStringList() << "uuid");
18
19 for (const auto& entry : results)
20 {
21 if (!entry["uuid"].toString().isEmpty())
22 return entry["uuid"].toString();
23 }
24
25 // create new uuidv5 based on net adapter MAC, save to db and return
26 QString hash;
27 foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
28 {
29 if (!(interface.flags() & QNetworkInterface::IsLoopBack))
30 {
31 hash = QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit(), QCryptographicHash::Sha1).toHex();
32 break;
33 }
34 }
35 const QString newUuid = QUuid::createUuidV5(QUuid(), hash).toString().mid(1, 36);
36 VectorPair cond;
37 cond.append(CPair("uuid", newUuid));
38 QVariantMap map;
39 map["created_at"] = QDateTime::currentDateTimeUtc().toString(Qt::ISODate);
40 createRecord(cond, map);
41
42 return newUuid;
43}
44

Callers 1

AccessManagerMethod · 0.80

Calls 2

isEmptyMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected