1/***************************************************************************
2 * Copyright (C) 2005-2014 by the Quassel Project *
3 * devel@quassel-irc.org *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21#ifndef _CORECONFIGWIZARD_H_
22#define _CORECONFIGWIZARD_H_
23
24#include <QHash>
25#include <QWizard>
26#include <QVariantMap>
27
28#include "ui_coreconfigwizardintropage.h"
29#include "ui_coreconfigwizardadminuserpage.h"
30#include "ui_coreconfigwizardstorageselectionpage.h"
31#include "ui_coreconfigwizardsyncpage.h"
32
33class CoreConnection;
34
35namespace CoreConfigWizardPages {
36class SyncPage;
37class SyncRelayPage;
38};
39
40class CoreConfigWizard : public QWizard
41{
42 Q_OBJECT
43
44public:
45 enum {
46 IntroPage,
47 AdminUserPage,
48 StorageSelectionPage,
49 SyncPage,
50 SyncRelayPage,
51 StorageDetailsPage,
52 ConclusionPage
53 };
54
55 CoreConfigWizard(CoreConnection *connection, const QList<QVariant> &backends, QWidget *parent = 0);
56 QHash<QString, QVariant> backends() const;
57
58 inline CoreConnection *coreConnection() const { return _connection; }
59
60signals:
61 void setupCore(const QVariant &setupData);
62 void loginToCore(const QString &user, const QString &password, bool rememberPassword);
63
64public slots:
65 void loginSuccess();
66 void syncFinished();
67
68private slots:
69 void prepareCoreSetup(const QString &backend, const QVariantMap &connectionProperties);
70 void coreSetupSuccess();
71 void coreSetupFailed(const QString &);
72 void startOver();
73
74private:
75 QHash<QString, QVariant> _backends;
76 CoreConfigWizardPages::SyncPage *syncPage;
77 CoreConfigWizardPages::SyncRelayPage *syncRelayPage;
78
79 CoreConnection *_connection;
80};
81
82
83namespace CoreConfigWizardPages {
84class IntroPage : public QWizardPage
85{
86 Q_OBJECT
87
88public:
89 IntroPage(QWidget *parent = 0);
90 int nextId() const;
91private:
92 Ui::CoreConfigWizardIntroPage ui;
93};
94
95
96class AdminUserPage : public QWizardPage
97{
98 Q_OBJECT
99
100public:
101 AdminUserPage(QWidget *parent = 0);
102 int nextId() const;
103 bool isComplete() const;
104private:
105 Ui::CoreConfigWizardAdminUserPage ui;
106};
107
108
109class StorageSelectionPage : public QWizardPage
110{
111 Q_OBJECT
112
113public:
114 StorageSelectionPage(const QHash<QString, QVariant> &backends, QWidget *parent = 0);
115 int nextId() const;
116 QString selectedBackend() const;
117 QVariantMap connectionProperties() const;
118
119private slots:
120 void on_backendList_currentIndexChanged();
121private:
122 Ui::CoreConfigWizardStorageSelectionPage ui;
123 QGroupBox *_connectionBox;
124 QHash<QString, QVariant> _backends;
125};
126
127
128class SyncPage : public QWizardPage
129{
130 Q_OBJECT
131
132public:
133 SyncPage(QWidget *parent = 0);
134 void initializePage();
135 int nextId() const;
136 bool isComplete() const;
137
138public slots:
139 void setStatus(const QString &status);
140 void setError(bool);
141 void setComplete(bool);
142
143signals:
144 void setupCore(const QString &backend, const QVariantMap &);
145
146private:
147 Ui::CoreConfigWizardSyncPage ui;
148 bool complete;
149 bool hasError;
150};
151
152
153class SyncRelayPage : public QWizardPage
154{
155 Q_OBJECT
156
157public:
158 SyncRelayPage(QWidget *parent = 0);
159 int nextId() const;
160 enum Mode { Success, Error };
161
162public slots:
163 void setMode(Mode);
164
165signals:
166 void startOver() const;
167
168private:
169 Mode mode;
170};
171}
172
173#endif
174