Kgapi

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

KDE's Doxygen guidelines are available online.