| 1 | /* |
| 2 | * This file is part of lomiri-online-accounts-ui |
| 3 | * |
| 4 | * Copyright (C) 2021 UBports Foundation |
| 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 "external-browser-request.h"cxx . . $ `<file>/online-accounts-ui/src/external-browser-request.h`/ |
| 22 | |
| 23 | #include <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/ |
| 24 | #include "dialog.h"cxx . . $ `<file>/online-accounts-ui/src/dialog.h`/ |
| 25 | #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/ |
| 26 | #include <online-accounts-common/i18n.h>cxx . . $ `<file>/online-accounts-common/i18n.h`/ |
| 27 | |
| 28 | #include <LomiriOnlineAccountsPlugin/request-handler.h>cxx . . $ `<file>/online-accounts-plugins/lib/LomiriOnlineAccountsPlugin/request-handler.h`/ |
| 29 | #include <QQmlContext> |
| 30 | #include <QQmlEngine> |
| 31 | #include <QVariant> |
| 32 | #include <SignOn/uisessiondata.h> |
| 33 | #include <SignOn/uisessiondata_priv.h> |
| 34 | |
| 35 | using namespace SignOnUi; |
| 36 | |
| 37 | namespace SignOnUicxx . . $ SignOnUi/ { |
| 38 | |
| 39 | class ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#: public QObjectcxx . . $ QObject# |
| 40 | { |
| 41 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 42 | Q_DECLARE_PUBLICcxx . . $ `<external>/15045578679651060896/qglobal.h:1172:9`!(ExternalBrowserRequest) |
| 43 | Q_PROPERTYcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:104:9`!(QString title READ title CONSTANT) |
| 44 | Q_PROPERTYcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:104:9`!(QUrl startUrl READ startUrl CONSTANT) |
| 45 | |
| 46 | public: |
| 47 | ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#ExternalBrowserRequestPrivate(12acec1834699ccb).(ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest# *request); |
| 48 | ~cxx . . $ SignOnUi/ExternalBrowserRequestPrivate#`~ExternalBrowserRequestPrivate`(ced63f7c635d850d).ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#(); |
| 49 | |
| 50 | void startcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#start(49f6e7a06ebc5aa8).(); |
| 51 | |
| 52 | QStringcxx . . $ QString# titlecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#title(6ef7b6c27b00b43d).() const { return q_ptrcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#q_ptr.->windowTitlecxx . . $ SignOnUi/Request#windowTitle(6ef7b6c27b00b43d).(); } |
| 53 | QUrlcxx . . $ QUrl# startUrlcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#startUrl(36d9834fe7321282).() const { return m_startUrlcxx . . $ QUrl#QUrl(37355d2f77053a23).; } |
| 54 | |
| 55 | public Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 56 | /* This method must be called when the final URL has been visited. |
| 57 | * Typically, a client should have setup a LoopbackServer on localhost, and |
| 58 | * forward the URL from the LoopbackServer::visited() signal to this slot. |
| 59 | */ |
| 60 | void urlVisitedcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#urlVisited(37355d2f77053a23).(const QUrlcxx . . $ QUrl# &url); |
| 61 | void cancelcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#cancel(49f6e7a06ebc5aa8).(); |
| 62 | |
| 63 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 64 | void onFinishedcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#onFinished(49f6e7a06ebc5aa8).(); |
| 65 | |
| 66 | private: |
| 67 | void buildDialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#buildDialog(3e95df3e31f2cce8).(const QVariantMapcxx . . $ QVariantMap# ¶ms); |
| 68 | void closeViewcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#closeView(49f6e7a06ebc5aa8).(); |
| 69 | |
| 70 | private: |
| 71 | Dialogcxx . . $ SignOnUi/Dialog# *m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.; |
| 72 | QUrlcxx . . $ QUrl# m_startUrlcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_startUrl.; |
| 73 | QUrlcxx . . $ QUrl# m_responseUrlcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_responseUrl.; |
| 74 | mutable ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest# *q_ptrcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#q_ptr.; |
| 75 | }; |
| 76 | |
| 77 | } // namespace |
| 78 | |
| 79 | ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#ExternalBrowserRequestPrivate(12acec1834699ccb).(ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest# *request): |
| 80 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(request), |
| 81 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.(0), |
| 82 | q_ptrcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#q_ptr.(request) |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::~cxx . . $ SignOnUi/ExternalBrowserRequestPrivate#`~ExternalBrowserRequestPrivate`(ced63f7c635d850d).ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#() |
| 87 | { |
| 88 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!(); |
| 89 | closeViewcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#closeView(49f6e7a06ebc5aa8).(); |
| 90 | delete m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.; |
| 91 | } |
| 92 | |
| 93 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::startcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#start(49f6e7a06ebc5aa8).() |
| 94 | { |
| 95 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ExternalBrowserRequest); |
| 96 | |
| 97 | const QVariantMapcxx . . $ QVariantMap# ¶ms = q->parameterscxx . . $ OnlineAccountsUi/Request#parameters(9daa5a8a8d37773d).(); |
| 98 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ `operator<<`(d06749710cb27f7f). params; |
| 99 | |
| 100 | m_startUrlcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_startUrl. =cxx . . $ QUrl#`operator=`(d8b3c366b09df6fa). params.valuecxx . . $ QMap#value(866b0a4e5fb46e14).(SSOUI_KEY_OPENURLcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:48:9`!).toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 101 | if (!q->hasHandlercxx . . $ SignOnUi/Request#hasHandler(50ce9a9e25b4a850).()) { |
| 102 | buildDialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#buildDialog(3e95df3e31f2cce8).(params); |
| 103 | |
| 104 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(int)), |
| 105 | this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onFinished())); |
| 106 | |
| 107 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.->enginecxx . . $ QQuickView#engine(a2abd829983e1876).()->addImportPathcxx . . $ QQmlEngine#addImportPath(3520e46b33348bf6).(PLUGIN_PRIVATE_MODULE_DIRcxx . . $ `<built-in>:480:9`!); |
| 108 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.->rootContextcxx . . $ QQuickView#rootContext(84d4a38f80cd3330).()->setContextPropertycxx . . $ QQmlContext#setContextProperty(6b24f83d17022bd9).("request"cxx . . $ QString#QString(85c52e162fed56f9)., this); |
| 109 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.->setSourcecxx . . $ QQuickView#setSource(37355d2f77053a23).(QUrlcxx . . $ QUrl#QUrl(ea1f3831e370f1cb).("qrc:/qml/SignOnUiPage.qml"cxx . . $ QString#QString(85c52e162fed56f9).)); |
| 110 | } else { |
| 111 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Setting request on handler"; |
| 112 | q->handlercxx . . $ SignOnUi/Request#handler(e7602e54d6d9851d).()->setRequestcxx . . $ SignOnUi/RequestHandler#setRequest(749de1b6ae65bddd).(this); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::urlVisitedcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#urlVisited(37355d2f77053a23).(const QUrlcxx . . $ QUrl# &url) |
| 117 | { |
| 118 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Url visited:" <<cxx . . $ `operator<<`(56a6a0968dd55378). url; |
| 119 | |
| 120 | m_responseUrlcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_responseUrl. =cxx . . $ QUrl#`operator=`(ba0721afb6bdccd9). url; |
| 121 | onFinishedcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#onFinished(49f6e7a06ebc5aa8).(); |
| 122 | } |
| 123 | |
| 124 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::cancelcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#cancel(49f6e7a06ebc5aa8).() |
| 125 | { |
| 126 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ExternalBrowserRequest); |
| 127 | |
| 128 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Client requested to cancel"; |
| 129 | q->setCanceledcxx . . $ SignOnUi/Request#setCanceled(49f6e7a06ebc5aa8).(); |
| 130 | closeViewcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#closeView(49f6e7a06ebc5aa8).(); |
| 131 | } |
| 132 | |
| 133 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::onFinishedcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#onFinished(49f6e7a06ebc5aa8).() |
| 134 | { |
| 135 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ExternalBrowserRequest); |
| 136 | |
| 137 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "ExternalBrowser dialog closed"; |
| 138 | QObjectcxx . . $ QObject#::disconnectcxx . . $ QObject#disconnect(cc30ff19c637f8ed).(m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(int)), |
| 139 | this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onFinished())); |
| 140 | |
| 141 | QVariantMapcxx . . $ QVariantMap# replycxx . . $ QMap#QMap(ced63f7c635d850d).; |
| 142 | reply[cxx . . $ QMap#`operator[]`(bbd415b616967878).SSOUI_KEY_URLRESPONSEcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:50:9`!] =cxx . . $ QVariant#`operator=`(79a68221451e88b7). m_responseUrlcxx . . $ QVariant#QVariant(3520e46b33348bf6)..toStringcxx . . $ QUrl#toString(632475ebea3355f1).(); |
| 143 | |
| 144 | closeViewcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#closeView(49f6e7a06ebc5aa8).(); |
| 145 | |
| 146 | q->setResultcxx . . $ OnlineAccountsUi/Request#setResult(3e95df3e31f2cce8).(reply); |
| 147 | } |
| 148 | |
| 149 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::buildDialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#buildDialog(3e95df3e31f2cce8).(const QVariantMapcxx . . $ QVariantMap# ¶ms) |
| 150 | { |
| 151 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog. = new Dialogcxx . . $ SignOnUi/Dialog#; |
| 152 | |
| 153 | QStringcxx . . $ QString# titlecxx . . $ QString#QString(ced63f7c635d850d).; |
| 154 | if (params.containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_TITLEcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:66:9`!)) { |
| 155 | title =cxx . . $ QString#`operator=`(4f35bf974e7f8568). params[cxx . . $ QMap#`operator[]`(bfda1f1f965926d4).SSOUI_KEY_TITLEcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:66:9`!].toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 156 | } else if (params.containscxx . . $ QMap#contains(8877ebe272b9620d).(SSOUI_KEY_CAPTIONcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:27:9`!)) { |
| 157 | title =cxx . . $ QString#`operator=`(4f35bf974e7f8568). OnlineAccountsUicxx . . $ OnlineAccountsUi/::_cxx . . $ OnlineAccountsUi/_(2618eaa6859b6ce4).("Web authentication for %1", |
| 158 | SIGNONUI_I18N_DOMAINcxx . . $ `<built-in>:490:9`!). |
| 159 | argcxx . . $ QString#arg(bc823072288cbbb5).(params[cxx . . $ QMap#`operator[]`(bfda1f1f965926d4).SSOUI_KEY_CAPTIONcxx . . $ `<external>/351535377674478989/uisessiondata_priv.h:27:9`!].toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 160 | } else { |
| 161 | title =cxx . . $ QString#`operator=`(4f35bf974e7f8568). OnlineAccountsUicxx . . $ OnlineAccountsUi/::_cxx . . $ OnlineAccountsUi/_(2618eaa6859b6ce4).("Web authentication", |
| 162 | SIGNONUI_I18N_DOMAINcxx . . $ `<built-in>:490:9`!); |
| 163 | } |
| 164 | |
| 165 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.->setTitlecxx . . $ QWindow#setTitle(3520e46b33348bf6).(title); |
| 166 | |
| 167 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Dialog was built"; |
| 168 | } |
| 169 | |
| 170 | void ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#::closeViewcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#closeView(49f6e7a06ebc5aa8).() |
| 171 | { |
| 172 | Q_Qcxx . . $ `<external>/15045578679651060896/qglobal.h:1178:9`!(ExternalBrowserRequest); |
| 173 | |
| 174 | DEBUGcxx . . $ `online-accounts-common/debug.h:42:13`!(); |
| 175 | if (q->hasHandlercxx . . $ SignOnUi/Request#hasHandler(50ce9a9e25b4a850).()) { |
| 176 | q->handlercxx . . $ SignOnUi/Request#handler(e7602e54d6d9851d).()->setRequestcxx . . $ SignOnUi/RequestHandler#setRequest(749de1b6ae65bddd).(0); |
| 177 | } else if (m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.) { |
| 178 | m_dialogcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#m_dialog.->closecxx . . $ QWindow#close(c9857a73d68e59ba).(); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#::ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#ExternalBrowserRequest(b00a08810fe27de2).( |
| 183 | int id, |
| 184 | const QStringcxx . . $ QString# &clientProfile, |
| 185 | const QVariantMapcxx . . $ QVariantMap# ¶meters, |
| 186 | QObjectcxx . . $ QObject# *parent): |
| 187 | Requestcxx . . $ SignOnUi/Request#(id, clientProfile, parameters, parent), |
| 188 | d_ptrcxx . . $ SignOnUi/ExternalBrowserRequest#d_ptr.(new ExternalBrowserRequestPrivatecxx . . $ SignOnUi/ExternalBrowserRequestPrivate#ExternalBrowserRequestPrivate(12acec1834699ccb).(this)) |
| 189 | { |
| 190 | } |
| 191 | |
| 192 | ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#::~cxx . . $ SignOnUi/ExternalBrowserRequest#`~ExternalBrowserRequest`(ced63f7c635d850d).ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#() |
| 193 | { |
| 194 | } |
| 195 | |
| 196 | void ExternalBrowserRequestcxx . . $ SignOnUi/ExternalBrowserRequest#::startcxx . . $ SignOnUi/ExternalBrowserRequest#start(49f6e7a06ebc5aa8).() |
| 197 | { |
| 198 | Q_Dcxx . . $ `<external>/15045578679651060896/qglobal.h:1177:9`!(ExternalBrowserRequest); |
| 199 | |
| 200 | Requestcxx . . $ SignOnUi/Request#::startcxx . . $ OnlineAccountsUi/Request#start(49f6e7a06ebc5aa8).(); |
| 201 | d->startcxx . . $ SignOnUi/ExternalBrowserRequestPrivate#start(49f6e7a06ebc5aa8).(); |
| 202 | } |
| 203 | |
| 204 | #include "external-browser-request.moc"cxx . . $ `<file>/build/online-accounts-ui/src/lomiri-online-accounts-ui_autogen/include/external-browser-request.moc`/ |