File indexing completed on 2024-11-24 04:54:56

0001 /*
0002  *   SPDX-FileCopyrightText: 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *   SPDX-FileCopyrightText: 2018 Abhijeet Sharma <sharma.abhijeet2096@gmail.com>
0004  *
0005  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 #pragma once
0009 
0010 #include "FwupdBackend.h"
0011 
0012 #include <KLocalizedString>
0013 #include <resources/AbstractResource.h>
0014 
0015 class FwupdResource : public AbstractResource
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit FwupdResource(FwupdDevice *device, AbstractResourcesBackend *parent);
0020     explicit FwupdResource(FwupdDevice *device, const QString &id, AbstractResourcesBackend *parent);
0021 
0022     QList<PackageState> addonsInformation() override
0023     {
0024         return {};
0025     }
0026     QString section() override;
0027     QString origin() const override;
0028     QString longDescription() override;
0029     QString availableVersion() const override;
0030     QString installedVersion() const override;
0031     QJsonArray licenses() override;
0032     quint64 size() override;
0033     QUrl homepage() override;
0034     QUrl helpURL() override;
0035     QUrl bugURL() override;
0036     QUrl donationURL() override;
0037     QStringList categories() override;
0038     AbstractResource::State state() override;
0039     QVariant icon() const override;
0040     QString comment() override;
0041     QString name() const override;
0042     QString packageName() const override;
0043     QString vendor() const;
0044     AbstractResource::Type type() const override
0045     {
0046         return Technical;
0047     }
0048     bool canExecute() const override
0049     {
0050         return false;
0051     }
0052     void invokeApplication() const override;
0053     void fetchChangelog() override;
0054     QUrl url() const override;
0055     QString executeLabel() const override;
0056     QDate releaseDate() const override
0057     {
0058         return m_releaseDate;
0059     }
0060     QString sourceIcon() const override
0061     {
0062         return {};
0063     }
0064     QString author() const override
0065     {
0066         return {};
0067     }
0068 
0069     void setIsDeviceLocked(bool locked)
0070     {
0071         m_isDeviceLocked = locked;
0072     }
0073     void setDescription(const QString &description)
0074     {
0075         m_description = description;
0076     }
0077     void setInstalledVersion(const QString &version)
0078     {
0079         m_installedVersion = version;
0080     }
0081 
0082     void setState(AbstractResource::State state);
0083     void setReleaseDetails(FwupdRelease *release);
0084 
0085     QString id() const
0086     {
0087         return m_id;
0088     }
0089 
0090     QString deviceId() const
0091     {
0092         return m_deviceID;
0093     }
0094 
0095     QUrl updateURI() const
0096     {
0097         return QUrl(m_updateURI);
0098     }
0099 
0100     bool isDeviceLocked() const
0101     {
0102         return m_isDeviceLocked;
0103     }
0104 
0105     bool isOnlyOffline() const
0106     {
0107         return m_isOnlyOffline;
0108     }
0109 
0110     bool isLiveUpdatable() const
0111     {
0112         return m_isLiveUpdatable;
0113     }
0114 
0115     bool needsReboot() const
0116     {
0117         return m_needsReboot;
0118     }
0119 
0120     QString cacheFile() const;
0121     bool isRemovable() const override
0122     {
0123         return false;
0124     }
0125 
0126 private:
0127     void setDeviceDetails(FwupdDevice *device);
0128 
0129     const QString m_id;
0130     const QString m_name;
0131     const QString m_deviceID;
0132     QString m_summary;
0133     QString m_description;
0134     QString m_installedVersion;
0135     QString m_availableVersion;
0136     QString m_vendor;
0137     QStringList m_categories;
0138     QString m_license;
0139     QString m_displayName;
0140     QDate m_releaseDate;
0141 
0142     AbstractResource::State m_state = None;
0143     QUrl m_homepage;
0144     QString m_iconName;
0145     quint64 m_size = 0;
0146 
0147     QString m_updateURI;
0148     bool m_isDeviceLocked = false; // True if device is locked!
0149     bool m_isOnlyOffline = false; // True if only offline updates
0150     bool m_isLiveUpdatable = false; // True if device is live updatable
0151     bool m_needsReboot = false; // True if device needs Reboot
0152     QString m_origin;
0153 };