mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-26 17:54:38 +00:00
fix warnings
This commit is contained in:
parent
0629079687
commit
21d07c2b30
@ -95,7 +95,7 @@ bool BigDataParser::newPackage(const QSharedPointer<PKG::BigDataHeader> &header,
|
|||||||
request.setCurrentPart(0);
|
request.setCurrentPart(0);
|
||||||
request.setPackageId(header->packageId());
|
request.setPackageId(header->packageId());
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Receive BigData Header:" + header->toString());
|
qDebug() << "Receive BigData Header:" << header->toString();
|
||||||
|
|
||||||
return node()->sendData(&request, sender, &hdr);
|
return node()->sendData(&request, sender, &hdr);
|
||||||
}
|
}
|
||||||
@ -112,10 +112,7 @@ bool BigDataParser::processPart(const QSharedPointer<PKG::BigDataPart> &part,
|
|||||||
|
|
||||||
auto& localPool = _pool[part->packageId()];
|
auto& localPool = _pool[part->packageId()];
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(QString("Process Part of %0: part %1/%2").
|
qDebug () << "Process Part of" << part->packageId() << ": part" << part->getPakckageNumber() << "/" << localPool.chaindata.size() - 1;
|
||||||
arg(part->packageId()).
|
|
||||||
arg(part->getPakckageNumber()).
|
|
||||||
arg(localPool.chaindata.size() - 1));
|
|
||||||
|
|
||||||
localPool.chaindata[part->getPakckageNumber()] = part;
|
localPool.chaindata[part->getPakckageNumber()] = part;
|
||||||
|
|
||||||
@ -167,7 +164,7 @@ bool BigDataParser::processRequest(const QSharedPointer<PKG::BigDataRequest> &re
|
|||||||
unsigned int id = request->packageId();
|
unsigned int id = request->packageId();
|
||||||
|
|
||||||
if (!_pool.contains(id)) {
|
if (!_pool.contains(id)) {
|
||||||
QuasarAppUtils::Params::log("requested data is missing!");
|
qDebug() << "requested data is missing!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ bool QH::DataSender::sendPackagePrivate(QByteArray array, void *target) const {
|
|||||||
auto ptr = static_cast<QAbstractSocket*>(target);
|
auto ptr = static_cast<QAbstractSocket*>(target);
|
||||||
|
|
||||||
if (!(ptr && ptr->isValid() && ptr->isWritable())) {
|
if (!(ptr && ptr->isValid() && ptr->isWritable())) {
|
||||||
QuasarAppUtils::Params::log("Send raw data error. Socket is invalid", QuasarAppUtils::Error);
|
qCritical() << "Send raw data error. Socket is invalid";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,13 +37,12 @@ bool QH::DataSender::sendPackagePrivate(QByteArray array, void *target) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ptr->flush()) {
|
if (!ptr->flush()) {
|
||||||
QuasarAppUtils::Params::log("Send raw data error. data not flushed", QuasarAppUtils::Error);
|
qCritical() << "Send raw data error. data not flushed";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array.size() != wrote) {
|
if (array.size() != wrote) {
|
||||||
QuasarAppUtils::Params::log("not writed data to socket", QuasarAppUtils::Error);
|
qCritical() << "Send raw data error. not all data writed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +116,10 @@ bool AbstractNode::run(const QString &addres, unsigned short port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!listen(adr)) {
|
if (!listen(adr)) {
|
||||||
QuasarAppUtils::Params::log("Run fail " + this->errorString(),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Address:: " + adr.toString(),
|
qCritical() << "Run fail " << this->errorString();
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "Address:: " << adr.toString();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,9 +255,9 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port,
|
|||||||
QHostInfo::lookupHost(domain, [this, port, domain, action, status](QHostInfo info) {
|
QHostInfo::lookupHost(domain, [this, port, domain, action, status](QHostInfo info) {
|
||||||
|
|
||||||
if (info.error() != QHostInfo::NoError) {
|
if (info.error() != QHostInfo::NoError) {
|
||||||
QuasarAppUtils::Params::log("The domain name :" + domain +
|
|
||||||
" has error: " + info.errorString(),
|
qCritical() << "The domain name :" + domain +
|
||||||
QuasarAppUtils::Error);
|
" has error: " + info.errorString();
|
||||||
addNodeFailed(AddNodeError::HostNotFound);
|
addNodeFailed(AddNodeError::HostNotFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -266,9 +265,8 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port,
|
|||||||
auto addresses = info.addresses();
|
auto addresses = info.addresses();
|
||||||
|
|
||||||
if (addresses.size() > 1) {
|
if (addresses.size() > 1) {
|
||||||
QuasarAppUtils::Params::log("The domain name :" + domain +
|
qWarning() << "The domain name :" + domain +
|
||||||
" has more 1 ip addresses.",
|
" has more 1 ip addresses.";
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action) {
|
if (action) {
|
||||||
@ -571,14 +569,13 @@ bool AbstractNode::sendPackage(const Package &pkg, QAbstractSocket *target) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!target || !target->isValid()) {
|
if (!target || !target->isValid()) {
|
||||||
QuasarAppUtils::Params::log("destination server not valid!",
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "Destination server not valid!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target->waitForConnected()) {
|
if (!target->waitForConnected()) {
|
||||||
QuasarAppUtils::Params::log("no connected to server! " + target->errorString(),
|
qCritical() << "no connected to server! " + target->errorString();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +593,7 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp,
|
|||||||
const Header *req) {
|
const Header *req) {
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
QuasarAppUtils::Params::log("Response not sent because client == null");
|
qDebug() << "Response not sent because client == null";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,15 +622,12 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp,
|
|||||||
|
|
||||||
return BIG_DATA_HASH_ID;
|
return BIG_DATA_HASH_ID;
|
||||||
}
|
}
|
||||||
|
qCritical() << "Response not sent because dont create package from object";
|
||||||
QuasarAppUtils::Params::log("Response not sent because dont create package from object",
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sendPackage(pkg, node->sct())) {
|
if (!sendPackage(pkg, node->sct())) {
|
||||||
QuasarAppUtils::Params::log("Response not sent!",
|
qCritical() << "Response not sent!";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,13 +639,13 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req,
|
|||||||
|
|
||||||
if (!changeTrust(address, diff)) {
|
if (!changeTrust(address, diff)) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Bad request detected, bud response command not sent!"
|
|
||||||
" because trust not changed",
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("SECURITY LOG: Force block the " + address.toString() +
|
qCritical() << "Bad request detected, bud response command not sent!"
|
||||||
" because trust defined",
|
" because trust not changed";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
|
qCritical() << "SECURITY LOG: Force block the " + address.toString() +
|
||||||
|
" because trust defined";
|
||||||
|
|
||||||
ban(address);
|
ban(address);
|
||||||
|
|
||||||
@ -665,9 +659,7 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Bad request sendet to adderess: " +
|
qInfo() << "Bad request sendet to adderess: " + address.toString();
|
||||||
address.toString(),
|
|
||||||
QuasarAppUtils::Info);
|
|
||||||
|
|
||||||
if (fCloseConnectionAfterBadRequest()) {
|
if (fCloseConnectionAfterBadRequest()) {
|
||||||
removeNode(node);
|
removeNode(node);
|
||||||
@ -776,8 +768,7 @@ void AbstractNode::incomingConnection(qintptr handle) {
|
|||||||
socket->setSocketDescriptor(handle);
|
socket->setSocketDescriptor(handle);
|
||||||
|
|
||||||
if (isBanned(getInfoPtr(HostAddress{socket->peerAddress(), socket->peerPort()}))) {
|
if (isBanned(getInfoPtr(HostAddress{socket->peerAddress(), socket->peerPort()}))) {
|
||||||
QuasarAppUtils::Params::log("Income connection from banned address",
|
qCritical() << "Income connection from banned address";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
return false;
|
return false;
|
||||||
@ -785,8 +776,7 @@ void AbstractNode::incomingConnection(qintptr handle) {
|
|||||||
|
|
||||||
if (!registerSocket(socket)) {
|
if (!registerSocket(socket)) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Failed to register new socket",
|
qCritical() << "Failed to register new socket";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
delete socket;
|
delete socket;
|
||||||
return false;
|
return false;
|
||||||
@ -903,8 +893,7 @@ void AbstractNode::avelableBytes(AbstractNodeInfo *sender) {
|
|||||||
pkg.reset();
|
pkg.reset();
|
||||||
hdrArray.clear();
|
hdrArray.clear();
|
||||||
} else if (static_cast<unsigned int>(pkg.data.size()) >= pkg.hdr.size) {
|
} else if (static_cast<unsigned int>(pkg.data.size()) >= pkg.hdr.size) {
|
||||||
QuasarAppUtils::Params::log("Invalid Package received." + pkg.toString(),
|
qWarning() << "Invalid Package received." + pkg.toString();
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
pkg.reset();
|
pkg.reset();
|
||||||
hdrArray.clear();
|
hdrArray.clear();
|
||||||
changeTrust(id, CRITICAL_ERROOR);
|
changeTrust(id, CRITICAL_ERROOR);
|
||||||
@ -968,9 +957,9 @@ AbstractNode::prepareData(const Package &pkg,
|
|||||||
|
|
||||||
auto value = _apiVersionParser->searchPackage(pkg.hdr.command, sender);
|
auto value = _apiVersionParser->searchPackage(pkg.hdr.command, sender);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
QuasarAppUtils::Params::log("You try parse not registered package type."
|
qDebug() << "Package type not registered!"
|
||||||
" Plese use the registerPackageType method befor parsing."
|
" Please use the registerPackageType method before parsing."
|
||||||
" Example invoke registerPackageType<MyData>() into constructor of you client and server nodes.");
|
" Example invoke registerPackageType<MyData>() into constructor of you client and server nodes.";
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1003,21 +992,18 @@ void AbstractNode::addNodeFailed(AddNodeError error) {
|
|||||||
|
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case AddNodeError::HostNotFound: {
|
case AddNodeError::HostNotFound: {
|
||||||
QuasarAppUtils::Params::log("The remote host not found or dns server not responce.",
|
qCritical() << "The remote host not found or dns server not responce.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case AddNodeError::RegisterSocketFailed: {
|
case AddNodeError::RegisterSocketFailed: {
|
||||||
QuasarAppUtils::Params::log("The remote node is banned or serve is overload.",
|
qCritical() << "The remote node is banned or serve is overload.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
QuasarAppUtils::Params::log("The unknown error ocurred.",
|
qCritical() << "The unknown error ocurred.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1072,7 +1058,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender,
|
|||||||
auto message = QString("Package not parsed! %0 \nresult: %1. \n%2").
|
auto message = QString("Package not parsed! %0 \nresult: %1. \n%2").
|
||||||
arg(pkg.toString(), iParser::pareseResultToString(parseResult), data->toString());
|
arg(pkg.toString(), iParser::pareseResultToString(parseResult), data->toString());
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(message, QuasarAppUtils::Info);
|
qInfo() << message;
|
||||||
|
|
||||||
if (parseResult == ParserResult::Error) {
|
if (parseResult == ParserResult::Error) {
|
||||||
|
|
||||||
@ -1093,7 +1079,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
QuasarAppUtils::Params::log(_apiVersionParser->toString(), QuasarAppUtils::Info);
|
qInfo() << _apiVersionParser->toString();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1181,8 +1167,7 @@ void AbstractNode::nodeConfirmend(AbstractNodeInfo *node) {
|
|||||||
|
|
||||||
void AbstractNode::nodeConnected(AbstractNodeInfo *node) {
|
void AbstractNode::nodeConnected(AbstractNodeInfo *node) {
|
||||||
if (!_apiVersionParser->sendSupportedAPI(node)) {
|
if (!_apiVersionParser->sendSupportedAPI(node)) {
|
||||||
QuasarAppUtils::Params::log("Failed to sent version information to dist node",
|
qCritical() << "Failed to sent version information to dist node";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
||||||
@ -1201,9 +1186,7 @@ void AbstractNode::nodeErrorOccured(AbstractNodeInfo *nodeInfo,
|
|||||||
Q_UNUSED(errorCode)
|
Q_UNUSED(errorCode)
|
||||||
|
|
||||||
QString message("Network error occured on the %0 node. Message: %1");
|
QString message("Network error occured on the %0 node. Message: %1");
|
||||||
QuasarAppUtils::Params::log(
|
qCritical() << message.arg(nodeInfo->networkAddress().toString(), errorString);
|
||||||
message.arg(nodeInfo->networkAddress().toString(), errorString),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
auto &actions = _connectActions[NodeCoonectionStatus::Connected];
|
||||||
actions.remove(nodeInfo->networkAddress());
|
actions.remove(nodeInfo->networkAddress());
|
||||||
|
@ -208,8 +208,7 @@ void AbstractNodeInfo::setTrust(int trust) {
|
|||||||
_trust = trust;
|
_trust = trust;
|
||||||
|
|
||||||
if (isBanned() && _sct) {
|
if (isBanned() && _sct) {
|
||||||
QuasarAppUtils::Params::log(QString("The node %0 is banned!").
|
qDebug() << "The node" << _sct->peerAddress().toString() << "is banned!";
|
||||||
arg(_sct->peerAddress().toString()));
|
|
||||||
|
|
||||||
removeSocket();
|
removeSocket();
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,7 @@ ParserResult APIVersionParser::parsePackage(const QSharedPointer<PKG::AbstractDa
|
|||||||
const auto parser = selectParser(pkg->cmd(), sender);
|
const auto parser = selectParser(pkg->cmd(), sender);
|
||||||
|
|
||||||
if (!parser) {
|
if (!parser) {
|
||||||
QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions"),
|
qWarning () << "Can't found requeried parser for versions";
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
return ParserResult::NotProcessed;
|
return ParserResult::NotProcessed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +100,7 @@ APIVersionParser::searchPackage(unsigned short cmd,
|
|||||||
|
|
||||||
for (const auto& parser: parsers) {
|
for (const auto& parser: parsers) {
|
||||||
if (!parser) {
|
if (!parser) {
|
||||||
QuasarAppUtils::Params::log(QString("Internal Error with selection parasers."),
|
qCritical() << "Internal Error with selection parasers.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +146,7 @@ bool QH::APIVersionParser::commandsValidation(const QSharedPointer<iParser> &par
|
|||||||
arg(parser->parserId()).
|
arg(parser->parserId()).
|
||||||
arg(parser->version());
|
arg(parser->version());
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(err, QuasarAppUtils::Error);
|
qCritical() << err;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -318,11 +316,7 @@ bool APIVersionParser::processAppVersion(const QSharedPointer<PKG::APIVersion> &
|
|||||||
if (!parser.contains(*parserKey)) {
|
if (!parser.contains(*parserKey)) {
|
||||||
auto requiredApi = distVersion.value(*parserKey);
|
auto requiredApi = distVersion.value(*parserKey);
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(QString("Can't found %0 parser for versions: %1-%2").
|
qCritical() << "Can't found required parser for versions: " << *parserKey << requiredApi.min() << requiredApi.max();
|
||||||
arg(*parserKey).
|
|
||||||
arg(requiredApi.min()).
|
|
||||||
arg(requiredApi.max()),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
unsigned short distMinVersion = sender->version().value(*parserKey).min();
|
unsigned short distMinVersion = sender->version().value(*parserKey).min();
|
||||||
|
|
||||||
|
@ -85,8 +85,7 @@ bool Async::asyncLauncher(const Async::Job &job, bool await, bool freaze) const
|
|||||||
|
|
||||||
if (!thread()->isRunning()) {
|
if (!thread()->isRunning()) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("The work threand of the async object is not running",
|
qCritical() << "The work threand of the async object is not running";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,11 @@ bool DataBase::initSqlDb(QString DBparamsFile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!upgradeDataBase()) {
|
if (!upgradeDataBase()) {
|
||||||
QuasarAppUtils::Params::log("Failed to upgrade database",
|
qCritical() << "Failed to upgrade database";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(QString("Database loaded from: %0").arg(dbLocation()),
|
qDebug() << "Database loaded from: " << dbLocation();
|
||||||
QuasarAppUtils::Debug);
|
|
||||||
|
|
||||||
connect(_db, &ISqlDB::sigItemChanged,
|
connect(_db, &ISqlDB::sigItemChanged,
|
||||||
this, &DataBase::sigObjectChanged,
|
this, &DataBase::sigObjectChanged,
|
||||||
@ -222,10 +220,9 @@ bool DataBase::upgradeDataBase() {
|
|||||||
|
|
||||||
if (!fsupportUpgrade) {
|
if (!fsupportUpgrade) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("The data base of application do not support soft upgrade. "
|
qCritical() << "The data base of application do not support soft upgrade. "
|
||||||
"Please remove database monyaly and restart application."
|
"Please remove database monyaly and restart application."
|
||||||
"You can disable upgrade functions for this override the upgradeDataBase method. ",
|
"You can disable upgrade functions for this override the upgradeDataBase method. ";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,20 +240,17 @@ bool DataBase::upgradeDataBase() {
|
|||||||
auto patches = patchesPack.value(currentVersion, {});
|
auto patches = patchesPack.value(currentVersion, {});
|
||||||
|
|
||||||
if (!patches.size()) {
|
if (!patches.size()) {
|
||||||
QuasarAppUtils::Params::log("Failed to " + message.arg("Unknown", "Required patch not found!"),
|
qCritical() << "Failed to " + message.arg("Unknown", "Required patch not found!");
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto patch = patches.last();
|
auto patch = patches.last();
|
||||||
message = message.arg(patch.versionTo);
|
message = message.arg(patch.versionTo);
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(message.arg("(Begin)"),
|
qInfo() << message.arg("(Begin)");
|
||||||
QuasarAppUtils::Info);
|
|
||||||
|
|
||||||
if (!patch.action(db())) {
|
if (!patch.action(db())) {
|
||||||
QuasarAppUtils::Params::log("Failed to " + message.arg("Patch finished with error code!"),
|
qCritical() << "Failed to " + message.arg("Patch finished with error code!");
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +305,8 @@ bool DataBase::setDBAttribute(const QString& key, const QVariant& newValue) {
|
|||||||
"value", newValue, "name");
|
"value", newValue, "name");
|
||||||
|
|
||||||
if (!_db->replaceObject(updateVersionRequest, true)) {
|
if (!_db->replaceObject(updateVersionRequest, true)) {
|
||||||
QuasarAppUtils::Params::log(QString("Failed to update %0 attribute").arg(key),
|
|
||||||
QuasarAppUtils::Error);
|
qCritical() << "Failed to update " << key << " attribute";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,9 @@ QSharedPointer<DBObject> iObjectProvider::getObjectRaw(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (list.size() > 1) {
|
if (list.size() > 1) {
|
||||||
QuasarAppUtils::Params::log("getObject method returned more than one object,"
|
qWarning() << "getObject method returned more than one object,"
|
||||||
" the first object was selected as the result,"
|
" the first object was selected as the result,"
|
||||||
" all the rest were lost.",
|
" all the rest were lost.";
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list.first();
|
return list.first();
|
||||||
|
@ -48,9 +48,9 @@ public:
|
|||||||
auto val = getObjectRaw(templateVal);
|
auto val = getObjectRaw(templateVal);
|
||||||
auto result = val.template dynamicCast<TYPE>();
|
auto result = val.template dynamicCast<TYPE>();
|
||||||
if (!result && !val.isNull()) {
|
if (!result && !val.isNull()) {
|
||||||
QuasarAppUtils::Params::log("getObject method returned object with deffirent type of TYPE,"
|
|
||||||
" check getAllObjects merhod",
|
qCritical() << "getObject method returned object with deffirent type of TYPE,"
|
||||||
QuasarAppUtils::Error);
|
" check getAllObjects merhod";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ void ISqlDB::globalUpdateDataBase(SqlDBCasheWriteMode mode) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!future.isValid()) {
|
if (!future.isValid()) {
|
||||||
QuasarAppUtils::Params::log("Failde to start update database thread");
|
qDebug() << "Failde to start update database thread";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -170,9 +170,7 @@ bool ISqlDB::getAllObjects(const DBObject &templateObject,
|
|||||||
|
|
||||||
for (const auto &object: std::as_const(result)) {
|
for (const auto &object: std::as_const(result)) {
|
||||||
if (object->isCached() && !insertToCache(object)) {
|
if (object->isCached() && !insertToCache(object)) {
|
||||||
QuasarAppUtils::Params::log("Selected object from database can not be saved into database cache. " +
|
qWarning() << "Selected object from database can not be saved into database cache. " + object->toString();
|
||||||
object->toString(),
|
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,10 +335,7 @@ void ISqlDB::globalUpdateDataBasePrivate(qint64 currentTime) {
|
|||||||
if (!obj || !obj->isValid()) {
|
if (!obj || !obj->isValid()) {
|
||||||
deleteFromCache(obj);
|
deleteFromCache(obj);
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
qCritical() << "writeUpdateItemIntoDB failed when db object is not valid! obj=" << obj->toString();
|
||||||
" db object is not valid! obj=" +
|
|
||||||
obj->toString(),
|
|
||||||
QuasarAppUtils::VerboseLvl::Error);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,25 +355,18 @@ void ISqlDB::globalUpdateDataBasePrivate(qint64 currentTime) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
QuasarAppUtils::Params::log("The Object of the cache have wrong type " +
|
qWarning() << "The Object of the cache have wrong type " << obj->toString();
|
||||||
obj->toString(),
|
|
||||||
QuasarAppUtils::VerboseLvl::Warning);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saveResult ) {
|
if (!saveResult ) {
|
||||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
qCritical() << "writeUpdateItemIntoDB failed when work globalUpdateDataRelease!!! obj=" << obj->toString();
|
||||||
" work globalUpdateDataRelease!!! obj=" +
|
|
||||||
obj->toString(),
|
|
||||||
QuasarAppUtils::VerboseLvl::Error);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("writeUpdateItemIntoDB failed when"
|
qCritical() << "writeUpdateItemIntoDB failed when db writer is not inited!";
|
||||||
" db writer is npt inited! ",
|
|
||||||
QuasarAppUtils::VerboseLvl::Error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,7 @@ PrepareResult DBObject::prepareInsertQuery(QSqlQuery &q, bool replace) const {
|
|||||||
DBVariantMap map = variantMap();
|
DBVariantMap map = variantMap();
|
||||||
|
|
||||||
if (!map.size()) {
|
if (!map.size()) {
|
||||||
QuasarAppUtils::Params::log("The variantMap method return an empty map.",
|
qCritical() << "The variantMap method return an empty map.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
@ -125,8 +124,7 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
|||||||
DBVariantMap map = variantMap();
|
DBVariantMap map = variantMap();
|
||||||
|
|
||||||
if (!map.size()) {
|
if (!map.size()) {
|
||||||
QuasarAppUtils::Params::log("The variantMap method return an empty map.",
|
qCritical() << "The variantMap method return an empty map.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
@ -134,8 +132,7 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
|||||||
auto [conditionQueryString, conditionBindingMap] = condition();
|
auto [conditionQueryString, conditionBindingMap] = condition();
|
||||||
|
|
||||||
if (conditionQueryString.isEmpty()) {
|
if (conditionQueryString.isEmpty()) {
|
||||||
QuasarAppUtils::Params::log("The object soue not have condition for update object.",
|
qCritical() << "The object soue not have condition for update object.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,9 +155,8 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tableUpdateValues.isEmpty()) {
|
if (tableUpdateValues.isEmpty()) {
|
||||||
QuasarAppUtils::Params::log("Fail to generate condition for object: " + toString() +
|
qCritical() << "Fail to generate condition for object: " + toString() +
|
||||||
". The object do not have valid update fields.",
|
". The object do not have valid update fields.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,11 +175,9 @@ PrepareResult DBObject::prepareUpdateQuery(QSqlQuery &q) const {
|
|||||||
for (auto it = conditionBindingMap.begin(); it != conditionBindingMap.end(); ++it) {
|
for (auto it = conditionBindingMap.begin(); it != conditionBindingMap.end(); ++it) {
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
if (bool(map.value(it.key()).type & MemberType::Update)) {
|
if (bool(map.value(it.key()).type & MemberType::Update)) {
|
||||||
QuasarAppUtils::Params::log(QString("Bad object configuration: "
|
qWarning() << "Bad object configuration: "
|
||||||
"The %0 field using in the condition and has MemberType::Update configuration."
|
"The " << it.key() << " field using in the condition and has MemberType::Update configuration."
|
||||||
" All condition fields should not use the MemberType::Update. \n %1").
|
" All condition fields should not use the MemberType::Update. \n" << toString();
|
||||||
arg(it.key(), toString()),
|
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
q.bindValue(it.key(), it.value());
|
q.bindValue(it.key(), it.value());
|
||||||
@ -218,10 +212,8 @@ std::pair<QString, QMap<QString, QVariant>> DBObject::condition() const {
|
|||||||
{{QString(":%0").arg(primaryKey()), {primaryVal}}}};
|
{{QString(":%0").arg(primaryKey()), {primaryVal}}}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCritical() << "Fail to generate condition for object: " + toString() +
|
||||||
QuasarAppUtils::Params::log("Fail to generate condition for object: " + toString() +
|
". Object do not have valid unique fields or valid database address.";
|
||||||
". Object do not have valid unique fields or valid database address.",
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -249,18 +241,17 @@ QString DBObject::toString() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QDataStream &DBObject::fromStream(QDataStream &stream) {
|
QDataStream &DBObject::fromStream(QDataStream &stream) {
|
||||||
QuasarAppUtils::Params::log("This object not support stream operator."
|
|
||||||
" Please Override the fromStream method for this object. " + toString(),
|
qWarning() << "This object not support stream operator."
|
||||||
QuasarAppUtils::Warning);
|
" Please Override the fromStream method for this object. " + toString();
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream &DBObject::toStream(QDataStream &stream) const {
|
QDataStream &DBObject::toStream(QDataStream &stream) const {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("This object not support stream operator."
|
qWarning() << "This object not support stream operator."
|
||||||
" Please Override the toStream method for this object. " + toString(),
|
" Please Override the toStream method for this object. " + toString();
|
||||||
QuasarAppUtils::Warning);
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,7 @@ PrepareResult SetSingleValue::prepareUpdateQuery(QSqlQuery &q) const {
|
|||||||
|
|
||||||
if (!q.prepare(queryString)) {
|
if (!q.prepare(queryString)) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Failed to prepare query: " + q.lastError().text(),
|
qCritical() << "Failed to prepare query: " + q.lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +58,7 @@ PrepareResult SetSingleValue::prepareInsertQuery(QSqlQuery &q, bool replace) con
|
|||||||
|
|
||||||
if (!q.prepare(queryString)) {
|
if (!q.prepare(queryString)) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("Failed to prepare query: " + q.lastError().text(),
|
qCritical() << "Failed to prepare query: " + q.lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return PrepareResult::Fail;
|
return PrepareResult::Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ QH::SoftDelete::~SoftDelete() {
|
|||||||
|
|
||||||
if (!fSoftDelete) {
|
if (!fSoftDelete) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log(QString("You delete %0 without preparing. "
|
qCritical() << "You delete %0 without preparing. " << typeid (this).name() <<
|
||||||
"All changes can not be saved. "
|
"The object was deleted without preparing. All changes can not be saved. "
|
||||||
"For fix it trouble use the softDelete method.").arg(typeid (this).name()),
|
"For fix it trouble use the softDelete method.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
std::abort();
|
std::abort();
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,9 +51,7 @@ bool SqlDBWriter::exec(QSqlQuery *sq, const QString& sqlFile) const {
|
|||||||
temp = temp.remove(0, delimiterIndex + 1);
|
temp = temp.remove(0, delimiterIndex + 1);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
QuasarAppUtils::Params::log(QString("Exec database error. File: %0. Line:%1: %2").
|
qCritical() << "Exec database error. File: " << sqlFile << " Line:" << lineNumber << sq->lastError().text();
|
||||||
arg(sqlFile).arg(lineNumber).arg(sq->lastError().text()),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
f.close();
|
f.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -64,8 +62,7 @@ bool SqlDBWriter::exec(QSqlQuery *sq, const QString& sqlFile) const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("sql source file is not open: " + sqlFile,
|
qCritical() << "sql source file is not open: " << sqlFile;
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -106,8 +103,7 @@ bool SqlDBWriter::initDbPrivate(const QVariantMap ¶ms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_db->open()) {
|
if (!_db->open()) {
|
||||||
QuasarAppUtils::Params::log(_db->lastError().text(),
|
qCritical() << _db->lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +136,7 @@ bool SqlDBWriter::doQueryPrivate(const QString &query, const QVariantMap &bindVa
|
|||||||
QSqlQuery q(*db());
|
QSqlQuery q(*db());
|
||||||
if (bindValues.size()) {
|
if (bindValues.size()) {
|
||||||
if (!q.prepare(query)) {
|
if (!q.prepare(query)) {
|
||||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
qCritical() << "request error : " << q.lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,14 +145,14 @@ bool SqlDBWriter::doQueryPrivate(const QString &query, const QVariantMap &bindVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!q.exec()) {
|
if (!q.exec()) {
|
||||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
qCritical() << "execute error : " << q.lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!q.exec(query)) {
|
if (!q.exec(query)) {
|
||||||
QuasarAppUtils::Params::log("request error : " + q.lastError().text(),
|
qCritical() << "bind values error : " << q.lastError().text();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +182,7 @@ bool SqlDBWriter::enableFK() {
|
|||||||
QSqlQuery query(*db());
|
QSqlQuery query(*db());
|
||||||
QString request = QString("PRAGMA foreign_keys = ON");
|
QString request = QString("PRAGMA foreign_keys = ON");
|
||||||
if (!query.exec(request)) {
|
if (!query.exec(request)) {
|
||||||
QuasarAppUtils::Params::log("request error : " + query.lastError().text());
|
qDebug() << "request error : " << query.lastError().text();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +198,7 @@ bool SqlDBWriter::disableFK() {
|
|||||||
QSqlQuery query(*db());
|
QSqlQuery query(*db());
|
||||||
QString request = QString("PRAGMA foreign_keys = OFF");
|
QString request = QString("PRAGMA foreign_keys = OFF");
|
||||||
if (!query.exec(request)) {
|
if (!query.exec(request)) {
|
||||||
QuasarAppUtils::Params::log("request error : " + query.lastError().text());
|
qDebug() << "request error : " << query.lastError().text();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,10 +449,8 @@ bool SqlDBWriter::selectQuery(const DBObject& requestObject,
|
|||||||
|
|
||||||
while (q.next()) {
|
while (q.next()) {
|
||||||
if (!newObject->fromSqlRecord(q.record())) {
|
if (!newObject->fromSqlRecord(q.record())) {
|
||||||
QuasarAppUtils::Params::log("Select query finished successful but, "
|
qCritical() << "Select query finished successful but, "
|
||||||
"the fromSqlRecord method return false." +
|
"the fromSqlRecord method return false." << newObject->toString();
|
||||||
newObject->toString(),
|
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,8 +465,7 @@ bool SqlDBWriter::selectQuery(const DBObject& requestObject,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!newObject->fromSqlRecord(q.record())) {
|
if (!newObject->fromSqlRecord(q.record())) {
|
||||||
QuasarAppUtils::Params::log("Init sql object error.",
|
qCritical() << "Init sql object error.";
|
||||||
QuasarAppUtils::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
result.push_back(newObject);
|
result.push_back(newObject);
|
||||||
@ -527,11 +519,9 @@ bool SqlDBWriter::workWithQuery(QSqlQuery &q,
|
|||||||
|
|
||||||
auto printError = [](const QSqlQuery &q) {
|
auto printError = [](const QSqlQuery &q) {
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("prepare sql error: " + q.executedQuery(),
|
qDebug() << "prepare sql error: " << q.lastError().text();
|
||||||
QuasarAppUtils::Debug);
|
|
||||||
|
|
||||||
QuasarAppUtils::Params::log("exec sql error: " + q.lastError().text(),
|
qCritical() << "exec sql error: " << q.lastError();
|
||||||
QuasarAppUtils::Error);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -545,17 +535,16 @@ bool SqlDBWriter::workWithQuery(QSqlQuery &q,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HEART_PRINT_SQL_QUERIES
|
#ifdef HEART_PRINT_SQL_QUERIES
|
||||||
QuasarAppUtils::Params::log(QString("Query executed successfull into %0\n"
|
qDebug() << QString("Query executed successfull into %0\n"
|
||||||
"query: %1").
|
"query: %1").
|
||||||
arg(_db->databaseName(), q.executedQuery()),
|
arg(_db->databaseName(), q.executedQuery();
|
||||||
QuasarAppUtils::Debug);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
case PrepareResult::Disabled: {
|
case PrepareResult::Disabled: {
|
||||||
QuasarAppUtils::Params::log("call disabled operator! ",
|
|
||||||
QuasarAppUtils::Warning);
|
qWarning() << "call disabled operator!";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user