1 | /* |
2 | SPDX-FileCopyrightText: 2008 Nicola Gigante <nicola.gigante@gmail.com> |
3 | SPDX-FileCopyrightText: 2009 Radek Novacek <rnovacek@redhat.com> |
4 | SPDX-FileCopyrightText: 2009-2010 Dario Freddi <drf@kde.org> |
5 | SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <kde@broulik.de> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.1-or-later |
8 | */ |
9 | |
10 | #ifndef POLKIT1BACKEND_H |
11 | #define POLKIT1BACKEND_H |
12 | |
13 | #include "AuthBackend.h" |
14 | |
15 | #include <QEventLoop> |
16 | #include <QHash> |
17 | #include <QStringList> |
18 | |
19 | #include <PolkitQt1/Authority> |
20 | |
21 | #include <memory> |
22 | |
23 | class QByteArray; |
24 | |
25 | namespace KAuth |
26 | { |
27 | class Polkit1Backend : public AuthBackend |
28 | { |
29 | Q_OBJECT |
30 | Q_PLUGIN_METADATA(IID "org.kde.Polkit1Backend" ) |
31 | Q_INTERFACES(KAuth::AuthBackend) |
32 | |
33 | public: |
34 | Polkit1Backend(); |
35 | ~Polkit1Backend() override; |
36 | void setupAction(const QString &) override; |
37 | void preAuthAction(const QString &action, QWindow *parent) override; |
38 | Action::AuthStatus authorizeAction(const QString &) override; |
39 | Action::AuthStatus actionStatus(const QString &) override; |
40 | QByteArray callerID() const override; |
41 | virtual bool isCallerAuthorized(const QString &action, const QByteArray &callerID, const QVariantMap &details) override; |
42 | QVariantMap backendDetails(const DetailsMap &details) override; |
43 | |
44 | private Q_SLOTS: |
45 | void checkForResultChanged(); |
46 | |
47 | private: |
48 | void sendWindowHandle(const QString &action, const QString &handle); |
49 | void sendActivationToken(const QString &action, QWindow *window); |
50 | |
51 | QHash<QString, Action::AuthStatus> m_cachedResults; |
52 | }; |
53 | |
54 | } // namespace Auth |
55 | |
56 | #endif |
57 | |