File indexing completed on 2024-05-19 15:57:54

0001 /*
0002  *  SPDX-FileCopyrightText: 2013 Alejandro Fiestas Olivares <afiestas@kde.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef CREATE_ACCOUNT_JOB_H
0008 #define CREATE_ACCOUNT_JOB_H
0009 
0010 #include "kaccounts_export.h"
0011 
0012 #include <kjob.h>
0013 
0014 #include <QStringList>
0015 
0016 namespace Accounts
0017 {
0018 class Account;
0019 class Manager;
0020 class AccountService;
0021 }
0022 namespace SignOn
0023 {
0024 class Error;
0025 class Identity;
0026 class SessionData;
0027 class IdentityInfo;
0028 }
0029 
0030 namespace KAccounts
0031 {
0032 
0033 /**
0034  * @brief Create a new account for the specified provider
0035  */
0036 class KACCOUNTS_EXPORT CreateAccountJob : public KJob
0037 {
0038     Q_OBJECT
0039     Q_PROPERTY(QString providerName READ providerName WRITE setProviderName NOTIFY providerNameChanged)
0040 public:
0041     explicit CreateAccountJob(QObject *parent = nullptr);
0042     explicit CreateAccountJob(const QString &providerName, QObject *parent = nullptr);
0043 
0044     QString providerName() const
0045     {
0046         return m_providerName;
0047     }
0048     void setProviderName(const QString &name);
0049     void start() override;
0050 
0051 private Q_SLOTS:
0052     void processSession();
0053     void sessionError(const SignOn::Error &signOnError);
0054     void sessionResponse(const SignOn::SessionData &data);
0055     void info(const SignOn::IdentityInfo &info);
0056     void pluginFinished(const QString &screenName, const QString &secret, const QVariantMap &map);
0057     void pluginError(const QString &error);
0058     void pluginCancelled();
0059     void startAuthSession(const QVariantMap &data);
0060 
0061 Q_SIGNALS:
0062     void providerNameChanged();
0063 
0064 private:
0065     void loadPluginAndShowDialog(const QString &pluginName);
0066 
0067     QString m_providerName;
0068     QStringList m_disabledServices;
0069     Accounts::Manager *m_manager = nullptr;
0070     Accounts::Account *m_account = nullptr;
0071     Accounts::AccountService *m_accInfo = nullptr;
0072     SignOn::Identity *m_identity = nullptr;
0073     bool m_done = false;
0074 };
0075 
0076 };
0077 
0078 #endif // CREATE_ACCOUNT_JOB_H