File indexing completed on 2024-04-21 16:22:33

0001 #ifndef POLICYKITLISTENER_H
0002 #define POLICYKITLISTENER_H
0003 
0004 /*  This file is part of the KDE project
0005     SPDX-FileCopyrightText: 2009 Jaroslav Reznik <jreznik@redhat.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include <QHash>
0011 #include <QPointer>
0012 
0013 #include <PolkitQt1/Agent/Listener>
0014 
0015 class AuthDialog;
0016 
0017 using namespace PolkitQt1::Agent;
0018 
0019 class PolicyKitListener : public Listener
0020 {
0021     Q_OBJECT
0022     Q_CLASSINFO("D-Bus Interface", "org.kde.Polkit1AuthAgent")
0023 public:
0024     explicit PolicyKitListener(QObject *parent = nullptr);
0025     ~PolicyKitListener() override;
0026 
0027 public Q_SLOTS:
0028     void initiateAuthentication(const QString &actionId,
0029                                 const QString &message,
0030                                 const QString &iconName,
0031                                 const PolkitQt1::Details &details,
0032                                 const QString &cookie,
0033                                 const PolkitQt1::Identity::List &identities,
0034                                 PolkitQt1::Agent::AsyncResult *result) override;
0035     bool initiateAuthenticationFinish() override;
0036     void cancelAuthentication() override;
0037 
0038     void tryAgain();
0039     void finishObtainPrivilege();
0040 
0041     void request(const QString &request, bool echo);
0042     void completed(bool gainedAuthorization);
0043     void showError(const QString &text);
0044     void showInfo(const QString &text);
0045 
0046     void setWIdForAction(const QString &action, qulonglong wID);
0047 
0048 private:
0049     QPointer<AuthDialog> m_dialog;
0050     QPointer<Session> m_session;
0051     bool m_inProgress;
0052     bool m_gainedAuthorization;
0053     bool m_wasCancelled;
0054     int m_numTries;
0055     PolkitQt1::Identity::List m_identities;
0056     PolkitQt1::Agent::AsyncResult *m_result;
0057     QString m_cookie;
0058     PolkitQt1::Identity m_selectedUser;
0059     QHash<QString, qulonglong> m_actionsToWID;
0060 
0061 private Q_SLOTS:
0062     void dialogAccepted();
0063     void dialogCanceled();
0064     void userSelected(const PolkitQt1::Identity &identity);
0065 };
0066 
0067 #endif