mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
refs #857, check if network is accessible in readers
* new read state "skipped" * renamed to "isNetworkConnectedAndAccessible" * checking before reading, which would only fail if network is not accessible
This commit is contained in:
committed by
Mathew Sutcliffe
parent
04e980a6ae
commit
1ced7f3c0b
@@ -181,6 +181,12 @@ namespace BlackCore
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (this->isShuttingDown()) { return; }
|
||||
entity &= CEntityFlags::AirportEntity;
|
||||
if (!this->isNetworkConnectedAndAccessible())
|
||||
{
|
||||
emit this->dataRead(entity, CEntityFlags::ReadSkipped, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.testFlag(CEntityFlags::AirportEntity))
|
||||
{
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace BlackCore
|
||||
|
||||
// ps_read is implemented in the derived classes
|
||||
if (entities == CEntityFlags::NoEntity) { return; }
|
||||
if (!this->isNetworkAvailable())
|
||||
if (!this->isNetworkConnectedAndAccessible())
|
||||
{
|
||||
CLogMessage(this).warning("No network, will not read %1") << CEntityFlags::flagToString(entities);
|
||||
return;
|
||||
@@ -318,7 +318,7 @@ namespace BlackCore
|
||||
|
||||
bool CDatabaseReader::requestHeadersOfSharedFiles(const CEntityFlags::Entity &entities)
|
||||
{
|
||||
if (!this->isNetworkAvailable())
|
||||
if (!this->isNetworkConnectedAndAccessible())
|
||||
{
|
||||
CLogMessage(this).warning("No network, will not read shared file headers for %1") << CEntityFlags::flagToString(entities);
|
||||
return false;
|
||||
|
||||
@@ -132,6 +132,12 @@ namespace BlackCore
|
||||
{
|
||||
this->threadAssertCheck(); // runs in background thread
|
||||
if (this->isShuttingDown()) { return; }
|
||||
entities &= CEntityFlags::AllIcaoAndCountries;
|
||||
if (!this->isNetworkConnectedAndAccessible())
|
||||
{
|
||||
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
CEntityFlags::Entity entitiesTriggered = CEntityFlags::NoEntity;
|
||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity))
|
||||
@@ -181,7 +187,7 @@ namespace BlackCore
|
||||
|
||||
if (entitiesTriggered != CEntityFlags::NoEntity)
|
||||
{
|
||||
emit dataRead(entitiesTriggered, CEntityFlags::StartRead, 0);
|
||||
emit this->dataRead(entitiesTriggered, CEntityFlags::StartRead, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,13 +147,19 @@ namespace BlackCore
|
||||
getDistributorsCount() > 0;
|
||||
}
|
||||
|
||||
void CModelDataReader::ps_read(CEntityFlags::Entity entity, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
void CModelDataReader::ps_read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (this->isShuttingDown()) { return; }
|
||||
entities &= CEntityFlags::DistributorLiveryModel;
|
||||
if (!this->isNetworkConnectedAndAccessible())
|
||||
{
|
||||
emit this->dataRead(entities, CEntityFlags::ReadSkipped, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
|
||||
if (entity.testFlag(CEntityFlags::LiveryEntity))
|
||||
if (entities.testFlag(CEntityFlags::LiveryEntity))
|
||||
{
|
||||
CUrl url(getLiveryUrl(mode));
|
||||
if (!url.isEmpty())
|
||||
@@ -172,7 +178,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.testFlag(CEntityFlags::DistributorEntity))
|
||||
if (entities.testFlag(CEntityFlags::DistributorEntity))
|
||||
{
|
||||
CUrl url(getDistributorUrl(mode));
|
||||
if (!url.isEmpty())
|
||||
@@ -191,7 +197,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.testFlag(CEntityFlags::ModelEntity))
|
||||
if (entities.testFlag(CEntityFlags::ModelEntity))
|
||||
{
|
||||
CUrl url(getModelUrl(mode));
|
||||
if (!url.isEmpty())
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace BlackCore
|
||||
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
|
||||
virtual bool hasChangedUrl(BlackMisc::Network::CEntityFlags::Entity entity) const override;
|
||||
virtual BlackMisc::Network::CUrl getDbServiceBaseUrl() const override;
|
||||
|
||||
private slots:
|
||||
//! Liveries have been read
|
||||
void ps_parseLiveryData(QNetworkReply *nwReply);
|
||||
@@ -147,7 +148,7 @@ namespace BlackCore
|
||||
void ps_parseModelData(QNetworkReply *nwReply);
|
||||
|
||||
//! Read / re-read data file
|
||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entity = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
||||
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::DistributorLiveryModel,
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime());
|
||||
|
||||
void ps_liveryCacheChanged();
|
||||
|
||||
Reference in New Issue
Block a user