diff --git a/libdiscover/backends/FwupdBackend/FwupdResource.cpp b/libdiscover/backends/FwupdBackend/FwupdResource.cpp index 77610fef..ac79cbc0 100644 --- a/libdiscover/backends/FwupdBackend/FwupdResource.cpp +++ b/libdiscover/backends/FwupdBackend/FwupdResource.cpp @@ -1,212 +1,211 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * Copyright © 2018 Abhijeet Sharma * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * ***************************************************************************/ #include "FwupdResource.h" #include #include #include #include FwupdResource::FwupdResource(QString name, AbstractResourcesBackend* parent) : AbstractResource(parent) , m_name(std::move(name)) - , m_state(State::Broken) { Q_ASSERT(!m_name.isEmpty()); setObjectName(m_name); } QString FwupdResource::availableVersion() const { return m_version; } QStringList FwupdResource::categories() { return m_categories; } QString FwupdResource::comment() { return m_summary; } int FwupdResource::size() { return m_size; } QUrl FwupdResource::homepage() { return m_homepage; } QUrl FwupdResource::helpURL() { return {}; } QUrl FwupdResource::bugURL() { return {}; } QUrl FwupdResource::donationURL() { return {}; } QVariant FwupdResource::icon() const { return m_iconName; } QString FwupdResource::installedVersion() const { return m_version; } QString FwupdResource::license() { return m_license; } QString FwupdResource::longDescription() { return m_description; } QString FwupdResource::name() const { return m_name; } QString FwupdResource::vendor() const { return m_vendor; } QString FwupdResource::origin() const { return m_origin; } QString FwupdResource::packageName() const { return m_name; } QString FwupdResource::section() { return QStringLiteral("Firmware Updates"); } AbstractResource::State FwupdResource::state() { return m_state; } void FwupdResource::fetchChangelog() { QString log = longDescription(); log.replace(QLatin1Char('\n'), QLatin1String("
")); emit changelogFetched(log); } void FwupdResource::setState(AbstractResource::State state) { if(m_state != state) { m_state = state; emit stateChanged(); } } void FwupdResource::invokeApplication() const { qWarning() << "Not Launchable"; } QUrl FwupdResource::url() const { return m_homepage; } QString FwupdResource::executeLabel() const { return QStringLiteral("Not Invokable"); } void FwupdResource::setReleaseDetails(FwupdRelease* release) { m_origin = QString::fromUtf8(fwupd_release_get_remote_id(release)); m_summary = QString::fromUtf8(fwupd_release_get_summary(release)); m_vendor = QString::fromUtf8(fwupd_release_get_vendor(release)); m_size = fwupd_release_get_size(release); m_version = QString::fromUtf8(fwupd_release_get_version(release)); m_description = QString::fromUtf8((fwupd_release_get_description(release))); m_homepage = QUrl(QString::fromUtf8(fwupd_release_get_homepage(release))); m_license = QString::fromUtf8(fwupd_release_get_license(release)); m_updateURI = QString::fromUtf8(fwupd_release_get_uri(release)); } void FwupdResource::setDeviceDetails(FwupdDevice* dev) { isLiveUpdatable = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE); isOnlyOffline = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_ONLY_OFFLINE); needsReboot = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); isDeviceRemoval = !fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_INTERNAL); needsBootLoader = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER); GPtrArray *guids = fwupd_device_get_guids(dev); if (guids->len > 0) { QString guidStr = QString::fromUtf8((char *)g_ptr_array_index(guids, 0)); for(uint i = 1; i < guids->len; i++) { guidStr += QLatin1Char(',') + QString::fromUtf8((char *)g_ptr_array_index(guids, i)); } guidString = guidStr; } if (fwupd_device_get_name(dev)) { QString vendorDesc = QString::fromUtf8(fwupd_device_get_name(dev)); const QString vendorName = QString::fromUtf8(fwupd_device_get_vendor(dev)); if (!vendorDesc.startsWith(vendorName)) vendorDesc = vendorName + QLatin1Char(' ') + vendorDesc; m_name = vendorDesc; } m_summary = QString::fromUtf8(fwupd_device_get_summary(dev)); m_vendor = QString::fromUtf8(fwupd_device_get_vendor(dev)); m_releaseDate = QDateTime::fromSecsSinceEpoch(fwupd_device_get_created(dev)).date(); m_version = QString::fromUtf8(fwupd_device_get_version(dev)); m_description = QString::fromUtf8((fwupd_device_get_description(dev))); if (fwupd_device_get_icons(dev)->len >= 1) m_iconName = QString::fromUtf8((const gchar *)g_ptr_array_index(fwupd_device_get_icons(dev), 0));// Check wether given icon exists or not! else m_iconName = QString::fromUtf8("device-notifier"); } diff --git a/libdiscover/backends/FwupdBackend/FwupdResource.h b/libdiscover/backends/FwupdBackend/FwupdResource.h index 847ab79e..63bfb6e4 100644 --- a/libdiscover/backends/FwupdBackend/FwupdResource.h +++ b/libdiscover/backends/FwupdBackend/FwupdResource.h @@ -1,103 +1,103 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * Copyright © 2018 Abhijeet Sharma * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * ***************************************************************************/ #ifndef FWUPDRESOURCE_H #define FWUPDRESOURCE_H #include "FwupdBackend.h" #include #include class AddonList; class FwupdResource : public AbstractResource { Q_OBJECT public: explicit FwupdResource(QString name, AbstractResourcesBackend* parent); QList addonsInformation() override { return {}; } QString section() override; QString origin() const override; QString longDescription() override; QString availableVersion() const override; QString installedVersion() const override; QString license() override; int size() override; QUrl homepage() override; QUrl helpURL() override; QUrl bugURL() override; QUrl donationURL() override; QStringList categories() override; AbstractResource::State state() override; QVariant icon() const override; QString comment() override; QString name() const override; QString packageName() const override; QString vendor() const; bool isTechnical() const override { return true; } bool canExecute() const override { return false; } void invokeApplication() const override; void fetchChangelog() override; QUrl url() const override; QString executeLabel() const override; QDate releaseDate() const override { return m_releaseDate; } QString sourceIcon() const override { return {}; } void setDeviceID(const QString &deviceId) { m_deviceID = deviceId; } void setIsDeviceLocked(bool locked) { isDeviceLocked = locked; } void setDescription(const QString &description) { m_description = description; } void setId(const QString &id) { m_id = id; } void setState(AbstractResource::State state); void setAddonInstalled(const QString& addon, bool installed); void setReleaseDetails(FwupdRelease *release); void setDeviceDetails(FwupdDevice* device); public: QString m_id; QString m_name; QString m_summary; QString m_description; QString m_version; QString m_vendor; QStringList m_categories; QString m_license; QDate m_releaseDate; - AbstractResource::State m_state; + AbstractResource::State m_state = None; QUrl m_homepage; QString m_iconName; int m_size = 0; QString m_deviceID; QString m_updateURI; QString m_file; bool isDeviceLocked = false; // True if device is locked! bool isOnlyOffline = false; // True if only offline updates bool isLiveUpdatable = false; // True if device is live updatable bool needsReboot = false; // True if device needs Reboot bool isDeviceRemoval = false; //True if device is Removal bool needsBootLoader = false; //True if BootLoader Required QString guidString; QString m_origin; }; #endif // FWUPDRESOURCE_H