File indexing completed on 2024-10-06 05:03:14
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 SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <kde@broulik.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include <QHash> 0012 #include <QPointer> 0013 0014 #include <PolkitQt1/Agent/Listener> 0015 0016 class QuickAuthDialog; 0017 0018 using namespace PolkitQt1::Agent; 0019 0020 class PolicyKitListener : public Listener 0021 { 0022 Q_OBJECT 0023 Q_CLASSINFO("D-Bus Interface", "org.kde.Polkit1AuthAgent") 0024 public: 0025 explicit PolicyKitListener(QObject *parent = nullptr); 0026 ~PolicyKitListener() override; 0027 0028 public Q_SLOTS: 0029 void initiateAuthentication(const QString &actionId, 0030 const QString &message, 0031 const QString &iconName, 0032 const PolkitQt1::Details &details, 0033 const QString &cookie, 0034 const PolkitQt1::Identity::List &identities, 0035 PolkitQt1::Agent::AsyncResult *result) override; 0036 bool initiateAuthenticationFinish() override; 0037 void cancelAuthentication() override; 0038 0039 void tryAgain(); 0040 void finishObtainPrivilege(); 0041 0042 void request(const QString &request, bool echo); 0043 void completed(bool gainedAuthorization); 0044 void showError(const QString &text); 0045 void showInfo(const QString &text); 0046 0047 void setWIdForAction(const QString &action, qulonglong wID); 0048 void setWindowHandleForAction(const QString &action, const QString &handle); 0049 void setActivationTokenForAction(const QString &action, const QString &token); 0050 0051 private: 0052 QPointer<QuickAuthDialog> m_dialog; 0053 QPointer<Session> m_session = nullptr; 0054 bool m_inProgress; 0055 bool m_gainedAuthorization; 0056 bool m_wasCancelled; 0057 int m_numTries; 0058 PolkitQt1::Identity::List m_identities; 0059 PolkitQt1::Agent::AsyncResult *m_result; 0060 QString m_cookie; 0061 PolkitQt1::Identity m_selectedUser; 0062 0063 QHash<QString /*action*/, QString /*window handle*/> m_windowHandles; 0064 QHash<QString /*action*/, QString /*activation token*/> m_activationTokens; 0065 0066 private Q_SLOTS: 0067 void dialogAccepted(); 0068 void dialogCanceled(); 0069 void userSelected(const PolkitQt1::Identity &identity); 0070 0071 private: 0072 void handleParentWindow(const QString &action, const QString &handle); 0073 void handleWaylandActivation(const QString &action, const QString &token); 0074 }; 0075 0076 #endif