@@ -42,7 +42,6 @@ namespace OCC {
42
42
OwncloudSetupWizard::OwncloudSetupWizard (QWidget *parent)
43
43
: QObject(parent)
44
44
, _ocWizard(new OwncloudWizard(parent))
45
- , _remoteFolder()
46
45
{
47
46
connect (_ocWizard, &OwncloudWizard::determineAuthType,
48
47
this , &OwncloudSetupWizard::slotCheckServer);
@@ -55,7 +54,7 @@ OwncloudSetupWizard::OwncloudSetupWizard(QWidget *parent)
55
54
Therefore Qt::QueuedConnection is required */
56
55
connect (_ocWizard, &OwncloudWizard::basicSetupFinished,
57
56
this , &OwncloudSetupWizard::slotAssistantFinished, Qt::QueuedConnection);
58
- connect (_ocWizard, &QDialog ::finished, this , &QObject::deleteLater);
57
+ connect (_ocWizard, &OwncloudWizard ::finished, this , &QObject::deleteLater);
59
58
}
60
59
61
60
OwncloudSetupWizard::~OwncloudSetupWizard ()
@@ -71,28 +70,6 @@ void OwncloudSetupWizard::startWizard()
71
70
_ocWizard->setAccount (account);
72
71
_ocWizard->setOCUrl (account->url ().toString ());
73
72
74
- _remoteFolder = Theme::instance ()->defaultServerFolder ();
75
- // remoteFolder may be empty, which means /
76
- QString localFolder = Theme::instance ()->defaultClientFolder ();
77
-
78
- // if its a relative path, prepend with users home dir, otherwise use as absolute path
79
-
80
- if (!QDir (localFolder).isAbsolute ()) {
81
- localFolder = QDir::homePath () + QDir::separator () + localFolder;
82
- }
83
-
84
- _ocWizard->setProperty (" localFolder" , localFolder);
85
-
86
- // remember the local folder to compare later if it changed, but clean first
87
- QString lf = QDir::fromNativeSeparators (localFolder);
88
- if (!lf.endsWith (QLatin1Char (' /' ))) {
89
- lf.append (QLatin1Char (' /' ));
90
- }
91
-
92
- _initLocalFolder = lf;
93
-
94
- _ocWizard->setRemoteFolder (_remoteFolder);
95
-
96
73
_ocWizard->setStartId (WizardCommon::Page_ServerSetup);
97
74
98
75
_ocWizard->restart ();
@@ -269,33 +246,33 @@ void OwncloudSetupWizard::testOwnCloudConnect()
269
246
job->checkServerAndUpdate ();
270
247
}
271
248
272
- void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders (const QString &localFolder, const QString &remoteFolder )
249
+ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders ()
273
250
{
274
- qCInfo (lcWizard) << " Setup local sync folder for new oC connection " << localFolder;
275
- const QDir fi (localFolder);
251
+ qCInfo (lcWizard) << " Setup local sync folder for new oC connection " << _ocWizard-> localFolder () ;
252
+ const QDir fi (_ocWizard-> localFolder () );
276
253
277
254
bool nextStep = true ;
278
255
if (fi.exists ()) {
279
- FileSystem::setFolderMinimumPermissions (localFolder);
280
- Utility::setupFavLink (localFolder);
256
+ FileSystem::setFolderMinimumPermissions (_ocWizard-> localFolder () );
257
+ Utility::setupFavLink (_ocWizard-> localFolder () );
281
258
// there is an existing local folder. If its non empty, it can only be synced if the
282
259
// ownCloud is newly created.
283
- qCDebug (lcWizard) << " Local sync folder" << localFolder << " already exists, setting it up for sync." ;
260
+ qCDebug (lcWizard) << " Local sync folder" << _ocWizard-> localFolder () << " already exists, setting it up for sync." ;
284
261
} else {
285
262
bool ok = true ;
286
- if (fi.mkpath (localFolder)) {
287
- FileSystem::setFolderMinimumPermissions (localFolder);
288
- Utility::setupFavLink (localFolder);
263
+ if (fi.mkpath (_ocWizard-> localFolder () )) {
264
+ FileSystem::setFolderMinimumPermissions (_ocWizard-> localFolder () );
265
+ Utility::setupFavLink (_ocWizard-> localFolder () );
289
266
} else {
290
267
ok = false ;
291
268
qCWarning (lcWizard) << " Failed to create " << fi.path ();
292
- _ocWizard->displayError (tr (" Could not create local folder %1" ).arg (Utility::escape (localFolder)));
269
+ _ocWizard->displayError (tr (" Could not create local folder %1" ).arg (Utility::escape (_ocWizard-> localFolder () )));
293
270
nextStep = false ;
294
271
}
295
- qCDebug (lcWizard) << " Creating local sync folder" << localFolder << " success:" << ok;
272
+ qCDebug (lcWizard) << " Creating local sync folder" << _ocWizard-> localFolder () << " success:" << ok;
296
273
}
297
274
if (nextStep) {
298
- EntityExistsJob *job = new EntityExistsJob (_ocWizard->account (), Utility::concatUrlPath (_ocWizard->account ()->davPath (), remoteFolder).path (), this );
275
+ EntityExistsJob *job = new EntityExistsJob (_ocWizard->account (), Utility::concatUrlPath (_ocWizard->account ()->davPath (), _ocWizard-> remoteFolder () ).path (), this );
299
276
connect (job, &EntityExistsJob::exists, this , &OwncloudSetupWizard::slotRemoteFolderExists);
300
277
job->start ();
301
278
} else {
@@ -314,12 +291,7 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
314
291
if (errId == QNetworkReply::NoError) {
315
292
qCInfo (lcWizard) << " Remote folder found, all cool!" ;
316
293
} else if (errId == QNetworkReply::ContentNotFoundError) {
317
- if (_remoteFolder.isEmpty ()) {
318
- error = tr (" No remote folder specified!" );
319
- ok = false ;
320
- } else {
321
- createRemoteFolder ();
322
- }
294
+ createRemoteFolder ();
323
295
} else {
324
296
error = tr (" Error: %1" ).arg (job->errorString ());
325
297
ok = false ;
@@ -334,12 +306,12 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
334
306
335
307
void OwncloudSetupWizard::createRemoteFolder ()
336
308
{
337
- qCDebug (lcWizard) << " creating folder on ownCloud:" << _remoteFolder ;
309
+ qCDebug (lcWizard) << " creating folder on ownCloud:" << _ocWizard-> remoteFolder () ;
338
310
339
- MkColJob *job = new MkColJob (_ocWizard->account (), _remoteFolder , this );
311
+ MkColJob *job = new MkColJob (_ocWizard->account (), _ocWizard-> remoteFolder () , this );
340
312
connect (job, &MkColJob::finishedWithError, this , &OwncloudSetupWizard::slotCreateRemoteFolderFinished);
341
313
connect (job, &MkColJob::finishedWithoutError, this , [this ] {
342
- qCDebug (lcWizard) << " Remote folder" << _remoteFolder << " created successfully." ;
314
+ qCDebug (lcWizard) << " Remote folder" << _ocWizard-> remoteFolder () << " created successfully." ;
343
315
finalizeSetup (true );
344
316
});
345
317
job->start ();
@@ -349,12 +321,10 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
349
321
{
350
322
auto error = reply->error ();
351
323
qCDebug (lcWizard) << " ** webdav mkdir request finished " << error;
352
- // disconnect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
353
- // this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
354
324
355
325
bool success = true ;
356
326
if (error == 202 ) {
357
- qCDebug (lcWizard) << " The remote folder" << _remoteFolder << " already exists. Connecting it for syncing." ;
327
+ qCDebug (lcWizard) << " The remote folder" << _ocWizard-> remoteFolder () << " already exists. Connecting it for syncing." ;
358
328
} else if (error > 202 && error < 300 ) {
359
329
_ocWizard->displayError (tr (" The folder creation resulted in HTTP error code %1" ).arg ((int )error));
360
330
@@ -364,12 +334,12 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
364
334
" are wrong!"
365
335
" <br/>Please go back and check your credentials.</p>" ));
366
336
qCDebug (lcWizard) << " Remote folder creation failed probably because the provided credentials are wrong. Please go back and check your credentials." ;
367
- _remoteFolder. clear ();
337
+ _ocWizard-> resetRemoteFolder ();
368
338
success = false ;
369
339
} else {
370
- qCDebug (lcWizard) << " Remote folder" << _remoteFolder << " creation failed with error" << error;
371
- _ocWizard->displayError (tr (" Remote folder %1 creation failed with error <tt>%2</tt>." ).arg (Utility::escape (_remoteFolder )).arg (error));
372
- _remoteFolder. clear ();
340
+ qCDebug (lcWizard) << " Remote folder" << _ocWizard-> remoteFolder () << " creation failed with error" << error;
341
+ _ocWizard->displayError (tr (" Remote folder %1 creation failed with error <tt>%2</tt>." ).arg (Utility::escape (_ocWizard-> remoteFolder () )).arg (error));
342
+ _ocWizard-> resetRemoteFolder ();
373
343
success = false ;
374
344
}
375
345
@@ -378,11 +348,9 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
378
348
379
349
void OwncloudSetupWizard::finalizeSetup (bool success)
380
350
{
381
- const QString localFolder = _ocWizard->property ( " localFolder" ). toString ();
351
+ const QString localFolder = _ocWizard->localFolder ();
382
352
if (success) {
383
- if (!(localFolder.isEmpty () || _remoteFolder.isEmpty ())) {
384
- qCDebug (lcWizard) << " A sync connection from" << localFolder << " to remote directory" << _remoteFolder << " was set up." ;
385
- }
353
+ qCDebug (lcWizard) << " A sync connection from" << localFolder << " to remote directory" << _ocWizard->remoteFolder () << " was set up." ;
386
354
qCDebug (lcWizard) << " Successfully connected" ;
387
355
_ocWizard->successfulStep ();
388
356
} else {
@@ -426,10 +394,10 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
426
394
427
395
bool startFromScratch = _ocWizard->field (" OCSyncFromScratch" ).toBool ();
428
396
if (!startFromScratch || ensureStartFromScratch (localFolder)) {
429
- qCInfo (lcWizard) << " Adding folder definition for" << localFolder << _remoteFolder ;
397
+ qCInfo (lcWizard) << " Adding folder definition for" << localFolder << _ocWizard-> remoteFolder () ;
430
398
FolderDefinition folderDefinition;
431
399
folderDefinition.localPath = localFolder;
432
- folderDefinition.targetPath = FolderDefinition::prepareTargetPath (_remoteFolder );
400
+ folderDefinition.targetPath = FolderDefinition::prepareTargetPath (_ocWizard-> remoteFolder () );
433
401
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles ();
434
402
if (_ocWizard->useVirtualFileSync ()) {
435
403
folderDefinition.virtualFilesMode = bestAvailableVfsMode ();
0 commit comments