Kgapi

accountmanager.h
1 /*
2  Copyright (C) 2018 Daniel Vrátil <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) version 3, or any
8  later version accepted by the membership of KDE e.V. (or its
9  successor approved by the membership of KDE e.V.), which shall
10  act as a proxy defined in Section 6 of version 3 of the license.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library. If not, see <https://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef LIBKGAPI2_ACCOUNTMANAGER_H_
22 #define LIBKGAPI2_ACCOUNTMANAGER_H_
23 
24 #include <QObject>
25 #include <QList>
26 
27 #include "account.h"
28 #include "kgapicore_export.h"
29 
30 
31 class QUrl;
32 
33 namespace KGAPI2 {
34 
35 class AccountManager;
44 class KGAPICORE_EXPORT AccountPromise : public QObject
45 {
46  Q_OBJECT
47 public:
48  ~AccountPromise() override;
49 
50  AccountPtr account() const;
51 
52  bool hasError() const;
53  QString errorText() const;
54 
55 Q_SIGNALS:
62  void finished(AccountPromise *self);
63 
64 private:
65  AccountPromise(QObject *parent = nullptr);
66  Q_DISABLE_COPY(AccountPromise)
67 
68  friend class AccountManager;
69  class Private;
71 };
72 
73 class KGAPICORE_EXPORT AccountManager : public QObject
74 {
75  Q_OBJECT
76 public:
77  ~AccountManager() override;
78 
79  static AccountManager *instance();
80 
102  AccountPromise *getAccount(const QString &apiKey, const QString &apiSecret,
103  const QString &accountName,
104  const QList<QUrl> &scopes);
105 
106 
118  AccountPromise *refreshTokens(const QString &apiKey, const QString &apiSecret,
119  const QString &accountName);
120 
131  AccountPromise *findAccount(const QString &aipKey, const QString &accountName,
132  const QList<QUrl> &scopes = {});
133 
134 
142  void removeScopes(const QString &apiKey, const QString &accountName,
143  const QList<QUrl> &removeScopes);
144 
145 protected:
146  explicit AccountManager(QObject *parent = nullptr);
147  Q_DISABLE_COPY(AccountManager)
148 
149  static AccountManager *sInstance;
150  class Private;
151  QScopedPointer<Private> const d;
152 };
153 
154 }
155 
156 #endif
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:30
AccountPromise is a result of asynchronous operations of AccountManager.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jun 6 2020 23:01:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.