File indexing completed on 2024-05-12 05:22:15
0001 /* 0002 SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "kgapicore_export.h" 0010 #include "types.h" 0011 0012 #include <functional> 0013 0014 namespace KGAPI2 0015 { 0016 0017 class AccountStorage; 0018 // Exported for tests, otherwise a private class 0019 class KGAPICORE_EXPORT AccountStorageFactory 0020 { 0021 public: 0022 static AccountStorageFactory *instance(); 0023 0024 virtual ~AccountStorageFactory(); 0025 virtual AccountStorage *create() const = 0; 0026 0027 protected: 0028 explicit AccountStorageFactory(); 0029 0030 static AccountStorageFactory *sFactory; 0031 0032 private: 0033 Q_DISABLE_COPY(AccountStorageFactory) 0034 }; 0035 0036 class AccountStorage 0037 { 0038 public: 0039 virtual ~AccountStorage(){}; 0040 virtual void open(const std::function<void(bool)> &callback) = 0; 0041 virtual bool opened() const = 0; 0042 0043 virtual AccountPtr getAccount(const QString &apiKey, const QString &accountName) = 0; 0044 virtual bool storeAccount(const QString &apiKey, const AccountPtr &account) = 0; 0045 virtual void removeAccount(const QString &apiKey, const QString &accountName) = 0; 0046 }; 0047 0048 }