mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T203, renamings to "update info" and "settings"
This commit is contained in:
@@ -163,7 +163,7 @@ namespace BlackCore
|
||||
// global setup
|
||||
m_setupReader.reset(new CSetupReader(this));
|
||||
connect(m_setupReader.data(), &CSetupReader::setupHandlingCompleted, this, &CApplication::setupHandlingIsCompleted, Qt::QueuedConnection);
|
||||
connect(m_setupReader.data(), &CSetupReader::distributionInfoAvailable, this, &CApplication::distributionInfoAvailable, Qt::QueuedConnection);
|
||||
connect(m_setupReader.data(), &CSetupReader::updateInfoAvailable, this, &CApplication::updateInfoAvailable, Qt::QueuedConnection);
|
||||
connect(m_setupReader.data(), &CSetupReader::successfullyReadSharedUrl, m_networkWatchDog.data(), &CNetworkWatchdog::setWorkingSharedUrl, Qt::QueuedConnection);
|
||||
|
||||
this->addParserOptions(m_setupReader->getCmdLineOptions()); // add options from reader
|
||||
@@ -340,12 +340,12 @@ namespace BlackCore
|
||||
return r->getSetup();
|
||||
}
|
||||
|
||||
CDistributionList CApplication::getDistributionInfo() const
|
||||
CUpdateInfo CApplication::getUpdateInfo() const
|
||||
{
|
||||
if (m_shutdown) { return CDistributionList(); }
|
||||
if (m_shutdown) { return CUpdateInfo(); }
|
||||
const CSetupReader *r = m_setupReader.data();
|
||||
if (!r) { return CDistributionList(); }
|
||||
return r->getDistributionInfo();
|
||||
if (!r) { return CUpdateInfo(); }
|
||||
return r->getUpdateInfo();
|
||||
}
|
||||
|
||||
bool CApplication::start()
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "blackcore/db/databasereaderconfig.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include "blackcore/webreaderflags.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/db/updateinfo.h"
|
||||
#include "blackmisc/network/urllist.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/slot.h"
|
||||
@@ -154,9 +154,9 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
BlackCore::Data::CGlobalSetup getGlobalSetup() const;
|
||||
|
||||
//! Distributions
|
||||
//! Update info
|
||||
//! \threadsafe
|
||||
BlackMisc::Db::CDistributionList getDistributionInfo() const;
|
||||
BlackMisc::Db::CUpdateInfo getUpdateInfo() const;
|
||||
|
||||
//! Delete all cookies from cookie manager
|
||||
void deleteAllCookies();
|
||||
@@ -471,7 +471,7 @@ namespace BlackCore
|
||||
void setupHandlingCompleted(bool success);
|
||||
|
||||
//! Update info available (cache, web load)
|
||||
void distributionInfoAvailable(bool success);
|
||||
void updateInfoAvailable(bool success);
|
||||
|
||||
//! Startup has been completed
|
||||
//! \remark needs to be triggered by application when it think it is done
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackcore/application.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/platform.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include <QStringList>
|
||||
|
||||
@@ -21,26 +22,26 @@ namespace BlackCore
|
||||
{
|
||||
namespace Application
|
||||
{
|
||||
//! Distribution settings, QStringList with 2 values: channel/platform
|
||||
struct TDistribution : public BlackMisc::TSettingTrait<QStringList>
|
||||
//! Update info settings, QStringList with 2 values: channel/platform
|
||||
struct TUpdatePreferences : public BlackMisc::TSettingTrait<QStringList>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "distribution"; }
|
||||
static const char *key() { return "updatepreferences"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static const QStringList &defaultValue()
|
||||
{
|
||||
// guessing / preseting some default values
|
||||
static const QStringList d = (sApp && !sApp->getDistributionInfo().isEmpty()) ?
|
||||
sApp->getDistributionInfo().guessMyDefaultChannelAndPlatform() : // from cached or loaded distribution data
|
||||
QStringList({"ALPHA", BlackConfig::CBuildConfig::guessMyPlatformString()}); // guessing
|
||||
static const QStringList d = (sApp && !sApp->getUpdateInfo().isEmpty()) ?
|
||||
sApp->getUpdateInfo().anticipateMyDefaultChannelAndPlatform() : // from cached or loaded update info
|
||||
QStringList({ "STABLE", BlackMisc::CPlatform::currentPlatform().getPlatformName()});
|
||||
return d;
|
||||
}
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable()
|
||||
{
|
||||
static const QString name("Download channel/platform");
|
||||
static const QString name("Updates channel/platform");
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,9 +93,9 @@ namespace BlackCore
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
}
|
||||
|
||||
CUrlList CGlobalSetup::getSwiftDistributionFileUrls() const
|
||||
CUrlList CGlobalSetup::getSwiftUpdateInfoFileUrls() const
|
||||
{
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/updateinfo/distribution.json");
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/updateinfo/updateinfo.json");
|
||||
}
|
||||
|
||||
CUrl CGlobalSetup::getDbHomePageUrl() const
|
||||
@@ -271,7 +271,7 @@ namespace BlackCore
|
||||
% separator
|
||||
|
||||
% "Distribution URLs: "
|
||||
% getSwiftDistributionFileUrls().toQString(i18n)
|
||||
% getSwiftUpdateInfoFileUrls().toQString(i18n)
|
||||
% separator
|
||||
% "Bootstrap URLs: "
|
||||
% getSwiftBootstrapFileUrls().toQString(i18n)
|
||||
@@ -345,7 +345,7 @@ namespace BlackCore
|
||||
case IndexVatsimBookings: return CVariant::fromValue(m_vatsimDataFileUrls);
|
||||
case IndexVatsimMetars: return CVariant::fromValue(m_vatsimMetarsUrls);
|
||||
case IndexBootstrapFileUrls: return CVariant::fromValue(this->getSwiftBootstrapFileUrls());
|
||||
case IndexDistributionFileUrls: return CVariant::fromValue(this->getSwiftDistributionFileUrls());
|
||||
case IndexUpdateInfoFileUrls: return CVariant::fromValue(this->getSwiftUpdateInfoFileUrls());
|
||||
case IndexSharedUrls: return CVariant::fromValue(m_sharedUrls);
|
||||
case IndexNewsUrls: return CVariant::fromValue(m_newsUrls);
|
||||
case IndexSwiftMapUrls: return CVariant::fromValue(m_mapUrls);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace BlackCore
|
||||
IndexSwiftDbFiles,
|
||||
IndexSwiftMapUrls,
|
||||
IndexBootstrapFileUrls,
|
||||
IndexDistributionFileUrls,
|
||||
IndexUpdateInfoFileUrls,
|
||||
IndexNewsUrls,
|
||||
IndexOnlineHelpUrls,
|
||||
IndexCrashReportServerUrl,
|
||||
@@ -142,7 +142,7 @@ namespace BlackCore
|
||||
|
||||
//! Distribution URLs
|
||||
//! \remark based on getSwiftSharedUrls
|
||||
BlackMisc::Network::CUrlList getSwiftDistributionFileUrls() const;
|
||||
BlackMisc::Network::CUrlList getSwiftUpdateInfoFileUrls() const;
|
||||
|
||||
//! URL to read VATSIM bookings
|
||||
const BlackMisc::Network::CUrl &getVatsimBookingsUrl() const { return m_vatsimBookingsUrl; }
|
||||
@@ -230,7 +230,7 @@ namespace BlackCore
|
||||
BlackMisc::Network::CUrlList m_onlineHelpUrls; //!< online help URLs
|
||||
BlackMisc::Network::CUrlList m_mapUrls; //!< swift map URLs
|
||||
BlackMisc::Network::CServerList m_fsdTestServers; //!< FSD test servers
|
||||
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl; //!< NCEP GFS url
|
||||
BlackMisc::Network::CUrl m_ncepGlobalForecastSystemUrl; //!< NCEP GFS url
|
||||
|
||||
// transient members, to be switched on/off via GUI or set from reader
|
||||
bool m_dbDebugFlag = false; //!< can trigger DEBUG on the server, so you need to know what you are doing
|
||||
|
||||
@@ -77,15 +77,14 @@ namespace BlackCore
|
||||
const bool cacheAvailable = cachedSetup.wasLoaded();
|
||||
msgs.push_back(cacheAvailable ?
|
||||
CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup synchronized and contains data") :
|
||||
CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup synchronized, but no data in cache")
|
||||
);
|
||||
CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup synchronized, but no data in cache"));
|
||||
|
||||
if (m_bootstrapMode == CacheOnly)
|
||||
{
|
||||
m_distributionUrls = cachedSetup.getSwiftDistributionFileUrls();
|
||||
m_updateInfoUrls = cachedSetup.getSwiftUpdateInfoFileUrls(); // we use the info URLs from cached setup
|
||||
msgs.push_back(cacheAvailable ?
|
||||
CStatusMessage(this, CStatusMessage::SeverityInfo, "Cache only setup, using it as it is") :
|
||||
CStatusMessage(this, CStatusMessage::SeverityError, "Cache only setup, but cache is empty")
|
||||
);
|
||||
CStatusMessage(this, CStatusMessage::SeverityError, "Cache only setup, but cache is empty"));
|
||||
msgs.push_back(this->manageSetupAvailability(false, false));
|
||||
return msgs;
|
||||
}
|
||||
@@ -247,23 +246,18 @@ namespace BlackCore
|
||||
return m;
|
||||
}
|
||||
|
||||
void CSetupReader::readDistributionInfo()
|
||||
void CSetupReader::readUpdateInfo()
|
||||
{
|
||||
const CUrl url(m_distributionUrls.obtainNextWorkingUrl());
|
||||
const CUrl url(m_updateInfoUrls.obtainNextWorkingUrl());
|
||||
if (url.isEmpty())
|
||||
{
|
||||
CLogMessage(this).warning("Cannot read update info, URLs: '%1', failed URLs: '%2'") << m_distributionUrls << m_distributionUrls.getFailedUrls();
|
||||
CLogMessage(this).warning("Cannot read update info, URLs: '%1', failed URLs: '%2'") << m_updateInfoUrls << m_updateInfoUrls.getFailedUrls();
|
||||
CLogMessage::preformatted(CNetworkUtils::createNetworkReport(sApp->getNetworkAccessManager()));
|
||||
this->manageDistributionsInfoAvailability(false);
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
return;
|
||||
}
|
||||
if (m_shutdown) { return; }
|
||||
sApp->getFromNetwork(url.toNetworkRequest(), { this, &CSetupReader::parseDistributionsFile});
|
||||
}
|
||||
|
||||
void CSetupReader::setupChanged()
|
||||
{
|
||||
// settings have changed on disk
|
||||
sApp->getFromNetwork(url.toNetworkRequest(), { this, &CSetupReader::parseUpdateInfoFile});
|
||||
}
|
||||
|
||||
CSetupReader::BootstrapMode CSetupReader::stringToEnum(const QString &s)
|
||||
@@ -352,7 +346,7 @@ namespace BlackCore
|
||||
bool sameVersionLoaded = (loadedSetup == currentSetup);
|
||||
if (sameVersionLoaded)
|
||||
{
|
||||
m_distributionUrls = currentSetup.getSwiftDistributionFileUrls(); // defaults
|
||||
m_updateInfoUrls = currentSetup.getSwiftUpdateInfoFileUrls(); // defaults
|
||||
CLogMessage(this).info("Same setup version loaded from '%1' as already in data cache '%2'") << urlString << m_setup.getFilename();
|
||||
CLogMessage::preformatted(this->manageSetupAvailability(true));
|
||||
return; // success
|
||||
@@ -365,7 +359,7 @@ namespace BlackCore
|
||||
if (m.isSeverityInfoOrLess())
|
||||
{
|
||||
// no issue with cache
|
||||
m_distributionUrls = loadedSetup.getSwiftDistributionFileUrls();
|
||||
m_updateInfoUrls = loadedSetup.getSwiftUpdateInfoFileUrls();
|
||||
CLogMessage(this).info("Loaded setup from '%1'") << urlString;
|
||||
CLogMessage(this).info("Setup: Updated data cache in '%1'") << m_setup.getFilename();
|
||||
{
|
||||
@@ -395,15 +389,16 @@ namespace BlackCore
|
||||
// network error, log as warning as we will read again if possible
|
||||
// however, store as error because this will be a possible root cause if nothing else is
|
||||
nwReply->abort();
|
||||
const CStatusMessage msg = CStatusMessage(this).error("Reading setup failed '%1' '%2' (can possibly be fixed by reading from another server afterwards)") << replyMessage << urlString;
|
||||
CLogMessage::preformatted(msg);
|
||||
this->setLastSetupReadErrorMessages(msg);
|
||||
}
|
||||
|
||||
// try next one if any
|
||||
if (m_bootstrapUrls.addFailedUrl(url))
|
||||
{
|
||||
m_distributionUrls.addFailedHost(url); // the same host will likely fail for distributions
|
||||
CStatusMessage msg = CStatusMessage(this).warning("Reading setup failed %1 %2 (can possibly be fixed by reading from another %3 servers afterwards)")
|
||||
<< replyMessage << urlString
|
||||
<< m_bootstrapUrls.numberOfStillValidUrls();
|
||||
this->setLastSetupReadErrorMessages(msg);
|
||||
CLogMessage::preformatted(msg);
|
||||
QTimer::singleShot(500, this, &CSetupReader::readSetup);
|
||||
}
|
||||
else
|
||||
@@ -413,7 +408,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CSetupReader::parseDistributionsFile(QNetworkReply *nwReplyPtr)
|
||||
void CSetupReader::parseUpdateInfoFile(QNetworkReply *nwReplyPtr)
|
||||
{
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
@@ -427,9 +422,9 @@ namespace BlackCore
|
||||
if (nwReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
const qint64 lastModified = CNetworkUtils::lastModifiedMsSinceEpoch(nwReply.data());
|
||||
const QString distributionJson(nwReplyPtr->readAll());
|
||||
const QString updateInfoJsonString(nwReplyPtr->readAll());
|
||||
nwReplyPtr->close();
|
||||
if (distributionJson.isEmpty())
|
||||
if (updateInfoJsonString.isEmpty())
|
||||
{
|
||||
CLogMessage(this).info("No distribution file content");
|
||||
// try next URL
|
||||
@@ -438,30 +433,30 @@ namespace BlackCore
|
||||
{
|
||||
try
|
||||
{
|
||||
const CDistributionList loadedDistributions = CDistributionList::fromDatabaseJson(distributionJson);
|
||||
if (loadedDistributions.isEmpty())
|
||||
const CUpdateInfo updateInfo = CUpdateInfo::fromDatabaseJson(updateInfoJsonString);
|
||||
if (updateInfo.isEmpty())
|
||||
{
|
||||
CLogMessage(this).error("Loading of distribution yielded no data");
|
||||
this->manageDistributionsInfoAvailability(false);
|
||||
CLogMessage(this).error("Loading of update info yielded no data");
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CStatusMessage m = m_distributions.set(loadedDistributions, lastModified);
|
||||
CStatusMessage m = m_updateInfo.set(updateInfo, lastModified);
|
||||
if (m.isFailure())
|
||||
{
|
||||
m.addCategories(getLogCategories());
|
||||
CLogMessage::preformatted(m);
|
||||
this->manageDistributionsInfoAvailability(false);
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
QWriteLocker l(&m_lockDistribution);
|
||||
m_lastSuccessfulDistributionUrl = urlString;
|
||||
m_lastSuccessfulUpdateInfoUrl = urlString;
|
||||
}
|
||||
CLogMessage(this).info("Distribution info loaded from '%1") << urlString;
|
||||
CLogMessage(this).info("Distribution info: Updated data cache in '%1'") << m_distributions.getFilename();
|
||||
this->manageDistributionsInfoAvailability(true);
|
||||
CLogMessage(this).info("Update info loaded from '%1") << urlString;
|
||||
CLogMessage(this).info("Update info: Updated data cache in '%1', artifacts: %2, distributions: %3") << m_updateInfo.getFilename() << updateInfo.getArtifactsPilotClient().size() << updateInfo.getDistributions().size();
|
||||
this->manageUpdateInfoAvailability(true);
|
||||
} // cache
|
||||
}
|
||||
return;
|
||||
@@ -481,20 +476,22 @@ namespace BlackCore
|
||||
} // no error
|
||||
else
|
||||
{
|
||||
// network error
|
||||
// network error, try next URL
|
||||
nwReply->abort();
|
||||
CLogMessage(this).error("Reading update info failed %1 %2 (can possibly be fixed by reading from another server afterwards)") << replyMessage << urlString;
|
||||
}
|
||||
|
||||
// try next one if any
|
||||
if (m_distributionUrls.addFailedUrl(url))
|
||||
if (m_updateInfoUrls.addFailedUrl(url))
|
||||
{
|
||||
QTimer::singleShot(500, this, &CSetupReader::readDistributionInfo);
|
||||
CLogMessage(this).warning("Reading update info failed %1 %2 (can possibly be fixed by reading from another %3 servers afterwards)")
|
||||
<< replyMessage << urlString
|
||||
<< m_updateInfoUrls.numberOfStillValidUrls();
|
||||
QTimer::singleShot(500, this, &CSetupReader::readUpdateInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CStatusMessageList msgs = this->manageSetupAvailability(false);
|
||||
CLogMessage::preformatted(msgs);
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
CLogMessage(this).error("Reading update info failed %1 %2, failed URLs %3") << replyMessage << urlString << m_updateInfoUrls.getFailedUrlsSize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,26 +558,26 @@ namespace BlackCore
|
||||
return m_lastSuccessfulSetupUrl;
|
||||
}
|
||||
|
||||
CDistributionList CSetupReader::getDistributionInfo() const
|
||||
CUpdateInfo CSetupReader::getUpdateInfo() const
|
||||
{
|
||||
return m_distributions.get();
|
||||
return m_updateInfo.get();
|
||||
}
|
||||
|
||||
bool CSetupReader::hasCachedDistributionInfo() const
|
||||
bool CSetupReader::hasCachedUpdateInfo() const
|
||||
{
|
||||
const CDistributionList distributions = m_distributions.get();
|
||||
return !distributions.isEmpty();
|
||||
const CUpdateInfo updateInfo = m_updateInfo.get();
|
||||
return !updateInfo.isEmpty();
|
||||
}
|
||||
|
||||
QDateTime CSetupReader::getDistributionCacheTimestamp() const
|
||||
{
|
||||
return m_distributions.getTimestamp();
|
||||
return m_updateInfo.getTimestamp();
|
||||
}
|
||||
|
||||
QString CSetupReader::getLastSuccessfulDistributionUrl() const
|
||||
{
|
||||
QReadLocker l(&m_lockDistribution);
|
||||
return m_lastSuccessfulDistributionUrl;
|
||||
return m_lastSuccessfulUpdateInfoUrl;
|
||||
}
|
||||
|
||||
CStatusMessageList CSetupReader::getLastSetupReadErrorMessages() const
|
||||
@@ -600,8 +597,8 @@ namespace BlackCore
|
||||
switch (m_bootstrapMode)
|
||||
{
|
||||
case CacheOnly: return "cache only";
|
||||
case Explicit: return "explicit";
|
||||
case Implicit: return "implicit";
|
||||
case Explicit: return "explicit";
|
||||
case Implicit: return "implicit";
|
||||
default: break;
|
||||
}
|
||||
return "";
|
||||
@@ -619,13 +616,13 @@ namespace BlackCore
|
||||
CStatusMessageList msgs;
|
||||
if (webRead)
|
||||
{
|
||||
msgs.push_back(CStatusMessage(this).info("Setup loaded from web, will trigger read of distribution information"));
|
||||
QTimer::singleShot(500, this, &CSetupReader::readDistributionInfo);
|
||||
msgs.push_back(CStatusMessage(this).info("Setup loaded from web, will trigger read of update information"));
|
||||
QTimer::singleShot(500, this, &CSetupReader::readUpdateInfo);
|
||||
}
|
||||
if (localRead)
|
||||
{
|
||||
msgs.push_back(CStatusMessage(this).info("Setup loaded locally, will trigger read of distribution information"));
|
||||
QTimer::singleShot(500, this, &CSetupReader::readDistributionInfo);
|
||||
msgs.push_back(CStatusMessage(this).info("Setup loaded locally, will trigger read of update information"));
|
||||
QTimer::singleShot(500, this, &CSetupReader::readUpdateInfo);
|
||||
}
|
||||
|
||||
bool available = false;
|
||||
@@ -635,7 +632,7 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
bool cacheAvailable = m_setup.get().wasLoaded();
|
||||
const bool cacheAvailable = m_setup.get().wasLoaded();
|
||||
available = cacheAvailable && m_bootstrapMode != Explicit;
|
||||
}
|
||||
|
||||
@@ -657,23 +654,23 @@ namespace BlackCore
|
||||
if (!webRead && !localRead)
|
||||
{
|
||||
msgs.push_back(CStatusMessage(this).warning("Since setup was not updated this time, will not start loading of update information"));
|
||||
this->manageDistributionsInfoAvailability(false);
|
||||
this->manageUpdateInfoAvailability(false);
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CSetupReader::manageDistributionsInfoAvailability(bool webRead)
|
||||
void CSetupReader::manageUpdateInfoAvailability(bool webRead)
|
||||
{
|
||||
if (webRead)
|
||||
{
|
||||
m_distributionInfoAvailable = true;
|
||||
emit distributionInfoAvailable(true);
|
||||
m_updateInfoAvailable = true;
|
||||
emit updateInfoAvailable(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool cached = m_distributions.isSaved();
|
||||
m_distributionInfoAvailable = cached;
|
||||
emit distributionInfoAvailable(cached);
|
||||
const bool cached = m_updateInfo.isSaved();
|
||||
m_updateInfoAvailable = cached;
|
||||
emit updateInfoAvailable(cached);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackmisc/db/distributionlist.h"
|
||||
#include "blackmisc/db/updateinfo.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/network/urllist.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
@@ -44,7 +44,7 @@ namespace BlackCore
|
||||
//! Once the file is in place (i.e. in the cache) it can be automatically updated.
|
||||
//!
|
||||
//! \sa BlackCore::Data::TGlobalSetup
|
||||
//! \sa BlackMisc::Db::TDistributionInfo
|
||||
//! \sa BlackMisc::Db::TUpdateInfo
|
||||
class BLACKCORE_EXPORT CSetupReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -91,13 +91,13 @@ namespace BlackCore
|
||||
//! \threadsafe
|
||||
QString getLastSuccessfulSetupUrl() const;
|
||||
|
||||
//! Distributions info (channel, version, platforms, download URLs)
|
||||
//! Update info (artifacts and distributions)
|
||||
//! \threadsafe
|
||||
BlackMisc::Db::CDistributionList getDistributionInfo() const;
|
||||
BlackMisc::Db::CUpdateInfo getUpdateInfo() const;
|
||||
|
||||
//! Has cached distribution info?
|
||||
//! \threadsafe
|
||||
bool hasCachedDistributionInfo() const;
|
||||
bool hasCachedUpdateInfo() const;
|
||||
|
||||
//! Distribution cache timestamp
|
||||
//! \threadsafe
|
||||
@@ -120,8 +120,8 @@ namespace BlackCore
|
||||
//! Setup fetched or failed (from web, cache, or local file)
|
||||
void setupHandlingCompleted(bool available);
|
||||
|
||||
//! Setup avialable (from web, cache
|
||||
void distributionInfoAvailable(bool available);
|
||||
//! Update infao available (from web, cache)
|
||||
void updateInfoAvailable(bool available);
|
||||
|
||||
//! A shared URL was successfully read
|
||||
void successfullyReadSharedUrl(const BlackMisc::Network::CUrl &sharedUrl);
|
||||
@@ -148,7 +148,7 @@ namespace BlackCore
|
||||
|
||||
//! Version info available?
|
||||
//! \threadsafe
|
||||
bool isUpdateInfoAvailable() const { return m_distributionInfoAvailable; }
|
||||
bool isUpdateInfoAvailable() const { return m_updateInfoAvailable; }
|
||||
|
||||
private:
|
||||
//! Bootstrap mode
|
||||
@@ -160,39 +160,36 @@ namespace BlackCore
|
||||
};
|
||||
|
||||
std::atomic<bool> m_shutdown { false };
|
||||
std::atomic<bool> m_setupAvailable { false };
|
||||
std::atomic<bool> m_distributionInfoAvailable { false };
|
||||
std::atomic<bool> m_setupAvailable { false }; //!< setup available
|
||||
std::atomic<bool> m_updateInfoAvailable { false }; //!< update info available
|
||||
std::atomic<bool> m_ignoreCmdBootstrapUrl { false }; //!< ignore the explicitly set bootstrap URL
|
||||
std::atomic<bool> m_checkCmdBootstrapUrl { true }; //!< check connection on CMD bootstrap URL
|
||||
QString m_localSetupFileValue; //!< Local file for setup, passed by cmd line arguments
|
||||
QString m_bootstrapUrlFileValue; //!< Bootstrap URL if not local
|
||||
BootstrapMode m_bootstrapMode = Explicit; //!< How to bootstrap
|
||||
BlackMisc::Network::CFailoverUrlList m_bootstrapUrls; //!< location of setup files
|
||||
BlackMisc::Network::CFailoverUrlList m_distributionUrls; //!< location of info files
|
||||
BlackMisc::Network::CFailoverUrlList m_updateInfoUrls; //!< location of info files
|
||||
QCommandLineOption m_cmdBootstrapUrl; //!< bootstrap URL
|
||||
QCommandLineOption m_cmdBootstrapMode; //!< bootstrap mode
|
||||
mutable QReadWriteLock m_lockSetup; //!< lock for setup
|
||||
mutable QReadWriteLock m_lockDistribution; //!< lock for distribution
|
||||
mutable QReadWriteLock m_lockUpdateInfo; //!< lock for update info
|
||||
QString m_lastSuccessfulSetupUrl; //!< last successful read setup URL
|
||||
QString m_lastSuccessfulDistributionUrl; //!< last successful read distribution URL
|
||||
QString m_lastSuccessfulUpdateInfoUrl; //!< last successful read update info URL
|
||||
BlackMisc::CStatusMessageList m_setupReadErrorMsgs; //!< last parsing error messages
|
||||
BlackMisc::CData<BlackCore::Data::TGlobalSetup> m_setup { this, &CSetupReader::setupChanged }; //!< data cache setup
|
||||
BlackMisc::CData<BlackMisc::Db::TDistributionsInfo> m_distributions { this }; //!< data cache distributions
|
||||
BlackMisc::CData<Data::TGlobalSetup> m_setup { this }; //!< data cache setup
|
||||
BlackMisc::CData<BlackMisc::Db::TUpdateInfo> m_updateInfo { this }; //!< data cache distributions
|
||||
|
||||
//! Setup has been read (aka bootstrap file)
|
||||
void parseSetupFile(QNetworkReply *nwReply);
|
||||
void parseBootstrapFile(QNetworkReply *nwReplyPtr);
|
||||
|
||||
//! Update info has been read
|
||||
void parseDistributionsFile(QNetworkReply *nwReplyPtr);
|
||||
void parseUpdateInfoFile(QNetworkReply *nwReplyPtr);
|
||||
|
||||
//! Do reading
|
||||
void readSetup();
|
||||
|
||||
//! Do reading of distributions
|
||||
void readDistributionInfo();
|
||||
|
||||
//! Setup has been changed
|
||||
void setupChanged();
|
||||
void readUpdateInfo();
|
||||
|
||||
//! Read by local individual file and update cache from that
|
||||
BlackMisc::CStatusMessageList readLocalBootstrapFile(const QString &fileName);
|
||||
@@ -206,12 +203,12 @@ namespace BlackCore
|
||||
|
||||
//! Emit the available signal
|
||||
//! \threadsafe
|
||||
void manageDistributionsInfoAvailability(bool webRead);
|
||||
void manageUpdateInfoAvailability(bool webRead);
|
||||
|
||||
//! Set last setup parsing messages
|
||||
void setLastSetupReadErrorMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
|
||||
//! Convert string to mode
|
||||
//! Convert string to bootstrap mode
|
||||
static BootstrapMode stringToEnum(const QString &s);
|
||||
|
||||
//! Bootsrap URL used for unit tests
|
||||
|
||||
Reference in New Issue
Block a user