File indexing completed on 2024-11-24 04:54:55
0001 /* 0002 * SPDX-FileCopyrightText: 2013 Lukas Appelhans <l.appelhans@gmx.de> 0003 * SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 #pragma once 0008 0009 #include <BackendNotifierModule.h> 0010 #include <functional> 0011 0012 #include "flatpak-helper.h" 0013 0014 class FlatpakNotifier : public BackendNotifierModule 0015 { 0016 Q_OBJECT 0017 Q_PLUGIN_METADATA(IID "org.kde.discover.BackendNotifierModule") 0018 Q_INTERFACES(BackendNotifierModule) 0019 public: 0020 explicit FlatpakNotifier(QObject *parent = nullptr); 0021 ~FlatpakNotifier() override; 0022 0023 bool hasUpdates() override; 0024 bool hasSecurityUpdates() override 0025 { 0026 return false; 0027 } 0028 void recheckSystemUpdateNeeded() override; 0029 bool needsReboot() const override 0030 { 0031 return false; 0032 } 0033 0034 struct Installation { 0035 explicit Installation(FlatpakNotifier *notifier); 0036 ~Installation(); 0037 0038 bool ensureInitialized(std::function<FlatpakInstallation *()> func, GCancellable *, GError **error); 0039 0040 FlatpakNotifier *m_notifier; 0041 bool m_hasUpdates = false; 0042 GFileMonitor *m_monitor = nullptr; 0043 FlatpakInstallation *m_installation = nullptr; 0044 }; 0045 0046 void onFetchUpdatesFinished(Installation *flatpakInstallation, bool hasUpdates); 0047 void loadRemoteUpdates(Installation *installation); 0048 bool setupFlatpakInstallations(GError **error); 0049 Installation m_user; 0050 Installation m_system; 0051 GCancellable *const m_cancellable; 0052 bool m_lastHasUpdates = false; 0053 };