1 /***************************************************************************
2 * Copyright (C) 2005-2016 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 {
42 class CoreConfigWizard : public QWizard
50 AuthenticationSelectionPage,
58 CoreConfigWizard(CoreConnection *connection, const QVariantList &backendInfos, const QVariantList &authInfos, QWidget *parent = 0);
60 inline CoreConnection *coreConnection() const { return _connection; }
63 void setupCore(const QVariant &setupData);
64 void loginToCore(const QString &user, const QString &password, bool rememberPassword);
71 void prepareCoreSetup(const QString &backend, const QVariantMap &properties, const QString &authenticator, const QVariantMap &authProperties);
72 void coreSetupSuccess();
73 void coreSetupFailed(const QString &);
77 CoreConfigWizardPages::SyncPage *syncPage;
78 CoreConfigWizardPages::SyncRelayPage *syncRelayPage;
80 CoreConnection *_connection;
84 namespace CoreConfigWizardPages {
85 class IntroPage : public QWizardPage
90 IntroPage(QWidget *parent = 0);
93 Ui::CoreConfigWizardIntroPage ui;
97 class AdminUserPage : public QWizardPage
102 AdminUserPage(QWidget *parent = 0);
104 bool isComplete() const;
106 Ui::CoreConfigWizardAdminUserPage ui;
109 // Authentication selection before storage selection.
110 class AuthenticationSelectionPage : public QWizardPage
113 using FieldInfo = std::tuple<QString, QString, QVariant>;
116 AuthenticationSelectionPage(const QVariantList &authInfos, QWidget *parent = 0);
118 QString displayName() const;
119 QString authenticator() const;
120 QVariantMap authProperties() const;
123 void on_backendList_currentIndexChanged(int index);
126 Ui::CoreConfigWizardAuthenticationSelectionPage ui;
127 QGroupBox *_fieldBox {nullptr};
128 std::vector<QVariantMap> _authProperties;
129 std::vector<std::vector<FieldInfo>> _authFields;
132 class StorageSelectionPage : public QWizardPage
135 using FieldInfo = std::tuple<QString, QString, QVariant>;
138 StorageSelectionPage(const QVariantList &backendInfos, QWidget *parent = 0);
140 QString displayName() const;
141 QString backend() const;
142 QVariantMap backendProperties() const;
145 void on_backendList_currentIndexChanged(int index);
148 Ui::CoreConfigWizardStorageSelectionPage ui;
149 QGroupBox *_fieldBox {nullptr};
150 std::vector<QVariantMap> _backendProperties;
151 std::vector<std::vector<FieldInfo>> _backendFields;
154 class SyncPage : public QWizardPage
159 SyncPage(QWidget *parent = 0);
160 void initializePage();
162 bool isComplete() const;
165 void setStatus(const QString &status);
167 void setComplete(bool);
170 void setupCore(const QString &backend, const QVariantMap &, const QString &authenticator, const QVariantMap &);
173 Ui::CoreConfigWizardSyncPage ui;
174 bool _complete {false};
175 bool _hasError {false};
179 class SyncRelayPage : public QWizardPage
184 SyncRelayPage(QWidget *parent = 0);
186 enum Mode { Success, Error };
192 void startOver() const;