1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 ***************************************************************************/
27 #include <QVariantMap>
29 #include "ui_coreconfigwizardintropage.h"
30 #include "ui_coreconfigwizardadminuserpage.h"
31 #include "ui_coreconfigwizardauthenticationselectionpage.h"
32 #include "ui_coreconfigwizardstorageselectionpage.h"
33 #include "ui_coreconfigwizardsyncpage.h"
37 namespace CoreConfigWizardPages {
44 class CoreConfigWizard : public QWizard
52 AuthenticationSelectionPage,
60 CoreConfigWizard(CoreConnection *connection, const QVariantList &backendInfos, const QVariantList &authInfos, QWidget *parent = 0);
62 inline CoreConnection *coreConnection() const { return _connection; }
65 void setupCore(const QVariant &setupData);
66 void loginToCore(const QString &user, const QString &password, bool rememberPassword);
72 void prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authenticator, const QVariantMap &authProperties);
73 void coreSetupSuccess();
74 void coreSetupFailed(const QString &);
78 CoreConfigWizardPages::SyncPage *syncPage;
79 CoreConfigWizardPages::SyncRelayPage *syncRelayPage;
81 CoreConnection *_connection;
85 namespace CoreConfigWizardPages {
87 class IntroPage : public QWizardPage
92 IntroPage(QWidget *parent = 0);
95 Ui::CoreConfigWizardIntroPage ui;
99 class AdminUserPage : public QWizardPage
104 AdminUserPage(QWidget *parent = 0);
106 bool isComplete() const;
108 Ui::CoreConfigWizardAdminUserPage ui;
112 class AuthenticationSelectionPage : public QWizardPage
115 using FieldInfo = std::tuple<QString, QString, QVariant>;
118 AuthenticationSelectionPage(const QVariantList &authInfos, QWidget *parent = 0);
120 QString displayName() const;
121 QString authenticator() const;
122 QVariantMap authProperties() const;
125 void on_backendList_currentIndexChanged(int index);
128 Ui::CoreConfigWizardAuthenticationSelectionPage ui;
129 std::vector<QVariantMap> _authProperties;
130 std::vector<std::vector<FieldInfo>> _authFields;
134 class StorageSelectionPage : public QWizardPage
137 using FieldInfo = std::tuple<QString, QString, QVariant>;
140 StorageSelectionPage(const QVariantList &backendInfos, QWidget *parent = 0);
142 QString displayName() const;
143 QString backend() const;
144 QVariantMap backendProperties() const;
147 void on_backendList_currentIndexChanged(int index);
150 Ui::CoreConfigWizardStorageSelectionPage ui;
151 std::vector<QVariantMap> _backendProperties;
152 std::vector<std::vector<FieldInfo>> _backendFields;
156 class SyncPage : public QWizardPage
161 SyncPage(QWidget *parent = 0);
162 void initializePage();
164 bool isComplete() const;
167 void setStatus(const QString &status);
169 void setComplete(bool);
172 void setupCore(const QString &backend, const QVariantMap &, const QString &authenticator, const QVariantMap &);
175 Ui::CoreConfigWizardSyncPage ui;
176 bool _complete {false};
177 bool _hasError {false};
181 class SyncRelayPage : public QWizardPage
186 SyncRelayPage(QWidget *parent = 0);
188 enum Mode { Success, Error };
194 void startOver() const;