@@ -11,27 +11,29 @@ QS_LOGGING_CATEGORY(logPolkit, "quickshell.service.polkit");
1111namespace qs ::service::polkit {
1212PolkitAgentImpl* PolkitAgentImpl::instance = nullptr ;
1313
14- PolkitAgentImpl::PolkitAgentImpl (PolkitAgent* agent): QObject(nullptr ), qmlAgent(agent) {
15- auto path = qmlAgent->path ().toUtf8 ();
16- listener = qs_polkit_agent_new (this );
17- qs_polkit_agent_register (listener, path.constData ());
14+ PolkitAgentImpl::PolkitAgentImpl (PolkitAgent* agent)
15+ : QObject(nullptr )
16+ , listener(qs_polkit_agent_new(this ))
17+ , qmlAgent(agent) {
18+ auto path = this ->qmlAgent ->path ().toUtf8 ();
19+ qs_polkit_agent_register (this ->listener , path.constData ());
1820}
1921
2022PolkitAgentImpl::~PolkitAgentImpl () {
21- for (; !queuedRequests.empty (); queuedRequests.pop_back ()) {
22- AuthRequest* req = queuedRequests.back ();
23+ for (; !this -> queuedRequests .empty (); this -> queuedRequests .pop_back ()) {
24+ AuthRequest* req = this -> queuedRequests .back ();
2325 qCDebug (logPolkit) << " destroying queued authentication request for action" << req->actionId ;
2426 req->cancel (" PolkitAgent is being destroyed" );
2527 delete req;
2628 }
2729
28- if (activeFlow) {
29- activeFlow->cancelAuthenticationRequest ();
30- activeFlow->deleteLater ();
30+ if (this -> activeFlow ) {
31+ this -> activeFlow ->cancelAuthenticationRequest ();
32+ this -> activeFlow ->deleteLater ();
3133 }
3234
33- if (isRegistered) qs_polkit_agent_unregister (listener);
34- g_object_unref (listener);
35+ if (this -> isRegistered ) qs_polkit_agent_unregister (this -> listener );
36+ g_object_unref (this -> listener );
3537}
3638
3739PolkitAgentImpl* PolkitAgentImpl::tryGetOrCreate (PolkitAgent* agent) {
@@ -47,10 +49,10 @@ PolkitAgentImpl* PolkitAgentImpl::tryGet(const PolkitAgent* agent) {
4749}
4850
4951PolkitAgentImpl* PolkitAgentImpl::tryTakeover (PolkitAgent* agent) {
50- if (auto impl = tryGet (agent); impl != nullptr ) return impl;
52+ if (auto * impl = tryGet (agent); impl != nullptr ) return impl;
5153
52- auto prevGen = EngineGeneration::findObjectGeneration (instance->qmlAgent );
53- auto myGen = EngineGeneration::findObjectGeneration (agent);
54+ auto * prevGen = EngineGeneration::findObjectGeneration (instance->qmlAgent );
55+ auto * myGen = EngineGeneration::findObjectGeneration (agent);
5456 if (prevGen == myGen) return nullptr ;
5557
5658 qCDebug (logPolkit) << " taking over listener from previous generation" ;
@@ -74,51 +76,51 @@ void PolkitAgentImpl::onEndOfQmlAgent(PolkitAgent* agent) {
7476
7577void PolkitAgentImpl::registerComplete (bool success) {
7678 if (success) {
77- isRegistered = true ;
78- emit qmlAgent->isRegisteredChanged ();
79+ this -> isRegistered = true ;
80+ emit this -> qmlAgent ->isRegisteredChanged ();
7981 } else {
80- qCWarning (logPolkit) << " failed to register listener on path" << qmlAgent->path ();
82+ qCWarning (logPolkit) << " failed to register listener on path" << this -> qmlAgent ->path ();
8183 }
8284}
8385
8486void PolkitAgentImpl::initiateAuthentication (AuthRequest* request) {
8587 qCDebug (logPolkit) << " incoming authentication request for action" << request->actionId ;
8688
87- queuedRequests.emplace_back (request);
89+ this -> queuedRequests .emplace_back (request);
8890
89- if (queuedRequests.size () == 1 ) {
90- activateAuthenticationRequest ();
91+ if (this -> queuedRequests .size () == 1 ) {
92+ this -> activateAuthenticationRequest ();
9193 }
9294}
9395
9496void PolkitAgentImpl::cancelAuthentication (AuthRequest* request) {
9597 qCDebug (logPolkit) << " cancelling authentication request from agent" ;
9698
97- if (activeFlow && activeFlow->authRequest () == request) {
98- activeFlow->cancelFromAgent ();
99- } else if (auto it = std::find (queuedRequests. begin (), queuedRequests. end () , request);
100- it != queuedRequests.end ())
99+ if (this -> activeFlow && this -> activeFlow ->authRequest () == request) {
100+ this -> activeFlow ->cancelFromAgent ();
101+ } else if (auto it = std::ranges:: find (this -> queuedRequests , request);
102+ it != this -> queuedRequests .end ())
101103 {
102104 qCDebug (logPolkit) << " removing queued authentication request for action" << (*it)->actionId ;
103105 (*it)->cancel (" Authentication request was cancelled" );
104106 delete (*it);
105- queuedRequests.erase (it);
107+ this -> queuedRequests .erase (it);
106108 } else {
107109 qCWarning (logPolkit) << " the cancelled request was not found in the queue." ;
108110 }
109111}
110112
111113void PolkitAgentImpl::activateAuthenticationRequest () {
112- if (queuedRequests.empty ()) return ;
114+ if (this -> queuedRequests .empty ()) return ;
113115
114- AuthRequest* req = queuedRequests.front ();
115- queuedRequests.pop_front ();
116+ AuthRequest* req = this -> queuedRequests .front ();
117+ this -> queuedRequests .pop_front ();
116118 qCDebug (logPolkit) << " activating authentication request for action" << req->actionId
117119 << " , cookie: " << req->cookie ;
118120
119121 QList<Identity*> identities;
120- for (auto identity: req->identities ) {
121- auto obj = Identity::fromPolkitIdentity (identity);
122+ for (auto * identity: req->identities ) {
123+ auto * obj = Identity::fromPolkitIdentity (identity);
122124 if (obj) identities.append (obj);
123125 }
124126 if (identities.isEmpty ()) {
@@ -129,33 +131,34 @@ void PolkitAgentImpl::activateAuthenticationRequest() {
129131 return ;
130132 }
131133
132- activeFlow = new AuthFlow (req, std::move (identities));
134+ this -> activeFlow = new AuthFlow (req, std::move (identities));
133135
134136 QObject::connect (
135- activeFlow,
137+ this -> activeFlow ,
136138 &AuthFlow::completedChanged,
137139 this ,
138140 &PolkitAgentImpl::finishAuthenticationRequest
139141 );
140142
141- emit qmlAgent->isActiveChanged ();
142- emit qmlAgent->flowChanged ();
143- emit qmlAgent->authenticationRequestStarted ();
143+ emit this -> qmlAgent ->isActiveChanged ();
144+ emit this -> qmlAgent ->flowChanged ();
145+ emit this -> qmlAgent ->authenticationRequestStarted ();
144146}
145147
146148void PolkitAgentImpl::finishAuthenticationRequest () {
147- if (!activeFlow) return ;
149+ if (!this -> activeFlow ) return ;
148150
149- qCDebug (logPolkit) << " finishing authentication request for action" << activeFlow->actionId ();
151+ qCDebug (logPolkit) << " finishing authentication request for action"
152+ << this ->activeFlow ->actionId ();
150153
151- activeFlow->deleteLater ();
152- activeFlow = nullptr ;
153- emit qmlAgent->flowChanged ();
154+ this -> activeFlow ->deleteLater ();
155+ this -> activeFlow = nullptr ;
156+ emit this -> qmlAgent ->flowChanged ();
154157
155- if (!queuedRequests.empty ()) {
156- activateAuthenticationRequest ();
158+ if (!this -> queuedRequests .empty ()) {
159+ this -> activateAuthenticationRequest ();
157160 } else {
158- emit qmlAgent->isActiveChanged ();
161+ emit this -> qmlAgent ->isActiveChanged ();
159162 }
160163}
161164} // namespace qs::service::polkit
0 commit comments