6 #include <QRegularExpression>
7 #include <QStringBuilder>
12 using namespace swift::config;
13 using namespace swift::misc::network;
17 namespace swift::misc::db
20 int size,
bool existing,
const CPlatform &platform)
21 : m_name(name.trimmed()), m_md5(md5), m_type(static_cast<int>(type)), m_size(size), m_existing(existing),
32 if (m) {
return true; }
38 if (m_size < 0) {
return {}; }
48 if (distribution.
isEmpty() || !this->hasDistributions()) {
return false; }
51 return dist == distribution || (acceptMoreStableDistributions && dist.
isStabilityBetter(distribution));
61 if (url.
isEmpty()) {
return {}; }
72 return this->
getQVersion() > CBuildConfig::getVersion();
126 case IndexMd5: m_md5 = variant.
toString();
break;
128 case IndexType: m_type = variant.
toInt();
break;
129 case IndexSize: m_size = variant.
toInt();
break;
145 const int size = json.
value(
"size").
toInt(-1);
146 const bool existing = json.
value(
"existing").
toBool();
148 CArtifact artifact(name, version, md5, type, size, existing, platform);
165 static const QString xswb(
"xswiftbus");
166 static const QString installer(
"pilot client installer");
167 static const QString symbols(
"symbols");
168 static const QString unknown(
"unknown");
173 case PilotClientInstaller:
return installer;
174 case Symbols:
return symbols;
175 case UnknownArtifact:
199 QString CArtifact::versionNumberFromFilename(
const QString &filename)
201 if (filename.
isEmpty()) {
return {}; }
212 if (s.contains(
"installer"))
return CArtifact::PilotClientInstaller;
213 if (s.contains(
"client"))
return CArtifact::PilotClientInstaller;
214 if (s.contains(
"symb"))
return CArtifact::Symbols;
215 if (s.contains(
"bus"))
return CArtifact::XSwiftBus;
216 return CArtifact::UnknownArtifact;
221 if (version.
count(
'.') != 3)
return version;
223 const QString p4 = trim4thSegment(parts[3]);
224 if (p4 == parts[3]) {
return version; }
233 if (seg.
length() >= 9) {
return QStringLiteral(
"0"); }
static QString humanReadableFileSize(qint64 size)
Human readable (GB, MB, ..) file size.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
QString getFormattedUtcTimestampYmdhms() const
As yyyy MM dd HH mm ss.
QDateTime getUtcTimestamp() const
Get timestamp.
void setUtcTimestamp(const QDateTime ×tamp)
Set timestamp.
Artifacts ("our software" products)
ColumnIndex
Properties by index.
bool hasUnrestrictedDistribution() const
Has unrestricted distribution.
bool isWithDistribution(const CDistribution &distribution, bool acceptMoreStableDistributions) const
Is distributed with given distribution?
bool hasDistributions() const
Has distributions?
void setName(const QString &name)
Set the name.
bool matchesAnyPlatform(const CPlatform &platform) const
Matches any platform.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QString getFileSizeHumanReadable() const
Human readable (GB, MB, ..) file size.
network::CRemoteFile asRemoteFile() const
Turn into remote file.
bool isUnknown() const
Unknown.
int getFileSize() const
File size.
const CPlatform & getPlatform() const
OS.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
static CPlatform artifactNameToPlatform(const QString &name)
Name to platform.
bool isNewerThanCurrentBuild() const
Newer than the current build.
void setDistributions(const CDistributionList &distributions)
Related distributions.
static const QString & typeToString(ArtifactType type)
Type as string.
static CArtifact fromDatabaseJson(const QJsonObject &json, const QString &prefix={})
Object from database JSON format.
bool matchesName(const QString &name, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Matching name?
CDistribution getMostStableDistribution() const
Most stable distribution if any.
const CDistributionList & getDistributions() const
Related distributions.
QString convertToQString(bool i18n=false) const
Cast as QString.
const QString & getName() const
Name (i.e. installer name, symbol name)
Distributions for channel.
bool isStabilityBetter(const CDistribution &otherDistribution) const
"this" having better stability than other distribution?
const QString & getChannel() const
Version channel (Alpha, Beta, Stable ..)
bool isEmpty() const
Empty?
const network::CUrl & getDownloadUrl() const
Download URL, i.e. here one can download installer.
Multiple distributions for different channels:
bool containsUnrestricted() const
Contains any unrestricted.
static CDistributionList fromDatabaseJson(const QJsonArray &array)
From database JSON by array.
QVersionNumber getQVersion() const
Version as QVersion.
QString m_version
version info
bool hasVersion() const
Having a version?s.
void setVersion(const QString &version)
Version info.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
static bool canHandleIndex(swift::misc::CPropertyIndexRef index)
Can given index be handled?
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
void setDescription(const QString &description)
Description.
void setUrl(const CUrl &url)
Set URL.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool isEmpty() const
Empty.
Plugin loaded by X-Plane which publishes a DBus service.
SWIFT_MISC_EXPORT bool caseInsensitiveStringCompare(const QString &c1, const QString &c2)
Case insensitive string compare.
bool contains(QLatin1StringView key) const const
bool isEmpty() const const
QJsonValue value(QLatin1StringView key) const const
QJsonArray toArray() const const
bool toBool(bool defaultValue) const const
int toInt(int defaultValue) const const
QJsonObject toObject() const const
QString toString() const const
QString captured(QAnyStringView name) const const
qsizetype count() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype length() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString toLower() const const
QString trimmed() const const
QString join(QChar separator) const const
QVariant fromValue(T &&value)
int toInt(bool *ok) const const
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.