File indexing completed on 2024-11-03 13:13:17
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libruqolacore_export.h" 0010 #include <KPluginMetaData> 0011 #include <QObject> 0012 #include <QVector> 0013 class PluginAuthentication; 0014 class PluginUtilData 0015 { 0016 public: 0017 PluginUtilData() = default; 0018 0019 QStringList mExtraInfo; 0020 QString mIdentifier; 0021 QString mName; 0022 }; 0023 0024 class AuthenticationManagerInfo 0025 { 0026 public: 0027 AuthenticationManagerInfo() = default; 0028 0029 KPluginMetaData data; 0030 QString metaDataFileNameBaseName; 0031 QString metaDataFileName; 0032 PluginUtilData pluginData; 0033 PluginAuthentication *plugin = nullptr; 0034 }; 0035 0036 class LIBRUQOLACORE_EXPORT AuthenticationManager : public QObject 0037 { 0038 Q_OBJECT 0039 public: 0040 enum AuthMethodType { 0041 Unknown = 0, 0042 Twitter = 1, 0043 FaceBook = 2, 0044 GitHub = 4, 0045 GitLab = 8, 0046 Google = 16, 0047 Linkedin = 32, 0048 Wordpress = 64, 0049 Password = 128, 0050 Apple = 256, 0051 NextCloud = 512, 0052 }; 0053 Q_ENUM(AuthMethodType) 0054 Q_DECLARE_FLAGS(AuthMethodTypes, AuthMethodType) 0055 0056 explicit AuthenticationManager(QObject *parent = nullptr); 0057 ~AuthenticationManager() override; 0058 0059 static AuthenticationManager *self(); 0060 0061 [[nodiscard]] QVector<PluginAuthentication *> pluginsList() const; 0062 0063 private: 0064 LIBRUQOLACORE_NO_EXPORT void initializePluginList(); 0065 LIBRUQOLACORE_NO_EXPORT void loadPlugin(AuthenticationManagerInfo *item); 0066 LIBRUQOLACORE_NO_EXPORT PluginUtilData createPluginMetaData(const KPluginMetaData &metaData); 0067 QVector<AuthenticationManagerInfo> mPluginList; 0068 QVector<PluginUtilData> mPluginDataList; 0069 }; 0070 Q_DECLARE_METATYPE(AuthenticationManager::AuthMethodTypes) 0071 Q_DECLARE_METATYPE(AuthenticationManager::AuthMethodType)