Kgapi

accountinfo.cpp
1 /*
2  * This file is part of LibKGAPI library
3  *
4  * SPDX-FileCopyrightText: 2013 Daniel Vr├ítil <[email protected]>
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 
16 using namespace KGAPI2;
17 
18 
19 class Q_DECL_HIDDEN AccountInfo::Private
20 {
21 public:
22  Private();
23  Private(const Private &other);
24  ~Private();
25 
26  QString id;
27  QString email;
28  QString name;
29  QString givenName;
30  QString familyName;
31 
32  QString birthday;
33  QString gender;
34 
35  QString link;
37  QString timezone;
38 
39  bool verifiedEmail = false;
40 
41  QString pictureUrl;
42 };
43 
44 AccountInfo::Private::Private()
45 {
46 }
47 
48 AccountInfo::Private::Private(const Private &other):
49  id(other.id),
50  email(other.email),
51  name(other.name),
52  givenName(other.givenName),
53  familyName(other.familyName),
54  birthday(other.birthday),
55  gender(other.gender),
56  link(other.link),
57  locale(other.locale),
58  timezone(other.timezone),
59  verifiedEmail(other.verifiedEmail),
60  pictureUrl(other.pictureUrl)
61 {
62 }
63 
64 AccountInfo::Private::~Private()
65 {
66 }
67 
69  Object(),
70  d(new Private)
71 {
72 }
73 
75  Object(other),
76  d(new Private(*(other.d)))
77 {
78 }
79 
81 {
82  delete d;
83 }
84 
85 bool AccountInfo::operator==(const AccountInfo &other) const
86 {
87  if (!Object::operator==(other)) {
88  return false;
89  }
90  GAPI_COMPARE(id)
91  GAPI_COMPARE(email)
92  GAPI_COMPARE(name)
93  GAPI_COMPARE(givenName)
94  GAPI_COMPARE(familyName)
95  GAPI_COMPARE(birthday)
96  GAPI_COMPARE(gender)
97  GAPI_COMPARE(link)
98  GAPI_COMPARE(locale)
99  GAPI_COMPARE(timezone)
100  GAPI_COMPARE(verifiedEmail)
101  GAPI_COMPARE(pictureUrl)
102  return true;
103 }
104 
106 {
107  d->id = id;
108 }
109 
111 {
112  return d->id;
113 }
114 
116 {
117  d->email = email;
118 }
119 
121 {
122  return d->email;
123 }
124 
126 {
127  d->name = name;
128 }
129 
131 {
132  return d->name;
133 }
134 
136 {
137  d->givenName = givenName;
138 }
139 
141 {
142  return d->givenName;
143 }
144 
146 {
147  d->familyName = familyName;
148 }
149 
151 {
152  return d->familyName;
153 }
154 
156 {
157  d->birthday = birthday;
158 }
159 
161 {
162  return d->birthday;
163 }
164 
166 {
167  d->gender = gender;
168 }
169 
171 {
172  return d->gender;
173 }
174 
176 {
177  d->link = link;
178 }
179 
181 {
182  return d->link;
183 }
184 
186 {
187  d->locale = locale;
188 }
189 
191 {
192  return d->locale;
193 }
194 
196 {
197  d->timezone = timezone;
198 }
199 
201 {
202  return d->timezone;
203 }
204 
206 {
207  d->verifiedEmail = verifiedEmail;
208 }
209 
211 {
212  return d->verifiedEmail;
213 }
214 
216 {
217  d->pictureUrl = url;
218 }
219 
221 {
222  return d->pictureUrl;
223 }
224 
226 {
227  QJsonDocument document = QJsonDocument::fromJson(jsonData);
228  if (document.isNull()) {
229  return AccountInfoPtr();
230  }
231 
232  QVariantMap data;
233  data = document.toVariant().toMap();
234 
235  AccountInfoPtr accountInfo(new AccountInfo);
236  accountInfo->setId(data.value(QStringLiteral("id")).toString());
237  accountInfo->setEmail(data.value(QStringLiteral("email")).toString());
238  accountInfo->setName(data.value(QStringLiteral("name")).toString());
239  accountInfo->setGivenName(data.value(QStringLiteral("given_name")).toString());
240  accountInfo->setFamilyName(data.value(QStringLiteral("family_name")).toString());
241  accountInfo->setBirthday(data.value(QStringLiteral("birthday")).toString());
242  accountInfo->setGender(data.value(QStringLiteral("gender")).toString());
243  accountInfo->setLink(data.value(QStringLiteral("link")).toString());
244  accountInfo->setLocale(data.value(QStringLiteral("locale")).toString());
245  accountInfo->setTimezone(data.value(QStringLiteral("timezone")).toString());
246  accountInfo->setPhotoUrl(data.value(QStringLiteral("picture")).toString());
247  accountInfo->setVerifiedEmail(data.value(QStringLiteral("verified_email")).toBool());
248 
249  return accountInfo;
250 }
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
void setLocale(const QString &locale)
Sets users locale settings.
QString name(const QVariant &location)
Base class for all objects.
Definition: object.h:30
void setLink(const QString &link)
Sets link to user&#39;s profile.
void setTimezone(const QString &timezone)
Sets user&#39;s timezone name.
void setGender(const QString &gender)
Sets user&#39;s gender.
void setEmail(const QString &email)
Sets account email.
void setVerifiedEmail(bool verified)
Sets whether the email address is verified.
bool isNull() const const
virtual ~AccountInfo()
destructor
Definition: accountinfo.cpp:80
void setName(const QString &name)
Sets user&#39;s real full name.
QString timezone() const
Returns name of user&#39;s timezone.
QString locale() const
Returns user&#39;s preferred locales.
static AccountInfoPtr fromJSON(const QByteArray &jsonData)
Parses raw JSON data into AccountInfo object.
QString gender() const
Returns user&#39;s gender.
bool verifiedEmail() const
Returns whether the email is verified.
QString link() const
Returns link to user&#39;s profile.
void setId(const QString &id)
Sets an account ID.
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:15
QString email() const
Returns account email address.
QString id() const
Returns account ID.
QString photoUrl() const
Returns URL of user&#39;s photo.
QString familyName() const
Returns user&#39;s surname.
QVariant toVariant() const const
QString givenName() const
Returns user&#39;s given name.
void setPhotoUrl(const QString &url)
Sets URL of user&#39;s photo.
QString name() const
Returns user&#39;s real full name.
QMap< QString, QVariant > toMap() const const
AccountInfo contains information about user&#39;s Google account.
Definition: accountinfo.h:31
KIOCORE_EXPORT CopyJob * link(const QUrl &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
void setBirthday(const QString &birthday)
Sets user&#39;s birthday.
LocaleWrapper locale()
QString birthday() const
Returns user&#39;s birthday.
void setGivenName(const QString &givenName)
Sets user&#39;s given name.
AccountInfo()
Constructor.
Definition: accountinfo.cpp:68
void setFamilyName(const QString &familyName)
Sets user&#39;s family name (surname).
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 23:11:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.