Kgapi

accountinfo.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "accountinfo.h"
10#include "utils_p.h"
11
12#include <QJsonDocument>
13
14#include <QVariantMap>
15
16using namespace KGAPI2;
17
18class Q_DECL_HIDDEN AccountInfo::Private
19{
20public:
21 Private();
22 Private(const Private &other);
23 ~Private();
24
25 QString id;
26 QString email;
28 QString givenName;
29 QString familyName;
30
31 QString birthday;
32 QString gender;
33
35 QString locale;
36 QString timezone;
37
38 bool verifiedEmail = false;
39
40 QString pictureUrl;
41};
42
43AccountInfo::Private::Private()
44{
45}
46
47AccountInfo::Private::Private(const Private &other)
48 : id(other.id)
49 , email(other.email)
50 , name(other.name)
51 , givenName(other.givenName)
52 , familyName(other.familyName)
53 , birthday(other.birthday)
54 , gender(other.gender)
55 , link(other.link)
56 , locale(other.locale)
57 , timezone(other.timezone)
59 , pictureUrl(other.pictureUrl)
60{
61}
62
63AccountInfo::Private::~Private()
64{
65}
66
68 : Object()
69 , d(new Private)
70{
71}
72
74 : Object(other)
75 , d(new Private(*(other.d)))
76{
77}
78
80{
81 delete d;
82}
83
84bool AccountInfo::operator==(const AccountInfo &other) const
85{
86 if (!Object::operator==(other)) {
87 return false;
88 }
89 GAPI_COMPARE(id)
90 GAPI_COMPARE(email)
91 GAPI_COMPARE(name)
92 GAPI_COMPARE(givenName)
93 GAPI_COMPARE(familyName)
94 GAPI_COMPARE(birthday)
95 GAPI_COMPARE(gender)
96 GAPI_COMPARE(link)
97 GAPI_COMPARE(locale)
98 GAPI_COMPARE(timezone)
99 GAPI_COMPARE(verifiedEmail)
100 GAPI_COMPARE(pictureUrl)
101 return true;
102}
103
105{
106 d->id = id;
107}
108
110{
111 return d->id;
112}
113
115{
116 d->email = email;
117}
118
120{
121 return d->email;
122}
123
125{
126 d->name = name;
127}
128
130{
131 return d->name;
132}
133
134void AccountInfo::setGivenName(const QString &givenName)
135{
136 d->givenName = givenName;
137}
138
140{
141 return d->givenName;
142}
143
144void AccountInfo::setFamilyName(const QString &familyName)
145{
146 d->familyName = familyName;
147}
148
150{
151 return d->familyName;
152}
153
155{
156 d->birthday = birthday;
157}
158
160{
161 return d->birthday;
162}
163
165{
166 d->gender = gender;
167}
168
170{
171 return d->gender;
172}
173
175{
176 d->link = link;
177}
178
180{
181 return d->link;
182}
183
185{
186 d->locale = locale;
187}
188
190{
191 return d->locale;
192}
193
195{
196 d->timezone = timezone;
197}
198
200{
201 return d->timezone;
202}
203
204void AccountInfo::setVerifiedEmail(const bool verifiedEmail)
205{
206 d->verifiedEmail = verifiedEmail;
207}
208
210{
211 return d->verifiedEmail;
212}
213
215{
216 d->pictureUrl = url;
217}
218
220{
221 return d->pictureUrl;
222}
223
225{
226 QJsonDocument document = QJsonDocument::fromJson(jsonData);
227 if (document.isNull()) {
228 return AccountInfoPtr();
229 }
230
231 QVariantMap data;
232 data = document.toVariant().toMap();
233
234 AccountInfoPtr accountInfo(new AccountInfo);
235 accountInfo->setId(data.value(QStringLiteral("id")).toString());
236 accountInfo->setEmail(data.value(QStringLiteral("email")).toString());
237 accountInfo->setName(data.value(QStringLiteral("name")).toString());
238 accountInfo->setGivenName(data.value(QStringLiteral("given_name")).toString());
239 accountInfo->setFamilyName(data.value(QStringLiteral("family_name")).toString());
240 accountInfo->setBirthday(data.value(QStringLiteral("birthday")).toString());
241 accountInfo->setGender(data.value(QStringLiteral("gender")).toString());
242 accountInfo->setLink(data.value(QStringLiteral("link")).toString());
243 accountInfo->setLocale(data.value(QStringLiteral("locale")).toString());
244 accountInfo->setTimezone(data.value(QStringLiteral("timezone")).toString());
245 accountInfo->setPhotoUrl(data.value(QStringLiteral("picture")).toString());
246 accountInfo->setVerifiedEmail(data.value(QStringLiteral("verified_email")).toBool());
247
248 return accountInfo;
249}
AccountInfo contains information about user's Google account.
Definition accountinfo.h:32
void setLink(const QString &link)
Sets link to user's profile.
QString link() const
Returns link to user's profile.
void setFamilyName(const QString &familyName)
Sets user's family name (surname).
void setEmail(const QString &email)
Sets account email.
void setPhotoUrl(const QString &url)
Sets URL of user's photo.
void setVerifiedEmail(bool verified)
Sets whether the email address is verified.
QString email() const
Returns account email address.
void setLocale(const QString &locale)
Sets users locale settings.
void setGender(const QString &gender)
Sets user's gender.
AccountInfo()
Constructor.
QString name() const
Returns user's real full name.
QString givenName() const
Returns user's given name.
QString familyName() const
Returns user's surname.
void setBirthday(const QString &birthday)
Sets user's birthday.
void setId(const QString &id)
Sets an account ID.
void setGivenName(const QString &givenName)
Sets user's given name.
QString gender() const
Returns user's gender.
QString id() const
Returns account ID.
void setTimezone(const QString &timezone)
Sets user's timezone name.
void setName(const QString &name)
Sets user's real full name.
QString photoUrl() const
Returns URL of user's photo.
static AccountInfoPtr fromJSON(const QByteArray &jsonData)
Parses raw JSON data into AccountInfo object.
bool verifiedEmail() const
Returns whether the email is verified.
~AccountInfo() override
destructor
QString locale() const
Returns user's preferred locales.
QString timezone() const
Returns name of user's timezone.
QString birthday() const
Returns user's birthday.
Base class for all objects.
Definition object.h:31
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
QString name(StandardAction id)
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
bool isNull() const const
QVariant toVariant() const const
QMap< QString, QVariant > toMap() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:58:17 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.