mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #509,renamed CDownload to CUpdateInfo
* as discussed in meeting * follow up adjustments (file renaming, msg. renaming)
This commit is contained in:
@@ -10,7 +10,7 @@ OTHER_FILES += local.env.template/*.*
|
|||||||
OTHER_FILES += local.env.template/bootstrap/*.*
|
OTHER_FILES += local.env.template/bootstrap/*.*
|
||||||
OTHER_FILES += shared//bootstrap/*.*
|
OTHER_FILES += shared//bootstrap/*.*
|
||||||
OTHER_FILES += shared/dbdata/*.*
|
OTHER_FILES += shared/dbdata/*.*
|
||||||
OTHER_FILES += shared/download/*.*
|
OTHER_FILES += shared/updateinfo/*.*
|
||||||
|
|
||||||
COPY_FILES += $$PWD/data/images/flags/*.png
|
COPY_FILES += $$PWD/data/images/flags/*.png
|
||||||
COPY_FILES += $$PWD/data/images/airlines/*.png
|
COPY_FILES += $$PWD/data/images/airlines/*.png
|
||||||
@@ -18,7 +18,7 @@ COPY_FILES += $$PWD/local.env.template/*.*
|
|||||||
COPY_FILES += $$PWD/local.env.template/bootstrap/*.*
|
COPY_FILES += $$PWD/local.env.template/bootstrap/*.*
|
||||||
COPY_FILES += $$PWD/shared/bootstrap/*.*
|
COPY_FILES += $$PWD/shared/bootstrap/*.*
|
||||||
COPY_FILES += $$PWD/shared/dbdata/*.*
|
COPY_FILES += $$PWD/shared/dbdata/*.*
|
||||||
COPY_FILES += $$PWD/shared/download/*.*
|
COPY_FILES += $$PWD/shared/updateinfo/*.*
|
||||||
|
|
||||||
package_resources.path = $$PREFIX
|
package_resources.path = $$PREFIX
|
||||||
package_resources.files += data
|
package_resources.files += data
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "blackcorefreefunctions.h"
|
#include "blackcorefreefunctions.h"
|
||||||
#include "blackcore/webreaderflags.h"
|
#include "blackcore/webreaderflags.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/download.h"
|
#include "blackcore/data/updateinfo.h"
|
||||||
|
|
||||||
|
|
||||||
#include "voice_channel.h"
|
#include "voice_channel.h"
|
||||||
@@ -29,7 +29,7 @@ namespace BlackCore
|
|||||||
qDBusRegisterMetaType<BlackCore::CLogSubscriptionPair>();
|
qDBusRegisterMetaType<BlackCore::CLogSubscriptionPair>();
|
||||||
|
|
||||||
BlackCore::Data::CGlobalSetup::registerMetadata();
|
BlackCore::Data::CGlobalSetup::registerMetadata();
|
||||||
BlackCore::Data::CDownload::registerMetadata();
|
BlackCore::Data::CUpdateInfo::registerMetadata();
|
||||||
BlackCore::CSetupReader::instance(); // kick off reader
|
BlackCore::CSetupReader::instance(); // kick off reader
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ namespace BlackCore
|
|||||||
CGlobalSetup::versionString() + "/productive/bootstrap/bootstrap.json");
|
CGlobalSetup::versionString() + "/productive/bootstrap/bootstrap.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrlList CGlobalSetup::downloadInfoUrls() const
|
CUrlList CGlobalSetup::updateInfoUrls() const
|
||||||
{
|
{
|
||||||
CUrlList urls(m_sharedUrls);
|
CUrlList urls(m_sharedUrls);
|
||||||
return urls.appendPath(isDevelopment() ?
|
return urls.appendPath(isDevelopment() ?
|
||||||
CGlobalSetup::versionString() + "/development/download/download.json" :
|
CGlobalSetup::versionString() + "/development/updateinfo/updateinfo.json" :
|
||||||
CGlobalSetup::versionString() + "/productive/download/download.json");
|
CGlobalSetup::versionString() + "/productive/updateinfo/updateinfo.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
CUrlList CGlobalSetup::swiftDbDataFileLocationUrls() const
|
CUrlList CGlobalSetup::swiftDbDataFileLocationUrls() const
|
||||||
@@ -117,8 +117,8 @@ namespace BlackCore
|
|||||||
s.append(boolToYesNo(isDevelopment()));
|
s.append(boolToYesNo(isDevelopment()));
|
||||||
s.append(separator);
|
s.append(separator);
|
||||||
|
|
||||||
s.append("Download URLs: ");
|
s.append("Update info URLs: ");
|
||||||
s.append(downloadInfoUrls().toQString(i18n));
|
s.append(updateInfoUrls().toQString(i18n));
|
||||||
s.append(separator);
|
s.append(separator);
|
||||||
s.append("Bootstrap URLs: ");
|
s.append("Bootstrap URLs: ");
|
||||||
s.append(bootstrapUrls().toQString(i18n));
|
s.append(bootstrapUrls().toQString(i18n));
|
||||||
@@ -183,8 +183,8 @@ namespace BlackCore
|
|||||||
return CVariant::fromValue(this->m_vatsimDataFileUrls);
|
return CVariant::fromValue(this->m_vatsimDataFileUrls);
|
||||||
case IndexVatsimMetars:
|
case IndexVatsimMetars:
|
||||||
return CVariant::fromValue(this->m_vatsimMetarsUrl);
|
return CVariant::fromValue(this->m_vatsimMetarsUrl);
|
||||||
case IndexDownload:
|
case IndexUpdateInfo:
|
||||||
return CVariant::fromValue(this->downloadInfoUrls());
|
return CVariant::fromValue(this->updateInfoUrls());
|
||||||
case IndexBootstrap:
|
case IndexBootstrap:
|
||||||
return CVariant::fromValue(this->bootstrapUrls());
|
return CVariant::fromValue(this->bootstrapUrls());
|
||||||
case IndexSwiftDbFiles:
|
case IndexSwiftDbFiles:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
//! Settings for readers
|
//! Global settings for readers, debug flags, etc.
|
||||||
class BLACKCORE_EXPORT CGlobalSetup :
|
class BLACKCORE_EXPORT CGlobalSetup :
|
||||||
public BlackMisc::CValueObject<CGlobalSetup>,
|
public BlackMisc::CValueObject<CGlobalSetup>,
|
||||||
public BlackMisc::ITimestampBased
|
public BlackMisc::ITimestampBased
|
||||||
@@ -42,7 +42,7 @@ namespace BlackCore
|
|||||||
IndexVatsimData,
|
IndexVatsimData,
|
||||||
IndexSwiftDbFiles,
|
IndexSwiftDbFiles,
|
||||||
IndexBootstrap,
|
IndexBootstrap,
|
||||||
IndexDownload,
|
IndexUpdateInfo,
|
||||||
IndexShared
|
IndexShared
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ namespace BlackCore
|
|||||||
//! Bootstrap URLs (where the data for the setup itself can be downloaded)
|
//! Bootstrap URLs (where the data for the setup itself can be downloaded)
|
||||||
BlackMisc::Network::CUrlList bootstrapUrls() const;
|
BlackMisc::Network::CUrlList bootstrapUrls() const;
|
||||||
|
|
||||||
//! Version files and download locations
|
//! Version and download locations
|
||||||
BlackMisc::Network::CUrlList downloadInfoUrls() const;
|
BlackMisc::Network::CUrlList updateInfoUrls() const;
|
||||||
|
|
||||||
//! Alternative locations of swift DB data files
|
//! Alternative locations of swift DB data files
|
||||||
BlackMisc::Network::CUrlList swiftDbDataFileLocationUrls() const;
|
BlackMisc::Network::CUrlList swiftDbDataFileLocationUrls() const;
|
||||||
@@ -149,7 +149,7 @@ namespace BlackCore
|
|||||||
struct GlobalSetup : public BlackCore::CDataTrait<CGlobalSetup>
|
struct GlobalSetup : public BlackCore::CDataTrait<CGlobalSetup>
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "readers/global/bootstrap"; }
|
static const char *key() { return "readers/global/setup"; }
|
||||||
|
|
||||||
//! Default value
|
//! Default value
|
||||||
static const CGlobalSetup &defaultValue()
|
static const CGlobalSetup &defaultValue()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "download.h"
|
#include "updateinfo.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -19,7 +19,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
CDownload::CDownload() :
|
CUpdateInfo::CUpdateInfo() :
|
||||||
ITimestampBased(0),
|
ITimestampBased(0),
|
||||||
m_downloadsStableUrls(QStringList {"http://swift-project.org/"}),
|
m_downloadsStableUrls(QStringList {"http://swift-project.org/"}),
|
||||||
m_downloadsBetaUrls(QStringList {"http://swift-project.org/"}),
|
m_downloadsBetaUrls(QStringList {"http://swift-project.org/"}),
|
||||||
@@ -29,27 +29,27 @@ namespace BlackCore
|
|||||||
m_lastSupportedVersionBeta("0.6")
|
m_lastSupportedVersionBeta("0.6")
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CUrlList CDownload::getDownloadUrls() const
|
CUrlList CUpdateInfo::getDownloadUrls() const
|
||||||
{
|
{
|
||||||
return CProject::isBetaTest() ? getDownloadUrlsBeta() : getDownloadUrlsStable();
|
return CProject::isBetaTest() ? getDownloadUrlsBeta() : getDownloadUrlsStable();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CDownload::getLatestVersion() const
|
QString CUpdateInfo::getLatestVersion() const
|
||||||
{
|
{
|
||||||
return CProject::isBetaTest() ? getLatestVersionBeta() : getLatestVersionStable();
|
return CProject::isBetaTest() ? getLatestVersionBeta() : getLatestVersionStable();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDownload::hasSameType(const CDownload &otherDownload) const
|
bool CUpdateInfo::hasSameType(const CUpdateInfo &otherDownload) const
|
||||||
{
|
{
|
||||||
return this->isDevelopment() == otherDownload.isDevelopment();
|
return this->isDevelopment() == otherDownload.isDevelopment();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CDownload::convertToQString(bool i18n) const
|
QString CUpdateInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
return convertToQString(", ", i18n);
|
return convertToQString(", ", i18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CDownload::convertToQString(const QString &separator, bool i18n) const
|
QString CUpdateInfo::convertToQString(const QString &separator, bool i18n) const
|
||||||
{
|
{
|
||||||
QString s("timestamp: ");
|
QString s("timestamp: ");
|
||||||
s.append(this->getFormattedUtcTimestampYmdhms());
|
s.append(this->getFormattedUtcTimestampYmdhms());
|
||||||
@@ -75,7 +75,7 @@ namespace BlackCore
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVariant CDownload::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
CVariant CUpdateInfo::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||||
@@ -100,9 +100,9 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDownload::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
void CUpdateInfo::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { (*this) = variant.to<CDownload>(); return; }
|
if (index.isMyself()) { (*this) = variant.to<CUpdateInfo>(); return; }
|
||||||
if (ITimestampBased::canHandleIndex(index))
|
if (ITimestampBased::canHandleIndex(index))
|
||||||
{
|
{
|
||||||
ITimestampBased::setPropertyByIndex(variant, index);
|
ITimestampBased::setPropertyByIndex(variant, index);
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
//! \file
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKCORE_DATA_DOWNLOAD_H
|
#ifndef BLACKCORE_DATA_UPDATEINFO_H
|
||||||
#define BLACKCORE_DATA_DOWNLOAD_H
|
#define BLACKCORE_DATA_UPDATEINFO_H
|
||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
#include "blackcore/blackcoreexport.h"
|
||||||
#include "blackcore/datacache.h"
|
#include "blackcore/datacache.h"
|
||||||
@@ -23,15 +23,15 @@ namespace BlackCore
|
|||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
//! Download locations and versions
|
//! Download locations and versions
|
||||||
class BLACKCORE_EXPORT CDownload :
|
class BLACKCORE_EXPORT CUpdateInfo :
|
||||||
public BlackMisc::CValueObject<CDownload>,
|
public BlackMisc::CValueObject<CUpdateInfo>,
|
||||||
public BlackMisc::ITimestampBased
|
public BlackMisc::ITimestampBased
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexDownloadUrlsStable = BlackMisc::CPropertyIndex::GlobalIndexCDownload,
|
IndexDownloadUrlsStable = BlackMisc::CPropertyIndex::GlobalIndexCUpdateInfo,
|
||||||
IndexDownloadUrlsBeta,
|
IndexDownloadUrlsBeta,
|
||||||
IndexLatestVersionStable,
|
IndexLatestVersionStable,
|
||||||
IndexLastSupportedVersionStable,
|
IndexLastSupportedVersionStable,
|
||||||
@@ -40,10 +40,10 @@ namespace BlackCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
CDownload();
|
CUpdateInfo();
|
||||||
|
|
||||||
//! Destructor.
|
//! Destructor.
|
||||||
~CDownload() {}
|
~CUpdateInfo() {}
|
||||||
|
|
||||||
//! Download URLs, ie here one can download installer
|
//! Download URLs, ie here one can download installer
|
||||||
const BlackMisc::Network::CUrlList &getDownloadUrlsBeta() const { return m_downloadsBetaUrls; }
|
const BlackMisc::Network::CUrlList &getDownloadUrlsBeta() const { return m_downloadsBetaUrls; }
|
||||||
@@ -73,7 +73,7 @@ namespace BlackCore
|
|||||||
bool isDevelopment() const { return m_development; }
|
bool isDevelopment() const { return m_development; }
|
||||||
|
|
||||||
//! Same type
|
//! Same type
|
||||||
bool hasSameType(const CDownload &otherDownload) const;
|
bool hasSameType(const CUpdateInfo &otherDownload) const;
|
||||||
|
|
||||||
//! Productive settings?
|
//! Productive settings?
|
||||||
void setDevelopment(bool development) { m_development = development; }
|
void setDevelopment(bool development) { m_development = development; }
|
||||||
@@ -91,7 +91,7 @@ namespace BlackCore
|
|||||||
void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CDownload)
|
BLACK_ENABLE_TUPLE_CONVERSION(BlackCore::Data::CUpdateInfo)
|
||||||
|
|
||||||
bool m_development = false; //!< for development
|
bool m_development = false; //!< for development
|
||||||
BlackMisc::Network::CUrlList m_downloadsStableUrls; //!< Download URLs, here I get the installer
|
BlackMisc::Network::CUrlList m_downloadsStableUrls; //!< Download URLs, here I get the installer
|
||||||
@@ -103,15 +103,15 @@ namespace BlackCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Trait for global setup data
|
//! Trait for global setup data
|
||||||
struct Download : public BlackCore::CDataTrait<CDownload>
|
struct UpdateInfo : public BlackCore::CDataTrait<CUpdateInfo>
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "readers/global/download"; }
|
static const char *key() { return "readers/global/updateinfo"; }
|
||||||
|
|
||||||
//! Default value
|
//! Default value
|
||||||
static const CDownload &defaultValue()
|
static const CUpdateInfo &defaultValue()
|
||||||
{
|
{
|
||||||
static const CDownload defaultValue;
|
static const CUpdateInfo defaultValue;
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -119,8 +119,8 @@ namespace BlackCore
|
|||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackCore::Data::CDownload)
|
Q_DECLARE_METATYPE(BlackCore::Data::CUpdateInfo)
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackCore::Data::CDownload, (
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackCore::Data::CUpdateInfo, (
|
||||||
attr(o.m_timestampMSecsSinceEpoch),
|
attr(o.m_timestampMSecsSinceEpoch),
|
||||||
attr(o.m_development),
|
attr(o.m_development),
|
||||||
attr(o.m_downloadsStableUrls),
|
attr(o.m_downloadsStableUrls),
|
||||||
@@ -41,13 +41,13 @@ namespace BlackCore
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->m_bootstrapUrls.uniqueWrite()->push_back(m_setup.get().bootstrapUrls());
|
this->m_bootstrapUrls.uniqueWrite()->push_back(m_setup.get().bootstrapUrls());
|
||||||
this->m_downloadUrls.uniqueWrite()->push_back(m_setup.get().downloadInfoUrls());
|
this->m_updateInfoUrls.uniqueWrite()->push_back(m_setup.get().updateInfoUrls());
|
||||||
|
|
||||||
this->m_networkManagerBootstrap = new QNetworkAccessManager(this);
|
this->m_networkManagerBootstrap = new QNetworkAccessManager(this);
|
||||||
this->connect(this->m_networkManagerBootstrap, &QNetworkAccessManager::finished, this, &CSetupReader::ps_parseSetupFile);
|
this->connect(this->m_networkManagerBootstrap, &QNetworkAccessManager::finished, this, &CSetupReader::ps_parseSetupFile);
|
||||||
|
|
||||||
this->m_networkManagerDownload = new QNetworkAccessManager(this);
|
this->m_networkManagerUpdateInfo = new QNetworkAccessManager(this);
|
||||||
this->connect(this->m_networkManagerDownload, &QNetworkAccessManager::finished, this, &CSetupReader::ps_parseDownloadFile);
|
this->connect(this->m_networkManagerUpdateInfo, &QNetworkAccessManager::finished, this, &CSetupReader::ps_parseUpdateInfoFile);
|
||||||
|
|
||||||
this->start(QThread::LowPriority);
|
this->start(QThread::LowPriority);
|
||||||
}
|
}
|
||||||
@@ -82,19 +82,19 @@ namespace BlackCore
|
|||||||
this->m_networkManagerBootstrap->get(request);
|
this->m_networkManagerBootstrap->get(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSetupReader::ps_readDownload()
|
void CSetupReader::ps_readUpdateInfo()
|
||||||
{
|
{
|
||||||
this->threadAssertCheck();
|
this->threadAssertCheck();
|
||||||
Q_ASSERT_X(this->m_networkManagerDownload, Q_FUNC_INFO, "Missing network manager");
|
Q_ASSERT_X(this->m_networkManagerUpdateInfo, Q_FUNC_INFO, "Missing network manager");
|
||||||
CUrl url(this->m_downloadUrls.uniqueWrite()->getNextWorkingUrl());
|
CUrl url(this->m_updateInfoUrls.uniqueWrite()->getNextWorkingUrl());
|
||||||
if (url.isEmpty())
|
if (url.isEmpty())
|
||||||
{
|
{
|
||||||
CLogMessage(this).warning("Cannot read download (info), failed URLs: %1") << this->m_downloadUrls.read()->getFailedUrls();
|
CLogMessage(this).warning("Cannot read update info, failed URLs: %1") << this->m_updateInfoUrls.read()->getFailedUrls();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
CNetworkUtils::ignoreSslVerification(request);
|
CNetworkUtils::ignoreSslVerification(request);
|
||||||
this->m_networkManagerDownload->get(request);
|
this->m_networkManagerUpdateInfo->get(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSetupReader::ps_setupSyncronized(bool success)
|
void CSetupReader::ps_setupSyncronized(bool success)
|
||||||
@@ -102,8 +102,8 @@ namespace BlackCore
|
|||||||
// trigger
|
// trigger
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Setup synchronized, will trigger read of download information");
|
CLogMessage(this).info("Setup synchronized, will trigger read of update information");
|
||||||
QTimer::singleShot(500, this, &CSetupReader::ps_readDownload);
|
QTimer::singleShot(500, this, &CSetupReader::ps_readUpdateInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -222,7 +222,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSetupReader::ps_parseDownloadFile(QNetworkReply *nwReplyPtr)
|
void CSetupReader::ps_parseUpdateInfoFile(QNetworkReply *nwReplyPtr)
|
||||||
{
|
{
|
||||||
// wrap pointer, make sure any exit cleans up reply
|
// wrap pointer, make sure any exit cleans up reply
|
||||||
// required to use delete later as object is created in a different thread
|
// required to use delete later as object is created in a different thread
|
||||||
@@ -235,7 +235,7 @@ namespace BlackCore
|
|||||||
if (this->isFinishedOrShutdown())
|
if (this->isFinishedOrShutdown())
|
||||||
{
|
{
|
||||||
CLogMessage(this).debug() << Q_FUNC_INFO;
|
CLogMessage(this).debug() << Q_FUNC_INFO;
|
||||||
CLogMessage(this).info("Terminated loading download info");
|
CLogMessage(this).info("Terminated loading of update info");
|
||||||
nwReply->abort();
|
nwReply->abort();
|
||||||
return; // stop, terminate straight away, ending thread
|
return; // stop, terminate straight away, ending thread
|
||||||
}
|
}
|
||||||
@@ -247,35 +247,35 @@ namespace BlackCore
|
|||||||
nwReplyPtr->close();
|
nwReplyPtr->close();
|
||||||
if (setupJson.isEmpty())
|
if (setupJson.isEmpty())
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("No download (info) file");
|
CLogMessage(this).info("No update info file");
|
||||||
// try next URL
|
// try next URL
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CDownload currentDownload(m_download.get()); // from cache
|
CUpdateInfo currentUpdateInfo(m_updateInfo.get()); // from cache
|
||||||
CDownload loadedDownload;
|
CUpdateInfo loadedUpdateInfo;
|
||||||
loadedDownload.convertFromJson(Json::jsonObjectFromString(setupJson));
|
loadedUpdateInfo.convertFromJson(Json::jsonObjectFromString(setupJson));
|
||||||
loadedDownload.setDevelopment(isForDevelopment()); // always update, regardless what persistent setting says
|
loadedUpdateInfo.setDevelopment(isForDevelopment()); // always update, regardless what persistent setting says
|
||||||
if (loadedDownload.getMSecsSinceEpoch() == 0 && lastModified > 0) { loadedDownload.setMSecsSinceEpoch(lastModified); }
|
if (loadedUpdateInfo.getMSecsSinceEpoch() == 0 && lastModified > 0) { loadedUpdateInfo.setMSecsSinceEpoch(lastModified); }
|
||||||
qint64 currentVersionTimestamp = currentDownload.getMSecsSinceEpoch();
|
qint64 currentVersionTimestamp = currentUpdateInfo.getMSecsSinceEpoch();
|
||||||
qint64 newVersionTimestamp = loadedDownload.getMSecsSinceEpoch();
|
qint64 newVersionTimestamp = loadedUpdateInfo.getMSecsSinceEpoch();
|
||||||
bool sameVersionLoaded = (loadedDownload == currentDownload);
|
bool sameVersionLoaded = (loadedUpdateInfo == currentUpdateInfo);
|
||||||
if (sameVersionLoaded)
|
if (sameVersionLoaded)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Same download info loaded from %1 as already in data cache %2") << urlString << m_download.getFilename();
|
CLogMessage(this).info("Same update info loaded from %1 as already in data cache %2") << urlString << m_updateInfo.getFilename();
|
||||||
return; // success
|
return; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sameType = loadedDownload.hasSameType(currentDownload);
|
bool sameType = loadedUpdateInfo.hasSameType(currentUpdateInfo);
|
||||||
bool outdatedVersionLoaded = sameType && (newVersionTimestamp < currentVersionTimestamp);
|
bool outdatedVersionLoaded = sameType && (newVersionTimestamp < currentVersionTimestamp);
|
||||||
if (outdatedVersionLoaded)
|
if (outdatedVersionLoaded)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Download loaded from %1 outdated, older than version in data cache %2") << urlString << m_download.getFilename();
|
CLogMessage(this).info("Update info loaded from %1 outdated, older than version in data cache %2") << urlString << m_updateInfo.getFilename();
|
||||||
// try next URL
|
// try next URL
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CStatusMessage m = m_download.set(loadedDownload);
|
CStatusMessage m = m_updateInfo.set(loadedUpdateInfo);
|
||||||
if (!m.isEmpty())
|
if (!m.isEmpty())
|
||||||
{
|
{
|
||||||
CLogMessage(this).preformatted(m);
|
CLogMessage(this).preformatted(m);
|
||||||
@@ -283,7 +283,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Download info: Updated data cache in %1") << m_download.getFilename();
|
CLogMessage(this).info("Update info: Updated data cache in %1") << m_updateInfo.getFilename();
|
||||||
return; // success
|
return; // success
|
||||||
} // cache
|
} // cache
|
||||||
} // outdated?
|
} // outdated?
|
||||||
@@ -293,12 +293,12 @@ namespace BlackCore
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// network error
|
// network error
|
||||||
CLogMessage(this).warning("Reading download info failed %1 %2") << replyMessage << urlString;
|
CLogMessage(this).warning("Reading update info failed %1 %2") << replyMessage << urlString;
|
||||||
nwReply->abort();
|
nwReply->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// try next one if any
|
// try next one if any
|
||||||
if (this->m_downloadUrls.uniqueWrite()->addFailedUrl(url))
|
if (this->m_updateInfoUrls.uniqueWrite()->addFailedUrl(url))
|
||||||
{
|
{
|
||||||
QTimer::singleShot(500, this, &CSetupReader::ps_readSetup);
|
QTimer::singleShot(500, this, &CSetupReader::ps_readSetup);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "blackmisc/threadedreader.h"
|
#include "blackmisc/threadedreader.h"
|
||||||
#include "blackmisc/lockfree.h"
|
#include "blackmisc/lockfree.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/download.h"
|
#include "blackcore/data/updateinfo.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -46,26 +46,26 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void ps_parseSetupFile(QNetworkReply *nwReply);
|
void ps_parseSetupFile(QNetworkReply *nwReply);
|
||||||
|
|
||||||
//! Download has been read
|
//! Update info has been read
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void ps_parseDownloadFile(QNetworkReply *nwReplyPtr);
|
void ps_parseUpdateInfoFile(QNetworkReply *nwReplyPtr);
|
||||||
|
|
||||||
//! Do reading
|
//! Do reading
|
||||||
void ps_readSetup();
|
void ps_readSetup();
|
||||||
|
|
||||||
//! Do reading
|
//! Do reading
|
||||||
void ps_readDownload();
|
void ps_readUpdateInfo();
|
||||||
|
|
||||||
//! Setup has beem syncronized
|
//! Setup has beem syncronized
|
||||||
void ps_setupSyncronized(bool success);
|
void ps_setupSyncronized(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *m_networkManagerBootstrap = nullptr;
|
QNetworkAccessManager *m_networkManagerBootstrap = nullptr;
|
||||||
QNetworkAccessManager *m_networkManagerDownload = nullptr;
|
QNetworkAccessManager *m_networkManagerUpdateInfo = nullptr;
|
||||||
BlackMisc::LockFree<BlackMisc::Network::CFailoverUrlList> m_bootstrapUrls;
|
BlackMisc::LockFree<BlackMisc::Network::CFailoverUrlList> m_bootstrapUrls;
|
||||||
BlackMisc::LockFree<BlackMisc::Network::CFailoverUrlList> m_downloadUrls;
|
BlackMisc::LockFree<BlackMisc::Network::CFailoverUrlList> m_updateInfoUrls;
|
||||||
CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache setup
|
CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache setup
|
||||||
CData<BlackCore::Data::Download> m_download {this}; //!< data cache downloads
|
CData<BlackCore::Data::UpdateInfo> m_updateInfo {this}; //!< data cache update info
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CSetupReader(QObject *owner);
|
explicit CSetupReader(QObject *owner);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace BlackMisc
|
|||||||
GlobalIndexIDatastoreInteger = 11000,
|
GlobalIndexIDatastoreInteger = 11000,
|
||||||
GlobalIndexIDatastoreString = 11100,
|
GlobalIndexIDatastoreString = 11100,
|
||||||
GlobalIndexCGlobalSetup = 12000,
|
GlobalIndexCGlobalSetup = 12000,
|
||||||
GlobalIndexCDownload = 12100,
|
GlobalIndexCUpdateInfo = 12100,
|
||||||
GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise, to be removed if no longer needed
|
GlobalIndexAbuseMode = 20000 // property index abused as map key or otherwise, to be removed if no longer needed
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "blackcore/context_runtime.h"
|
#include "blackcore/context_runtime.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/download.h"
|
#include "blackcore/data/updateinfo.h"
|
||||||
#include "blackcore/setupreader.h"
|
#include "blackcore/setupreader.h"
|
||||||
#include "blackgui/systemtraywindow.h"
|
#include "blackgui/systemtraywindow.h"
|
||||||
#include "blackgui/managedstatusbar.h"
|
#include "blackgui/managedstatusbar.h"
|
||||||
@@ -74,7 +74,7 @@ private:
|
|||||||
BlackGui::CManagedStatusBar m_statusBar;
|
BlackGui::CManagedStatusBar m_statusBar;
|
||||||
BlackCore::CWebDataServices *m_webDataReader = nullptr;
|
BlackCore::CWebDataServices *m_webDataReader = nullptr;
|
||||||
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CSwiftData::ps_setupChanged}; //!< setup cache
|
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CSwiftData::ps_setupChanged}; //!< setup cache
|
||||||
BlackCore::CData<BlackCore::Data::Download> m_download { this }; // download data
|
BlackCore::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void CSwiftData::ps_onMenuClicked()
|
|||||||
}
|
}
|
||||||
else if (sender == this->ui->menu_JsonDownloadTemplate)
|
else if (sender == this->ui->menu_JsonDownloadTemplate)
|
||||||
{
|
{
|
||||||
QString json(m_download.get().toJsonString());
|
QString json(m_updateInfo.get().toJsonString());
|
||||||
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
|
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
|
||||||
this->displayConsole();
|
this->displayConsole();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "ui_swiftlauncher.h"
|
#include "ui_swiftlauncher.h"
|
||||||
#include "blackgui/stylesheetutility.h"
|
#include "blackgui/stylesheetutility.h"
|
||||||
#include "blackcore/dbus_server.h"
|
#include "blackcore/dbus_server.h"
|
||||||
#include "blackcore/data/download.h"
|
#include "blackcore/data/updateinfo.h"
|
||||||
#include "blackmisc/network/networkutils.h"
|
#include "blackmisc/network/networkutils.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
@@ -259,9 +259,9 @@ void CSwiftLauncher::ps_loadSetup()
|
|||||||
|
|
||||||
void CSwiftLauncher::ps_loadedSetup()
|
void CSwiftLauncher::ps_loadedSetup()
|
||||||
{
|
{
|
||||||
CDownload download(this->m_download.get());
|
CUpdateInfo updateInfo(this->m_updateInfo.get());
|
||||||
QString latestVersion(download.getLatestVersion()) ; // need to get this from somewhere
|
QString latestVersion(updateInfo.getLatestVersion()) ; // need to get this from somewhere
|
||||||
CUrlList downloadUrls(download.getDownloadUrls());
|
CUrlList downloadUrls(updateInfo.getDownloadUrls());
|
||||||
bool newVersionAvailable = CProject::isNewerVersion(latestVersion) && !downloadUrls.isEmpty();
|
bool newVersionAvailable = CProject::isNewerVersion(latestVersion) && !downloadUrls.isEmpty();
|
||||||
this->ui->wi_NewVersionAvailable->setVisible(newVersionAvailable);
|
this->ui->wi_NewVersionAvailable->setVisible(newVersionAvailable);
|
||||||
this->ui->wi_NoNewVersion->setVisible(!newVersionAvailable);
|
this->ui->wi_NoNewVersion->setVisible(!newVersionAvailable);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSwiftLauncher> ui;
|
QScopedPointer<Ui::CSwiftLauncher> ui;
|
||||||
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup { this, &CSwiftLauncher::ps_loadedSetup }; //!< setup cache
|
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup { this, &CSwiftLauncher::ps_loadedSetup }; //!< setup cache
|
||||||
BlackCore::CData<BlackCore::Data::Download> m_download { this, &CSwiftLauncher::ps_loadedSetup };
|
BlackCore::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_loadedSetup };
|
||||||
QString m_executable;
|
QString m_executable;
|
||||||
QStringList m_executableArgs;
|
QStringList m_executableArgs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user