Debian Codegraph @

tests/online-accounts-ui/mock/signonui-request-mock.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 <online-accounts-common/globals.h>
22 #include "signonui-request-mock.h"
23
24 #include <QDebug>
25 #include <SignOn/uisessiondata.h>
26 #include <SignOn/uisessiondata_priv.h>
27
28 using namespace SignOnUi;
29
30 RequestPrivate::RequestPrivate(Request *request):
31 QObject(request),
32 q_ptr(request),
33 m_handler(0)
34 {
35 const QVariantMap &parameters = request->parameters();
36 if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) {
37 m_clientData = parameters[SSOUI_KEY_CLIENT_DATA].toMap();
38 }
39 }
40
41 RequestPrivate::~RequestPrivate()
42 {
43 }
44
45 Request::Request(int id,
46 const QString &clientProfile,
47 const QVariantMap &parameters,
48 QObject *parent):
49 OnlineAccountsUi::Request(SIGNONUI_INTERFACE, id, clientProfile,
50 parameters, parent),
51 d_ptr(new RequestPrivate(this))
52 {
53 }
54
55 Request::~Request()
56 {
57 }
58
59 QString Request::ssoId(const QVariantMap &parameters)
60 {
61 return parameters[SSOUI_KEY_REQUESTID].toString();
62 }
63
64 QString Request::ssoId() const
65 {
66 return Request::ssoId(parameters());
67 }
68
69 void Request::setWindow(QWindow *window)
70 {
71 OnlineAccountsUi::Request::setWindow(window);
72 }
73
74 uint Request::identity() const
75 {
76 return parameters().value(SSOUI_KEY_IDENTITY).toUInt();
77 }
78
79 QString Request::method() const
80 {
81 return parameters().value(SSOUI_KEY_METHOD).toString();
82 }
83
84 QString Request::mechanism() const
85 {
86 return parameters().value(SSOUI_KEY_MECHANISM).toString();
87 }
88
89 QString Request::providerId() const
90 {
91 Q_D(const Request);
92 return d->m_providerId;
93 }
94
95 QString Request::windowTitle() const
96 {
97 Q_D(const Request);
98 return d->m_windowTitle;
99 }
100
101 const QVariantMap &Request::clientData() const
102 {
103 Q_D(const Request);
104 return d->m_clientData;
105 }
106
107 void Request::setHandler(RequestHandler *handler)
108 {
109 Q_D(Request);
110 d->m_handler = handler;
111 }
112
113 RequestHandler *Request::handler() const
114 {
115 Q_D(const Request);
116 return d->m_handler;
117 }
118
119 void Request::setCanceled()
120 {
121 QVariantMap result;
122 result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED;
123
124 setResult(result);
125 }