mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
refs #921, remove UpdateInfo class (now distribution list)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
929e2883d0
commit
cbf69d9847
@@ -1,145 +0,0 @@
|
|||||||
/* Copyright (C) 2015
|
|
||||||
* swift project community / contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
|
||||||
#include "blackcore/data/updateinfo.h"
|
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
using namespace BlackConfig;
|
|
||||||
using namespace BlackMisc;
|
|
||||||
using namespace BlackMisc::Network;
|
|
||||||
|
|
||||||
namespace BlackCore
|
|
||||||
{
|
|
||||||
namespace Data
|
|
||||||
{
|
|
||||||
CUpdateInfo::CUpdateInfo() :
|
|
||||||
ITimestampBased(0),
|
|
||||||
m_downloadsStableUrls(QStringList {"http://swift-project.org/"}),
|
|
||||||
m_downloadsBetaUrls(QStringList {"http://swift-project.org/"}),
|
|
||||||
m_latestVersionStable(CVersion::version()),
|
|
||||||
m_lastSupportedVersionStable("0.6"),
|
|
||||||
m_latestVersionBeta(CVersion::version()),
|
|
||||||
m_lastSupportedVersionBeta("0.6")
|
|
||||||
{ }
|
|
||||||
|
|
||||||
CUrlList CUpdateInfo::getDownloadUrls() const
|
|
||||||
{
|
|
||||||
return CBuildConfig::isBetaTest() ? getDownloadUrlsBeta() : getDownloadUrlsStable();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CUpdateInfo::getLatestVersion() const
|
|
||||||
{
|
|
||||||
return CBuildConfig::isBetaTest() ? getLatestVersionBeta() : getLatestVersionStable();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CUpdateInfo::getChannel() const
|
|
||||||
{
|
|
||||||
return CBuildConfig::isBetaTest() ? "beta" : "stable";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CUpdateInfo::hasSameType(const CUpdateInfo &otherDownload) const
|
|
||||||
{
|
|
||||||
return this->isDevelopment() == otherDownload.isDevelopment();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CUpdateInfo::convertToQString(bool i18n) const
|
|
||||||
{
|
|
||||||
return convertToQString(", ", i18n);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CUpdateInfo::convertToQString(const QString &separator, bool i18n) const
|
|
||||||
{
|
|
||||||
QString s("timestamp: ");
|
|
||||||
s.append(this->getFormattedUtcTimestampYmdhms());
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Download URLs (stable): ");
|
|
||||||
s.append(getDownloadUrlsStable().toQString(i18n));
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Download URLs (beta): ");
|
|
||||||
s.append(getDownloadUrlsBeta().toQString(i18n));
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Latest version (stable): ");
|
|
||||||
s.append(getLatestVersionStable());
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Latest version (beta): ");
|
|
||||||
s.append(getLatestVersionBeta());
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Latest supported version (stable): ");
|
|
||||||
s.append(getLastSupportedVersionStable());
|
|
||||||
s.append(separator);
|
|
||||||
s.append("Latest supported version (beta): ");
|
|
||||||
s.append(getLastSupportedVersionBeta());
|
|
||||||
s.append(separator);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
CVariant CUpdateInfo::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
|
||||||
{
|
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
|
||||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
|
||||||
|
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case IndexDownloadUrlsStable:
|
|
||||||
return CVariant::fromValue(this->m_downloadsStableUrls);
|
|
||||||
case IndexDownloadUrlsBeta:
|
|
||||||
return CVariant::fromValue(this->m_downloadsBetaUrls);
|
|
||||||
case IndexLastSupportedVersionStable:
|
|
||||||
return CVariant::fromValue(this->m_lastSupportedVersionStable);
|
|
||||||
case IndexLatestVersionStable:
|
|
||||||
return CVariant::fromValue(this->m_latestVersionStable);
|
|
||||||
case IndexLastSupportedVersionBeta:
|
|
||||||
return CVariant::fromValue(this->m_lastSupportedVersionBeta);
|
|
||||||
case IndexLatestVersionBeta:
|
|
||||||
return CVariant::fromValue(this->m_latestVersionBeta);
|
|
||||||
default:
|
|
||||||
return CValueObject::propertyByIndex(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CUpdateInfo::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
|
||||||
{
|
|
||||||
if (index.isMyself()) { (*this) = variant.to<CUpdateInfo>(); return; }
|
|
||||||
if (ITimestampBased::canHandleIndex(index))
|
|
||||||
{
|
|
||||||
ITimestampBased::setPropertyByIndex(index, variant);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case IndexDownloadUrlsStable:
|
|
||||||
this->m_downloadsStableUrls = variant.value<CUrlList>();
|
|
||||||
break;
|
|
||||||
case IndexDownloadUrlsBeta:
|
|
||||||
this->m_downloadsBetaUrls = variant.value<CUrlList>();
|
|
||||||
break;
|
|
||||||
case IndexLastSupportedVersionStable:
|
|
||||||
this->m_lastSupportedVersionStable = variant.toQString();
|
|
||||||
break;
|
|
||||||
case IndexLatestVersionStable:
|
|
||||||
this->m_latestVersionStable = variant.toQString();
|
|
||||||
break;
|
|
||||||
case IndexLastSupportedVersionBeta:
|
|
||||||
this->m_lastSupportedVersionBeta = variant.toQString();
|
|
||||||
break;
|
|
||||||
case IndexLatestVersionBeta:
|
|
||||||
this->m_latestVersionBeta = variant.toQString();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CValueObject::setPropertyByIndex(index, variant);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // ns
|
|
||||||
} // ns
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
/* Copyright (C) 2015
|
|
||||||
* swift project community / contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
#ifndef BLACKCORE_DATA_UPDATEINFO_H
|
|
||||||
#define BLACKCORE_DATA_UPDATEINFO_H
|
|
||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
|
||||||
#include "blackmisc/datacache.h"
|
|
||||||
#include "blackmisc/metaclass.h"
|
|
||||||
#include "blackmisc/network/urllist.h"
|
|
||||||
#include "blackmisc/propertyindex.h"
|
|
||||||
#include "blackmisc/timestampbased.h"
|
|
||||||
#include "blackmisc/valueobject.h"
|
|
||||||
#include "blackmisc/variant.h"
|
|
||||||
|
|
||||||
#include <QMetaType>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace BlackCore
|
|
||||||
{
|
|
||||||
namespace Data
|
|
||||||
{
|
|
||||||
//! Download locations and versions
|
|
||||||
class BLACKCORE_EXPORT CUpdateInfo :
|
|
||||||
public BlackMisc::CValueObject<CUpdateInfo>,
|
|
||||||
public BlackMisc::ITimestampBased
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Properties by index
|
|
||||||
enum ColumnIndex
|
|
||||||
{
|
|
||||||
IndexDownloadUrlsStable = BlackMisc::CPropertyIndex::GlobalIndexCUpdateInfo,
|
|
||||||
IndexDownloadUrlsBeta,
|
|
||||||
IndexLatestVersionStable,
|
|
||||||
IndexLastSupportedVersionStable,
|
|
||||||
IndexLatestVersionBeta,
|
|
||||||
IndexLastSupportedVersionBeta
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Default constructor
|
|
||||||
CUpdateInfo();
|
|
||||||
|
|
||||||
//! Destructor.
|
|
||||||
~CUpdateInfo() {}
|
|
||||||
|
|
||||||
//! Download URLs, ie here one can download installer
|
|
||||||
const BlackMisc::Network::CUrlList &getDownloadUrlsBeta() const { return m_downloadsBetaUrls; }
|
|
||||||
|
|
||||||
//! Download URLs, ie here one can download installer
|
|
||||||
const BlackMisc::Network::CUrlList &getDownloadUrlsStable() const { return m_downloadsStableUrls; }
|
|
||||||
|
|
||||||
//! Download URLs
|
|
||||||
BlackMisc::Network::CUrlList getDownloadUrls() const;
|
|
||||||
|
|
||||||
//! Latest version stable channel
|
|
||||||
const QString &getLatestVersionStable() const { return m_latestVersionStable; }
|
|
||||||
|
|
||||||
//! Latest version beta channel
|
|
||||||
const QString &getLatestVersionBeta() const { return m_latestVersionBeta; }
|
|
||||||
|
|
||||||
//! Latest version
|
|
||||||
QString getLatestVersion() const;
|
|
||||||
|
|
||||||
//! Version channel (Beta, Stable)
|
|
||||||
QString getChannel() const;
|
|
||||||
|
|
||||||
//! Last supported version stable
|
|
||||||
const QString &getLastSupportedVersionStable() const { return m_lastSupportedVersionStable; }
|
|
||||||
|
|
||||||
//! Last supported version beta
|
|
||||||
const QString &getLastSupportedVersionBeta() const { return m_lastSupportedVersionStable; }
|
|
||||||
|
|
||||||
//! Productive settings?
|
|
||||||
bool isDevelopment() const { return m_development; }
|
|
||||||
|
|
||||||
//! Same type
|
|
||||||
bool hasSameType(const CUpdateInfo &otherDownload) const;
|
|
||||||
|
|
||||||
//! Productive settings?
|
|
||||||
void setDevelopment(bool development) { m_development = development; }
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
|
||||||
QString convertToQString(bool i18n = false) const;
|
|
||||||
|
|
||||||
//! To string
|
|
||||||
QString convertToQString(const QString &separator, bool i18n = false) const;
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
|
||||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_development = false; //!< for development
|
|
||||||
BlackMisc::Network::CUrlList m_downloadsStableUrls; //!< Download URLs, here I get the installer
|
|
||||||
BlackMisc::Network::CUrlList m_downloadsBetaUrls; //!< Download URLs, here I get the installer
|
|
||||||
QString m_latestVersionStable; //!< latest version
|
|
||||||
QString m_lastSupportedVersionStable; //!< last supported version
|
|
||||||
QString m_latestVersionBeta; //!< latest version
|
|
||||||
QString m_lastSupportedVersionBeta; //!< last supported version
|
|
||||||
|
|
||||||
BLACK_METACLASS(
|
|
||||||
CUpdateInfo,
|
|
||||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
|
|
||||||
BLACK_METAMEMBER(development),
|
|
||||||
BLACK_METAMEMBER(downloadsStableUrls),
|
|
||||||
BLACK_METAMEMBER(downloadsBetaUrls),
|
|
||||||
BLACK_METAMEMBER(latestVersionStable),
|
|
||||||
BLACK_METAMEMBER(lastSupportedVersionStable),
|
|
||||||
BLACK_METAMEMBER(latestVersionBeta),
|
|
||||||
BLACK_METAMEMBER(lastSupportedVersionBeta)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Trait for global setup data
|
|
||||||
struct TUpdateInfo : public BlackMisc::TDataTrait<CUpdateInfo>
|
|
||||||
{
|
|
||||||
//! Key in data cache
|
|
||||||
static const char *key() { return "version"; }
|
|
||||||
|
|
||||||
//! First load is synchronous
|
|
||||||
static constexpr bool isPinned() { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // ns
|
|
||||||
} // ns
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackCore::Data::CUpdateInfo)
|
|
||||||
|
|
||||||
#endif // guard
|
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "blackcore/context/contextapplication.h"
|
#include "blackcore/context/contextapplication.h"
|
||||||
#include "blackcore/data/launchersetup.h"
|
#include "blackcore/data/launchersetup.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/updateinfo.h"
|
|
||||||
#include "blackcore/data/vatsimsetup.h"
|
#include "blackcore/data/vatsimsetup.h"
|
||||||
#include "blackcore/db/databasereader.h"
|
#include "blackcore/db/databasereader.h"
|
||||||
#include "blackcore/vatsim/vatsimsettings.h"
|
#include "blackcore/vatsim/vatsimsettings.h"
|
||||||
@@ -40,7 +39,6 @@ namespace BlackCore
|
|||||||
BlackCore::Db::CDatabaseReaderConfig::registerMetadata();
|
BlackCore::Db::CDatabaseReaderConfig::registerMetadata();
|
||||||
BlackCore::Db::CDatabaseReaderConfigList::registerMetadata();
|
BlackCore::Db::CDatabaseReaderConfigList::registerMetadata();
|
||||||
BlackCore::Data::CGlobalSetup::registerMetadata();
|
BlackCore::Data::CGlobalSetup::registerMetadata();
|
||||||
BlackCore::Data::CUpdateInfo::registerMetadata();
|
|
||||||
BlackCore::Data::CVatsimSetup::registerMetadata();
|
BlackCore::Data::CVatsimSetup::registerMetadata();
|
||||||
BlackCore::Data::CLauncherSetup::registerMetadata();
|
BlackCore::Data::CLauncherSetup::registerMetadata();
|
||||||
BlackCore::Vatsim::CReaderSettings::registerMetadata();
|
BlackCore::Vatsim::CReaderSettings::registerMetadata();
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ namespace BlackCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
// only in not officially shipped versions
|
// only in not officially shipped versions
|
||||||
return (CBuildConfig::isShippedVersion() && !CBuildConfig::isBetaTest()) ? e : opts;
|
return (CBuildConfig::isStableBranch() && !CBuildConfig::isDevBranch()) ? e : opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetworkVatlib::getCmdLineClientIdAndKey(int &id, QString &key) const
|
bool CNetworkVatlib::getCmdLineClientIdAndKey(int &id, QString &key) const
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include "blackconfig/buildconfig.h"
|
#include "blackconfig/buildconfig.h"
|
||||||
#include "blackcore/context/contextnetwork.h"
|
#include "blackcore/context/contextnetwork.h"
|
||||||
#include "blackcore/data/globalsetup.h"
|
#include "blackcore/data/globalsetup.h"
|
||||||
#include "blackcore/data/updateinfo.h"
|
|
||||||
#include "blackgui/components/applicationclosedialog.h"
|
#include "blackgui/components/applicationclosedialog.h"
|
||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/guiutility.h"
|
#include "blackgui/guiutility.h"
|
||||||
@@ -434,10 +433,10 @@ namespace BlackGui
|
|||||||
});
|
});
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
|
||||||
a = sm->addAction("JSON update info");
|
a = sm->addAction("JSON distribution info");
|
||||||
c = connect(a, &QAction::triggered, this, [a, this]()
|
c = connect(a, &QAction::triggered, this, [a, this]()
|
||||||
{
|
{
|
||||||
this->displayTextInConsole(this->getUpdateInfo().toJsonString());
|
this->displayTextInConsole(this->getDistributionInfo().toJsonString());
|
||||||
});
|
});
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#ifndef SWIFTDATA_H
|
#ifndef SWIFTDATA_H
|
||||||
#define SWIFTDATA_H
|
#define SWIFTDATA_H
|
||||||
|
|
||||||
#include "blackcore/data/updateinfo.h"
|
|
||||||
#include "blackgui/mainwindowaccess.h"
|
#include "blackgui/mainwindowaccess.h"
|
||||||
#include "blackgui/managedstatusbar.h"
|
#include "blackgui/managedstatusbar.h"
|
||||||
#include "blackmisc/datacache.h"
|
#include "blackmisc/datacache.h"
|
||||||
@@ -75,7 +74,6 @@ private:
|
|||||||
|
|
||||||
QScopedPointer<Ui::CSwiftData> ui;
|
QScopedPointer<Ui::CSwiftData> ui;
|
||||||
BlackGui::CManagedStatusBar m_statusBar;
|
BlackGui::CManagedStatusBar m_statusBar;
|
||||||
BlackMisc::CData<BlackCore::Data::TUpdateInfo> m_updateInfo { this }; //!< download / version data
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user