diff --git a/discover/DiscoverObject.h b/discover/DiscoverObject.h index cadb9dc3..220f4bdd 100644 --- a/discover/DiscoverObject.h +++ b/discover/DiscoverObject.h @@ -1,105 +1,104 @@ /* * Copyright (C) 2012 Aleix Pol Gonzalez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library/Lesser General Public License * version 2, or (at your option) any later version, as published by the * Free Software Foundation * * 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 Library/Lesser General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DISCOVEROBJECT_H #define DISCOVEROBJECT_H #include #include class AbstractResource; class Category; class QWindow; class QQmlApplicationEngine; class CachedNetworkAccessManagerFactory; -class ResourcesProxyModel; class DiscoverObject : public QObject { Q_OBJECT Q_PROPERTY(CompactMode compactMode READ compactMode WRITE setCompactMode NOTIFY compactModeChanged) Q_PROPERTY(bool isRoot READ isRoot CONSTANT) Q_PROPERTY(QRect initialGeometry READ initialGeometry CONSTANT) public: enum CompactMode { Auto, Compact, Full }; Q_ENUM(CompactMode) explicit DiscoverObject(CompactMode mode); ~DiscoverObject() override; QStringList modes() const; void setupActions(); CompactMode compactMode() const { return m_mode; } void setCompactMode(CompactMode mode); bool eventFilter(QObject * object, QEvent * event) override; Q_SCRIPTABLE QAction * action(const QString& name) const; Q_SCRIPTABLE static QString iconName(const QIcon& icon); void loadTest(const QUrl& url); static bool isRoot(); QWindow* rootObject() const; void showPassiveNotification(const QString &msg); QRect initialGeometry() const; public Q_SLOTS: void openApplication(const QUrl& app); void openMimeType(const QString& mime); void openCategory(const QString& category); void openMode(const QString& mode); void openLocalPackage(const QUrl &localfile); void copyTextToClipboard(const QString &text); void reboot(); private Q_SLOTS: void reportBug(); void switchApplicationLanguage(); void aboutApplication(); Q_SIGNALS: void openSearch(const QString &search); void openApplicationInternal(AbstractResource* app); void listMimeInternal(const QString& mime); void listCategoryInternal(Category* cat); void compactModeChanged(DiscoverObject::CompactMode compactMode); void preventedClose(); void unableToFind(const QString &resid); void openErrorPage(const QString &errorMessage); private: void setRootObjectProperty(const char *name, const QVariant &value); void integrateObject(QObject* object); QQmlApplicationEngine* engine() const { return m_engine; } QMap m_collection; QQmlApplicationEngine * const m_engine; CompactMode m_mode; QScopedPointer m_networkAccessManagerFactory; }; #endif // DISCOVEROBJECT_H diff --git a/libdiscover/DiscoverBackendsFactory.h b/libdiscover/DiscoverBackendsFactory.h index d51e2fb4..6f8594d1 100644 --- a/libdiscover/DiscoverBackendsFactory.h +++ b/libdiscover/DiscoverBackendsFactory.h @@ -1,51 +1,50 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 DISCOVERBACKENDSFACTORY_H #define DISCOVERBACKENDSFACTORY_H #include "discovercommon_export.h" #include class QCommandLineParser; class QStringList; -class KPluginInfo; class AbstractResourcesBackend; class DISCOVERCOMMON_EXPORT DiscoverBackendsFactory { public: DiscoverBackendsFactory(); QVector backend(const QString& name) const; QVector allBackends() const; QStringList allBackendNames(bool whitelist = true, bool allowDummy = false) const; int backendsCount() const; static void setupCommandLine(QCommandLineParser* parser); static void processCommandLine(QCommandLineParser* parser, bool test); static void setRequestedBackends(const QStringList &backends); static bool hasRequestedBackends(); private: QVector backendForFile(const QString& path, const QString& name) const; }; #endif // MUONBACKENDSFACTORY_H diff --git a/libdiscover/ReviewsBackend/Review.h b/libdiscover/ReviewsBackend/Review.h index d65ee008..c9ba4a1c 100644 --- a/libdiscover/ReviewsBackend/Review.h +++ b/libdiscover/ReviewsBackend/Review.h @@ -1,80 +1,79 @@ /*************************************************************************** * Copyright © 2011 Jonathan Thomas * * * * 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 REVIEW_H #define REVIEW_H #include #include #include "ReviewsModel.h" #include "discovercommon_export.h" -class AbstractResource; class DISCOVERCOMMON_EXPORT Review { public: Review(QString name, QString pkgName, QString language, QString summary, QString reviewText, QString userName, const QDateTime& date, bool show, quint64 id, int rating, int usefulTotal, int usefulFavorable, QString packageVersion); ~Review(); // Creation date determines greater than/less than bool operator<(const Review &rhs) const; bool operator>(const Review &rhs) const; QString applicationName() const; QString packageName() const; QString packageVersion() const; QString language() const; QString summary() const; QString reviewText() const; QString reviewer() const; QDateTime creationDate() const; bool shouldShow() const; quint64 id() const; int rating() const; int usefulnessTotal() const; int usefulnessFavorable() const; ReviewsModel::UserChoice usefulChoice() const; void setUsefulChoice(ReviewsModel::UserChoice useful); void addMetadata(const QString &key, const QVariant &value); QVariant getMetadata(const QString &key); private: QString m_appName; QDateTime m_creationDate; bool m_shouldShow; quint64 m_id; QString m_language; QString m_packageName; int m_rating; QString m_reviewText; QString m_reviewer; int m_usefulnessTotal; int m_usefulnessFavorable; ReviewsModel::UserChoice m_usefulChoice; QString m_summary; QString m_packageVersion; QVariantMap m_metadata; }; #endif diff --git a/libdiscover/backends/DummyBackend/DummyBackend.h b/libdiscover/backends/DummyBackend/DummyBackend.h index 01581f9f..fd5326ce 100644 --- a/libdiscover/backends/DummyBackend/DummyBackend.h +++ b/libdiscover/backends/DummyBackend/DummyBackend.h @@ -1,67 +1,66 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * * * 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 DUMMYBACKEND_H #define DUMMYBACKEND_H #include #include -class QAction; class DummyReviewsBackend; class StandardBackendUpdater; class DummyResource; class DummyBackend : public AbstractResourcesBackend { Q_OBJECT Q_PROPERTY(int startElements MEMBER m_startElements) public: explicit DummyBackend(QObject* parent = nullptr); int updatesCount() const override; AbstractBackendUpdater* backendUpdater() const override; AbstractReviewsBackend* reviewsBackend() const override; ResultsStream* search(const AbstractResourcesBackend::Filters & search) override; ResultsStream * findResourceByPackageName(const QUrl& search); QHash resources() const { return m_resources; } bool isValid() const override { return true; } // No external file dependencies that could cause runtime errors Transaction* installApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app, const AddonList& addons) override; Transaction* removeApplication(AbstractResource* app) override; bool isFetching() const override { return m_fetching; } void checkForUpdates() override; QString displayName() const override; bool hasApplications() const override; public Q_SLOTS: void toggleFetching(); private: void populate(const QString& name); QHash m_resources; StandardBackendUpdater* m_updater; DummyReviewsBackend* m_reviews; bool m_fetching; int m_startElements; }; #endif // DUMMYBACKEND_H diff --git a/libdiscover/backends/FlatpakBackend/FlatpakBackend.h b/libdiscover/backends/FlatpakBackend/FlatpakBackend.h index cd1c05a4..d9b46260 100644 --- a/libdiscover/backends/FlatpakBackend/FlatpakBackend.h +++ b/libdiscover/backends/FlatpakBackend/FlatpakBackend.h @@ -1,123 +1,122 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * Copyright © 2017 Jan Grulich * * * * 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 FLATPAKBACKEND_H #define FLATPAKBACKEND_H #include "FlatpakResource.h" #include #include #include #include #include extern "C" { #include } -class QAction; class FlatpakSourcesBackend; class StandardBackendUpdater; class OdrsReviewsBackend; class FlatpakBackend : public AbstractResourcesBackend { Q_OBJECT public: explicit FlatpakBackend(QObject *parent = nullptr); ~FlatpakBackend(); int updatesCount() const override; AbstractBackendUpdater * backendUpdater() const override; AbstractReviewsBackend * reviewsBackend() const override; ResultsStream * search(const AbstractResourcesBackend::Filters & search) override; ResultsStream * findResourceByPackageName(const QUrl &search); QList resources() const { return m_resources.values(); } bool isValid() const override; Transaction* installApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app, const AddonList& addons) override; Transaction* removeApplication(AbstractResource* app) override; bool isFetching() const override { return m_isFetching>0; } void checkForUpdates() override; QString displayName() const override; bool hasApplications() const override { return true; } FlatpakResource * addSourceFromFlatpakRepo(const QUrl &url); QStringList extends() const override { return m_extends; } FlatpakResource * addAppFromFlatpakBundle(const QUrl &url); FlatpakResource * addAppFromFlatpakRef(const QUrl &url); private Q_SLOTS: void onFetchMetadataFinished(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource, const QByteArray &metadata); void onFetchSizeFinished(FlatpakResource *resource, guint64 downloadSize, guint64 installedSize); void onFetchUpdatesFinished(FlatpakInstallation *flatpakInstallation, GPtrArray *updates); Q_SIGNALS: //for tests void initialized(); private: void metadataRefreshed(); bool flatpakResourceLessThan(AbstractResource* l, AbstractResource* r) const; void announceRatingsReady(); FlatpakInstallation * preferredInstallation() const { return m_installations.constFirst(); } void integrateRemote(FlatpakInstallation *flatpakInstallation, FlatpakRemote *remote); FlatpakRemote * getFlatpakRemoteByUrl(const QString &url, FlatpakInstallation *installation) const; FlatpakInstalledRef * getInstalledRefForApp(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource) const; FlatpakResource * getAppForInstalledRef(FlatpakInstallation *flatpakInstallation, FlatpakInstalledRef *ref) const; FlatpakResource * getRuntimeForApp(FlatpakResource *resource) const; void addResource(FlatpakResource *resource); void loadAppsFromAppstreamData(); bool loadAppsFromAppstreamData(FlatpakInstallation *flatpakInstallation); void loadInstalledApps(); bool loadInstalledApps(FlatpakInstallation *flatpakInstallation); void loadLocalUpdates(FlatpakInstallation *flatpakInstallation); void loadRemoteUpdates(FlatpakInstallation *flatpakInstallation); bool parseMetadataFromAppBundle(FlatpakResource *resource); void refreshAppstreamMetadata(FlatpakInstallation *installation, FlatpakRemote *remote); bool setupFlatpakInstallations(GError **error); void updateAppInstalledMetadata(FlatpakInstalledRef *installedRef, FlatpakResource *resource); bool updateAppMetadata(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource); bool updateAppMetadata(FlatpakResource *resource, const QByteArray &data); bool updateAppMetadata(FlatpakResource *resource, const QString &path); bool updateAppSize(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource); bool updateAppSizeFromRemote(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource); void updateAppState(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource); QVector resourcesByAppstreamName(const QString &name) const; void acquireFetching(bool f); QHash m_resources; StandardBackendUpdater *m_updater; FlatpakSourcesBackend *m_sources = nullptr; QSharedPointer m_reviews; uint m_isFetching = 0; uint m_refreshAppstreamMetadataJobs; QStringList m_extends; GCancellable *m_cancellable; QVector m_installations; QThreadPool m_threadPool; }; #endif // FLATPAKBACKEND_H diff --git a/libdiscover/backends/FwupdBackend/FwupdResource.h b/libdiscover/backends/FwupdBackend/FwupdResource.h index 2678a2a9..b7c43189 100644 --- a/libdiscover/backends/FwupdBackend/FwupdResource.h +++ b/libdiscover/backends/FwupdBackend/FwupdResource.h @@ -1,113 +1,112 @@ /*************************************************************************** * 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; QJsonArray licenses() 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; AbstractResource::Type type() const override { return Technical; } 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 {}; } QString author() const override { return {}; } void setDeviceId(const QString &deviceId) { m_deviceID = deviceId; } void setIsDeviceLocked(bool locked) { m_isDeviceLocked = locked; } void setDescription(const QString &description) { m_description = description; } void setId(const QString &id) { m_id = id; } void setState(AbstractResource::State state); void setReleaseDetails(FwupdRelease *release); void setDeviceDetails(FwupdDevice* device); QString id() const { return m_id; } QString deviceId() const { return m_deviceID; } QUrl updateURI() const { return QUrl(m_updateURI); } bool isDeviceLocked() const { return m_isDeviceLocked; } bool isOnlyOffline() const { return m_isOnlyOffline; } bool isLiveUpdatable() const { return m_isLiveUpdatable; } bool needsReboot() const { return m_needsReboot; } QString cacheFile() const; private: QString m_id; const QString m_name; QString m_summary; QString m_description; QString m_version; QString m_vendor; QStringList m_categories; QString m_license; QString m_displayName; QDate m_releaseDate; AbstractResource::State m_state = None; QUrl m_homepage; QString m_iconName; int m_size = 0; QString m_deviceID; QString m_updateURI; bool m_isDeviceLocked = false; // True if device is locked! bool m_isOnlyOffline = false; // True if only offline updates bool m_isLiveUpdatable = false; // True if device is live updatable bool m_needsReboot = false; // True if device needs Reboot bool m_isDeviceRemoval = false; //True if device is Removal bool m_needsBootLoader = false; //True if BootLoader Required QString m_origin; }; #endif // FWUPDRESOURCE_H diff --git a/libdiscover/backends/KNSBackend/KNSBackend.h b/libdiscover/backends/KNSBackend/KNSBackend.h index ac457cd9..235f50db 100644 --- a/libdiscover/backends/KNSBackend/KNSBackend.h +++ b/libdiscover/backends/KNSBackend/KNSBackend.h @@ -1,108 +1,107 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 KNSBACKEND_H #define KNSBACKEND_H #include #include #include #include "Transaction/AddonList.h" #include "discovercommon_export.h" -class KConfigGroup; class KNSReviews; class KNSResource; class StandardBackendUpdater; namespace KNSCore { class Engine; } class DISCOVERCOMMON_EXPORT KNSBackend : public AbstractResourcesBackend { Q_OBJECT public: explicit KNSBackend(QObject* parent, const QString& iconName, const QString &knsrc); ~KNSBackend() override; Transaction* removeApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app, const AddonList& addons) override; int updatesCount() const override; AbstractReviewsBackend* reviewsBackend() const override; AbstractBackendUpdater* backendUpdater() const override; bool isFetching() const override; ResultsStream* search(const AbstractResourcesBackend::Filters & filter) override; ResultsStream* findResourceByPackageName(const QUrl & search); QVector category() const override { return m_rootCategories; } bool hasApplications() const override { return m_hasApplications; } bool isValid() const override; QStringList extends() const override { return m_extends; } QString iconName() const { return m_iconName; } KNSCore::Engine* engine() const { return m_engine; } void checkForUpdates() override {} QString displayName() const override; Q_SIGNALS: void receivedResources(const QVector &resources); void searchFinished(); void startingSearch(); void availableForQueries(); void initialized(); public Q_SLOTS: void receivedEntries(const KNSCore::EntryInternal::List& entries); void statusChanged(const KNSCore::EntryInternal& entry); void signalErrorCode(const KNSCore::ErrorCode& errorCode, const QString& message, const QVariant& metadata); private: void fetchInstalled(); KNSResource* resourceForEntry(const KNSCore::EntryInternal& entry); void setFetching(bool f); void markInvalid(const QString &message); void searchStream(ResultsStream* stream, const QString &searchText); void fetchMore(); bool m_onePage = false; bool m_responsePending = false; bool m_fetching; bool m_isValid; KNSCore::Engine* m_engine; QHash m_resourcesByName; KNSReviews* const m_reviews; QString m_name; QString m_iconName; StandardBackendUpdater* const m_updater; QStringList m_extends; QStringList m_categories; QVector m_rootCategories; QString m_displayName; bool m_initialized = false; bool m_hasApplications = false; }; #endif // KNSBACKEND_H diff --git a/libdiscover/backends/KNSBackend/KNSReviews.h b/libdiscover/backends/KNSBackend/KNSReviews.h index 8da15b20..26e237b6 100644 --- a/libdiscover/backends/KNSBackend/KNSReviews.h +++ b/libdiscover/backends/KNSBackend/KNSReviews.h @@ -1,67 +1,66 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 KNSREVIEWS_H #define KNSREVIEWS_H #include #include class KNSBackend; class QUrl; namespace Attica { -class ProviderManager; class BaseJob; } class KNSReviews : public AbstractReviewsBackend { Q_OBJECT public: explicit KNSReviews(KNSBackend* backend); void fetchReviews(AbstractResource* app, int page = 1) override; bool isFetching() const override; void flagReview(Review* r, const QString& reason, const QString& text) override; void deleteReview(Review* r) override; void submitReview(AbstractResource* app, const QString& summary, const QString& review_text, const QString& rating) override; void submitUsefulness(Review* r, bool useful) override; void logout() override; void registerAndLogin() override; void login() override; Rating* ratingForApplication(AbstractResource* app) const override; bool hasCredentials() const override; QString userName() const override; void setProviderUrl(const QUrl &url); bool isResourceSupported(AbstractResource * res) const override; private Q_SLOTS: void commentsReceived(Attica::BaseJob* job); void credentialsReceived(const QString& user, const QString& password); private: Attica::Provider provider() const; KNSBackend* const m_backend; QUrl m_providerUrl; int m_fetching = 0; }; #endif // KNSREVIEWS_H diff --git a/libdiscover/backends/KNSBackend/tests/KNSBackendTest.h b/libdiscover/backends/KNSBackend/tests/KNSBackendTest.h index 342825a5..7aa7c8db 100644 --- a/libdiscover/backends/KNSBackend/tests/KNSBackendTest.h +++ b/libdiscover/backends/KNSBackend/tests/KNSBackendTest.h @@ -1,56 +1,55 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 KNSBACKENDTEST_H #define KNSBACKENDTEST_H #include #include #include "ReviewsBackend/ReviewsModel.h" class AbstractResourcesBackend; class AbstractResource; class ResultsStream; -class Category; class KNSBackendTest : public QObject { Q_OBJECT public: explicit KNSBackendTest(QObject* parent = nullptr); private Q_SLOTS: void testRetrieval(); void testReviews(); void testResourceByUrl(); void testResourceByUrlResourcesModel(); public Q_SLOTS: void reviewsArrived(AbstractResource *r, const QVector& revs); private: QVector getResources(ResultsStream* stream, bool canBeEmpty = false); QVector getAllResources(AbstractResourcesBackend* backend); QPointer m_backend; QPointer m_r; QVector m_revs; }; #endif // KNSBACKENDTEST_H diff --git a/libdiscover/backends/PackageKitBackend/PackageKitBackend.h b/libdiscover/backends/PackageKitBackend/PackageKitBackend.h index ac8f5515..29af61d7 100644 --- a/libdiscover/backends/PackageKitBackend/PackageKitBackend.h +++ b/libdiscover/backends/PackageKitBackend/PackageKitBackend.h @@ -1,126 +1,125 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 PACKAGEKITBACKEND_H #define PACKAGEKITBACKEND_H #include "PackageKitResource.h" #include #include #include #include #include #include #include #include #include class AppPackageKitResource; class PackageKitUpdater; -class PKTransaction; class OdrsReviewsBackend; class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend { Q_OBJECT public: explicit PackageKitBackend(QObject* parent = nullptr); ~PackageKitBackend() override; AbstractBackendUpdater* backendUpdater() const override; AbstractReviewsBackend* reviewsBackend() const override; QSet resourcesByPackageName(const QString& name) const; ResultsStream* search(const AbstractResourcesBackend::Filters & search) override; ResultsStream* findResourceByPackageName(const QUrl& search); int updatesCount() const override; bool hasSecurityUpdates() const override; Transaction* installApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app, const AddonList& addons) override; Transaction* removeApplication(AbstractResource* app) override; bool isValid() const override { return true; } QSet upgradeablePackages() const; bool isFetching() const override; bool isPackageNameUpgradeable(const PackageKitResource* res) const; QString upgradeablePackageId(const PackageKitResource* res) const; QVector extendedBy(const QString& id) const; void resolvePackages(const QStringList &packageNames); void fetchDetails(const QString& pkgid) { fetchDetails(QSet{pkgid}); } void fetchDetails(const QSet& pkgid); void checkForUpdates() override; QString displayName() const override; bool hasApplications() const override { return true; } static QString locateService(const QString &filename); QList componentsById(const QString &id) const; void fetchUpdates(); public Q_SLOTS: void reloadPackageList(); void transactionError(PackageKit::Transaction::Error, const QString& message); private Q_SLOTS: void getPackagesFinished(); void addPackage(PackageKit::Transaction::Info info, const QString &packageId, const QString &summary, bool arch); void addPackageArch(PackageKit::Transaction::Info info, const QString &packageId, const QString &summary); void addPackageNotArch(PackageKit::Transaction::Info info, const QString &packageId, const QString &summary); void packageDetails(const PackageKit::Details& details); void addPackageToUpdate(PackageKit::Transaction::Info, const QString& pkgid, const QString& summary); void getUpdatesFinished(PackageKit::Transaction::Exit,uint); private: friend class PackageKitResource; template T resourcesByPackageNames(const QStringList& names) const; void checkDaemonRunning(); void acquireFetching(bool f); void includePackagesToAdd(); void performDetailsFetch(); AppPackageKitResource* addComponent(const AppStream::Component& component, const QStringList& pkgNames); void updateProxy(); QScopedPointer m_appdata; PackageKitUpdater* m_updater; QPointer m_refresher; int m_isFetching; QSet m_updatesPackageId; bool m_hasSecurityUpdates = false; QSet m_packagesToAdd; QSet m_packagesToDelete; struct Packages { QHash packages; QHash packageToApp; QHash> extendedBy; void clear() { *this = {}; } }; QTimer m_delayedDetailsFetch; QSet m_packageNamesToFetchDetails; Packages m_packages; QSharedPointer m_reviews; }; #endif // PACKAGEKITBACKEND_H diff --git a/libdiscover/backends/SnapBackend/SnapBackend.h b/libdiscover/backends/SnapBackend/SnapBackend.h index e8ac0359..a163e4a3 100644 --- a/libdiscover/backends/SnapBackend/SnapBackend.h +++ b/libdiscover/backends/SnapBackend/SnapBackend.h @@ -1,77 +1,76 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * * * 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 SNAPBACKEND_H #define SNAPBACKEND_H #include #include #include #include #include -class QAction; class OdrsReviewsBackend; class StandardBackendUpdater; class SnapResource; class SnapBackend : public AbstractResourcesBackend { Q_OBJECT public: explicit SnapBackend(QObject* parent = nullptr); ~SnapBackend() override; ResultsStream * search(const AbstractResourcesBackend::Filters & search) override; ResultsStream * findResourceByPackageName(const QUrl& search); QString displayName() const override; int updatesCount() const override; AbstractBackendUpdater* backendUpdater() const override; AbstractReviewsBackend* reviewsBackend() const override; bool isValid() const override { return m_valid; } Transaction* installApplication(AbstractResource* app) override; Transaction* installApplication(AbstractResource* app, const AddonList& addons) override; Transaction* removeApplication(AbstractResource* app) override; bool isFetching() const override { return m_fetching; } void checkForUpdates() override {} bool hasApplications() const override { return true; } QSnapdClient* client() { return &m_client; } void refreshStates(); private: void setFetching(bool fetching); template ResultsStream* populateWithFilter(T* snaps, std::function&)>& filter); template ResultsStream* populate(T* snaps); QHash m_resources; StandardBackendUpdater* m_updater; QSharedPointer m_reviews; bool m_valid = true; bool m_fetching = false; QSnapdClient m_client; }; #endif // SNAPBACKEND_H diff --git a/libdiscover/backends/SnapBackend/SnapResource.h b/libdiscover/backends/SnapBackend/SnapResource.h index 7611476c..acda3603 100644 --- a/libdiscover/backends/SnapBackend/SnapResource.h +++ b/libdiscover/backends/SnapBackend/SnapResource.h @@ -1,94 +1,93 @@ /*************************************************************************** * Copyright © 2013 Aleix Pol Gonzalez * * * * 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 SNAPRESOURCE_H #define SNAPRESOURCE_H #include #include #include #include class SnapBackend; class QAbstractItemModel; class QSnapdClient; -class QSnapdChannel; class SnapResource : public AbstractResource { Q_OBJECT Q_PROPERTY(QStringList objects MEMBER m_objects CONSTANT) Q_PROPERTY(QString channel READ channel WRITE setChannel NOTIFY channelChanged) public: explicit SnapResource(QSharedPointer snap, AbstractResource::State state, SnapBackend* parent); ~SnapResource() override = default; QString section() override; QString origin() const override; QString longDescription() override; QString availableVersion() const override; QString installedVersion() const override; QJsonArray licenses() override; int size() override; QStringList categories() override; AbstractResource::State state() override; QVariant icon() const override; QString comment() override; QString name() const override; QString packageName() const override; AbstractResource::Type type() const override; bool canExecute() const override { return true; } void invokeApplication() const override; void fetchChangelog() override; void fetchScreenshots() override; QString author() const override; QList addonsInformation() override { return {}; } void setSnap(const QSharedPointer &snap); void setState(AbstractResource::State state); QString sourceIcon() const override { return QStringLiteral("snap"); } QDate releaseDate() const override; Q_SCRIPTABLE QAbstractItemModel* plugs(QObject* parentC); Q_SCRIPTABLE QObject* channels(QObject* parent); QString appstreamId() const override; QString channel() const; void setChannel(const QString &channel); QSharedPointer snap() const { return m_snap; } Q_SIGNALS: void channelChanged(const QString &channel); void newSnap(); public: QSnapdClient* client() const; void refreshSnap(); void gotIcon(); AbstractResource::State m_state; QSharedPointer m_snap; mutable QVariant m_icon; static const QStringList m_objects; }; #endif // SNAPRESOURCE_H diff --git a/libdiscover/resources/AbstractBackendUpdater.h b/libdiscover/resources/AbstractBackendUpdater.h index 9c75e13f..71af7d0a 100644 --- a/libdiscover/resources/AbstractBackendUpdater.h +++ b/libdiscover/resources/AbstractBackendUpdater.h @@ -1,223 +1,222 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 ABSTRACTBACKENDUPDATER_H #define ABSTRACTBACKENDUPDATER_H #include #include "discovercommon_export.h" class QDateTime; -class QIcon; class AbstractResource; /** * \class AbstractBackendUpdater AbstractBackendUpdater.h "AbstractBackendUpdater.h" * * \brief This is the base class for all abstract classes, which handle system upgrades. * * While implementing this is not mandatory for all backends (you can also use the * StandardBackendUpdater, which just uses the functions in the ResourcesBackend to * update the packages), it is recommended for many. * * Before starting the update, the AbstractBackendUpdater will have to keep a list of * packages, which are about to be upgraded. First, all packages have to be inserted * into this list in the \prepare method and they can then be changed by the user through * the \addResources and \removeResources functions. * * When \start is called, the AbstractBackendUpdater should start the update and report its * progress through the rest of methods outlined in this API documentation. * * @see addResources * @see removeResources * @see start * @see prepare */ class DISCOVERCOMMON_EXPORT AbstractBackendUpdater : public QObject { Q_OBJECT Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(bool isCancelable READ isCancelable NOTIFY cancelableChanged) Q_PROPERTY(bool isProgressing READ isProgressing NOTIFY progressingChanged) Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged) Q_PROPERTY(quint64 downloadSpeed READ downloadSpeed NOTIFY downloadSpeedChanged) public: enum State { None, Downloading, Installing, Done }; Q_ENUM(State); /** * Constructs an AbstractBackendUpdater */ explicit AbstractBackendUpdater(QObject* parent = nullptr); /** * This method is called, when Muon switches to the updates view. * Here the backend should mark all upgradeable packages as to be upgraded. */ virtual void prepare() = 0; /** * @returns true if the backend contains packages which can be updated */ virtual bool hasUpdates() const = 0; /** * @returns the progress of the update in percent */ virtual qreal progress() const = 0; /** * This method is used to remove resources from the list of packages * marked to be upgraded. It will potentially be called before \start. */ virtual void removeResources(const QList& apps) = 0; /** * This method is used to add resource to the list of packages marked to be upgraded. * It will potentially be called before \start. */ virtual void addResources(const QList& apps) = 0; /** * @returns the list of updateable resources in the system */ virtual QList toUpdate() const = 0; /** * @returns the QDateTime when the last update happened */ virtual QDateTime lastUpdate() const = 0; /** * @returns whether the updater can currently be canceled or not * @see cancelableChanged */ virtual bool isCancelable() const = 0; /** * @returns whether the updater is currently running or not * this property decides, if there will be progress reporting in the GUI. * This has to stay true during the whole transaction! * @see progressingChanged */ virtual bool isProgressing() const = 0; /** * @returns whether @p res is marked for update */ virtual bool isMarked(AbstractResource* res) const = 0; virtual void fetchChangelog() const; /** * @returns the size of all the packages set to update combined */ virtual double updateSize() const = 0; /** * @returns the speed at which we are downloading */ virtual quint64 downloadSpeed() const = 0; void enableNeedsReboot(); bool needsReboot() const; public Q_SLOTS: /** * If \isCancelable is true during the transaction, this method has * to be implemented and will potentially be called when the user * wants to cancel the update. */ virtual void cancel(); /** * This method starts the update. All packages which are in \toUpdate * are going to be updated. * * From this moment on the AbstractBackendUpdater should continuously update * the other methods to show its progress. * * @see progress * @see progressChanged * @see isProgressing * @see progressingChanged */ virtual void start() = 0; /** * Answers a proceed request */ virtual void proceed() {} Q_SIGNALS: /** * The AbstractBackendUpdater should emit this signal when the progress changed. * @see progress */ void progressChanged(qreal progress); /** * The AbstractBackendUpdater should emit this signal when the cancelable property changed. * @see isCancelable */ void cancelableChanged(bool cancelable); /** * The AbstractBackendUpdater should emit this signal when the progressing property changed. * @see isProgressing */ void progressingChanged(bool progressing); /** * The AbstractBackendUpdater should emit this signal when the status detail changed. * @see statusDetail */ void statusDetailChanged(const QString& msg); /** * The AbstractBackendUpdater should emit this signal when the status message changed. * @see statusMessage */ void statusMessageChanged(const QString& msg); /** * The AbstractBackendUpdater should emit this signal when the download speed changed. * @see downloadSpeed */ void downloadSpeedChanged(quint64 downloadSpeed); /** * Provides the @p progress of a specific @p resource in a percentage. */ void resourceProgressed(AbstractResource* resource, qreal progress, AbstractBackendUpdater::State state); void passiveMessage(const QString &message); /** * Provides a message to be shown to the user * * The user gets to acknowledge and proceed or cancel the transaction. * * @sa proceed(), cancel() */ void proceedRequest(const QString &title, const QString &description); /** * emitted when the updater decides it needs to reboot */ void needsRebootChanged(); private: bool m_needsReboot = false; }; #endif // ABSTRACTBACKENDUPDATER_H diff --git a/libdiscover/resources/ResourcesProxyModel.h b/libdiscover/resources/ResourcesProxyModel.h index 9483ea44..52945acf 100644 --- a/libdiscover/resources/ResourcesProxyModel.h +++ b/libdiscover/resources/ResourcesProxyModel.h @@ -1,178 +1,177 @@ /*************************************************************************** * Copyright © 2010 Jonathan Thomas * * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 RESOURCESPROXYMODEL_H #define RESOURCESPROXYMODEL_H #include #include #include #include #include #include "discovercommon_export.h" #include "AbstractResource.h" #include "AbstractResourcesBackend.h" -class Transaction; class AggregatedResultsStream; class DISCOVERCOMMON_EXPORT ResourcesProxyModel : public QAbstractListModel, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(Roles sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged) Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged) Q_PROPERTY(Category* filteredCategory READ filteredCategory WRITE setFiltersFromCategory NOTIFY categoryChanged) Q_PROPERTY(QString originFilter READ originFilter WRITE setOriginFilter) Q_PROPERTY(AbstractResource::State stateFilter READ stateFilter WRITE setStateFilter NOTIFY stateFilterChanged) Q_PROPERTY(bool filterMinimumState READ filterMinimumState WRITE setFilterMinimumState NOTIFY filterMinimumStateChanged) Q_PROPERTY(QString mimeTypeFilter READ mimeTypeFilter WRITE setMimeTypeFilter) Q_PROPERTY(QString search READ lastSearch WRITE setSearch NOTIFY searchChanged) Q_PROPERTY(QUrl resourcesUrl READ resourcesUrl WRITE setResourcesUrl NOTIFY resourcesUrlChanged) Q_PROPERTY(QString extending READ extends WRITE setExtends) Q_PROPERTY(bool allBackends READ allBackends WRITE setAllBackends) Q_PROPERTY(QVariantList subcategories READ subcategories NOTIFY subcategoriesChanged) Q_PROPERTY(bool isBusy READ isBusy NOTIFY busyChanged) Q_PROPERTY(int count READ rowCount NOTIFY countChanged) Q_PROPERTY(bool sortByRelevancy READ sortByRelevancy NOTIFY sortByRelevancyChanged) public: explicit ResourcesProxyModel(QObject* parent = nullptr); enum Roles { NameRole = Qt::UserRole, IconRole, CommentRole, StateRole, RatingRole, RatingPointsRole, RatingCountRole, SortableRatingRole, InstalledRole, ApplicationRole, OriginRole, DisplayOriginRole, CanUpgrade, PackageNameRole, CategoryRole, CategoryDisplayRole, SectionRole, MimeTypes, SizeRole, LongDescriptionRole, SourceIconRole, ReleaseDateRole }; Q_ENUM(Roles) QHash roleNames() const override; void setSearch(const QString &text); QString lastSearch() const; void setOriginFilter(const QString &origin); QString originFilter() const; void setFiltersFromCategory(Category *category); void setStateFilter(AbstractResource::State s); AbstractResource::State stateFilter() const; void setSortRole(Roles sortRole); Roles sortRole() const { return m_sortRole; } void setSortOrder(Qt::SortOrder sortOrder); Qt::SortOrder sortOrder() const { return m_sortOrder; } void setFilterMinimumState(bool filterMinimumState); bool filterMinimumState() const; Category* filteredCategory() const; QString mimeTypeFilter() const; void setMimeTypeFilter(const QString& mime); QString extends() const; void setExtends(const QString &extends); QUrl resourcesUrl() const; void setResourcesUrl(const QUrl& resourcesUrl); bool allBackends() const; void setAllBackends(bool allBackends); QVariantList subcategories() const; QVariant data(const QModelIndex & index, int role) const override; int rowCount(const QModelIndex & parent = {}) const override; Q_SCRIPTABLE int indexOf(AbstractResource* res); Q_SCRIPTABLE AbstractResource* resourceAt(int row) const; bool isBusy() const { return m_currentStream != nullptr; } bool lessThan(AbstractResource* rl, AbstractResource* rr) const; Q_SCRIPTABLE void invalidateFilter(); void invalidateSorting(); bool canFetchMore(const QModelIndex & parent) const override; void fetchMore(const QModelIndex & parent) override; bool sortByRelevancy() const; void classBegin() override {} void componentComplete() override; private Q_SLOTS: void refreshBackend(AbstractResourcesBackend* backend, const QVector& properties); void refreshResource(AbstractResource* resource, const QVector& properties); void removeResource(AbstractResource* resource); private: void sortedInsertion(const QVector &res); QVariant roleToValue(AbstractResource* res, int role) const; QVector propertiesToRoles(const QVector& properties) const; void addResources(const QVector &res); void fetchSubcategories(); void removeDuplicates(QVector& newResources); bool isSorted(const QVector & resources); Roles m_sortRole; Qt::SortOrder m_sortOrder; bool m_sortByRelevancy; bool m_setup = false; AbstractResourcesBackend::Filters m_filters; QVariantList m_subcategories; QVector m_displayedResources; const QHash m_roles; AggregatedResultsStream* m_currentStream; Q_SIGNALS: void busyChanged(bool isBusy); void sortRoleChanged(int sortRole); void sortOrderChanged(Qt::SortOrder order); void categoryChanged(); void stateFilterChanged(); void searchChanged(const QString &search); void subcategoriesChanged(const QVariantList &subcategories); void resourcesUrlChanged(const QUrl &url); void countChanged(); void filterMinimumStateChanged(bool filterMinimumState); void sortByRelevancyChanged(bool sortByRelevancy); }; #endif diff --git a/libdiscover/resources/ResourcesUpdatesModel.h b/libdiscover/resources/ResourcesUpdatesModel.h index 58f8a91d..f2f2af1b 100644 --- a/libdiscover/resources/ResourcesUpdatesModel.h +++ b/libdiscover/resources/ResourcesUpdatesModel.h @@ -1,88 +1,85 @@ /*************************************************************************** * Copyright © 2012 Aleix Pol Gonzalez * * * * 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 RESOURCESUPDATESMODEL_H #define RESOURCESUPDATESMODEL_H #include #include #include #include "discovercommon_export.h" #include "resources/AbstractBackendUpdater.h" -class AbstractResourcesBackend; class AbstractResource; -class QAction; -class ResourcesModel; class UpdateTransaction; class Transaction; class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel { Q_OBJECT Q_PROPERTY(bool isProgressing READ isProgressing NOTIFY progressingChanged) Q_PROPERTY(QDateTime lastUpdate READ lastUpdate NOTIFY progressingChanged) Q_PROPERTY(qint64 secsToLastUpdate READ secsToLastUpdate NOTIFY progressingChanged) Q_PROPERTY(Transaction* transaction READ transaction NOTIFY progressingChanged) Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged) public: explicit ResourcesUpdatesModel(QObject* parent = nullptr); quint64 downloadSpeed() const; Q_SCRIPTABLE void prepare(); bool isProgressing() const; QList toUpdate() const; QDateTime lastUpdate() const; double updateSize() const; void addResources(const QList& resources); void removeResources(const QList& resources); qint64 secsToLastUpdate() const; QVector updaters() const { return m_updaters; } Transaction* transaction() const; bool needsReboot() const; Q_SIGNALS: void downloadSpeedChanged(); void progressingChanged(); void finished(); void resourceProgressed(AbstractResource* resource, qreal progress, AbstractBackendUpdater::State state); void passiveMessage(const QString &message); void needsRebootChanged(); public Q_SLOTS: void updateAll(); private Q_SLOTS: void updaterDestroyed(QObject* obj); void message(const QString& msg); private: void init(); void updateFinished(); void setTransaction(UpdateTransaction* transaction); QVector m_updaters; bool m_lastIsProgressing; QPointer m_transaction; }; #endif // RESOURCESUPDATESMODEL_H diff --git a/notifier/DiscoverNotifier.h b/notifier/DiscoverNotifier.h index 64d52db6..d3ffd51d 100644 --- a/notifier/DiscoverNotifier.h +++ b/notifier/DiscoverNotifier.h @@ -1,88 +1,87 @@ /*************************************************************************** * Copyright © 2014 Aleix Pol Gonzalez * * * * 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 DISCOVERNOTIFIERMODULE_H #define DISCOVERNOTIFIERMODULE_H #include #include #include class QNetworkConfigurationManager; -class KStatusNotifierItem; class DiscoverNotifier : public QObject { Q_OBJECT Q_PROPERTY(QStringList modules READ loadedModules CONSTANT) Q_PROPERTY(QString iconName READ iconName NOTIFY stateChanged) Q_PROPERTY(QString message READ message NOTIFY stateChanged) Q_PROPERTY(State state READ state NOTIFY stateChanged) Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged) public: enum State { NoUpdates, NormalUpdates, SecurityUpdates, RebootRequired, Offline, }; Q_ENUM(State) explicit DiscoverNotifier(QObject* parent = nullptr); ~DiscoverNotifier() override; State state() const; QString iconName() const; QString message() const; bool hasUpdates() const { return m_hasUpdates; } bool hasSecurityUpdates() const { return m_hasSecurityUpdates; } QStringList loadedModules() const; bool needsReboot() const { return m_needsReboot; } public Q_SLOTS: void configurationChanged(); void recheckSystemUpdateNeeded(); void showDiscover(); void showDiscoverUpdates(); void showUpdatesNotification(); void reboot(); void foundUpgradeAction(UpgradeAction* action); Q_SIGNALS: void stateChanged(); bool needsRebootChanged(bool needsReboot); void newUpgradeAction(UpgradeAction* action); private: void showRebootNotification(); void updateStatusNotifier(); QList m_backends; bool m_verbose = false; QTimer m_timer; bool m_hasSecurityUpdates = false; bool m_hasUpdates = false; bool m_needsReboot = false; QNetworkConfigurationManager* const m_manager; }; #endif //ABSTRACTKDEDMODULE_H