File indexing completed on 2024-10-27 04:58:02

0001 /*
0002     SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 // this code was taken from kmail-account-wizard
0008 
0009 #pragma once
0010 
0011 #include "key.h"
0012 
0013 #include <QObject>
0014 #include <QVector>
0015 
0016 #include <gpgme++/key.h>
0017 
0018 namespace KWallet
0019 {
0020 class Wallet;
0021 }
0022 
0023 class SetupManager : public QObject
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit SetupManager(QObject *parent);
0028     ~SetupManager() override;
0029 
0030     void setName(const QString &);
0031     void setEmail(const QString &);
0032     void setPassword(const QString &);
0033     void setPersonalDataAvailable(bool available);
0034     void setPgpAutoSign(bool autosign);
0035     void setPgpAutoEncrypt(bool autoencrypt);
0036     void setKey(const GpgME::Key &key);
0037     void setKeyPublishingMethod(Key::PublishingMethod method);
0038 
0039     QVector<SetupObject *> objectsToSetup() const;
0040     QVector<SetupObject *> setupObjects() const;
0041 
0042 public Q_SLOTS:
0043     Q_SCRIPTABLE bool personalDataAvailable() const;
0044     Q_SCRIPTABLE QString name() const;
0045     Q_SCRIPTABLE QString email() const;
0046     Q_SCRIPTABLE QString password() const;
0047     Q_SCRIPTABLE QString country() const;
0048     /** Ensures the wallet is open for subsequent sync wallet access in the resources. */
0049     Q_SCRIPTABLE void openWallet();
0050     Q_SCRIPTABLE QObject *createResource(const QString &type);
0051     Q_SCRIPTABLE QObject *createTransport(const QString &type);
0052     Q_SCRIPTABLE QObject *createConfigFile(const QString &configName);
0053     Q_SCRIPTABLE QObject *createLdap();
0054     Q_SCRIPTABLE QObject *createIdentity();
0055     Q_SCRIPTABLE QObject *createKey();
0056     Q_SCRIPTABLE void execute();
0057     Q_SCRIPTABLE void setupInfoSlot(const QString &msg);
0058     Q_SCRIPTABLE QObject *ispDB(const QString &type);
0059 
0060     void requestRollback();
0061 
0062 Q_SIGNALS:
0063     void rollbackComplete();
0064     void setupFinished(SetupObject *obj);
0065     void setupSucceeded(const QString &msg);
0066     void setupFailed(const QString &msg);
0067     void setupInfo(const QString &msg);
0068 
0069 private:
0070     void setupNext();
0071     void rollback();
0072     SetupObject *connectObject(SetupObject *obj);
0073 
0074 private Q_SLOTS:
0075     void setupSuccessSlot(const QString &msg);
0076     void setupFailedSlot(const QString &msg);
0077 
0078 private:
0079     QString m_name, m_email, m_password;
0080     QVector<SetupObject *> m_objectToSetup;
0081     QVector<SetupObject *> m_setupObjects;
0082     SetupObject *m_currentSetupObject = nullptr;
0083     KWallet::Wallet *m_wallet = nullptr;
0084     GpgME::Key m_key;
0085     Key::PublishingMethod m_keyPublishingMethod;
0086     bool m_personalDataAvailable = false;
0087     bool m_rollbackRequested = false;
0088     bool m_pgpAutoSign = false;
0089     bool m_pgpAutoEncrypt = false;
0090 };
0091