File indexing completed on 2024-05-19 05:29:11

0001 /*
0002  *   SPDX-FileCopyrightText: 2021 Mariam Fahmy Sobhy <mariamfahmy66@gmail.com>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include "OstreeFormat.h"
0010 
0011 #include <resources/AbstractResource.h>
0012 
0013 class RpmOstreeBackend;
0014 class QAbstractItemModel;
0015 
0016 /*
0017  * Represents an ostree deployment (an installed version of the system) as a
0018  * resource in Discover.
0019  */
0020 class RpmOstreeResource : public AbstractResource
0021 {
0022     Q_OBJECT
0023 public:
0024     RpmOstreeResource(const QVariantMap &map, RpmOstreeBackend *parent);
0025 
0026     QString appstreamId() const override;
0027     AbstractResource::State state() override;
0028     QVariant icon() const override;
0029     QString comment() override;
0030     QString name() const override;
0031     Q_SCRIPTABLE QString packageName() const override;
0032     QStringList categories() override;
0033     QJsonArray licenses() override;
0034     QString longDescription() override;
0035     QList<PackageState> addonsInformation() override;
0036     bool isRemovable() const override;
0037     QString availableVersion() const override;
0038     QString installedVersion() const override;
0039     QString origin() const override;
0040     QString section() override;
0041     void fetchScreenshots() override{};
0042     quint64 size() override;
0043     QString sizeDescription() override;
0044     void fetchChangelog() override{};
0045     QStringList extends() const override;
0046     AbstractResource::Type type() const override;
0047     QString author() const override;
0048     bool canExecute() const override;
0049     void invokeApplication() const override{};
0050     QUrl url() const override;
0051     QString sourceIcon() const override;
0052     QUrl homepage() override;
0053     QUrl helpURL() override;
0054     QUrl bugURL() override;
0055     QDate releaseDate() const override;
0056     QUrl donationURL() override;
0057 
0058     void setState(AbstractResource::State);
0059 
0060     /* Get the current version */
0061     QString version();
0062 
0063     /* Set the target version for updates */
0064     void setNewVersion(const QString &newVersion);
0065 
0066     /* Get the target version for updates */
0067     QString getNewVersion() const;
0068 
0069     /* Validate and set the target major version for rebase */
0070     bool setNewMajorVersion(const QString &newMajorVersion);
0071 
0072     /* Returns the next major version for the deployment */
0073     QString getNextMajorVersion() const;
0074 
0075     /* Returns the ostree ref for the next major version for the deployment */
0076     QString getNextMajorVersionRef() const;
0077 
0078     /* Returns if a given deployment is the currently booted deployment */
0079     Q_SCRIPTABLE bool isBooted();
0080 
0081     /* Returns if a given deployment is currently pending */
0082     Q_SCRIPTABLE bool isPending();
0083 
0084     /* Returns true only if the deployment is from a classic Ostree format */
0085     bool isClassic();
0086 
0087     /* Returns true only if the deployment is from an OCI based format */
0088     bool isOCI();
0089 
0090     /* Get the full repo:tag reference, only if it's OCI */
0091     QString OCIUrl();
0092 
0093 private:
0094     QString m_name;
0095     QString m_variant;
0096     QString m_osname;
0097     QString m_version;
0098     QDate m_timestamp;
0099     QString m_appstreamid;
0100     bool m_booted;
0101     bool m_pinned;
0102     bool m_pending;
0103     QStringList m_requested_base_local_replacements;
0104     QStringList m_requested_base_removals;
0105     QStringList m_requested_local_packages;
0106     QStringList m_requested_modules;
0107     QStringList m_requested_packages;
0108     QString m_checksum;
0109 
0110     /* Store the format used by ostree to pull each deployment*/
0111     QScopedPointer<OstreeFormat> m_ostreeFormat;
0112 
0113     AbstractResource::State m_state;
0114 
0115     QString m_newVersion;
0116     QString m_nextMajorVersion;
0117     QString m_nextMajorVersionRef;
0118 };