1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2025 Kai Uwe Broulik <kde@broulik.de> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KINHIBITIONJOBTRACKER_P_H |
9 | #define KINHIBITIONJOBTRACKER_P_H |
10 | |
11 | #include <config-kjobwidgets.h> |
12 | |
13 | #ifdef Q_OS_WINDOWS |
14 | #include <windows.h> |
15 | #elif HAVE_QTDBUS |
16 | #include <QDBusObjectPath> |
17 | #endif |
18 | |
19 | #include <QHash> |
20 | #include <QObject> |
21 | #include <QString> |
22 | |
23 | class QTimer; |
24 | |
25 | class KJob; |
26 | class KInhibitionJobTracker; |
27 | |
28 | class Inhibition : public QObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | explicit Inhibition(const QString &appName, const QString &reason, QObject *parent = nullptr); |
34 | ~Inhibition() override; |
35 | |
36 | private: |
37 | void inhibit(); |
38 | void uninhibit(); |
39 | |
40 | QString m_appName; |
41 | QString m_reason; |
42 | |
43 | #ifdef Q_OS_WINDOWS |
44 | HANDLE m_handle = INVALID_HANDLE_VALUE; |
45 | #elif HAVE_QTDBUS |
46 | QDBusObjectPath m_portalInhibitionRequest; // portal. |
47 | std::optional<uint> m_inhibitionCookie; // fdo. |
48 | #endif |
49 | }; |
50 | |
51 | class KInhibitionJobTrackerPrivate |
52 | { |
53 | public: |
54 | explicit KInhibitionJobTrackerPrivate(KInhibitionJobTracker *q); |
55 | |
56 | void inhibit(KJob *job); |
57 | |
58 | QHash<KJob *, QString> reasons; |
59 | QHash<KJob *, QTimer *> timers; |
60 | QHash<KJob *, Inhibition *> inhibitions; |
61 | |
62 | private: |
63 | KInhibitionJobTracker *const q; |
64 | |
65 | void doInhibit(KJob *job); |
66 | }; |
67 | |
68 | #endif // KINHIBITIONJOBTRACKER_P_H |
69 | |