// Method executed when the user ends the wizard, either with 'accept' or 'reject'. // accept the custom config to be the main one if Accepted. void OwncloudSetupWizard::slotAssistantFinished( int result ) { MirallConfigFile cfg( _configHandle ); if( result == QDialog::Rejected ) { // the old config remains valid. Remove the temporary one. cfg.cleanupCustomConfig(); qDebug() << "Rejected the new config, use the old!"; } else if( result == QDialog::Accepted ) { qDebug() << "Config Changes were accepted!"; // go through all folders and remove the journals if the server changed. MirallConfigFile prevCfg; QUrl prevUrl( prevCfg.ownCloudUrl() ); QUrl newUrl( cfg.ownCloudUrl() ); bool urlHasChanged = (prevUrl.host() != newUrl.host() || prevUrl.path() != newUrl.path()); // if the user changed, its also a changed url. if( prevCfg.ownCloudUser() != cfg.ownCloudUser() ) { urlHasChanged = true; qDebug() << "The User has changed, same as url change."; } const QString localFolder = _ocWizard->localFolder(); bool acceptCfg = true; if( urlHasChanged ) { _folderMan->unloadAllFolders(); bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool(); if( startFromScratch ) { // first try to rename (backup) the current local dir. bool renameOk = false; while( !renameOk ) { renameOk = _folderMan->startFromScratch(localFolder); if( ! renameOk ) { QMessageBox::StandardButton but; but = QMessageBox::question( 0, tr("Folder rename failed"), tr("Can't remove and back up the folder because the folder or a file in it is open in another program." "Please close the folder or file and hit retry or cancel the setup."), QMessageBox::Retry | QMessageBox::Abort, QMessageBox::Retry); if( but == QMessageBox::Abort ) { renameOk = true; acceptCfg = false; } } } } } // save the user credentials and afterwards clear the cred store. if( acceptCfg ) { cfg.acceptCustomConfig(); } // Now write the resulting folder definition if folder names are set. if( acceptCfg && urlHasChanged ) { _folderMan->removeAllFolderDefinitions(); _folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(), localFolder, _remoteFolder, false ); _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder)); } else { // url is unchanged. Only the password was changed. if( acceptCfg ) { qDebug() << "Only password was changed, no changes to folder configuration."; } else { qDebug() << "User interrupted change of configuration."; } } } // clear the custom config handle _configHandle.clear(); ownCloudInfo::instance()->setCustomConfigHandle( QString::null ); // notify others. emit ownCloudWizardDone( result ); }
// Method executed when the user ends the wizard, either with 'accept' or 'reject'. // accept the custom config to be the main one if Accepted. void OwncloudSetupWizard::slotAssistantFinished( int result ) { MirallConfigFile cfg( _configHandle ); if( result == QDialog::Rejected ) { // the old config remains valid. Remove the temporary one. cfg.cleanupCustomConfig(); qDebug() << "Rejected the new config, use the old!"; } else if( result == QDialog::Accepted ) { qDebug() << "Config Changes were accepted!"; // go through all folders and remove the journals if the server changed. MirallConfigFile prevCfg; QUrl prevUrl( prevCfg.ownCloudUrl() ); QUrl newUrl( cfg.ownCloudUrl() ); bool urlHasChanged = (prevUrl.host() != newUrl.host() || prevUrl.path() != newUrl.path()); // if the user changed, its also a changed url. if( prevCfg.ownCloudUser() != cfg.ownCloudUser() ) { urlHasChanged = true; qDebug() << "The User has changed, same as url change."; } // save the user credentials and afterwards clear the cred store. cfg.acceptCustomConfig(); // Now write the resulting folder definition if folder names are set. const QString localFolder = _ocWizard->localFolder(); if( !( localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set. if( urlHasChanged ) { _folderMan->removeAllFolderDefinitions(); _folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(), localFolder, _remoteFolder, false ); _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder)); bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool(); if( startFromScratch ) { // clean the entire directory. if( _folderMan->startFromScratch( localFolder ) ) { _ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully prepared syncing from scratch!</font>")); } else { _ocWizard->appendToConfigurationLog(tr("<font color=\"red\">Failed to prepare syncing from scratch!</font>")); } } } else { // url is unchanged. Only the password was changed. qDebug() << "Only password was changed, no changes to folder configuration."; } } } else { qDebug() << "WRN: Got unknown dialog result code " << result; } // clear the custom config handle _configHandle.clear(); ownCloudInfo::instance()->setCustomConfigHandle( QString::null ); // notify others. emit ownCloudWizardDone( result ); }