forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathowncloudwizard.cpp
More file actions
224 lines (185 loc) · 6.23 KB
/
Copy pathowncloudwizard.cpp
File metadata and controls
224 lines (185 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) by Krzesimir Nowak <krzesimir@endocode.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "mirall/account.h"
#include "mirall/mirallconfigfile.h"
#include "mirall/theme.h"
#include "wizard/owncloudwizard.h"
#include "wizard/owncloudsetuppage.h"
#include "wizard/owncloudhttpcredspage.h"
#include "wizard/owncloudshibbolethcredspage.h"
#include "wizard/owncloudadvancedsetuppage.h"
#include "wizard/owncloudwizardresultpage.h"
#include "QProgressIndicator.h"
#include <QtCore>
#include <QtGui>
#include <stdlib.h>
namespace Mirall
{
OwncloudWizard::OwncloudWizard(QWidget *parent)
: QWizard(parent),
_account(0),
_setupPage(new OwncloudSetupPage),
_httpCredsPage(new OwncloudHttpCredsPage),
_shibbolethCredsPage(new OwncloudShibbolethCredsPage),
_advancedSetupPage(new OwncloudAdvancedSetupPage),
_resultPage(new OwncloudWizardResultPage),
_credentialsPage(0),
_configFile(),
_oCUser(),
_setupLog(),
_configExists(false)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setPage(WizardCommon::Page_ServerSetup, _setupPage);
setPage(WizardCommon::Page_HttpCreds, _httpCredsPage);
setPage(WizardCommon::Page_ShibbolethCreds, _shibbolethCredsPage);
setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage);
setPage(WizardCommon::Page_Result, _resultPage);
connect(this, SIGNAL(finished(int)), SIGNAL(basicSetupFinished(int)));
// note: start Id is set by the calling class depending on if the
// welcome text is to be shown or not.
setWizardStyle( QWizard::ModernStyle );
connect( this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentPageChanged(int)));
connect( _setupPage, SIGNAL(determineAuthType(QString)), SIGNAL(determineAuthType(QString)));
connect( _httpCredsPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
connect( _shibbolethCredsPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
connect( _advancedSetupPage, SIGNAL(createLocalAndRemoteFolders(QString, QString)),
SIGNAL(createLocalAndRemoteFolders(QString, QString)));
Theme *theme = Theme::instance();
setWindowTitle( tr("%1 Connection Wizard").arg(theme->appNameGUI()));
setWizardStyle(QWizard::ModernStyle);
setPixmap( QWizard::BannerPixmap, theme->wizardHeaderBanner() );
setPixmap( QWizard::LogoPixmap, theme->wizardHeaderLogo() );
setOption( QWizard::NoBackButtonOnStartPage );
setOption( QWizard::NoBackButtonOnLastPage );
setOption( QWizard::NoCancelButton );
setTitleFormat(Qt::RichText);
setSubTitleFormat(Qt::RichText);
}
void OwncloudWizard::setAccount(Account *account)
{
_account = account;
}
Account *OwncloudWizard::account() const
{
return _account;
}
void OwncloudWizard::setMultipleFoldersExist(bool exist)
{
_advancedSetupPage->setMultipleFoldersExist(exist);
}
QString OwncloudWizard::localFolder() const
{
return(_advancedSetupPage->localFolder());
}
QString OwncloudWizard::ocUrl() const
{
QString url = field("OCUrl").toString().simplified();
return url;
}
void OwncloudWizard::enableFinishOnResultWidget(bool enable)
{
_resultPage->setComplete(enable);
}
void OwncloudWizard::setRemoteFolder( const QString& remoteFolder )
{
_advancedSetupPage->setRemoteFolder( remoteFolder );
_resultPage->setRemoteFolder( remoteFolder );
}
void OwncloudWizard::successfulStep()
{
const int id(currentId());
switch (id) {
case WizardCommon::Page_HttpCreds:
_httpCredsPage->setConnected(true);
break;
case WizardCommon::Page_ShibbolethCreds:
_shibbolethCredsPage->setConnected();
break;
case WizardCommon::Page_AdvancedSetup:
_advancedSetupPage->directoriesCreated();
break;
case WizardCommon::Page_ServerSetup:
case WizardCommon::Page_Result:
qWarning("Should not happen at this stage.");
break;
}
next();
}
void OwncloudWizard::setAuthType(WizardCommon::AuthType type)
{
_setupPage->setAuthType(type);
if (type == WizardCommon::Shibboleth) {
_credentialsPage = _shibbolethCredsPage;
} else {
_credentialsPage = _httpCredsPage;
}
next();
}
// TODO: update this function
void OwncloudWizard::slotCurrentPageChanged( int id )
{
qDebug() << "Current Wizard page changed to " << id;
if( id == WizardCommon::Page_ServerSetup ) {
emit clearPendingRequests();
}
if( id == WizardCommon::Page_Result ) {
disconnect(this, SIGNAL(finished(int)), this, SIGNAL(basicSetupFinished(int)));
emit basicSetupFinished(QDialog::Accepted);
appendToConfigurationLog( QString::null );
}
}
void OwncloudWizard::displayError( const QString& msg )
{
switch (currentId()) {
case WizardCommon::Page_ServerSetup:
_setupPage->setErrorString( msg );
break;
case WizardCommon::Page_HttpCreds:
_httpCredsPage->setErrorString(msg);
break;
case WizardCommon::Page_AdvancedSetup:
_advancedSetupPage->setErrorString(msg);
break;
}
}
void OwncloudWizard::appendToConfigurationLog( const QString& msg, LogType /*type*/ )
{
_setupLog << msg;
qDebug() << "Setup-Log: " << msg;
}
void OwncloudWizard::setOCUrl( const QString& url )
{
_setupPage->setServerUrl( url );
}
void OwncloudWizard::setConfigExists( bool config )
{
_configExists = config;
_setupPage->setConfigExists( config );
_httpCredsPage->setConfigExists(config);
_advancedSetupPage->setConfigExists(config);
}
bool OwncloudWizard::configExists()
{
return _configExists;
}
AbstractCredentials* OwncloudWizard::getCredentials() const
{
if (_credentialsPage) {
return _credentialsPage->getCredentials();
}
return 0;
}
} // end namespace