1010#include < polkitagent/polkitagent.h>
1111#include < polkit/polkit.h>
1212
13+ #include " ../../core/logcat.hpp"
14+
15+ namespace {
16+ QS_LOGGING_CATEGORY (logPolkit, " quickshell.service.polkit" );
17+ }
18+
1319namespace qs ::service::polkit {
1420
1521static const QString emptyString;
@@ -69,7 +75,7 @@ PolkitAgent::~PolkitAgent() {
6975 // method doesn't start a new one.
7076 for (; queuedRequests.size () > 1 ; queuedRequests.pop_back ()) {
7177 AuthRequest& req = *queuedRequests.back ();
72- qDebug ( ) << " PolkitAgent: destroying queued authentication request for action" << req.actionId ;
78+ qCDebug (logPolkit ) << " destroying queued authentication request for action" << req.actionId ;
7379 req.cancel (" PolkitAgent is being destroyed" );
7480 }
7581
@@ -107,7 +113,7 @@ void PolkitAgent::classBegin() {
107113
108114void PolkitAgent::componentComplete () {
109115 if (!mPath .isEmpty ()) {
110- qDebug ( ) << " PolkitAgent: registering listener on path" << mPath ;
116+ qCDebug (logPolkit ) << " registering listener on path" << mPath ;
111117 if (qs_polkit_agent_register (listener)) {
112118 registeredAgentsByPath[mPath ] = this ;
113119 // If we were previously waiting to acquire this path, we no longer
@@ -118,18 +124,18 @@ void PolkitAgent::componentComplete() {
118124 waitingAgentsByPath.erase (it);
119125 }
120126 } else {
121- qWarning ( ) << " PolkitAgent: failed to register listener on path" << mPath ;
127+ qCWarning (logPolkit ) << " failed to register listener on path" << mPath ;
122128 // We may be able to register later if the current holder of the path
123129 // goes away.
124130 waitingAgentsByPath[mPath ] = this ;
125131 }
126132 } else {
127- qWarning ( ) << " PolkitAgent: no path set, not registering listener." ;
133+ qCWarning (logPolkit ) << " no path set, not registering listener." ;
128134 }
129135}
130136
131137void PolkitAgent::submit (const QString& value) {
132- qDebug ( ) << " PolkitAgent: submitting response for authentication request" ;
138+ qCDebug (logPolkit ) << " submitting response for authentication request" ;
133139 if (currentSession) {
134140 currentSession->respond (value);
135141 }
@@ -141,7 +147,7 @@ void PolkitAgent::submit(const QString& value) {
141147}
142148
143149void PolkitAgent::cancelAuthenticationRequest () {
144- qDebug ( ) << " PolkitAgent: cancelling authentication request by user request." ;
150+ qCDebug (logPolkit ) << " cancelling authentication request by user request." ;
145151
146152 if (currentSession) {
147153 currentSession->cancel ();
@@ -155,7 +161,7 @@ void PolkitAgent::setPath(const QString& path) {
155161 if (mPath .isEmpty ()) {
156162 mPath = path;
157163 } else if (mPath != path) {
158- qWarning ( ) << " PolkitAgent: cannot change path after it has been set." ;
164+ qCWarning (logPolkit ) << " cannot change path after it has been set." ;
159165 }
160166}
161167
@@ -195,7 +201,7 @@ void PolkitAgent::setSelectedIdentity(Identity* identity) {
195201 return ;
196202 }
197203
198- qDebug ( ) << " PolkitAgent: changing selected identity to"
204+ qCDebug (logPolkit ) << " changing selected identity to"
199205 << (identity ? identity->name () : " <null>" );
200206
201207 mSelectedIdentity = identity;
@@ -212,7 +218,7 @@ InputRequest* PolkitAgent::inputRequest() const { return mInputRequest; }
212218SubMessage* PolkitAgent::subMessage () const { return mSubMessage ; }
213219
214220void PolkitAgent::initiateAuthentication (AuthRequest* request) {
215- qDebug ( ) << " PolkitAgent: incoming authentication request for action" << request->actionId ;
221+ qCDebug (logPolkit ) << " incoming authentication request for action" << request->actionId ;
216222
217223 queuedRequests.emplace_back (request);
218224
@@ -222,7 +228,7 @@ void PolkitAgent::initiateAuthentication(AuthRequest* request) {
222228}
223229
224230void PolkitAgent::cancelAuthentication (AuthRequest* request) {
225- qDebug ( ) << " PolkitAgent: cancelling authentication request from agent" ;
231+ qCDebug (logPolkit ) << " cancelling authentication request from agent" ;
226232
227233 if (!queuedRequests.empty () && request == queuedRequests.front ()) {
228234 if (currentSession) {
@@ -234,18 +240,18 @@ void PolkitAgent::cancelAuthentication(AuthRequest* request) {
234240 } else if (auto it = std::find (queuedRequests.begin (), queuedRequests.end (), request);
235241 it != queuedRequests.end ())
236242 {
237- qDebug ( ) << " PolkitAgent: removing queued authentication request for action"
243+ qCDebug (logPolkit ) << " removing queued authentication request for action"
238244 << (*it)->actionId ;
239245 (*it)->cancel (" Authentication request was cancelled" );
240246 (*it)->deleteLater ();
241247 queuedRequests.erase (it);
242248 } else {
243- qWarning ( ) << " PolkitAgent: the cancelled request was not found in the queue." ;
249+ qCWarning (logPolkit ) << " the cancelled request was not found in the queue." ;
244250 }
245251}
246252
247253void PolkitAgent::request (const QString& message, bool echo) {
248- qDebug ( ) << " PolkitAgent: requesting user input for authentication" ;
254+ qCDebug (logPolkit ) << " requesting user input for authentication" ;
249255
250256 if (mInputRequest ) {
251257 mInputRequest ->deleteLater ();
@@ -256,7 +262,7 @@ void PolkitAgent::request(const QString& message, bool echo) {
256262}
257263
258264void PolkitAgent::completed (bool gainedAuthorization) {
259- qDebug ( ) << " PolkitAgent: authentication request completed" ;
265+ qCDebug (logPolkit ) << " authentication request completed" ;
260266
261267 auto & req = *queuedRequests.front ();
262268 if (gainedAuthorization) {
@@ -275,7 +281,7 @@ void PolkitAgent::completed(bool gainedAuthorization) {
275281}
276282
277283void PolkitAgent::showError (const QString& message) {
278- qDebug ( ) << " PolkitAgent: showing error message:" << message;
284+ qCDebug (logPolkit ) << " showing error message:" << message;
279285
280286 if (mSubMessage ) {
281287 mSubMessage ->deleteLater ();
@@ -286,7 +292,7 @@ void PolkitAgent::showError(const QString& message) {
286292}
287293
288294void PolkitAgent::showInfo (const QString& message) {
289- qDebug ( ) << " PolkitAgent: showing info message:" << message;
295+ qCDebug (logPolkit ) << " showing info message:" << message;
290296
291297 if (mSubMessage ) {
292298 mSubMessage ->deleteLater ();
@@ -303,7 +309,7 @@ void PolkitAgent::activateAuthenticationRequest() {
303309
304310 AuthRequest& req = *queuedRequests.front ();
305311
306- qDebug ( ) << " PolkitAgent: activating authentication request for action" << req.actionId ;
312+ qCDebug (logPolkit ) << " activating authentication request for action" << req.actionId ;
307313
308314 for (auto identity: mIdentities ) {
309315 delete identity;
@@ -360,8 +366,7 @@ void PolkitAgent::activateAuthenticationRequest() {
360366
361367 mSelectedIdentity = mIdentities .isEmpty () ? nullptr : mIdentities .first ();
362368 if (mSelectedIdentity == nullptr ) {
363- qWarning (
364- ) << " PolkitAgent: no supported identities available for authentication request, cancelling." ;
369+ qCWarning (logPolkit) << " no supported identities available for authentication request, cancelling." ;
365370
366371 req.cancel (" Error requesting authentication: no supported identities available." );
367372
@@ -379,7 +384,7 @@ void PolkitAgent::activateAuthenticationRequest() {
379384void PolkitAgent::setupSession () {
380385 AuthRequest& req = *queuedRequests.front ();
381386
382- qDebug ( ) << " PolkitAgent: setting up authentication session for identity"
387+ qCDebug (logPolkit ) << " setting up authentication session for identity"
383388 << (mSelectedIdentity ? mSelectedIdentity ->name () : " <null>" );
384389
385390 currentSession = new Session (mSelectedIdentity ->polkitIdentity , req.cookie );
@@ -397,8 +402,8 @@ void PolkitAgent::finishAuthenticationRequest() {
397402 return ;
398403 }
399404
400- qDebug ( ) << " PolkitAgent: finishing authentication request for action"
401- << queuedRequests.front ()->actionId ;
405+ qCDebug (logPolkit ) << " finishing authentication request for action"
406+ << queuedRequests.front ()->actionId ;
402407
403408 queuedRequests.front ()->deleteLater ();
404409 queuedRequests.pop_front ();
0 commit comments