File indexing completed on 2024-11-17 04:55:42
0001 /* 0002 * SPDX-FileCopyrightText: 2013 Lukas Appelhans <l.appelhans@gmx.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #pragma once 0007 0008 #include <AppStreamQt/pool.h> 0009 #include <BackendNotifierModule.h> 0010 #include <PackageKit/Transaction> 0011 #include <QPointer> 0012 #include <QVariantList> 0013 #include <functional> 0014 0015 class QTimer; 0016 class QProcess; 0017 0018 class PackageKitNotifier : public BackendNotifierModule 0019 { 0020 Q_OBJECT 0021 Q_PLUGIN_METADATA(IID "org.kde.discover.BackendNotifierModule") 0022 Q_INTERFACES(BackendNotifierModule) 0023 public: 0024 explicit PackageKitNotifier(QObject *parent = nullptr); 0025 ~PackageKitNotifier() override; 0026 0027 bool hasUpdates() override; 0028 bool hasSecurityUpdates() override; 0029 void recheckSystemUpdateNeeded() override; 0030 void refreshDatabase(); 0031 bool needsReboot() const override 0032 { 0033 return m_needsReboot; 0034 } 0035 void checkDistroUpgrade(); 0036 0037 private Q_SLOTS: 0038 void package(PackageKit::Transaction::Info info, const QString &packageID, const QString &summary); 0039 void finished(PackageKit::Transaction::Exit exit, uint); 0040 void onRequireRestart(PackageKit::Transaction::Restart type, const QString &packageID); 0041 void transactionListChanged(const QStringList &transactionIDs); 0042 0043 private: 0044 void nowNeedsReboot(); 0045 void recheckSystemUpdate(); 0046 void checkOfflineUpdates(); 0047 void setupGetUpdatesTransaction(PackageKit::Transaction *transaction); 0048 QProcess *checkAptVariable(const QString &aptconfig, const QLatin1String &varname, const std::function<void(const QStringView &val)> &func); 0049 0050 bool m_needsReboot = false; 0051 uint m_securityUpdates; 0052 uint m_normalUpdates; 0053 bool m_hasDistUpgrade; 0054 QPointer<PackageKit::Transaction> m_refresher; 0055 QTimer *m_recheckTimer; 0056 0057 QHash<QString, PackageKit::Transaction *> m_transactions; 0058 std::unique_ptr<AppStream::Pool> m_appdata; 0059 };