6 #include <QRegularExpression>
7 #include <QStringBuilder>
12 using namespace swift::config;
13 using namespace swift::misc::network;
17 namespace swift::misc::db
19 CArtifact::CArtifact() {}
22 int size,
bool existing,
const CPlatform &platform)
23 : m_name(name.trimmed()), m_md5(md5), m_type(static_cast<int>(type)), m_size(size), m_existing(existing),
34 if (m) {
return true; }
40 if (m_size < 0) {
return {}; }
50 if (distribution.
isEmpty() || !this->hasDistributions()) {
return false; }
53 if (dist == distribution) {
return true; }
54 if (acceptMoreStableDistributions && dist.isStabilityBetter(distribution)) {
return true; }
76 return this->
getQVersion() > CBuildConfig::getVersion();
130 case IndexMd5: m_md5 = variant.
toString();
break;
132 case IndexType: m_type = variant.
toInt();
break;
133 case IndexSize: m_size = variant.
toInt();
break;
149 const int size = json.
value(
"size").
toInt(-1);
150 const bool existing = json.
value(
"existing").
toBool();
152 CArtifact artifact(name, version, md5, type, size, existing, platform);
169 static const QString xswb(
"xswiftbus");
170 static const QString installer(
"pilot client installer");
171 static const QString symbols(
"symbols");
172 static const QString unknown(
"unknown");
177 case PilotClientInstaller:
return installer;
178 case Symbols:
return symbols;
179 case UnknownArtifact:
203 QString CArtifact::versionNumberFromFilename(
const QString &filename)
205 if (filename.
isEmpty()) {
return {}; }
216 if (s.contains(
"installer"))
return CArtifact::PilotClientInstaller;
217 if (s.contains(
"client"))
return CArtifact::PilotClientInstaller;
218 if (s.contains(
"symb"))
return CArtifact::Symbols;
219 if (s.contains(
"bus"))
return CArtifact::XSwiftBus;
220 return CArtifact::UnknownArtifact;
225 if (version.
count(
'.') != 3)
return version;
227 const QString p4 = trim4thSegment(parts[3]);
228 if (p4 == parts[3]) {
return version; }
237 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.
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.