Debian Codegraph @

online-accounts-ui/src/signonui-request.cpp

raw symbols SCIP
1 /*
2 * This file is part of lomiri-online-accounts-ui
3 *
4 * Copyright (C) 2011-2014 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <[email protected]>
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 "signonui-request.h"cxx . . $ `<file>/online-accounts-ui/src/signonui-request.h`/
22
23 #include "browser-request.h"cxx . . $ `<file>/online-accounts-ui/src/browser-request.h`/
24 #include <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/
25 #include "dialog-request.h"cxx . . $ `<file>/online-accounts-ui/src/dialog-request.h`/
26 #include "external-browser-request.h"cxx . . $ `<file>/online-accounts-ui/src/external-browser-request.h`/
27 #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/
28
29 #include <Accounts/Account>
30 #include <Accounts/Provider>
31 #include <LomiriOnlineAccountsPlugin/account-manager.h>cxx . . $ `<file>/online-accounts-plugins/lib/LomiriOnlineAccountsPlugin/account-manager.h`/
32 #include <LomiriOnlineAccountsPlugin/request-handler.h>cxx . . $ `<file>/online-accounts-plugins/lib/LomiriOnlineAccountsPlugin/request-handler.h`/
33 #include <QDBusArgument>
34 #include <QPointer>
35 #include <QUrl>
36 #include <SignOn/uisessiondata.h>
37 #include <SignOn/uisessiondata_priv.h>
38 #include <sys/apparmor.h>
39 #include <sys/types.h>
40 #include <unistd.h>
41
42 using namespace SignOnUi;
43
44 namespace SignOnUicxx . . $ SignOnUi/ {
45
46 class RequestPrivatecxx . . $ SignOnUi/RequestPrivate#: public QObjectcxx . . $ QObject#
47 {
48 Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`!
49 Q_DECLARE_PUBLICcxx . . $ `<external>/15045578679651060896/qglobal.h:1172:9`!(Request)
50
51 public:
52 RequestPrivatecxx . . $ SignOnUi/RequestPrivate#RequestPrivate(c05017e728e6cbe8).(Requestcxx . . $ SignOnUi/Request# *request);
53 ~cxx . . $ SignOnUi/RequestPrivate#`~RequestPrivate`(ced63f7c635d850d).RequestPrivatecxx . . $ SignOnUi/RequestPrivate#();
54
55 private:
56 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *findAccountcxx . . $ SignOnUi/RequestPrivate#findAccount(d3fe6ac06685c083).();
57
58 private:
59 mutable Requestcxx . . $ SignOnUi/Request# *q_ptrcxx . . $ SignOnUi/RequestPrivate#q_ptr.;
60 QVariantMapcxx . . $ QVariantMap# m_clientDatacxx . . $ SignOnUi/RequestPrivate#m_clientData.;
61 QPointercxx . . $ QPointer#<RequestHandlercxx . . $ SignOnUi/RequestHandler#> m_handlercxx . . $ SignOnUi/RequestPrivate#m_handler.;
62 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *m_accountcxx . . $ SignOnUi/RequestPrivate#m_account.;
63 };
64
65 } // namespace
66
67 RequestPrivatecxx . . $ SignOnUi/RequestPrivate#::RequestPrivatecxx . . $ SignOnUi/RequestPrivate#RequestPrivate(c05017e728e6cbe8).(Requestcxx . . $ SignOnUi/Request# *request):
68 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(request),
69 q_ptrcxx . . $ SignOnUi/RequestPrivate#q_ptr.(request),
70 m_handlercxx . . $ SignOnUi/RequestPrivate#m_handler.(0)
71 {
72 const QVariantMapcxx . . $ QVariantMap# &parameters = request->parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).();
73 if (parameters.containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_CLIENT_DATAcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:72:9`!)) {
74 QVariantcxx . . $ QVariant# variant = parameters[cxx . . $ QMap#`operator[]`(bfda1f1f965926d4).SSOUI_KEY_CLIENT_DATAcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:72:9`!];
75 m_clientDatacxx . . $ SignOnUi/RequestPrivate#m_clientData. =cxx . . $ QMap#`operator=`(86243d55ea3d6313). (variant.typecxx . . $ QVariant#type(5e54638cd06c4ff1).() == QVariantcxx . . $ QVariant#::Mapcxx . . $ QVariant#Map.) ?
76 variant.toMapcxx . . $ QVariant#toMap(87f780dbe64191c4).() :
77 qdbus_castcxx . . $ qdbus_cast(77fb564ca0a1ed4b).<QVariantMapcxx . . $ QVariantMap#>(variant.valuecxx . . $ QVariant#value(8f5363d873dd4781).<QDBusArgumentcxx . . $ QDBusArgument#>());
78 }
79
80 m_accountcxx . . $ SignOnUi/RequestPrivate#m_account. = findAccountcxx . . $ SignOnUi/RequestPrivate#findAccount(d3fe6ac06685c083).();
81 }
82
83 RequestPrivatecxx . . $ SignOnUi/RequestPrivate#::~cxx . . $ SignOnUi/RequestPrivate#`~RequestPrivate`(ced63f7c635d850d).RequestPrivatecxx . . $ SignOnUi/RequestPrivate#()
84 {
85 }
86
87 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *RequestPrivatecxx . . $ SignOnUi/RequestPrivate#::findAccountcxx . . $ SignOnUi/RequestPrivate#findAccount(d3fe6ac06685c083).()
88 {
89 Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(Request);
90
91 uintcxx . . $ uint# identity = q->identitycxx . . $ SignOnUi/Request#identity(ddd8539a2fcdd4ce).();
92 if (identity == 0)
93 return 0;
94
95 /* Find the account using this identity.
96 * FIXME: there might be more than one!
97 */
98 OnlineAccountsUicxx . . $ OnlineAccountsUi/::AccountManagercxx . . $ OnlineAccountsUi/AccountManager# *manager =
99 OnlineAccountsUicxx . . $ OnlineAccountsUi/::AccountManagercxx . . $ OnlineAccountsUi/AccountManager#::instancecxx . . $ OnlineAccountsUi/AccountManager#instance(10dcba297537ffe).();
100 Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(Accounts::AccountId accountId, manager->accountList()) {
101 Accountscxx . . $ Accounts/::Accountcxx . . $ Accounts/Account# *account = manager->accountcxx . . $ Accounts/Manager#account(e94dad5fac3d2066).(accountId);
102 if (account == 0) continue;
103
104 QVariantcxx . . $ QVariant# valuecxx . . $ QVariant#QVariant(1a1706d2be599c68).(QVariantcxx . . $ QVariant#::UIntcxx . . $ QVariant#UInt.);
105 if (account->valuecxx . . $ Accounts/Account#value(fffe9bba6fb611).("CredentialsId"cxx . . $ QString#QString(85c52e162fed56f9)., value) != Accountscxx . . $ Accounts/::NONEcxx . . $ Accounts/NONE. &&
106 value.toUIntcxx . . $ QVariant#toUInt(870b63f89c7fb98).() == identity) {
107 return account;
108 }
109 }
110
111 // Not found
112 return 0;
113 }
114
115 #ifndef NO_REQUEST_FACTORY
116 Requestcxx . . $ SignOnUi/Request# *Requestcxx . . $ SignOnUi/Request#::newRequestcxx . . $ SignOnUi/Request#newRequest(7c93cb798db8aea0).(int id,
117 const QStringcxx . . $ QString# &clientProfile,
118 const QVariantMapcxx . . $ QVariantMap# &parameters,
119 QObjectcxx . . $ QObject# *parent)
120 {
121 if (parameters.containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_OPENURLcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:48:9`!)) {
122 QUrlcxx . . $ QUrl# finalUrl =
123 QUrlcxx . . $ QUrl#::fromUserInputcxx . . $ QUrl#fromUserInput(daf4b0201622af21).(parameters.valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_FINALURLcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:49:9`!).
124 toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).());
125 if (finalUrl.hostcxx . . $ QUrl#host(9d7420bec8bfe6c9).() ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "localhost") {
126 /* Let's assume that we only use a loopback callback URL when we
127 * are forced to use the system browser; when we don't have this
128 * constraint, we can generally use any other URL. */
129 return new SignOnUicxx . . $ SignOnUi/::ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#(id, clientProfile,
130 parameters, parent);
131 } else {
132 return new SignOnUicxx . . $ SignOnUi/::BrowserRequestcxx . . $ SignOnUi/BrowserRequest#(id, clientProfile,
133 parameters, parent);
134 }
135 } else {
136 return new SignOnUicxx . . $ SignOnUi/::DialogRequestcxx . . $ SignOnUi/DialogRequest#(id, clientProfile,
137 parameters, parent);
138 }
139 }
140 #endif
141
142 static QStringcxx . . $ QString# findClientProfilecxx . . $ findClientProfile(6ab37f152db508d2).(const QStringcxx . . $ QString# &clientProfile,
143 const QVariantMapcxx . . $ QVariantMap# &parameters)
144 {
145 QStringcxx . . $ QString# profile = clientProfilecxx . . $ QString#QString(132dd6869045752b).;
146 /* If the request is coming on the SignOnUi interface from an
147 * unconfined process and it carries the SSOUI_KEY_PID key, it means that
148 * it's coming from signond. In that case, we want to know what was the
149 * client which originated the call.
150 */
151 if (profile ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "unconfined" &&
152 parameters.containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_PIDcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:80:9`!)) {
153 pid_t pid = parameters.valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_PIDcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:80:9`!).toUIntcxx . . $ QVariant#toUInt(870b63f89c7fb98).();
154 if (pid == getpid()) {
155 /* If the request was initiated by our own process, we might not
156 * have the rights to call the aa_* functions (we might be
157 * confined). */
158 return QStringcxx . . $ QString#QString(ced63f7c635d850d).();
159 }
160
161 char *con = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, *mode = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
162 int ret = aa_gettaskcon(pid, &con, &mode);
163 if (Q_LIKELYcxx . . $ `<external>/4507883856836070869/qcompilerdetection.h:246:11`!(ret >= 0)) {
164 profile =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(5ac70cc0fa2a874e).(con);
165 /* libapparmor allocates "con" and "mode" in a single allocation,
166 * so freeing "con" is actually freeing both. */
167 free(con);
168 } else {
169 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Couldn't get apparmor profile of PID" <<cxx . . $ QDebug#`operator<<`(6e3b7ae53f380c3). pid;
170 }
171 }
172 return profilecxx . . $ QString#QString(28715ad661ad3cec).;
173 }
174
175 Requestcxx . . $ SignOnUi/Request#::Requestcxx . . $ SignOnUi/Request#Request(b00a08810fe27de2).(int id,
176 const QStringcxx . . $ QString# &clientProfile,
177 const QVariantMapcxx . . $ QVariantMap# &parameters,
178 QObjectcxx . . $ QObject# *parent):
179 OnlineAccountsUicxx . . $ OnlineAccountsUi/::Requestcxx . . $ OnlineAccountsUi/Request#(SIGNONUI_INTERFACEcxx . . $ `online-accounts-common/globals.h:53:9`!, id,
180 findClientProfilecxx . . $ findClientProfile(6ab37f152db508d2).(clientProfile, parameters),
181 parameters, parent),
182 d_ptrcxx . . $ SignOnUi/Request#d_ptr.(new RequestPrivatecxx . . $ SignOnUi/RequestPrivate#RequestPrivate(c05017e728e6cbe8).(this))
183 {
184 }
185
186 Requestcxx . . $ SignOnUi/Request#::~cxx . . $ SignOnUi/Request#`~Request`(ced63f7c635d850d).Requestcxx . . $ SignOnUi/Request#()
187 {
188 }
189
190 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::ssoIdcxx . . $ SignOnUi/Request#ssoId(3452ecdc0389abe1).(const QVariantMapcxx . . $ QVariantMap# &parameters)
191 {
192 return parameters[cxx . . $ QMap#`operator[]`(bfda1f1f965926d4).SSOUI_KEY_REQUESTIDcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:54:9`!].toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).();
193 }
194
195 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::ssoIdcxx . . $ SignOnUi/Request#ssoId(6ef7b6c27b00b43d).() const
196 {
197 return Requestcxx . . $ SignOnUi/Request#::ssoIdcxx . . $ SignOnUi/Request#ssoId(3452ecdc0389abe1).(parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).());
198 }
199
200 void Requestcxx . . $ SignOnUi/Request#::setWindowcxx . . $ SignOnUi/Request#setWindow(35681b993d9a3c79).(QWindowcxx . . $ QWindow# *window)
201 {
202 /* Show the window only if we are in a prompt session */
203 if (qgetenvcxx . . $ qgetenv(531409eeffcde449).("MIR_SOCKET").isEmptycxx . . $ QByteArray#isEmpty(50ce9a9e25b4a850).()) {
204 QVariantMapcxx . . $ QVariantMap# resultcxx . . $ QMap#QMap(ced63f7c635d850d).;
205 result[cxx . . $ QMap#`operator[]`(bbd415b616967878).SSOUI_KEY_ERRORcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:26:9`!] =cxx . . $ QVariant#`operator=`(79a68221451e88b7). SignOncxx . . $ QVariant#QVariant(d4f767463ce0a6b3).::QUERY_ERROR_FORBIDDENcxx . . $ SignOn/QUERY_ERROR_FORBIDDEN.;
206 setResultcxx . . $ OnlineAccountsUi/Request#setResult(3e95df3e31f2cce8).(result);
207 } else {
208 OnlineAccountsUicxx . . $ OnlineAccountsUi/::Requestcxx . . $ OnlineAccountsUi/Request#::setWindowcxx . . $ OnlineAccountsUi/Request#setWindow(35681b993d9a3c79).(window);
209 }
210 }
211
212 uintcxx . . $ uint# Requestcxx . . $ SignOnUi/Request#::identitycxx . . $ SignOnUi/Request#identity(ddd8539a2fcdd4ce).() const
213 {
214 return parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).().valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_IDENTITYcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:59:9`!).toUIntcxx . . $ QVariant#toUInt(870b63f89c7fb98).();
215 }
216
217 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::methodcxx . . $ SignOnUi/Request#method(6ef7b6c27b00b43d).() const
218 {
219 return parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).().valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_METHODcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:76:9`!).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).();
220 }
221
222 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::mechanismcxx . . $ SignOnUi/Request#mechanism(6ef7b6c27b00b43d).() const
223 {
224 return parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).().valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_MECHANISMcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:77:9`!).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).();
225 }
226
227 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::providerIdcxx . . $ SignOnUi/Request#providerId(6ef7b6c27b00b43d).() const
228 {
229 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const Request);
230 return d->m_accountcxx . . $ SignOnUi/RequestPrivate#m_account. ? d->m_accountcxx . . $ SignOnUi/RequestPrivate#m_account.->providerNamecxx . . $ Accounts/Account#providerName(6ef7b6c27b00b43d).() :
231 d->m_clientDatacxx . . $ SignOnUi/RequestPrivate#m_clientData..valuecxx . . $ QMap#value(866b0a4e5fb46e14).("providerId"cxx . . $ QString#QString(85c52e162fed56f9).).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).();
232 }
233
234 QStringcxx . . $ QString# Requestcxx . . $ SignOnUi/Request#::windowTitlecxx . . $ SignOnUi/Request#windowTitle(6ef7b6c27b00b43d).() const
235 {
236 if (parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).().containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_TITLEcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:66:9`!)) {
237 return parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).()[cxx . . $ QMap#`operator[]`(bfda1f1f965926d4).SSOUI_KEY_TITLEcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:66:9`!].toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).();
238 }
239
240 OnlineAccountsUicxx . . $ OnlineAccountsUi/::AccountManagercxx . . $ OnlineAccountsUi/AccountManager# *manager =
241 OnlineAccountsUicxx . . $ OnlineAccountsUi/::AccountManagercxx . . $ OnlineAccountsUi/AccountManager#::instancecxx . . $ OnlineAccountsUi/AccountManager#instance(10dcba297537ffe).();
242 Accountscxx . . $ Accounts/::Providercxx . . $ Accounts/Provider# provider = manager->providercxx . . $ Accounts/Manager#provider(9b65a80ff034fbb0).(providerIdcxx . . $ SignOnUi/Request#providerId(6ef7b6c27b00b43d).());
243 return provider.displayNamecxx . . $ Accounts/Provider#displayName(6ef7b6c27b00b43d).();
244 }
245
246 const QVariantMapcxx . . $ QVariantMap# &Requestcxx . . $ SignOnUi/Request#::clientDatacxx . . $ SignOnUi/Request#clientData(9daa5a8a8d37773d).() const
247 {
248 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const Request);
249 return d->m_clientDatacxx . . $ SignOnUi/RequestPrivate#m_clientData.;
250 }
251
252 void Requestcxx . . $ SignOnUi/Request#::setHandlercxx . . $ SignOnUi/Request#setHandler(33a36a88f472ca4b).(RequestHandlercxx . . $ SignOnUi/RequestHandler# *handler)
253 {
254 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(Request);
255 if (handler && d->m_handlercxx . . $ SignOnUi/RequestPrivate#m_handler.) {
256 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Request handler already set!";
257 return;
258 }
259 d->m_handlercxx . . $ SignOnUi/RequestPrivate#m_handler. =cxx . . $ QPointer#`operator=`(500fb76d9e491ab0). handler;
260 }
261
262 RequestHandlercxx . . $ SignOnUi/RequestHandler# *Requestcxx . . $ SignOnUi/Request#::handlercxx . . $ SignOnUi/Request#handler(e7602e54d6d9851d).() const
263 {
264 Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(const Request);
265 return d->m_handlercxx . . $ SignOnUi/RequestPrivate#m_handler.;
266 }
267
268 void Requestcxx . . $ SignOnUi/Request#::setCanceledcxx . . $ SignOnUi/Request#setCanceled(49f6e7a06ebc5aa8).()
269 {
270 QVariantMapcxx . . $ QVariantMap# resultcxx . . $ QMap#QMap(ced63f7c635d850d).;
271 result[cxx . . $ QMap#`operator[]`(bbd415b616967878).SSOUI_KEY_ERRORcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:26:9`!] =cxx . . $ QVariant#`operator=`(79a68221451e88b7). SignOncxx . . $ QVariant#QVariant(d4f767463ce0a6b3).::QUERY_ERROR_CANCELEDcxx . . $ SignOn/QUERY_ERROR_CANCELED.;
272
273 setResultcxx . . $ OnlineAccountsUi/Request#setResult(3e95df3e31f2cce8).(result);
274 }
275
276 #include "signonui-request.moc"cxx . . $ `<file>/build/online-accounts-ui/src/lomiri-online-accounts-ui_autogen/include/signonui-request.moc`/