Debian Codegraph @

online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/authentication_request.cpp

raw symbols SCIP
1 /*
2 * This file is part of OnlineAccountsDaemon
3 *
4 * Copyright (C) 2015 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 Lesser General Public License version 3, as
10 * published 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 Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "authentication_request.h"
22
23 #include <QDebug>
24 #include "authenticator.h"
25 #include "manager_adaptor.h"
26
27 using namespace OnlineAccountsDaemon;
28
29 namespace OnlineAccountsDaemon {
30
31 class AuthenticationRequestPrivate: public QObject
32 {
33 Q_OBJECT
34 Q_DECLARE_PUBLIC(AuthenticationRequest)
35
36 public:
37 AuthenticationRequestPrivate(AuthenticationRequest *q);
38
39 private Q_SLOTS:
40 void onFinished();
41
42 private:
43 Authenticator m_authenticator;
44 AuthenticationRequest *q_ptr;
45 };
46
47 } // namespace
48
49 AuthenticationRequestPrivate::AuthenticationRequestPrivate(AuthenticationRequest *q):
50 QObject(q),
51 q_ptr(q)
52 {
53 QObject::connect(&m_authenticator, SIGNAL(finished()),
54 this, SLOT(onFinished()));
55 }
56
57 void AuthenticationRequestPrivate::onFinished()
58 {
59 Q_Q(AuthenticationRequest);
60 if (m_authenticator.isError()) {
61 q->setError(m_authenticator.errorName(),
62 m_authenticator.errorMessage());
63 } else {
64 q->setReply(QList<QVariant>() << m_authenticator.reply());
65 }
66 }
67
68 AuthenticationRequest::AuthenticationRequest(const CallContext &context, QObject *parent):
69 AsyncOperation(context, parent),
70 d_ptr(new AuthenticationRequestPrivate(this))
71 {
72 }
73
74 AuthenticationRequest::~AuthenticationRequest()
75 {
76 delete d_ptr;
77 }
78
79 void AuthenticationRequest::setInteractive(bool interactive)
80 {
81 Q_D(AuthenticationRequest);
82 d->m_authenticator.setInteractive(interactive);
83 }
84
85 void AuthenticationRequest::invalidateCache()
86 {
87 Q_D(AuthenticationRequest);
88 d->m_authenticator.invalidateCache();
89 }
90
91 void AuthenticationRequest::authenticate(const Accounts::AuthData &authData,
92 const QVariantMap &parameters)
93 {
94 Q_D(AuthenticationRequest);
95 QVariantMap p(parameters);
96 p.insert("requestorPid", context().clientPid());
97 d->m_authenticator.authenticate(authData, p);
98 }
99
100 #include "authentication_request.moc"