File indexing completed on 2024-03-24 17:22:56

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef KUPDAEMON_H
0006 #define KUPDAEMON_H
0007 
0008 #include <KSharedConfig>
0009 
0010 #define KUP_DBUS_SERVICE_NAME QStringLiteral("org.kde.kupdaemon")
0011 #define KUP_DBUS_OBJECT_PATH QStringLiteral("/DaemonControl")
0012 
0013 class KupSettings;
0014 class PlanExecutor;
0015 
0016 class KJob;
0017 class KUiServerJobTracker;
0018 
0019 class QLocalServer;
0020 class QLocalSocket;
0021 class QSessionManager;
0022 class QTimer;
0023 
0024 class KupDaemon : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     KupDaemon();
0030     ~KupDaemon() override;
0031     bool shouldStart();
0032     void setupGuiStuff();
0033     void slotShutdownRequest(QSessionManager &pManager);
0034     void registerJob(KJob *pJob);
0035     void unregisterJob(KJob *pJob);
0036 
0037 public slots:
0038     void reloadConfig();
0039     void runIntegrityCheck(const QString& pPath);
0040     void saveNewBackup(int pPlanNumber);
0041 
0042 private:
0043     void setupExecutors();
0044     void handleRequests(QLocalSocket *pSocket);
0045     void sendStatus(QLocalSocket *pSocket);
0046 
0047     KSharedConfigPtr mConfig;
0048     KupSettings *mSettings;
0049     QList<PlanExecutor *> mExecutors;
0050     QTimer *mUsageAccTimer;
0051     QTimer *mStatusUpdateTimer;
0052     bool mWaitingToReloadConfig;
0053     KUiServerJobTracker *mJobTracker;
0054     QLocalServer *mLocalServer;
0055     QList<QLocalSocket *> mSockets;
0056 };
0057 
0058 #endif /*KUPDAEMON_H*/