1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
26 #include <QVariantMap>
29 #include "ui_coreconfigwizardadminuserpage.h"
30 #include "ui_coreconfigwizardauthenticationselectionpage.h"
31 #include "ui_coreconfigwizardintropage.h"
32 #include "ui_coreconfigwizardstorageselectionpage.h"
33 #include "ui_coreconfigwizardsyncpage.h"
37 namespace CoreConfigWizardPages {
42 } // namespace CoreConfigWizardPages
44 class CoreConfigWizard : public QWizard
53 AuthenticationSelectionPage,
61 CoreConfigWizard(CoreConnection* connection, const QVariantList& backendInfos, const QVariantList& authInfos, QWidget* parent = nullptr);
63 inline CoreConnection* coreConnection() const { return _connection; }
66 void setupCore(const QVariant& setupData);
67 void loginToCore(const QString& user, const QString& password, bool rememberPassword);
73 void prepareCoreSetup(const QString& backend,
74 const QVariantMap& properties,
75 const QString& authenticator,
76 const QVariantMap& authProperties);
77 void coreSetupSuccess();
78 void coreSetupFailed(const QString&);
82 CoreConfigWizardPages::SyncPage* syncPage;
83 CoreConfigWizardPages::SyncRelayPage* syncRelayPage;
85 CoreConnection* _connection;
88 namespace CoreConfigWizardPages {
90 class IntroPage : public QWizardPage
95 IntroPage(QWidget* parent = nullptr);
96 int nextId() const override;
99 Ui::CoreConfigWizardIntroPage ui;
102 class AdminUserPage : public QWizardPage
107 AdminUserPage(QWidget* parent = nullptr);
108 int nextId() const override;
109 bool isComplete() const override;
112 Ui::CoreConfigWizardAdminUserPage ui;
115 class AuthenticationSelectionPage : public QWizardPage
118 using FieldInfo = std::tuple<QString, QString, QVariant>;
121 AuthenticationSelectionPage(const QVariantList& authInfos, QWidget* parent = nullptr);
122 int nextId() const override;
123 QString displayName() const;
124 QString authenticator() const;
125 QVariantMap authProperties() const;
128 void on_backendList_currentIndexChanged(int index);
131 Ui::CoreConfigWizardAuthenticationSelectionPage ui;
132 std::vector<QVariantMap> _authProperties;
133 std::vector<std::vector<FieldInfo>> _authFields;
136 class StorageSelectionPage : public QWizardPage
139 using FieldInfo = std::tuple<QString, QString, QVariant>;
142 StorageSelectionPage(const QVariantList& backendInfos, QWidget* parent = nullptr);
143 int nextId() const override;
144 QString displayName() const;
145 QString backend() const;
146 QVariantMap backendProperties() const;
149 void on_backendList_currentIndexChanged(int index);
152 Ui::CoreConfigWizardStorageSelectionPage ui;
153 std::vector<QVariantMap> _backendProperties;
154 std::vector<std::vector<FieldInfo>> _backendFields;
157 class SyncPage : public QWizardPage
162 SyncPage(QWidget* parent = nullptr);
163 void initializePage() override;
164 int nextId() const override;
165 bool isComplete() const override;
168 void setStatus(const QString& status);
170 void setComplete(bool);
173 void setupCore(const QString& backend, const QVariantMap&, const QString& authenticator, const QVariantMap&);
176 Ui::CoreConfigWizardSyncPage ui;
177 bool _complete{false};
178 bool _hasError{false};
181 class SyncRelayPage : public QWizardPage
186 SyncRelayPage(QWidget* parent = nullptr);
187 int nextId() const override;
198 void startOver() const;
204 } // namespace CoreConfigWizardPages