Kgapi

user.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 "user.h"
10#include "utils_p.h"
11
12using namespace KGAPI2;
13using namespace KGAPI2::Drive;
14
15class Q_DECL_HIDDEN User::Private
16{
17public:
18 Private();
19 Private(const Private &other);
20
22 QUrl pictureUrl;
23 bool isAuthenticatedUser;
24 QString permissionId;
25};
26
27User::Private::Private()
28 : isAuthenticatedUser(false)
29{
30}
31
32User::Private::Private(const Private &other)
34 , pictureUrl(other.pictureUrl)
35 , isAuthenticatedUser(other.isAuthenticatedUser)
36 , permissionId(other.permissionId)
37{
38}
39
40User::User()
41 : d(new Private)
42{
43}
44
45User::User(const User &other)
46 : d(new Private(*(other.d)))
47{
48}
49
50User::~User()
51{
52 delete d;
53}
54
55bool User::operator==(const User &other) const
56{
57 GAPI_COMPARE(displayName)
58 GAPI_COMPARE(pictureUrl)
59 GAPI_COMPARE(isAuthenticatedUser)
60 GAPI_COMPARE(permissionId)
61 return true;
62}
63
65{
66 return d->displayName;
67}
68
70{
71 return d->pictureUrl;
72}
73
75{
76 return d->isAuthenticatedUser;
77}
78
80{
81 return d->permissionId;
82}
83
84UserPtr User::fromJSON(const QVariantMap &map)
85{
86 if (!map.contains(QLatin1StringView("kind")) || map[QStringLiteral("kind")].toString() != QLatin1StringView("drive#user")) {
87 return UserPtr();
88 }
89
90 UserPtr user(new User());
91 user->d->displayName = map[QStringLiteral("displayName")].toString();
92 const QVariantMap picture = map[QStringLiteral("picture")].toMap();
93 user->d->pictureUrl = picture[QStringLiteral("url")].toUrl();
94 user->d->isAuthenticatedUser = map[QStringLiteral("isAuthenticatedUser")].toBool();
95 user->d->permissionId = map[QStringLiteral("permissionId")].toString();
96
97 return user;
98}
The authenticated user.
Definition user.h:27
QString permissionId() const
Returns the user's ID as visible in the permissions collection.
Definition user.cpp:79
QUrl pictureUrl() const
Returns a URL that points to a profile picture of this user.
Definition user.cpp:69
bool isAuthenticatedUser() const
Returns whether this user is the same as the authenticated user for whom the request was made.
Definition user.cpp:74
QString displayName() const
Returns a plain text displayable name for this user.
Definition user.cpp:64
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.