File indexing completed on 2024-04-28 04:43:32
0001 /* 0002 This file is part of the Polkit-qt project 0003 SPDX-FileCopyrightText: 2009 Jaroslav Reznik <jreznik@redhat.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include <QDebug> 0009 #include <QInputDialog> 0010 0011 #include "klistener.h" 0012 #include <polkitqt1-agent-session.h> 0013 0014 using namespace PolkitQt1::Agent; 0015 0016 KListener::KListener(QObject *parent) 0017 : Listener(parent) 0018 { 0019 qDebug() << "Registering KDE listener"; 0020 } 0021 0022 // README: this is just testing code... 0023 0024 void KListener::initiateAuthentication(const QString &actionId, 0025 const QString &message, 0026 const QString &iconName, 0027 const PolkitQt1::Details &details, 0028 const QString &cookie, 0029 const PolkitQt1::Identity::List &identities, 0030 AsyncResult *result) 0031 { 0032 qDebug() << "initiateAuthentication for " << actionId << " with message " << message; 0033 qDebug() << "iconName " << iconName; 0034 qDebug() << details.keys(); 0035 qDebug() << "cookie" << cookie; 0036 0037 Q_FOREACH (const PolkitQt1::Identity &identity, identities) { 0038 qDebug() << identity.toString(); 0039 Session *session; 0040 session = new Session(identity, cookie, result); 0041 connect(session, SIGNAL(request(QString,bool)), this, SLOT(request(QString,bool))); 0042 connect(session, SIGNAL(completed(bool)), this, SLOT(completed(bool))); 0043 connect(session, SIGNAL(showError(QString)), this, SLOT(showError(QString))); 0044 connect(session, SIGNAL(showInfo(QString)), this, SLOT(showInfo(QString))); 0045 session->initiate(); 0046 } 0047 } 0048 0049 bool KListener::initiateAuthenticationFinish() 0050 { 0051 qDebug() << "initiateAuthenticationFinish()"; 0052 return true; 0053 } 0054 0055 void KListener::cancelAuthentication() 0056 { 0057 qDebug() << "Cancelling authentication"; 0058 } 0059 0060 void KListener::request(const QString &request, bool echo) 0061 { 0062 qDebug() << "Request: " << request; 0063 0064 Session *session = (Session *)sender(); 0065 0066 session->setResponse(""); 0067 } 0068 0069 void KListener::completed(bool gainedAuthorization) 0070 { 0071 qDebug() << "Completed: " << gainedAuthorization; 0072 Session *session = (Session *)sender(); 0073 0074 session->result()->setCompleted(); 0075 0076 delete session; 0077 } 0078 0079 void KListener::showError(const QString &text) 0080 { 0081 qDebug() << "Error: " << text; 0082 } 0083 0084 void KListener::showInfo(const QString &text) 0085 { 0086 qDebug() << "Info: " << text; 0087 }