mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #507, changed setup reader and simplied global setup and setup reader
* a single base URL (shared), derived URLs by appended path * simplified dir structure shared with sub directories * renamed functions * automatically synchronize setup with DB when initialized * trigger download info loading when setup is completed * allow to automatically read after setup data have been synchronized * read DB data when setup has been loaded * allow to reload from threaded reader * improved handling (log messages, skip reading) when data are not available
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4d4d6fcdc9
commit
d131cd2d33
@@ -170,6 +170,8 @@ namespace BlackMisc
|
||||
bool CProject::isNewerVersion(const QString &versionString)
|
||||
{
|
||||
if (versionString.isEmpty()) { return false; }
|
||||
if (CProject::version() == versionString) { return false; }
|
||||
|
||||
QList<int> newer(getVersionParts(versionString));
|
||||
QList<int> current(getVersionParts(version()));
|
||||
for (int i = 0; i < current.length(); i++)
|
||||
@@ -178,7 +180,7 @@ namespace BlackMisc
|
||||
if (current.at(i) > newer.at(i)) { return false; }
|
||||
if (current.at(i) < newer.at(i)) { return true; }
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CProject::isDebugBuild()
|
||||
@@ -295,6 +297,12 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const QStringList &CProject::swiftTeamDefaultServers()
|
||||
{
|
||||
static const QStringList s( { "https://vatsim-germany.org:50443/mapping/public/shared", "http://ubuntu12/public/bootstrap/shared"});
|
||||
return s;
|
||||
}
|
||||
|
||||
QString CProject::envVarPrivateSetupDirValue()
|
||||
{
|
||||
return QProcessEnvironment::systemEnvironment().value(envVarPrivateSetupDir());
|
||||
|
||||
@@ -144,6 +144,9 @@ namespace BlackMisc
|
||||
//! Executable name for swift data, no(!) appendix
|
||||
static const QString &swiftDataExecutableName();
|
||||
|
||||
//! swift team default servers for DB, bootstrap etc.
|
||||
static const QStringList &swiftTeamDefaultServers();
|
||||
|
||||
private:
|
||||
//! Constructor
|
||||
CProject() {}
|
||||
|
||||
@@ -19,6 +19,19 @@ namespace BlackMisc
|
||||
m_updateTimer(new QTimer(this))
|
||||
{ }
|
||||
|
||||
qint64 CThreadedReader::lastModifiedMsSinceEpoch(QNetworkReply *nwReply) const
|
||||
{
|
||||
if (nwReply)
|
||||
{
|
||||
QVariant lastModifiedQv = nwReply->header(QNetworkRequest::LastModifiedHeader);
|
||||
if (lastModifiedQv.isValid() && lastModifiedQv.canConvert<QDateTime>())
|
||||
{
|
||||
return lastModifiedQv.value<QDateTime>().toMSecsSinceEpoch();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CThreadedReader::isFinishedOrShutdown() const
|
||||
{
|
||||
return m_shutdown || isFinished();
|
||||
@@ -38,14 +51,20 @@ namespace BlackMisc
|
||||
|
||||
void CThreadedReader::requestStop()
|
||||
{
|
||||
setFinished();
|
||||
QMetaObject::invokeMethod(m_updateTimer, "stop");
|
||||
}
|
||||
|
||||
void CThreadedReader::requestReload()
|
||||
{
|
||||
// default implementation, subclasses shall override as required
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
void CThreadedReader::gracefulShutdown()
|
||||
{
|
||||
this->m_shutdown = true;
|
||||
this->requestStop();
|
||||
this->quit();
|
||||
}
|
||||
|
||||
CThreadedReader::~CThreadedReader()
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
void requestStop();
|
||||
|
||||
//! Request new reading
|
||||
//! \note override as required, default is to call initialize()
|
||||
virtual void requestReload();
|
||||
|
||||
//! Destructor
|
||||
virtual ~CThreadedReader();
|
||||
|
||||
@@ -62,13 +66,16 @@ namespace BlackMisc
|
||||
void gracefulShutdown();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CThreadedReader(QObject *owner, const QString &name);
|
||||
|
||||
QTimer *m_updateTimer = nullptr; //!< update timer
|
||||
std::atomic<bool> m_shutdown { false }; //!< in shutdown process
|
||||
mutable QReadWriteLock m_lock {QReadWriteLock::Recursive}; //!< lock which can be used from the derived classes
|
||||
|
||||
//! Constructor
|
||||
CThreadedReader(QObject *owner, const QString &name);
|
||||
|
||||
//! When was reply last modified, -1 if N/A
|
||||
qint64 lastModifiedMsSinceEpoch(QNetworkReply *nwReply) const;
|
||||
|
||||
//! Shutdown in progress or finished
|
||||
bool isFinishedOrShutdown() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user