2
* This file is part of libOnlineAccounts
4
* Copyright (C) 2015 Canonical Ltd.
6
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
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.
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.
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/>.
21
#include "authentication_data_p.h"
23
#include <QDBusMetaType>
24
#include "dbus_constants.h"
26
using namespace OnlineAccounts;
28
AuthenticationDataPrivate::AuthenticationDataPrivate(AuthenticationMethod method):
31
m_invalidateCachedReply(false)
35
AuthenticationData::AuthenticationData(AuthenticationDataPrivate *priv):
40
AuthenticationData::AuthenticationData(const AuthenticationData &other):
45
AuthenticationData::~AuthenticationData()
49
AuthenticationMethod AuthenticationData::method() const
54
void AuthenticationData::setInteractive(bool interactive)
56
d->m_interactive = interactive;
59
bool AuthenticationData::interactive() const
61
return d->m_interactive;
64
void AuthenticationData::invalidateCachedReply()
66
d->m_invalidateCachedReply = true;
69
bool AuthenticationData::mustInvalidateCachedReply() const
71
return d->m_invalidateCachedReply;
76
OAuth2Data::OAuth2Data():
77
AuthenticationData(new AuthenticationDataPrivate(AuthenticationMethodOAuth2))
79
qDBusRegisterMetaType<QList<QByteArray>>();
82
void OAuth2Data::setClientId(const QByteArray &id)
84
d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_ID] = id;
87
QByteArray OAuth2Data::clientId() const
89
return d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_ID].toByteArray();
92
void OAuth2Data::setClientSecret(const QByteArray &secret)
94
d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_SECRET] = secret;
97
QByteArray OAuth2Data::clientSecret() const
99
return d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CLIENT_SECRET].toByteArray();
102
void OAuth2Data::setScopes(const QList<QByteArray> &scopes)
104
d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_SCOPES] = QVariant::fromValue(scopes);
107
QList<QByteArray> OAuth2Data::scopes() const
109
return d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_SCOPES].value<QList<QByteArray> >();
114
OAuth1Data::OAuth1Data():
115
AuthenticationData(new AuthenticationDataPrivate(AuthenticationMethodOAuth1))
119
void OAuth1Data::setConsumerKey(const QByteArray &key)
121
d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_KEY] = key;
124
QByteArray OAuth1Data::consumerKey() const
126
return d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_KEY].toByteArray();
129
void OAuth1Data::setConsumerSecret(const QByteArray &secret)
131
d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_SECRET] = secret;
134
QByteArray OAuth1Data::consumerSecret() const
136
return d->m_parameters[ONLINE_ACCOUNTS_AUTH_KEY_CONSUMER_SECRET].toByteArray();
141
PasswordData::PasswordData():
142
AuthenticationData(new AuthenticationDataPrivate(AuthenticationMethodPassword))