Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
@@ -8,15 +8,15 @@
|
||||
|
||||
namespace LtsLicence
|
||||
{
|
||||
static bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec);
|
||||
static bool extractLicence(const QDomElement &licenceElement, QVector<Licence> &licenceVec);
|
||||
|
||||
static NGL::INGLLogger& getLogger()
|
||||
{
|
||||
static NGL::INGLLogger &getLogger()
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LtsLicence");
|
||||
}
|
||||
}
|
||||
|
||||
QVector<Licence> readLicences(const QByteArray& unencryptedXmlData)
|
||||
{
|
||||
QVector<Licence> readLicences(const QByteArray &unencryptedXmlData)
|
||||
{
|
||||
QVector<Licence> licenceVec;
|
||||
|
||||
QDomDocument xmlDoc;
|
||||
@@ -24,10 +24,10 @@ QVector<Licence> readLicences(const QByteArray& unencryptedXmlData)
|
||||
const auto parseResult = xmlDoc.setContent(unencryptedXmlData);
|
||||
if (!parseResult)
|
||||
{
|
||||
ERROR_LOG(getLogger()) << "Error reading xml data, "
|
||||
<< "error in line " << int(parseResult.errorLine) << ", column " << int(parseResult.errorColumn)
|
||||
<< ", message: " << parseResult.errorMessage;
|
||||
return licenceVec;
|
||||
ERROR_LOG(getLogger()) << "Error reading xml data, "
|
||||
<< "error in line " << int(parseResult.errorLine) << ", column " << int(parseResult.errorColumn)
|
||||
<< ", message: " << parseResult.errorMessage;
|
||||
return licenceVec;
|
||||
}
|
||||
|
||||
INFO_LOG(getLogger()) << "Try to extract licences";
|
||||
@@ -36,23 +36,22 @@ QVector<Licence> readLicences(const QByteArray& unencryptedXmlData)
|
||||
|
||||
while (!licenceElement.isNull())
|
||||
{
|
||||
if (!extractLicence(licenceElement, licenceVec))
|
||||
{
|
||||
licenceVec.clear();
|
||||
return licenceVec;
|
||||
}
|
||||
if (!extractLicence(licenceElement, licenceVec))
|
||||
{
|
||||
licenceVec.clear();
|
||||
return licenceVec;
|
||||
}
|
||||
|
||||
licenceElement = licenceElement.nextSiblingElement(QLatin1String("licence"));
|
||||
licenceElement = licenceElement.nextSiblingElement(QLatin1String("licence"));
|
||||
}
|
||||
return licenceVec;
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray writeUnencryptedLicences(const QVector<Licence>& licences)
|
||||
{
|
||||
QByteArray writeUnencryptedLicences(const QVector<Licence> &licences)
|
||||
{
|
||||
QDomDocument xmlDoc;
|
||||
|
||||
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(
|
||||
QLatin1String("xml"), QLatin1String("version='1.0' encoding='UTF-8' standalone='yes'"));
|
||||
QDomProcessingInstruction instr = xmlDoc.createProcessingInstruction(QLatin1String("xml"), QLatin1String("version='1.0' encoding='UTF-8' standalone='yes'"));
|
||||
xmlDoc.appendChild(instr);
|
||||
|
||||
QDomElement root = xmlDoc.createElement(QLatin1String("licences"));
|
||||
@@ -60,43 +59,43 @@ QByteArray writeUnencryptedLicences(const QVector<Licence>& licences)
|
||||
|
||||
for (int i = 0; i < licences.size(); ++i)
|
||||
{
|
||||
QDomElement lic = xmlDoc.createElement(QLatin1String("licence"));
|
||||
root.appendChild(lic);
|
||||
QDomElement lic = xmlDoc.createElement(QLatin1String("licence"));
|
||||
root.appendChild(lic);
|
||||
|
||||
QDomElement element = xmlDoc.createElement(QLatin1String("name"));
|
||||
QDomText text = xmlDoc.createTextNode(licences[i].name);
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
QDomElement element = xmlDoc.createElement(QLatin1String("name"));
|
||||
QDomText text = xmlDoc.createTextNode(licences[i].name);
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
|
||||
element = xmlDoc.createElement(QLatin1String("ignoreMaxCount"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreMaxCount));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
element = xmlDoc.createElement(QLatin1String("ignoreMaxCount"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreMaxCount));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
|
||||
element = xmlDoc.createElement(QLatin1String("ignoreExpiration"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreExpiration));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
element = xmlDoc.createElement(QLatin1String("ignoreExpiration"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].ignoreExpiration));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
|
||||
element = xmlDoc.createElement(QLatin1String("maxCount"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].maxCount));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
element = xmlDoc.createElement(QLatin1String("maxCount"));
|
||||
text = xmlDoc.createTextNode(QString::number(licences[i].maxCount));
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
|
||||
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
||||
const QString qs = licences[i].expiration.toString(format);
|
||||
const QLatin1String format("dd.MM.yyyy hh:mm:ss");
|
||||
const QString qs = licences[i].expiration.toString(format);
|
||||
|
||||
element = xmlDoc.createElement(QLatin1String("expiration"));
|
||||
text = xmlDoc.createTextNode(qs);
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
element = xmlDoc.createElement(QLatin1String("expiration"));
|
||||
text = xmlDoc.createTextNode(qs);
|
||||
element.appendChild(text);
|
||||
lic.appendChild(element);
|
||||
}
|
||||
INFO_LOG(getLogger()) << "Generated XML Data...\n" << xmlDoc.toByteArray();
|
||||
return xmlDoc.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licenceVec)
|
||||
{
|
||||
bool extractLicence(const QDomElement &licenceElement, QVector<Licence> &licenceVec)
|
||||
{
|
||||
Licence licence;
|
||||
|
||||
QDomElement tag = licenceElement.firstChildElement(QLatin1String("name"));
|
||||
@@ -120,29 +119,28 @@ bool extractLicence(const QDomElement& licenceElement, QVector<Licence>& licence
|
||||
|
||||
if (!qdt.isValid())
|
||||
{
|
||||
ERROR_LOG(getLogger()) << "Invalid expiration format! " << qs << " used format: " << format;
|
||||
return false;
|
||||
ERROR_LOG(getLogger()) << "Invalid expiration format! " << qs << " used format: " << format;
|
||||
return false;
|
||||
}
|
||||
|
||||
licence.expiration = qdt;
|
||||
INFO_LOG(getLogger()) << "Read licence for:'" << licence.name << "'"
|
||||
<< " IgnoreMaxCount: " << licence.ignoreMaxCount
|
||||
<< " IgnoreExpiration: " << licence.ignoreExpiration << " MaxCount: " << licence.maxCount
|
||||
<< " Expiration: " << licence.expiration.date().toString() << " "
|
||||
<< licence.expiration.time().toString() << " RefCount: " << licence.licenceRefCount;
|
||||
<< " IgnoreMaxCount: " << licence.ignoreMaxCount << " IgnoreExpiration: " << licence.ignoreExpiration << " MaxCount: " << licence.maxCount
|
||||
<< " Expiration: " << licence.expiration.date().toString() << " " << licence.expiration.time().toString()
|
||||
<< " RefCount: " << licence.licenceRefCount;
|
||||
|
||||
licenceVec.append(licence);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QString Licence::toString() const
|
||||
{
|
||||
QString Licence::toString() const
|
||||
{
|
||||
return QObject::tr("Name: %1, Count: %2, ExpireDate: %3, Expires: %4, UseMaxCount: %5")
|
||||
.arg(name)
|
||||
.arg(maxCount)
|
||||
.arg(expiration.toString())
|
||||
.arg(ignoreExpiration)
|
||||
.arg(ignoreMaxCount);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LtsLicence
|
||||
Reference in new issue
Block a user