Added "url" to signature "dataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number, const QUrl &url)"

Allows to write log. messages with URL
This commit is contained in:
Klaus Basan
2020-03-14 01:49:32 +01:00
committed by Mat Sutcliffe
parent f840244bdb
commit 5b3c011a15
37 changed files with 195 additions and 143 deletions

View File

@@ -100,6 +100,7 @@ namespace BlackCore
}
else
{
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
const QJsonObject airportsJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
if (!airportsJson.isEmpty())
{
@@ -109,12 +110,12 @@ namespace BlackCore
c = airports.size();
msgs.push_back(m_airportCache.set(airports, fi.birthTime().toUTC().toMSecsSinceEpoch()));
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, c);
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, c, url);
reallyRead |= CEntityFlags::AirportEntity;
}
catch (const CJsonException &ex)
{
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFailed, 0);
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFailed, 0, url);
return ex.toStatusMessage(this, QStringLiteral("Reading airports from '%1'").arg(fileName));
}
}
@@ -168,7 +169,7 @@ namespace BlackCore
bool CAirportDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
{
Q_UNUSED(entity);
Q_UNUSED(entity)
oldUrlInfo = m_readerUrlCache.get();
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);
@@ -192,15 +193,17 @@ namespace BlackCore
if (!this->doWorkCheck()) { return; }
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReplyPtr);
const QUrl url = nwReply->url();
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFailed, 0, url);
return;
}
// parsing
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadParsing, 0, url);
CAirportList airports;
CAirportList inconsistent;
if (res.isRestricted())
@@ -215,7 +218,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
airports = CAirportList::fromDatabaseJson(res, &inconsistent);
this->logParseMessage("airports", airports.size(), time.elapsed(), res);
this->logParseMessage("airports", airports.size(), static_cast<int>(time.elapsed()), res);
}
if (!inconsistent.isEmpty())
@@ -247,7 +250,7 @@ namespace BlackCore
entity &= CEntityFlags::AirportEntity;
if (!this->isInternetAccessible())
{
emit this->dataRead(entity, CEntityFlags::ReadSkipped, 0);
emit this->dataRead(entity, CEntityFlags::ReadSkipped, 0, {});
return;
}
@@ -258,7 +261,7 @@ namespace BlackCore
{
url.appendQuery(queryLatestTimestamp(newerThan));
this->getFromNetworkAndLog(url, { this, &CAirportDataReader::parseAirportData });
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadStarted, 0);
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadStarted, 0, url);
}
else
{

View File

@@ -206,7 +206,7 @@ namespace BlackCore
{
if (!myself) { return; }
if (!sApp || sApp->isShuttingDown()) { return; }
emit this->dataRead(validInCacheEntities, CEntityFlags::ReadFinished, 0);
emit this->dataRead(validInCacheEntities, CEntityFlags::ReadFinished, 0, {});
});
}
if (newerHeaderEntities == CEntityFlags::NoEntity) { return CEntityFlags::NoEntity; }
@@ -490,7 +490,7 @@ namespace BlackCore
const int c = this->getCacheCount(currentCachedEntity);
if (!onlyIfHasData || c > 0)
{
emit this->dataRead(currentCachedEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(currentCachedEntity, CEntityFlags::ReadFinished, c, {});
emitted |= currentCachedEntity;
}
currentCachedEntity = CEntityFlags::iterateDbEntities(cachedEntitiesToEmit);
@@ -503,7 +503,7 @@ namespace BlackCore
// never emit when lock is held, deadlock
Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO, "Expect single entity");
CLogMessage(this).info(u"Read %1 entities of '%2' from '%3' (%4)") << number << CEntityFlags::flagToString(entity) << res.getUrlString() << res.getLoadTimeStringWithStartedHint();
emit this->dataRead(entity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, number);
emit this->dataRead(entity, res.isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished, number, res.getUrl());
}
void CDatabaseReader::logNoWorkingUrl(CEntityFlags::Entity entity)

View File

@@ -295,7 +295,7 @@ namespace BlackCore
//! Combined read signal
//! \remark normally in success case state for a single case, skipped cases can be reported for 1..n enities
void dataRead(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Network::CEntityFlags::ReadState state, int number);
void dataRead(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Network::CEntityFlags::ReadState state, int number, const QUrl &url);
//! Header of shared file read
void sharedFileHeaderRead(BlackMisc::Network::CEntityFlags::Entity entity, const QString &fileName, bool success);

View File

@@ -178,16 +178,18 @@ namespace BlackCore
this->threadAssertCheck(); // runs in background thread
if (!this->doWorkCheck()) { return; }
entities &= CEntityFlags::AllIcaoCountriesCategory;
if (!this->isInternetAccessible())
{
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0);
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0, {});
return;
}
CEntityFlags::Entity entitiesTriggered = CEntityFlags::NoEntity;
CUrl url;
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity))
{
CUrl url(this->getAircraftIcaoUrl(mode));
url = this->getAircraftIcaoUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -202,7 +204,7 @@ namespace BlackCore
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity))
{
CUrl url(this->getAirlineIcaoUrl(mode));
url = this->getAirlineIcaoUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -217,7 +219,7 @@ namespace BlackCore
if (entities.testFlag(CEntityFlags::CountryEntity))
{
CUrl url(this->getCountryUrl(mode));
url = this->getCountryUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -232,7 +234,7 @@ namespace BlackCore
if (entities.testFlag(CEntityFlags::AircraftCategoryEntity))
{
CUrl url(this->getAircraftCategoryUrl(mode));
url = this->getAircraftCategoryUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -247,7 +249,7 @@ namespace BlackCore
if (entitiesTriggered != CEntityFlags::NoEntity)
{
emit this->dataRead(entitiesTriggered, CEntityFlags::ReadStarted, 0);
emit this->dataRead(entitiesTriggered, CEntityFlags::ReadStarted, 0, url);
}
}
@@ -295,14 +297,16 @@ namespace BlackCore
if (!this->doWorkCheck()) { return; }
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
const QUrl url = nwReply->url();
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0, url);
return;
}
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadParsing, 0, url);
CAircraftIcaoCodeList codes;
CAircraftIcaoCodeList inconsistent;
const CAircraftCategoryList categories = this->getAircraftCategories();
@@ -320,7 +324,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
codes = CAircraftIcaoCodeList::fromDatabaseJson(res, categories, true, &inconsistent);
this->logParseMessage("aircraft ICAO", codes.size(), time.elapsed(), res);
this->logParseMessage("aircraft ICAO", codes.size(), static_cast<int>(time.elapsed()), res);
}
if (!inconsistent.isEmpty())
@@ -350,15 +354,16 @@ namespace BlackCore
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
if (!this->doWorkCheck()) { return; }
const QUrl url = nwReply->url();
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0, url);
return;
}
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadParsing, 0, url);
CAirlineIcaoCodeList codes;
CAirlineIcaoCodeList inconsistent;
if (res.isRestricted())
@@ -375,7 +380,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
codes = CAirlineIcaoCodeList::fromDatabaseJson(res, true, &inconsistent);
this->logParseMessage("airline ICAO", codes.size(), time.elapsed(), res);
this->logParseMessage("airline ICAO", codes.size(), static_cast<int>(time.elapsed()), res);
}
if (!inconsistent.isEmpty())
@@ -404,14 +409,16 @@ namespace BlackCore
{
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
const QUrl url = nwReply->url();
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0, url);
return;
}
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadParsing, 0, url);
CCountryList countries;
if (res.isRestricted())
{
@@ -427,7 +434,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
countries = CCountryList::fromDatabaseJson(res);
this->logParseMessage("countries", countries.size(), time.elapsed(), res);
this->logParseMessage("countries", countries.size(), static_cast<int>(time.elapsed()), res);
}
if (!this->doWorkCheck()) { return; }
@@ -449,14 +456,16 @@ namespace BlackCore
{
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
const QUrl url = nwReply->url();
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFailed, 0, url);
return;
}
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadParsing, 0, url);
CAircraftCategoryList categories;
if (res.isRestricted())
{
@@ -472,7 +481,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
categories = CAircraftCategoryList::fromDatabaseJson(res);
this->logParseMessage("categories", categories.size(), time.elapsed(), res);
this->logParseMessage("categories", categories.size(), static_cast<int>(time.elapsed()), res);
}
if (!this->doWorkCheck()) { return; }
@@ -516,6 +525,7 @@ namespace BlackCore
}
else
{
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
const QJsonObject countriesJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
if (countriesJson.isEmpty())
{
@@ -529,11 +539,11 @@ namespace BlackCore
const int c = countries.size();
msgs.push_back(m_countryCache.set(countries, fi.birthTime().toUTC().toMSecsSinceEpoch()));
reallyRead |= CEntityFlags::CountryEntity;
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFinished, c, url);
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::CountryEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading countries from '%1'").arg(fileName)));
}
}
@@ -554,6 +564,7 @@ namespace BlackCore
}
else
{
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
const QJsonObject aircraftJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
if (aircraftJson.isEmpty())
{
@@ -567,11 +578,11 @@ namespace BlackCore
const int c = aircraftIcaos.size();
msgs.push_back(m_aircraftIcaoCache.set(aircraftIcaos, fi.birthTime().toUTC().toMSecsSinceEpoch()));
reallyRead |= CEntityFlags::AircraftIcaoEntity;
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, c, url);
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading aircraft ICAOs from '%1'").arg(fileName)));
}
}
@@ -592,6 +603,7 @@ namespace BlackCore
}
else
{
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
const QJsonObject airlineJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
if (airlineJson.isEmpty())
{
@@ -605,11 +617,11 @@ namespace BlackCore
const int c = airlineIcaos.size();
msgs.push_back(m_airlineIcaoCache.set(airlineIcaos, fi.birthTime().toUTC().toMSecsSinceEpoch()));
reallyRead |= CEntityFlags::AirlineIcaoEntity;
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c, url);
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading airline ICAOs from '%1'").arg(fileName)));
}
}
@@ -630,6 +642,7 @@ namespace BlackCore
}
else
{
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
const QJsonObject aircraftCategory(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
if (aircraftCategory.isEmpty())
{
@@ -643,11 +656,11 @@ namespace BlackCore
const int c = aircraftCategories.size();
msgs.push_back(m_categoryCache.set(aircraftCategories, fi.birthTime().toUTC().toMSecsSinceEpoch()));
reallyRead |= CEntityFlags::AircraftCategoryEntity;
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFinished, c, url);
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading categories from '%1'").arg(fileName)));
}
}

View File

@@ -151,7 +151,7 @@ namespace BlackCore
if (!url.isEmpty())
{
this->getFromNetworkAndLog(url, { this, &CInfoDataReader::parseInfoObjectsData});
emit this->dataRead(this->getEntityForMode(), CEntityFlags::ReadStarted, 0);
emit this->dataRead(this->getEntityForMode(), CEntityFlags::ReadStarted, 0, url);
}
else
{
@@ -170,7 +170,7 @@ namespace BlackCore
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(this->getEntityForMode(), CEntityFlags::ReadFailed, 0);
emit this->dataRead(this->getEntityForMode(), CEntityFlags::ReadFailed, 0, res.getUrl());
return;
}
@@ -181,7 +181,7 @@ namespace BlackCore
// Service URL => DB data
// DB data directory => shared files
const QString urlStr = nwReply->url().toString();
Q_UNUSED(urlStr); // debug only
Q_UNUSED(urlStr) // debug only
// this part needs to be synchronized
{
@@ -212,9 +212,9 @@ namespace BlackCore
void CInfoDataReader::read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
{
Q_UNUSED(entities);
Q_UNUSED(mode);
Q_UNUSED(newerThan);
Q_UNUSED(entities)
Q_UNUSED(mode)
Q_UNUSED(newerThan)
Q_ASSERT_X(false, Q_FUNC_INFO, "Not implemented for CInfoDataReader");
}
@@ -231,9 +231,9 @@ namespace BlackCore
CStatusMessageList CInfoDataReader::readFromJsonFiles(const QString &dir, CEntityFlags::Entity whatToRead, bool overrideNewer)
{
Q_UNUSED(dir);
Q_UNUSED(whatToRead);
Q_UNUSED(overrideNewer);
Q_UNUSED(dir)
Q_UNUSED(whatToRead)
Q_UNUSED(overrideNewer)
Q_ASSERT_X(false, Q_FUNC_INFO, "Not supported");
return CStatusMessage(this).error(u"Not supported");
@@ -241,8 +241,8 @@ namespace BlackCore
bool CInfoDataReader::readFromJsonFilesInBackground(const QString &dir, CEntityFlags::Entity whatToRead, bool overrideNewer)
{
Q_UNUSED(dir);
Q_UNUSED(whatToRead);
Q_UNUSED(dir)
Q_UNUSED(whatToRead)
Q_UNUSED(overrideNewer)
Q_ASSERT_X(false, Q_FUNC_INFO, "Not supported");
return false;

View File

@@ -192,14 +192,16 @@ namespace BlackCore
entities &= CEntityFlags::DistributorLiveryModel;
if (!this->isInternetAccessible())
{
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0);
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0, {});
return;
}
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
CUrl url;
if (entities.testFlag(CEntityFlags::LiveryEntity))
{
CUrl url(getLiveryUrl(mode));
url = this->getLiveryUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -214,7 +216,7 @@ namespace BlackCore
if (entities.testFlag(CEntityFlags::DistributorEntity))
{
CUrl url(getDistributorUrl(mode));
url = this->getDistributorUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -229,7 +231,7 @@ namespace BlackCore
if (entities.testFlag(CEntityFlags::ModelEntity))
{
CUrl url(getModelUrl(mode));
url = this->getModelUrl(mode);
if (!url.isEmpty())
{
url.appendQuery(queryLatestTimestamp(newerThan));
@@ -244,7 +246,7 @@ namespace BlackCore
if (triggeredRead != CEntityFlags::NoEntity)
{
emit dataRead(triggeredRead, CEntityFlags::ReadStarted, 0);
emit dataRead(triggeredRead, CEntityFlags::ReadStarted, 0, url);
}
}
@@ -301,12 +303,12 @@ namespace BlackCore
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFailed, 0);
emit dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFailed, 0, res.getUrl());
return;
}
// get all or incremental set of distributor
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadParsing, 0, res.getUrl());
CLiveryList liveries;
if (res.isRestricted())
{
@@ -321,7 +323,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
liveries = CLiveryList::fromDatabaseJson(res);
this->logParseMessage("liveries", liveries.size(), time.elapsed(), res);
this->logParseMessage("liveries", liveries.size(), static_cast<int>(time.elapsed()), res);
}
if (!this->doWorkCheck()) { return; }
@@ -349,12 +351,12 @@ namespace BlackCore
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFailed, 0);
emit dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFailed, 0, res.getUrl());
return;
}
// get all or incremental set of distributors
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadParsing, 0, res.getUrl());
CDistributorList distributors;
if (res.isRestricted())
{
@@ -369,7 +371,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
distributors = CDistributorList::fromDatabaseJson(res);
this->logParseMessage("distributors", distributors.size(), time.elapsed(), res);
this->logParseMessage("distributors", distributors.size(), static_cast<int>(time.elapsed()), res);
}
if (!this->doWorkCheck()) { return; }
@@ -394,16 +396,16 @@ namespace BlackCore
// required to use delete later as object is created in a different thread
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
if (!this->doWorkCheck()) { return; }
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFailed, 0, res.getUrl());
return;
}
// get all or incremental set of models
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadParsing, 0);
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadParsing, 0, res.getUrl());
// use prefilled data:
// this saves a lot of parsing time as the models do not need to re-parse the sub parts
@@ -427,7 +429,7 @@ namespace BlackCore
QElapsedTimer time;
time.start();
models = CAircraftModelList::fromDatabaseJsonCaching(res, icaos, categories, liveries, distributors);
this->logParseMessage("models", models.size(), time.elapsed(), res);
this->logParseMessage("models", models.size(), static_cast<int>(time.elapsed()), res);
}
// synchronized update
@@ -473,6 +475,7 @@ namespace BlackCore
else
{
const QJsonObject liveriesJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
if (liveriesJson.isEmpty())
{
msgs.push_back(CStatusMessage(this).error(u"Failed to read from file/empty file '%1'") << fileName);
@@ -484,12 +487,12 @@ namespace BlackCore
const CLiveryList liveries = CLiveryList::fromMultipleJsonFormats(liveriesJson);
const int c = liveries.size();
msgs.push_back(m_liveryCache.set(liveries, fi.birthTime().toUTC().toMSecsSinceEpoch()));
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFinished, c, url);
reallyRead |= CEntityFlags::LiveryEntity;
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading liveries from '%1'").arg(fileName)));
}
}
@@ -511,6 +514,8 @@ namespace BlackCore
else
{
const QJsonObject modelsJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
if (modelsJson.isEmpty())
{
msgs.push_back(CStatusMessage(this).error(u"Failed to read from file/empty file '%1'") << fileName);
@@ -522,12 +527,12 @@ namespace BlackCore
const CAircraftModelList models = CAircraftModelList::fromMultipleJsonFormats(modelsJson);
const int c = models.size();
msgs.push_back(m_modelCache.set(models, fi.birthTime().toUTC().toMSecsSinceEpoch()));
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, c, url);
reallyRead |= CEntityFlags::ModelEntity;
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading models from '%1'").arg(fileName)));
}
}
@@ -549,6 +554,8 @@ namespace BlackCore
else
{
const QJsonObject distributorsJson(CDatabaseUtils::readQJsonObjectFromDatabaseFile(fileName));
const QUrl url = QUrl::fromLocalFile(fi.absoluteFilePath());
if (distributorsJson.isEmpty())
{
msgs.push_back(CStatusMessage(this).error(u"Failed to read from file/empty file '%1'") << fileName);
@@ -560,12 +567,12 @@ namespace BlackCore
const CDistributorList distributors = CDistributorList::fromMultipleJsonFormats(distributorsJson);
const int c = distributors.size();
msgs.push_back(m_distributorCache.set(distributors, fi.birthTime().toUTC().toMSecsSinceEpoch()));
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, c);
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, c, url);
reallyRead |= CEntityFlags::DistributorEntity;
}
catch (const CJsonException &ex)
{
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFailed, 0);
emit this->dataRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFailed, 0, url);
msgs.push_back(ex.toStatusMessage(this, QStringLiteral("Reading distributors from '%1'").arg(fileName)));
}
}
@@ -687,7 +694,7 @@ namespace BlackCore
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity, CUrl &oldUrlInfo, CUrl &newUrlInfo) const
{
Q_UNUSED(entity);
Q_UNUSED(entity)
oldUrlInfo = m_readerUrlCache.get();
newUrlInfo = this->getBaseUrl(CDbFlags::DbReading);
return CDatabaseReader::isChangedUrl(oldUrlInfo, newUrlInfo);