Debian Codegraph @

online-accounts-service/src/request-manager.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2013 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This file is part of lomiri-online-accounts-service
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/
22 #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/
23 #include "request.h"cxx . . $ `<file>/online-accounts-service/src/request.h`/
24 #include "request-manager.h"cxx . . $ `<file>/online-accounts-service/src/request-manager.h`/
25 #include "ui-proxy.h"cxx . . $ `<file>/online-accounts-service/src/ui-proxy.h`/
26
27 #include <QQueue>
28
29 using namespace OnlineAccountsUi;
30
31 namespace OnlineAccountsUicxx . . $ OnlineAccountsUi/ {
32
33 static RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *m_instancecxx . . $ OnlineAccountsUi/m_instance. = 0;
34
35 typedef QQueuecxx . . $ QQueue#<Requestcxx . . $ OnlineAccountsUi/Request#*> RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue#;
36
37 class RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#: public QObjectcxx . . $ QObject#
38 {
39 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
40 Q_DECLARE_PUBLICcxx . . $ `<external>/15045578679651060896/qglobal.h:1172:9`!(RequestManager)
41
42 public:
43 RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#RequestManagerPrivate(a2d7ff460633d0b2).(RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *service);
44 ~cxx . . $ OnlineAccountsUi/RequestManagerPrivate#`~RequestManagerPrivate`(ced63f7c635d850d).RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#();
45
46 RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &queueForWindowIdcxx . . $ OnlineAccountsUi/RequestManagerPrivate#queueForWindowId(5125760651023ee5).(quint64cxx . . $ quint64# windowId);
47 void enqueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#enqueue(5accaa2ad66e8668).(Requestcxx . . $ OnlineAccountsUi/Request# *request);
48 void runQueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#runQueue(b56d85f3821cbfa3).(RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &queue);
49
50 private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!:
51 void onRequestCompletedcxx . . $ OnlineAccountsUi/RequestManagerPrivate#onRequestCompleted(49f6e7a06ebc5aa8).();
52 void onProxyFinishedcxx . . $ OnlineAccountsUi/RequestManagerPrivate#onProxyFinished(49f6e7a06ebc5aa8).();
53
54 private:
55 mutable RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *q_ptrcxx . . $ OnlineAccountsUi/RequestManagerPrivate#q_ptr.;
56 /* each window Id has a different queue */
57 QMapcxx . . $ QMap#<quint64cxx . . $ quint64#,RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue#> m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests.;
58 QListcxx . . $ QList#<UiProxycxx . . $ OnlineAccountsUi/UiProxy#*> m_proxiescxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_proxies.;
59 };
60
61 } // namespace
62
63 RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#RequestManagerPrivate(a2d7ff460633d0b2).(RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *service):
64 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(service),
65 q_ptrcxx . . $ OnlineAccountsUi/RequestManagerPrivate#q_ptr.(service)
66 {
67 }
68
69 RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::~cxx . . $ OnlineAccountsUi/RequestManagerPrivate#`~RequestManagerPrivate`(ced63f7c635d850d).RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#()
70 {
71 }
72
73 RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::queueForWindowIdcxx . . $ OnlineAccountsUi/RequestManagerPrivate#queueForWindowId(5125760651023ee5).(quint64cxx . . $ quint64# windowId)
74 {
75 if (!m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests..containscxx . . $ QMap#contains(8877ebe272b9620d).(windowId)) {
76 RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# queue;
77 m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests..insertcxx . . $ QMap#insert(929a1ed410fe8423).(windowId, queue);
78 }
79 return m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests.[cxx . . $ QMap#`operator[]`(bbd415b616967878).windowId];
80 }
81
82 void RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::enqueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#enqueue(5accaa2ad66e8668).(Requestcxx . . $ OnlineAccountsUi/Request# *request)
83 {
84 Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(RequestManager);
85
86 /* First, see if any of the existing proxies can handle this request */
87 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(UiProxy *proxy, m_proxies) {
88 if (proxy->hasHandlerForcxx . . $ OnlineAccountsUi/UiProxy#hasHandlerFor(749620a94a1e100c).(request->parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).())) {
89 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(request, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(completed()),
90 request, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(deleteLater()));
91 proxy->handleRequestcxx . . $ OnlineAccountsUi/UiProxy#handleRequest(5accaa2ad66e8668).(request);
92 return;
93 }
94 }
95
96 bool wasIdle = q->isIdlecxx . . $ OnlineAccountsUi/RequestManager#isIdle(50ce9a9e25b4a850).();
97
98 quint64cxx . . $ quint64# windowId = request->windowIdcxx . . $ OnlineAccountsUi/Request#windowId(1c5fc1fd41a99ae7).();
99
100 RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &queue = queueForWindowIdcxx . . $ OnlineAccountsUi/RequestManagerPrivate#queueForWindowId(5125760651023ee5).(windowId);
101 queue.enqueuecxx . . $ QQueue#enqueue(77d9f17553126ecb).(request);
102
103 if (wasIdle) {
104 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! q->isIdleChangedcxx . . $ OnlineAccountsUi/RequestManager#isIdleChanged(49f6e7a06ebc5aa8).();
105 }
106
107 runQueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#runQueue(b56d85f3821cbfa3).(queue);
108 }
109
110 void RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::runQueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#runQueue(b56d85f3821cbfa3).(RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &queue)
111 {
112 Requestcxx . . $ OnlineAccountsUi/Request# *request = queue.headcxx . . $ QQueue#head(19b2b6f17af048b).();
113 DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Head:" <<cxx . . $ `operator<<`(31d1e923961dacbd). request;
114
115 if (request->isInProgresscxx . . $ OnlineAccountsUi/Request#isInProgress(50ce9a9e25b4a850).()) {
116 DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Already in progress";
117 return; // Nothing to do
118 }
119
120 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(request, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(completed()),
121 this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onRequestCompleted()));
122
123 UiProxycxx . . $ OnlineAccountsUi/UiProxy# *proxy = new UiProxycxx . . $ OnlineAccountsUi/UiProxy#UiProxy(1ee1e1ac455d3e6e).(request->clientPidcxx . . $ OnlineAccountsUi/Request#clientPid(455f465bc33b4cdf).(), this);
124 if (Q_UNLIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:247:11`!(!proxy->init())) {
125 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "UiProxy initialization failed!";
126 request->failcxx . . $ OnlineAccountsUi/Request#fail(c1427772cd1877b0).(OAU_ERROR_PROMPT_SESSIONcxx . . $ `online-accounts-common/globals.h:47:9`!,
127 "Could not create a prompt session"cxx . . $ QString#QString(85c52e162fed56f9).);
128 return;
129 }
130 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(proxy, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished()),
131 this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onProxyFinished()));
132 m_proxiescxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_proxies..appendcxx . . $ QList#append(77d9f17553126ecb).(proxy);
133 proxy->handleRequestcxx . . $ OnlineAccountsUi/UiProxy#handleRequest(5accaa2ad66e8668).(request);
134 }
135
136 void RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::onRequestCompletedcxx . . $ OnlineAccountsUi/RequestManagerPrivate#onRequestCompleted(49f6e7a06ebc5aa8).()
137 {
138 Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(RequestManager);
139
140 Requestcxx . . $ OnlineAccountsUi/Request# *request = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<Requestcxx . . $ OnlineAccountsUi/Request#*>(sendercxx . . $ QObject#sender(2dbb680a34285c44).());
141 quint64cxx . . $ quint64# windowId = request->windowIdcxx . . $ OnlineAccountsUi/Request#windowId(1c5fc1fd41a99ae7).();
142
143 RequestQueuecxx . . $ OnlineAccountsUi/RequestQueue# &queue = queueForWindowIdcxx . . $ OnlineAccountsUi/RequestManagerPrivate#queueForWindowId(5125760651023ee5).(windowId);
144 if (request != queue.headcxx . . $ QQueue#head(19b2b6f17af048b).()) {
145 qCriticalcxx . . $ `<external>/10450329605257866924/qlogging.h:167:9`!("Completed request is not first in queue!");
146 return;
147 }
148
149 queue.dequeuecxx . . $ QQueue#dequeue(5f357b03ed472e5e).();
150 request->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
151
152 if (queue.isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) {
153 m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests..removecxx . . $ QMap#remove(dd8e59d271e40448).(windowId);
154 } else {
155 /* start the next request */
156 runQueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#runQueue(b56d85f3821cbfa3).(queue);
157 }
158
159 if (q->isIdlecxx . . $ OnlineAccountsUi/RequestManager#isIdle(50ce9a9e25b4a850).()) {
160 Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! q->isIdleChangedcxx . . $ OnlineAccountsUi/RequestManager#isIdleChanged(49f6e7a06ebc5aa8).();
161 }
162 }
163
164 void RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#::onProxyFinishedcxx . . $ OnlineAccountsUi/RequestManagerPrivate#onProxyFinished(49f6e7a06ebc5aa8).()
165 {
166 UiProxycxx . . $ OnlineAccountsUi/UiProxy# *proxy = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<UiProxycxx . . $ OnlineAccountsUi/UiProxy#*>(sendercxx . . $ QObject#sender(2dbb680a34285c44).());
167 m_proxiescxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_proxies..removeOnecxx . . $ QList#removeOne(fe1ba53999e710f3).(proxy);
168
169 proxy->deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
170 }
171
172 RequestManagercxx . . $ OnlineAccountsUi/RequestManager#::RequestManagercxx . . $ OnlineAccountsUi/RequestManager#RequestManager(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent):
173 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent),
174 d_ptrcxx . . $ OnlineAccountsUi/RequestManager#d_ptr.(new RequestManagerPrivatecxx . . $ OnlineAccountsUi/RequestManagerPrivate#RequestManagerPrivate(a2d7ff460633d0b2).(this))
175 {
176 if (m_instancecxx . . $ OnlineAccountsUi/m_instance. == 0) {
177 m_instancecxx . . $ OnlineAccountsUi/m_instance. = this;
178 } else {
179 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Instantiating a second RequestManager!";
180 }
181 }
182
183 RequestManagercxx . . $ OnlineAccountsUi/RequestManager#::~cxx . . $ OnlineAccountsUi/RequestManager#`~RequestManager`(ced63f7c635d850d).RequestManagercxx . . $ OnlineAccountsUi/RequestManager#()
184 {
185 }
186
187 RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *RequestManagercxx . . $ OnlineAccountsUi/RequestManager#::instancecxx . . $ OnlineAccountsUi/RequestManager#instance(852f6a16edb34689).()
188 {
189 return m_instancecxx . . $ OnlineAccountsUi/m_instance.;
190 }
191
192 void RequestManagercxx . . $ OnlineAccountsUi/RequestManager#::enqueuecxx . . $ OnlineAccountsUi/RequestManager#enqueue(5accaa2ad66e8668).(Requestcxx . . $ OnlineAccountsUi/Request# *request)
193 {
194 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(RequestManager);
195 d->enqueuecxx . . $ OnlineAccountsUi/RequestManagerPrivate#enqueue(5accaa2ad66e8668).(request);
196 }
197
198 bool RequestManagercxx . . $ OnlineAccountsUi/RequestManager#::isIdlecxx . . $ OnlineAccountsUi/RequestManager#isIdle(50ce9a9e25b4a850).() const
199 {
200 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const RequestManager);
201 return d->m_requestscxx . . $ OnlineAccountsUi/RequestManagerPrivate#m_requests..isEmptycxx . . $ QMap#isEmpty(50ce9a9e25b4a850).();
202 }
203
204
205 #include "request-manager.moc"cxx . . $ `<file>/build/online-accounts-service/src/lomiri-online-accounts-service_autogen/include/request-manager.moc`/