~ubuntu-branches/ubuntu/utopic/ubuntu-system-settings-online-accounts/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/online-accounts-ui/mock/signonui-request-mock.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Ubuntu daily release, Alberto Mardegan
  • Date: 2014-10-01 13:31:34 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20141001133134-3fgng1e52axk5d6t
Tags: 0.4+14.10.20141001-0ubuntu1
[ Ubuntu daily release ]
* New rebuild forced

[ Alberto Mardegan ]
* Minor improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of online-accounts-ui
 
3
 *
 
4
 * Copyright (C) 2011-2014 Canonical Ltd.
 
5
 *
 
6
 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
 
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 "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
const QVariantMap &Request::clientData() const
 
90
{
 
91
    Q_D(const Request);
 
92
    return d->m_clientData;
 
93
}
 
94
 
 
95
void Request::setHandler(RequestHandler *handler)
 
96
{
 
97
    Q_D(Request);
 
98
    d->m_handler = handler;
 
99
}
 
100
 
 
101
RequestHandler *Request::handler() const
 
102
{
 
103
    Q_D(const Request);
 
104
    return d->m_handler;
 
105
}
 
106
 
 
107
void Request::setCanceled()
 
108
{
 
109
    QVariantMap result;
 
110
    result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED;
 
111
 
 
112
    setResult(result);
 
113
}