mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
New setup dialog, simplified version.
This commit is contained in:
parent
5aa8f5bc01
commit
c848ff4bdb
@ -194,7 +194,7 @@ void Application::slotStartFolderSetup( int result )
|
||||
|
||||
ownCloudInfo::instance()->checkInstallation();
|
||||
} else {
|
||||
_owncloudSetupWizard->startWizard(true); // with intro
|
||||
_owncloudSetupWizard->startWizard();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Setup Wizard was canceled. No reparsing of config.";
|
||||
@ -813,7 +813,7 @@ void Application::slotEnableFolder(const QString& alias, const bool enable)
|
||||
void Application::slotConfigure()
|
||||
{
|
||||
_folderMan->setSyncEnabled(false); // do not start more syncs.
|
||||
_owncloudSetupWizard->startWizard(false);
|
||||
_owncloudSetupWizard->startWizard();
|
||||
}
|
||||
|
||||
void Application::slotConfigureProxy()
|
||||
|
||||
@ -124,7 +124,7 @@ public slots:
|
||||
protected slots:
|
||||
void slotReplyFinished( );
|
||||
void slotError( QNetworkReply::NetworkError );
|
||||
void slotAuthentication( QNetworkReply*, QAuthenticator *);
|
||||
// void slotAuthentication( QNetworkReply*, QAuthenticator *);
|
||||
|
||||
#if QT46_IMPL
|
||||
void qhttpRequestFinished(int id, bool success );
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include <QtCore>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "mirall/owncloudsetupwizard.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/owncloudinfo.h"
|
||||
@ -19,11 +24,6 @@
|
||||
#include "mirall/credentialstore.h"
|
||||
#include "mirall/utility.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class Theme;
|
||||
@ -34,28 +34,7 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
|
||||
_checkInstallationRequest(0),
|
||||
_folderMan(folderMan)
|
||||
{
|
||||
_process = new QProcess( this );
|
||||
|
||||
QObject::connect(_process, SIGNAL(readyReadStandardOutput()),
|
||||
SLOT(slotReadyReadStandardOutput()));
|
||||
|
||||
QObject::connect(_process, SIGNAL(readyReadStandardError()),
|
||||
SLOT(slotReadyReadStandardError()));
|
||||
|
||||
QObject::connect(_process, SIGNAL(stateChanged(QProcess::ProcessState)),
|
||||
SLOT(slotStateChanged(QProcess::ProcessState)));
|
||||
|
||||
QObject::connect(_process, SIGNAL(error(QProcess::ProcessError)),
|
||||
SLOT(slotError(QProcess::ProcessError)));
|
||||
|
||||
QObject::connect(_process, SIGNAL(started()),
|
||||
SLOT(slotStarted()));
|
||||
|
||||
QObject::connect(_process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
SLOT(slotProcessFinished(int, QProcess::ExitStatus)));
|
||||
|
||||
|
||||
_ocWizard = new OwncloudWizard();
|
||||
_ocWizard = new OwncloudWizard;
|
||||
|
||||
connect( _ocWizard, SIGNAL(connectToOCUrl( const QString& ) ),
|
||||
this, SLOT(slotConnectToOCUrl( const QString& )));
|
||||
@ -63,14 +42,8 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
|
||||
connect( _ocWizard, SIGNAL(installOCServer()),
|
||||
this, SLOT(slotInstallOCServer()));
|
||||
|
||||
connect( _ocWizard, SIGNAL(installOCLocalhost()),
|
||||
this, SLOT(slotCreateOCLocalhost()));
|
||||
|
||||
connect( _ocWizard, SIGNAL(finished(int)),this,SLOT(slotAssistantFinished(int)));
|
||||
|
||||
// in case of cancel, terminate the owncloud-admin script.
|
||||
connect( _ocWizard, SIGNAL(rejected()), _process, SLOT(terminate()));
|
||||
|
||||
connect( _ocWizard, SIGNAL(clearPendingRequests()),
|
||||
this, SLOT(slotClearPendingRequests()));
|
||||
|
||||
@ -80,7 +53,11 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
|
||||
|
||||
OwncloudSetupWizard::~OwncloudSetupWizard()
|
||||
{
|
||||
// delete _ocWizard; FIXME: this crashes!
|
||||
}
|
||||
|
||||
OwncloudWizard *OwncloudSetupWizard::wizard() {
|
||||
return _ocWizard;
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::startWizard()
|
||||
@ -97,10 +74,17 @@ void OwncloudSetupWizard::startWizard()
|
||||
_ocWizard->setOCUser( user );
|
||||
}
|
||||
|
||||
QString d( QDir::homePath()+QLatin1Char('/')+Theme::instance()->defaultClientFolder() );
|
||||
_remoteFolder = Theme::instance()->defaultServerFolder();
|
||||
// remoteFolder may be empty, which means /
|
||||
|
||||
_localFolder = Theme::instance()->defaultClientFolder();
|
||||
|
||||
// if its a relative path, prepend with users home dir, otherwise use as absolute path
|
||||
if( !_localFolder.startsWith(QLatin1Char('/')) ) {
|
||||
_localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder();
|
||||
}
|
||||
_ocWizard->setFolderNames(_localFolder, _remoteFolder);
|
||||
|
||||
QString localPath = QDir::toNativeSeparators(d);
|
||||
_ocWizard->setLocalFolder( localPath );
|
||||
_ocWizard->setStartId(OwncloudWizard::Page_oCSetup);
|
||||
|
||||
_ocWizard->restart();
|
||||
@ -137,7 +121,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
|
||||
if( _folderMan ) {
|
||||
_folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(),
|
||||
_localFolder, _remoteFolder, false );
|
||||
_ocWizard->appendToResultWidget(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(_localFolder));
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(_localFolder));
|
||||
} else {
|
||||
qDebug() << "WRN: Folderman is zero in Setup Wizzard.";
|
||||
}
|
||||
@ -158,7 +142,7 @@ void OwncloudSetupWizard::slotConnectToOCUrl( const QString& url )
|
||||
{
|
||||
qDebug() << "Connect to url: " << url;
|
||||
_ocWizard->setField(QLatin1String("OCUrl"), url );
|
||||
_ocWizard->appendToResultWidget(tr("Trying to connect to %1 at %2...")
|
||||
_ocWizard->appendToConfigurationLog(tr("Trying to connect to %1 at %2...")
|
||||
.arg( Theme::instance()->appNameGUI() ).arg(url) );
|
||||
testOwnCloudConnect();
|
||||
}
|
||||
@ -174,22 +158,39 @@ void OwncloudSetupWizard::slotClearPendingRequests()
|
||||
qDebug() << "ABORTing pending check installation request.";
|
||||
_checkInstallationRequest->abort();
|
||||
}
|
||||
if( _checkRemoteFolderRequest && _checkRemoteFolderRequest->isRunning() ) {
|
||||
qDebug() << "ABORTing pending remote folder check request.";
|
||||
_checkRemoteFolderRequest->abort();
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::testOwnCloudConnect()
|
||||
{
|
||||
// write a temporary config.
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
|
||||
// remove a possibly existing custom config.
|
||||
if( ! _configHandle.isEmpty() ) {
|
||||
// remove the old config file.
|
||||
MirallConfigFile oldConfig( _configHandle );
|
||||
oldConfig.cleanupCustomConfig();
|
||||
}
|
||||
|
||||
_configHandle = now.toString(QLatin1String("MMddyyhhmmss"));
|
||||
|
||||
MirallConfigFile cfgFile( _configHandle );
|
||||
|
||||
QString url = _ocWizard->field(QLatin1String("OCUrl")).toString();
|
||||
if( url.isEmpty() ) return;
|
||||
if( !( url.startsWith(QLatin1String("https://")) || url.startsWith(QLatin1String("http://"))) ) {
|
||||
qDebug() << "url does not start with a valid protocol, assuming https.";
|
||||
url.prepend(QLatin1String("https://"));
|
||||
// FIXME: give a hint about the auto completion
|
||||
_ocWizard->setOCUrl(url);
|
||||
}
|
||||
cfgFile.writeOwncloudConfig( Theme::instance()->appName(),
|
||||
_ocWizard->field(QLatin1String("OCUrl")).toString(),
|
||||
url,
|
||||
_ocWizard->field(QLatin1String("OCUser")).toString(),
|
||||
_ocWizard->field(QLatin1String("OCPasswd")).toString(),
|
||||
_ocWizard->field(QLatin1String("secureConnect")).toBool(),
|
||||
_ocWizard->field(QLatin1String("PwdNoLocalStore")).toBool() );
|
||||
_ocWizard->field(QLatin1String("OCPasswd")).toString() );
|
||||
|
||||
// If there is already a config, take its proxy config.
|
||||
if( ownCloudInfo::instance()->isConfigured() ) {
|
||||
@ -206,6 +207,10 @@ void OwncloudSetupWizard::testOwnCloudConnect()
|
||||
if( info->isConfigured() ) {
|
||||
// reset the SSL Untrust flag to let the SSL dialog appear again.
|
||||
info->resetSSLUntrust();
|
||||
connect(info, SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
||||
connect(info, SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
||||
_checkInstallationRequest = info->checkInstallation();
|
||||
} else {
|
||||
qDebug() << " ownCloud seems not to be configured, can not start test connect.";
|
||||
@ -214,7 +219,12 @@ void OwncloudSetupWizard::testOwnCloudConnect()
|
||||
|
||||
void OwncloudSetupWizard::slotOwnCloudFound( const QString& url, const QString& infoString, const QString& version, const QString& )
|
||||
{
|
||||
_ocWizard->appendToResultWidget(tr("<font color=\"green\">Successfully connected to %1: %2 version %3 (%4)</font><br/><br/>")
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
||||
|
||||
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully connected to %1: %2 version %3 (%4)</font><br/><br/>")
|
||||
.arg( url ).arg(Theme::instance()->appNameGUI()).arg(infoString).arg(version));
|
||||
|
||||
// enable the finish button.
|
||||
@ -226,9 +236,13 @@ void OwncloudSetupWizard::slotOwnCloudFound( const QString& url, const QString&
|
||||
|
||||
void OwncloudSetupWizard::slotNoOwnCloudFound( QNetworkReply *err )
|
||||
{
|
||||
_ocWizard->appendToResultWidget(tr("<font color=\"red\">Failed to connect to %1!</font>")
|
||||
.arg(Theme::instance()->appNameGUI()));
|
||||
_ocWizard->appendToResultWidget(tr("Error: <tt>%1</tt>").arg(err->errorString()) );
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
||||
this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
|
||||
this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
||||
|
||||
_ocWizard->displayError(tr("Failed to connect to %1:<br/>%2").
|
||||
arg(Theme::instance()->appNameGUI()).arg(err->errorString()));
|
||||
|
||||
// remove the config file again
|
||||
MirallConfigFile cfgFile( _configHandle );
|
||||
@ -236,197 +250,8 @@ void OwncloudSetupWizard::slotNoOwnCloudFound( QNetworkReply *err )
|
||||
finalizeSetup( false );
|
||||
}
|
||||
|
||||
bool OwncloudSetupWizard::isBusy()
|
||||
{
|
||||
return _process->state() > 0;
|
||||
}
|
||||
|
||||
OwncloudWizard *OwncloudSetupWizard::wizard()
|
||||
{
|
||||
return _ocWizard;
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotCreateOCLocalhost()
|
||||
{
|
||||
if( isBusy() ) {
|
||||
qDebug() << "Can not install now, busy. Come back later.";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Install OC on localhost";
|
||||
|
||||
QStringList args;
|
||||
|
||||
args << QLatin1String("install");
|
||||
args << QLatin1String("--server-type") << QLatin1String("local");
|
||||
args << QLatin1String("--root_helper") << QLatin1String("kdesu -c");
|
||||
|
||||
const QString adminUser = _ocWizard->field(QLatin1String("OCUser")).toString();
|
||||
const QString adminPwd = _ocWizard->field(QLatin1String("OCPasswd")).toString();
|
||||
|
||||
args << QLatin1String("--admin-user") << adminUser;
|
||||
args << QLatin1String("--admin-password") << adminPwd;
|
||||
|
||||
runOwncloudAdmin( args );
|
||||
|
||||
// define
|
||||
_ocWizard->setField( QLatin1String("OCUrl"), QLatin1String( "http://localhost/owncloud/") );
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotInstallOCServer()
|
||||
{
|
||||
if( isBusy() ) {
|
||||
qDebug() << "Can not install now, busy. Come back later.";
|
||||
return;
|
||||
}
|
||||
|
||||
const QString server = _ocWizard->field(QLatin1String("ftpUrl")).toString();
|
||||
const QString user = _ocWizard->field(QLatin1String("ftpUser")).toString();
|
||||
const QString passwd = _ocWizard->field(QLatin1String("ftpPasswd")).toString();
|
||||
const QString adminUser = _ocWizard->field(QLatin1String("OCUser")).toString();
|
||||
const QString adminPwd = _ocWizard->field(QLatin1String("OCPasswd")).toString();
|
||||
|
||||
qDebug() << "Install OC on " << server << " as user " << user;
|
||||
|
||||
QStringList args;
|
||||
args << QLatin1String("install");
|
||||
args << QLatin1String("--server-type") << QLatin1String("ftp");
|
||||
args << QLatin1String("--server") << server;
|
||||
args << QLatin1String("--ftp-user") << user;
|
||||
if( ! passwd.isEmpty() ) {
|
||||
args << QLatin1String("--ftp-password") << passwd;
|
||||
}
|
||||
args << QLatin1String("--admin-user") << adminUser;
|
||||
args << QLatin1String("--admin-password") << adminPwd;
|
||||
|
||||
runOwncloudAdmin( args );
|
||||
_ocWizard->setField( QLatin1String("OCUrl"), QString::fromLatin1( "%1/owncloud/")
|
||||
.arg(_ocWizard->field(QLatin1String("myOCDomain")).toString() ));
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::runOwncloudAdmin( const QStringList& args )
|
||||
{
|
||||
const QString bin(QLatin1String("/usr/bin/owncloud-admin"));
|
||||
qDebug() << "starting " << bin << " with args. " << args;
|
||||
if( _process->state() != QProcess::NotRunning ) {
|
||||
qDebug() << "Owncloud admin is still running, skip!";
|
||||
return;
|
||||
}
|
||||
if( checkOwncloudAdmin( bin )) {
|
||||
_ocWizard->appendToResultWidget( tr("Starting script owncloud-admin...") );
|
||||
_process->start( bin, args );
|
||||
} else {
|
||||
slotProcessFinished( 1, QProcess::NormalExit );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OwncloudSetupWizard::slotReadyReadStandardOutput()
|
||||
{
|
||||
QByteArray arr = _process->readAllStandardOutput();
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
// render the output to status line
|
||||
QString string = codec->toUnicode( arr );
|
||||
_ocWizard->appendToResultWidget( string, OwncloudWizard::LogPlain );
|
||||
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotReadyReadStandardError()
|
||||
{
|
||||
qDebug() << "!! " <<_process->readAllStandardError();
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotStateChanged( QProcess::ProcessState )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotError( QProcess::ProcessError err )
|
||||
{
|
||||
qDebug() << "An Error happend with owncloud-admin: " << err << ", exit-Code: " << _process->exitCode();
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotStarted()
|
||||
{
|
||||
_ocWizard->button( QWizard::FinishButton )->setEnabled( false );
|
||||
_ocWizard->button( QWizard::BackButton )->setEnabled( false );
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void OwncloudSetupWizard::slotProcessFinished( int res, QProcess::ExitStatus )
|
||||
{
|
||||
_ocWizard->button( QWizard::FinishButton )->setEnabled( true );
|
||||
_ocWizard->button( QWizard::BackButton)->setEnabled( true );
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
qDebug() << "exit code: " << res;
|
||||
if( res ) {
|
||||
_ocWizard->appendToResultWidget( tr("<font color=\"red\">Installation of %1 failed!</font>").arg(Theme::instance()->appNameGUI()));
|
||||
_ocWizard->showOCUrlLabel( false );
|
||||
emit ownCloudSetupFinished( false );
|
||||
} else {
|
||||
// Successful installation. Write the config.
|
||||
_ocWizard->appendToResultWidget( tr("<font color=\"green\">Installation of %1 succeeded!</font>").arg(Theme::instance()->appNameGUI()));
|
||||
_ocWizard->showOCUrlLabel( true );
|
||||
|
||||
testOwnCloudConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::startWizard(bool intro)
|
||||
{
|
||||
// create the ocInfo object
|
||||
connect(ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
||||
connect(ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
||||
connect(ownCloudInfo::instance(),SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
|
||||
|
||||
MirallConfigFile cfgFile;
|
||||
|
||||
QString url = cfgFile.ownCloudUrl();
|
||||
if( !url.isEmpty() ) {
|
||||
_ocWizard->setOCUrl( url );
|
||||
}
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
QString user = cfgFile.ownCloudUser();
|
||||
if( !user.isEmpty() ) {
|
||||
_ocWizard->setOCUser( user );
|
||||
}
|
||||
|
||||
bool doStore = cfgFile.passwordStorageAllowed();
|
||||
_ocWizard->setAllowPasswordStorage( doStore );
|
||||
|
||||
if (intro)
|
||||
_ocWizard->setStartId(OwncloudWizard::Page_oCWelcome);
|
||||
else
|
||||
_ocWizard->setStartId(OwncloudWizard::Page_oCSetup);
|
||||
#endif
|
||||
_ocWizard->restart();
|
||||
_ocWizard->show();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* method to check the if the owncloud admin script is existing
|
||||
*/
|
||||
bool OwncloudSetupWizard::checkOwncloudAdmin( const QString& bin )
|
||||
{
|
||||
QFileInfo fi( bin );
|
||||
qDebug() << "checking owncloud-admin " << bin;
|
||||
if( ! (fi.exists() && fi.isExecutable() ) ) {
|
||||
_ocWizard->appendToResultWidget( tr("The owncloud admin script can not be found.\n"
|
||||
"Setup can not be done.") );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::setupLocalSyncFolder()
|
||||
{
|
||||
_localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder();
|
||||
|
||||
if( ! _folderMan ) return;
|
||||
|
||||
qDebug() << "Setup local sync folder for new oC connection " << _localFolder;
|
||||
@ -437,7 +262,7 @@ void OwncloudSetupWizard::setupLocalSyncFolder()
|
||||
if( fi.exists() ) {
|
||||
// there is an existing local folder. If its non empty, it can only be synced if the
|
||||
// ownCloud is newly created.
|
||||
_ocWizard->appendToResultWidget( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(_localFolder));
|
||||
_ocWizard->appendToConfigurationLog( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(_localFolder));
|
||||
} else {
|
||||
QString res = tr("Creating local sync folder %1... ").arg(_localFolder);
|
||||
if( fi.mkpath( _localFolder ) ) {
|
||||
@ -448,61 +273,111 @@ void OwncloudSetupWizard::setupLocalSyncFolder()
|
||||
res += tr("failed.");
|
||||
qDebug() << "Failed to create " << fi.path();
|
||||
localFolderOk = false;
|
||||
_ocWizard->displayError(tr("Could not create local folder %1").arg(_localFolder));
|
||||
}
|
||||
_ocWizard->appendToResultWidget( res );
|
||||
_ocWizard->appendToConfigurationLog( res );
|
||||
}
|
||||
|
||||
if( localFolderOk ) {
|
||||
_remoteFolder = Theme::instance()->defaultServerFolder();
|
||||
slotCreateRemoteFolder(true);
|
||||
checkRemoteFolder();
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotCreateRemoteFolder(bool credentialsOk )
|
||||
void OwncloudSetupWizard::checkRemoteFolder()
|
||||
{
|
||||
if( ! credentialsOk ) {
|
||||
// User pressed cancel while being asked for password.
|
||||
_ocWizard->appendToResultWidget("User canceled password dialog. Can not connect.");
|
||||
return;
|
||||
}
|
||||
connect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
||||
this,SLOT(slotAuthCheckReply(QString,QNetworkReply*)));
|
||||
|
||||
if( createRemoteFolder( _remoteFolder ) ) {
|
||||
qDebug() << "Started remote folder creation ok";
|
||||
qDebug() << "# checking for authentication settings.";
|
||||
ownCloudInfo::instance()->setCustomConfigHandle(_configHandle);
|
||||
_checkRemoteFolderRequest = ownCloudInfo::instance()->getRequest(_remoteFolder, true ); // this call needs to be authenticated.
|
||||
// continue in slotAuthCheckReply
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotAuthCheckReply( const QString&, QNetworkReply *reply )
|
||||
{
|
||||
// disconnect from ownCloud Info signals
|
||||
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
||||
this,SLOT(slotAuthCheckReply(QString,QNetworkReply*)));
|
||||
|
||||
bool ok = true;
|
||||
QString error;
|
||||
QNetworkReply::NetworkError errId = reply->error();
|
||||
|
||||
if( errId == QNetworkReply::NoError ) {
|
||||
qDebug() << "******** Remote folder found, all cool!";
|
||||
} else if( errId == QNetworkReply::AuthenticationRequiredError ) { // returned if the user is wrong.
|
||||
qDebug() << "******** Password is wrong!";
|
||||
error = tr("Credentials are wrong!");
|
||||
ok = false;
|
||||
} else if( errId == QNetworkReply::OperationCanceledError ) {
|
||||
// the username was wrong and ownCloudInfo was closing the request after a couple of auth tries.
|
||||
qDebug() << "******** Username or password is wrong!";
|
||||
error = tr("Username or password is wrong!");
|
||||
ok = false;
|
||||
} else if( errId == QNetworkReply::ContentNotFoundError ) {
|
||||
// FIXME try to create the remote folder!
|
||||
if( !createRemoteFolder() ) {
|
||||
error = tr("The remote folder could not be accessed!");
|
||||
ok = false;
|
||||
} else {
|
||||
return; // Finish here, the mkdir request will go on.
|
||||
}
|
||||
} else {
|
||||
_ocWizard->appendToResultWidget(tr("Creation of remote folder %1 could not be started.").arg(_remoteFolder));
|
||||
error = tr("Error: %1").arg(reply->errorString());
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if( !ok ) {
|
||||
_ocWizard->displayError(error);
|
||||
} else {
|
||||
_ocWizard->setFolderNames( _localFolder, _remoteFolder );
|
||||
}
|
||||
|
||||
finalizeSetup( ok );
|
||||
}
|
||||
|
||||
bool OwncloudSetupWizard::createRemoteFolder( const QString& folder )
|
||||
bool OwncloudSetupWizard::createRemoteFolder()
|
||||
{
|
||||
if( folder.isEmpty() ) return false;
|
||||
if( _remoteFolder.isEmpty() ) return false;
|
||||
|
||||
qDebug() << "creating folder on ownCloud: " << folder;
|
||||
_ocWizard->appendToConfigurationLog( tr("creating folder on ownCloud: %1" ).arg( _remoteFolder ));
|
||||
connect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
|
||||
this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
|
||||
|
||||
_mkdirRequestReply = ownCloudInfo::instance()->mkdirRequest( folder );
|
||||
_mkdirRequestReply = ownCloudInfo::instance()->mkdirRequest( _remoteFolder );
|
||||
|
||||
return true;
|
||||
return (_mkdirRequestReply != NULL);
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::NetworkError error )
|
||||
{
|
||||
qDebug() << "** webdav mkdir request finished " << error;
|
||||
disconnect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
|
||||
this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
|
||||
|
||||
bool success = true;
|
||||
|
||||
if( error == QNetworkReply::NoError ) {
|
||||
_ocWizard->appendToResultWidget( tr("Remote folder %1 created successfully.").arg(_remoteFolder));
|
||||
_ocWizard->appendToConfigurationLog( tr("Remote folder %1 created successfully.").arg(_remoteFolder));
|
||||
} else if( error == 202 ) {
|
||||
_ocWizard->appendToResultWidget( tr("The remote folder %1 already exists. Connecting it for syncing.").arg(_remoteFolder));
|
||||
_ocWizard->appendToConfigurationLog( tr("The remote folder %1 already exists. Connecting it for syncing.").arg(_remoteFolder));
|
||||
} else if( error > 202 && error < 300 ) {
|
||||
_ocWizard->appendToResultWidget( tr("The folder creation resulted in HTTP error code %1").arg((int)error) );
|
||||
_ocWizard->displayError( tr("The folder creation resulted in HTTP error code %1").arg((int)error ));
|
||||
|
||||
_ocWizard->appendToConfigurationLog( tr("The folder creation resulted in HTTP error code %1").arg((int)error) );
|
||||
} else if( error == QNetworkReply::OperationCanceledError ) {
|
||||
_ocWizard->appendToResultWidget( tr("<p><font color=\"red\">Remote folder creation failed probably because the provided credentials are wrong.</font>"
|
||||
_ocWizard->displayError( tr("The remote folder creation failed because the provided credentials "
|
||||
"are wrong!"
|
||||
"<br/>Please go back and check your credentials.</p>"));
|
||||
_ocWizard->appendToConfigurationLog( tr("<p><font color=\"red\">Remote folder creation failed probably because the provided credentials are wrong.</font>"
|
||||
"<br/>Please go back and check your credentials.</p>"));
|
||||
_localFolder.clear();
|
||||
_remoteFolder.clear();
|
||||
success = false;
|
||||
} else {
|
||||
_ocWizard->appendToResultWidget( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
|
||||
_ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
|
||||
_ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error) );
|
||||
_localFolder.clear();
|
||||
_remoteFolder.clear();
|
||||
success = false;
|
||||
@ -518,21 +393,21 @@ void OwncloudSetupWizard::finalizeSetup( bool success )
|
||||
|
||||
if( success ) {
|
||||
if( !(_localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
|
||||
_ocWizard->appendToResultWidget( tr("A sync connection from %1 to remote directory %2 was set up.")
|
||||
_ocWizard->appendToConfigurationLog( tr("A sync connection from %1 to remote directory %2 was set up.")
|
||||
.arg(_localFolder).arg(_remoteFolder));
|
||||
}
|
||||
_ocWizard->appendToResultWidget( QLatin1String(" "));
|
||||
_ocWizard->appendToResultWidget( QLatin1String("<p><font color=\"green\"><b>")
|
||||
_ocWizard->appendToConfigurationLog( QLatin1String(" "));
|
||||
_ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>")
|
||||
+ tr("Successfully connected to %1!")
|
||||
.arg(Theme::instance()->appNameGUI())
|
||||
+ QLatin1String("</b></font></p>"));
|
||||
_ocWizard->appendToResultWidget( tr("Press Finish to permanently accept this connection."));
|
||||
} else {
|
||||
_ocWizard->appendToResultWidget(QLatin1String("<p><font color=\"red\">")
|
||||
_ocWizard->appendToConfigurationLog(QLatin1String("<p><font color=\"red\">")
|
||||
+ tr("Connection to %1 could not be established. Please check again.")
|
||||
.arg(Theme::instance()->appNameGUI())
|
||||
+ QLatin1String("</font></p>"));
|
||||
}
|
||||
_ocWizard->successfullyConnected(success);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -68,20 +68,8 @@ signals:
|
||||
public slots:
|
||||
|
||||
protected slots:
|
||||
// QProcess related slots:
|
||||
void slotReadyReadStandardOutput();
|
||||
void slotReadyReadStandardError();
|
||||
void slotStateChanged( QProcess::ProcessState );
|
||||
void slotError( QProcess::ProcessError );
|
||||
void slotStarted();
|
||||
void slotProcessFinished( int, QProcess::ExitStatus );
|
||||
|
||||
// wizard dialog signals
|
||||
void slotInstallOCServer();
|
||||
void slotConnectToOCUrl( const QString& );
|
||||
void slotCreateOCLocalhost();
|
||||
|
||||
void slotCreateRemoteFolder(bool);
|
||||
|
||||
private slots:
|
||||
void slotOwnCloudFound( const QString&, const QString&, const QString&, const QString& );
|
||||
@ -89,11 +77,11 @@ private slots:
|
||||
void slotCreateRemoteFolderFinished( QNetworkReply::NetworkError );
|
||||
void slotAssistantFinished( int );
|
||||
void slotClearPendingRequests();
|
||||
|
||||
void slotAuthCheckReply( const QString&, QNetworkReply * );
|
||||
private:
|
||||
bool checkOwncloudAdmin( const QString& );
|
||||
void runOwncloudAdmin( const QStringList& );
|
||||
bool createRemoteFolder( const QString& );
|
||||
bool createRemoteFolder();
|
||||
void checkRemoteFolder();
|
||||
|
||||
void finalizeSetup( bool );
|
||||
|
||||
/* Start a request to the newly installed ownCloud to check the connection */
|
||||
@ -102,8 +90,9 @@ private:
|
||||
OwncloudWizard *_ocWizard;
|
||||
QPointer<QNetworkReply> _mkdirRequestReply;
|
||||
QPointer<QNetworkReply> _checkInstallationRequest;
|
||||
QPointer<QNetworkReply> _checkRemoteFolderRequest;
|
||||
|
||||
FolderMan *_folderMan;
|
||||
QProcess *_process;
|
||||
|
||||
QString _configHandle;
|
||||
QString _localFolder;
|
||||
|
||||
@ -15,18 +15,10 @@
|
||||
#include "mirall/owncloudwizard.h"
|
||||
#include "mirall/mirallconfigfile.h"
|
||||
#include "mirall/theme.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QProgressIndicator.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QValidator>
|
||||
#include <QWizardPage>
|
||||
#include <QDir>
|
||||
#include <QScrollBar>
|
||||
#include <QSslSocket>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -59,19 +51,14 @@ OwncloudSetupPage::OwncloudSetupPage()
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
|
||||
// Backgroundcolor for owncloud logo #1d2d42
|
||||
setTitle(tr("Create Connection to %1").arg(Theme::instance()->appNameGUI()));
|
||||
|
||||
connect(_ui.leUrl, SIGNAL(textChanged(QString)), SLOT(handleNewOcUrl(QString)));
|
||||
|
||||
registerField( QLatin1String("OCUrl"), _ui.leUrl );
|
||||
registerField( QLatin1String("OCUrl"), _ui.leUrl );
|
||||
registerField( QLatin1String("OCUser"), _ui.leUsername );
|
||||
registerField( QLatin1String("OCPasswd"), _ui.lePassword);
|
||||
registerField( QLatin1String("connectMyOC"), _ui.cbConnectOC );
|
||||
registerField( QLatin1String("secureConnect"), _ui.cbSecureConnect );
|
||||
registerField( QLatin1String("PwdNoLocalStore"), _ui.cbNoPasswordStore );
|
||||
|
||||
_ui.cbSecureConnect->setEnabled(QSslSocket::supportsSsl());
|
||||
|
||||
connect( _ui.lePassword, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
||||
connect( _ui.leUsername, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
|
||||
connect( _ui.cbAdvanced, SIGNAL(stateChanged (int)), SLOT(slotToggleAdvanced(int)));
|
||||
@ -110,9 +97,23 @@ OwncloudSetupPage::OwncloudSetupPage()
|
||||
setupCustomization();
|
||||
}
|
||||
|
||||
|
||||
OwncloudSetupPage::~OwncloudSetupPage()
|
||||
{
|
||||
delete _progressIndi;
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::slotToggleAdvanced(int state)
|
||||
{
|
||||
_ui.advancedBox->setVisible( state == Qt::Checked );
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::slotChangedSelective(QAbstractButton* button)
|
||||
{
|
||||
if( button = _ui.pbBoxMode ) {
|
||||
// box mode - sync the entire oC
|
||||
} else {
|
||||
// content mode, select folder list.
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::setOCUser( const QString & user )
|
||||
@ -122,11 +123,6 @@ void OwncloudSetupPage::setOCUser( const QString & user )
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::setAllowPasswordStorage( bool allow )
|
||||
{
|
||||
_ui.cbNoPasswordStore->setChecked( ! allow );
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::setOCUrl( const QString& newUrl )
|
||||
{
|
||||
QString url( newUrl );
|
||||
@ -134,14 +130,6 @@ void OwncloudSetupPage::setOCUrl( const QString& newUrl )
|
||||
_ui.leUrl->clear();
|
||||
return;
|
||||
}
|
||||
if( url.startsWith( QLatin1String("https"))) {
|
||||
_ui.cbSecureConnect->setChecked( true );
|
||||
url.remove(0,5);
|
||||
} else if( url.startsWith( QLatin1String("http"))) {
|
||||
_ui.cbSecureConnect->setChecked( false );
|
||||
url.remove(0,4);
|
||||
}
|
||||
if( url.startsWith( QLatin1String("://"))) url.remove(0,3);
|
||||
|
||||
_ui.leUrl->setText( url );
|
||||
}
|
||||
@ -149,8 +137,6 @@ void OwncloudSetupPage::setOCUrl( const QString& newUrl )
|
||||
void OwncloudSetupPage::setupCustomization()
|
||||
{
|
||||
// set defaults for the customize labels.
|
||||
_ui.sideLabel->setText( QString::null );
|
||||
_ui.sideLabel->setFixedWidth(160);
|
||||
|
||||
// _ui.topLabel->hide();
|
||||
_ui.bottomLabel->hide();
|
||||
@ -171,30 +157,29 @@ void OwncloudSetupPage::setupCustomization()
|
||||
if( !fixUrl.isEmpty() ) {
|
||||
setOCUrl( fixUrl );
|
||||
_ui.leUrl->setEnabled( false );
|
||||
_ui.cbSecureConnect->hide();
|
||||
_ui.leUrl->hide();
|
||||
}
|
||||
}
|
||||
|
||||
// slot hit from textChanged of the url entry field.
|
||||
void OwncloudSetupPage::handleNewOcUrl(const QString& ocUrl)
|
||||
{
|
||||
QString url = ocUrl;
|
||||
int len = 0;
|
||||
bool visible = false;
|
||||
#if 0
|
||||
if (url.startsWith(QLatin1String("https://"))) {
|
||||
_ui.cbSecureConnect->setChecked(true);
|
||||
len = 8;
|
||||
_ui.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-high.png"));
|
||||
_ui.urlLabel->setToolTip(tr("This url is secure. You can use it."));
|
||||
visible = true;
|
||||
}
|
||||
if (url.startsWith(QLatin1String("http://"))) {
|
||||
_ui.cbSecureConnect->setChecked(false);
|
||||
len = 7;
|
||||
_ui.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-low.png"));
|
||||
_ui.urlLabel->setToolTip(tr("This url is NOT secure. You should not use it."));
|
||||
visible = true;
|
||||
}
|
||||
if( len ) {
|
||||
int pos = _ui.leUrl->cursorPosition();
|
||||
url.remove(0, len);
|
||||
_ui.leUrl->setText(url);
|
||||
_ui.leUrl->setCursorPosition(qMax(0, pos-len));
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool OwncloudSetupPage::isComplete() const
|
||||
@ -202,14 +187,13 @@ bool OwncloudSetupPage::isComplete() const
|
||||
if( _ui.leUrl->text().isEmpty() ) return false;
|
||||
if( _checking ) return false;
|
||||
|
||||
if( _ui.cbNoPasswordStore->checkState() == Qt::Checked ) {
|
||||
return !(_ui.leUsername->text().isEmpty());
|
||||
}
|
||||
return !(_ui.leUsername->text().isEmpty() || _ui.lePassword->text().isEmpty() );
|
||||
return !( _ui.lePassword->text().isEmpty() || _ui.leUsername->text().isEmpty() );
|
||||
}
|
||||
|
||||
void OwncloudSetupPage::initializePage()
|
||||
{
|
||||
_connected = false;
|
||||
_checking = false;
|
||||
}
|
||||
|
||||
int OwncloudSetupPage::nextId() const
|
||||
@ -217,35 +201,22 @@ int OwncloudSetupPage::nextId() const
|
||||
return OwncloudWizard::Page_Result;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
OwncloudWizardSelectTypePage::OwncloudWizardSelectTypePage()
|
||||
QString OwncloudSetupPage::url() const
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
registerField( QLatin1String("connectMyOC"), _ui.connectMyOCRadioBtn );
|
||||
registerField( QLatin1String("createNewOC"), _ui.createNewOCRadioBtn );
|
||||
registerField( QLatin1String("OCUrl"), _ui.OCUrlLineEdit );
|
||||
|
||||
connect( _ui.connectMyOCRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
|
||||
connect( _ui.createNewOCRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
|
||||
connect( _ui.OCUrlLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
|
||||
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
_ui.createNewOCRadioBtn->setVisible( false );
|
||||
_ui.createNewOwncloudLabel->setVisible( false );
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
_ui.OCUrlLineEdit->setPlaceholderText(tr("http://owncloud.mydomain.org"));
|
||||
#endif
|
||||
QString url = _ui.leUrl->text().simplified();
|
||||
return url;
|
||||
}
|
||||
|
||||
OwncloudWizardSelectTypePage::~OwncloudWizardSelectTypePage()
|
||||
void OwncloudSetupPage::setConnected( bool comp )
|
||||
{
|
||||
_connected = comp;
|
||||
_progressIndi->setVisible(false);
|
||||
_progressIndi->stopAnimation();
|
||||
}
|
||||
|
||||
void OwncloudWizardSelectTypePage::initializePage()
|
||||
bool OwncloudSetupPage::validatePage()
|
||||
{
|
||||
bool re = false;
|
||||
|
||||
if( ! _connected) {
|
||||
setErrorString(QString::null);
|
||||
@ -265,128 +236,72 @@ void OwncloudWizardSelectTypePage::initializePage()
|
||||
}
|
||||
}
|
||||
|
||||
int OwncloudWizardSelectTypePage::nextId() const
|
||||
void OwncloudSetupPage::setErrorString( const QString& err )
|
||||
{
|
||||
if( _ui.connectMyOCRadioBtn->isChecked() ) {
|
||||
return OwncloudWizard::Page_OC_Credentials;
|
||||
}
|
||||
return OwncloudWizard::Page_Create_OC;
|
||||
}
|
||||
|
||||
bool OwncloudWizardSelectTypePage::isComplete() const
|
||||
{
|
||||
if( _ui.connectMyOCRadioBtn->isChecked() ) {
|
||||
// a valid url is needed.
|
||||
QString u = _ui.OCUrlLineEdit->text();
|
||||
QUrl url( u );
|
||||
if( url.isValid() ) {
|
||||
return true;
|
||||
if( err.isEmpty()) {
|
||||
_ui.errorLabel->setVisible(false);
|
||||
} else {
|
||||
_ui.errorLabel->setVisible(true);
|
||||
_ui.errorLabel->setText(err);
|
||||
}
|
||||
_checking = false;
|
||||
emit completeChanged();
|
||||
stopSpinner();
|
||||
}
|
||||
|
||||
OwncloudCredentialsPage::~OwncloudCredentialsPage()
|
||||
void OwncloudSetupPage::stopSpinner()
|
||||
{
|
||||
// _ui.addressLayout->removeWidget( _progressIndi );
|
||||
|
||||
_progressIndi->setVisible(false);
|
||||
_progressIndi->stopAnimation();
|
||||
}
|
||||
|
||||
void OwncloudCredentialsPage::slotPwdStoreChanged( int state )
|
||||
OwncloudSetupPage::SyncMode OwncloudSetupPage::syncMode()
|
||||
{
|
||||
_ui.OCPasswdEdit->setEnabled( state == Qt::Unchecked );
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
bool OwncloudCredentialsPage::isComplete() const
|
||||
{
|
||||
if( _ui.cbPwdNoLocalStore->checkState() == Qt::Checked ) {
|
||||
return !(_ui.OCUserEdit->text().isEmpty());
|
||||
if( _selectiveSyncButtons->checkedButton() &&
|
||||
_selectiveSyncButtons->checkedButton() == _ui.pbSelectiveMode ) {
|
||||
return SelectiveMode;
|
||||
}
|
||||
return !(_ui.OCUserEdit->text().isEmpty() || _ui.OCPasswdEdit->text().isEmpty() );
|
||||
return BoxMode;
|
||||
}
|
||||
|
||||
void OwncloudCredentialsPage::initializePage()
|
||||
void OwncloudSetupPage::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
{
|
||||
_ui.pbSelectLocalFolder->setText(folder);
|
||||
_ui.pbSelectLocalFolder->setText(localFolder);
|
||||
if( !remoteFolder.isEmpty() )
|
||||
_remoteFolder = remoteFolder;
|
||||
|
||||
QString t;
|
||||
if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
|
||||
t = tr("Your entire account will be synced to the local folder %1").arg(localFolder);
|
||||
} else {
|
||||
t = tr("ownCloud folder %1 is synced to local folder %2").arg(_remoteFolder).arg(localFolder);
|
||||
}
|
||||
|
||||
QString t = tr("Your entire account will be synced to the local folder %1").arg(folder);
|
||||
_ui.syncModeLabel->setText(t);
|
||||
}
|
||||
|
||||
int OwncloudCredentialsPage::nextId() const
|
||||
QString OwncloudSetupPage::selectedLocalFolder() const
|
||||
{
|
||||
return OwncloudWizard::Page_Install;
|
||||
return _ui.pbSelectLocalFolder->text();
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
OwncloudFTPAccessPage::OwncloudFTPAccessPage()
|
||||
void OwncloudSetupPage::slotSelectFolder()
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
registerField( QLatin1String("ftpUrl"), _ui.ftpUrlEdit );
|
||||
registerField( QLatin1String("ftpUser"), _ui.ftpUserEdit );
|
||||
registerField( QLatin1String("ftpPasswd"), _ui.ftpPasswdEdit );
|
||||
// registerField( QLatin1String("ftpDir"), _ui.ftpDir );
|
||||
|
||||
QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath());
|
||||
if( !dir.isEmpty() ) {
|
||||
setLocalFolder(dir);
|
||||
setFolderNames(dir);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
CreateAnOwncloudPage::CreateAnOwncloudPage()
|
||||
OwncloudSetupPage::SyncMode OwncloudWizard::syncMode()
|
||||
{
|
||||
_ui.setupUi(this);
|
||||
registerField(QLatin1String("createLocalOC"), _ui.createLocalRadioBtn );
|
||||
registerField(QLatin1String("createOnDomain"), _ui.createPerFTPRadioBtn );
|
||||
registerField(QLatin1String("myOCDomain"), _ui.myDomainEdit );
|
||||
|
||||
connect( _ui.createLocalRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
|
||||
connect( _ui.createPerFTPRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
|
||||
connect( _ui.myDomainEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
_ui.myDomainEdit->setPlaceholderText(tr("mydomain.org"));
|
||||
#endif
|
||||
return _setupPage->syncMode();
|
||||
return OwncloudSetupPage::BoxMode;
|
||||
}
|
||||
|
||||
CreateAnOwncloudPage::~CreateAnOwncloudPage()
|
||||
{
|
||||
}
|
||||
|
||||
void CreateAnOwncloudPage::initializePage()
|
||||
{
|
||||
// _ui.lineEditOCAlias->setText( "Owncloud" );
|
||||
}
|
||||
|
||||
int CreateAnOwncloudPage::nextId() const
|
||||
{
|
||||
if( _ui.createLocalRadioBtn->isChecked() ) {
|
||||
return OwncloudWizard::Page_OC_Credentials;
|
||||
}
|
||||
|
||||
return OwncloudWizard::Page_FTP;
|
||||
}
|
||||
|
||||
bool CreateAnOwncloudPage::isComplete() const
|
||||
{
|
||||
|
||||
if( _ui.createPerFTPRadioBtn->isChecked() ) {
|
||||
QString dom = _ui.myDomainEdit->text();
|
||||
qDebug() << "check is Complete with " << dom;
|
||||
return (!dom.isEmpty() && dom.contains( QLatin1Char('.'))
|
||||
&& dom.lastIndexOf(QLatin1Char('.')) < dom.length()-2 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CreateAnOwncloudPage::domain() const
|
||||
{
|
||||
return _ui.myDomainEdit->text();
|
||||
}
|
||||
// ======================================================================
|
||||
|
||||
OwncloudWizardResultPage::OwncloudWizardResultPage()
|
||||
@ -407,7 +322,7 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
|
||||
|
||||
_ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
|
||||
_ui.pbOpenServer->setIcon(QIcon(":/mirall/resources/mirall-48.png"));
|
||||
_ui.pbOpenServer->setIcon(QIcon(":/mirall/resources/owncloud_logo_blue.png"));
|
||||
_ui.pbOpenServer->setText(tr("Open Server"));
|
||||
_ui.pbOpenServer->setIconSize(QSize(48, 48));
|
||||
_ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
@ -418,15 +333,32 @@ OwncloudWizardResultPage::~OwncloudWizardResultPage()
|
||||
{
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setComplete(bool complete)
|
||||
{
|
||||
_complete = complete;
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
bool OwncloudWizardResultPage::isComplete() const
|
||||
{
|
||||
return _complete;
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setOwncloudUrl( const QString& url )
|
||||
{
|
||||
_url = url;
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setLocalFolder( const QString& folder )
|
||||
void OwncloudWizardResultPage::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
{
|
||||
_localFolder = folder;
|
||||
_ui.localFolderLabel->setText(tr("Your entire account is synced to the local folder %1").arg(folder));
|
||||
QString text;
|
||||
if( remoteFolder == QLatin1String("/") ||
|
||||
remoteFolder.isEmpty() ) {
|
||||
text = tr("Your entire account is synced to the local folder <i>%1</i>").arg(localFolder);
|
||||
} else {
|
||||
text = tr("ownCloud folder <i>%1</i> is synced to local folder <i>%2</i>").arg(remoteFolder).arg(localFolder);
|
||||
}
|
||||
_ui.localFolderLabel->setText( text );
|
||||
}
|
||||
|
||||
void OwncloudWizardResultPage::setupCustomization()
|
||||
@ -448,16 +380,18 @@ void OwncloudWizardResultPage::setupCustomization()
|
||||
OwncloudWizard::OwncloudWizard(QWidget *parent)
|
||||
: QWizard(parent)
|
||||
{
|
||||
setPage(Page_oCSetup, new OwncloudSetupPage() );
|
||||
setPage(Page_Result, new OwncloudWizardResultPage() );
|
||||
_setupPage = new OwncloudSetupPage;
|
||||
_resultPage = new OwncloudWizardResultPage;
|
||||
setPage(Page_oCSetup, _setupPage );
|
||||
setPage(Page_Result, _resultPage );
|
||||
|
||||
// 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)));
|
||||
|
||||
OwncloudSetupPage *p = static_cast<OwncloudSetupPage*>(page(Page_oCSetup));
|
||||
connect( p, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
|
||||
connect( _setupPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
|
||||
|
||||
QPixmap pix(QSize(540, 78));
|
||||
pix.fill(QColor("#1d2d42"));
|
||||
@ -467,6 +401,7 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
|
||||
setPixmap( QWizard::LogoPixmap, logo );
|
||||
setWizardStyle(QWizard::ModernStyle);
|
||||
setOption( QWizard::NoBackButtonOnStartPage );
|
||||
setOption( QWizard::NoBackButtonOnLastPage );
|
||||
setOption( QWizard::NoCancelButton );
|
||||
setTitleFormat(Qt::RichText);
|
||||
setSubTitleFormat(Qt::RichText);
|
||||
@ -476,80 +411,73 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
|
||||
QString OwncloudWizard::ocUrl() const
|
||||
{
|
||||
QString url = field("OCUrl").toString().simplified();
|
||||
if( field("secureConnect").toBool() ) {
|
||||
url.prepend(QLatin1String("https://"));
|
||||
} else {
|
||||
url.prepend(QLatin1String("http://"));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
void OwncloudWizard::enableFinishOnResultWidget(bool enable)
|
||||
{
|
||||
OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Install ));
|
||||
p->setComplete(enable);
|
||||
_resultPage->setComplete(enable);
|
||||
}
|
||||
|
||||
void OwncloudWizard::setFolderNames( const QString& localFolder, const QString& remoteFolder )
|
||||
{
|
||||
_setupPage->setFolderNames( localFolder, remoteFolder );
|
||||
_resultPage->setFolderNames( localFolder, remoteFolder );
|
||||
}
|
||||
|
||||
void OwncloudWizard::showConnectInfo( const QString& msg )
|
||||
{
|
||||
if( _setupPage ) {
|
||||
_setupPage->setErrorString( msg );
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudWizard::successfullyConnected(bool enable)
|
||||
{
|
||||
_setupPage->setConnected( enable );
|
||||
|
||||
if( enable ) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudWizard::slotCurrentPageChanged( int id )
|
||||
{
|
||||
qDebug() << "Current Wizard page changed to " << id;
|
||||
qDebug() << "Current Wizard page changed to " << id;
|
||||
|
||||
QString host = QLatin1String("ftp.") +domain;
|
||||
OwncloudFTPAccessPage *p1 = static_cast<OwncloudFTPAccessPage*> (page( Page_FTP ));
|
||||
p1->setFTPUrl( host );
|
||||
}
|
||||
if( id == Page_oCSetup ) {
|
||||
setButtonText( QWizard::NextButton, tr("Connect...") );
|
||||
emit clearPendingRequests();
|
||||
_setupPage->initializePage();
|
||||
|
||||
if( id == Page_Result ) {
|
||||
appendToResultWidget( QString::null );
|
||||
showOCUrlLabel( false );
|
||||
OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Result ));
|
||||
if( p ) p->setLocalFolder( selectedLocalFolder() );
|
||||
}
|
||||
}
|
||||
|
||||
if( id == Page_Result ) {
|
||||
appendToConfigurationLog( QString::null );
|
||||
}
|
||||
}
|
||||
|
||||
void OwncloudWizard::showOCUrlLabel( bool show )
|
||||
void OwncloudWizard::displayError( const QString& msg )
|
||||
{
|
||||
OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Result ));
|
||||
_setupPage->setErrorString( msg );
|
||||
}
|
||||
|
||||
void OwncloudWizard::appendToResultWidget( const QString& msg, LogType type )
|
||||
void OwncloudWizard::appendToConfigurationLog( const QString& msg, LogType type )
|
||||
{
|
||||
OwncloudWizardResultPage *r = static_cast<OwncloudWizardResultPage*> (page( Page_Result ));
|
||||
qDebug() << "XXXXXXXXXXXXX " << msg;
|
||||
_setupLog << msg;
|
||||
qDebug() << "Setup-Log: " << msg;
|
||||
}
|
||||
|
||||
void OwncloudWizard::setOCUrl( const QString& url )
|
||||
{
|
||||
_oCUrl = url;
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
OwncloudSetupPage *p = static_cast<OwncloudSetupPage*>(page(Page_oCSetup));
|
||||
#else
|
||||
OwncloudWizardSelectTypePage *p = static_cast<OwncloudWizardSelectTypePage*>(page( Page_SelectType ));
|
||||
#endif
|
||||
if( p )
|
||||
p->setOCUrl( url );
|
||||
|
||||
_setupPage->setOCUrl( url );
|
||||
}
|
||||
|
||||
void OwncloudWizard::setOCUser( const QString& user )
|
||||
{
|
||||
_oCUser = user;
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
OwncloudSetupPage *p = static_cast<OwncloudSetupPage*>(page(Page_oCSetup));
|
||||
if( p )
|
||||
p->setOCUser( user );
|
||||
#else
|
||||
OwncloudWizardSelectTypePage *p = static_cast<OwncloudWizardSelectTypePage*>(page( Page_SelectType ));
|
||||
#endif
|
||||
}
|
||||
|
||||
void OwncloudWizard::setAllowPasswordStorage( bool allow )
|
||||
{
|
||||
#ifdef OWNCLOUD_CLIENT
|
||||
OwncloudSetupPage *p = static_cast<OwncloudSetupPage*>(page(Page_oCSetup));
|
||||
if( p )
|
||||
p->setAllowPasswordStorage( allow );
|
||||
#endif
|
||||
_setupPage->setOCUser( user );
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
|
||||
#include <QWizard>
|
||||
|
||||
#include "ui_owncloudwizardresultpage.h"
|
||||
#include "ui_owncloudsetuppage_ng.h"
|
||||
#include "ui_owncloudwizardresultpage.h"
|
||||
|
||||
class QLabel;
|
||||
class QVariant;
|
||||
@ -27,6 +27,9 @@ class QProgressIndicator;
|
||||
|
||||
namespace Mirall {
|
||||
|
||||
class OwncloudSetupPage;
|
||||
class OwncloudWizardResultPage;
|
||||
|
||||
class OwncloudSetupPage: public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -34,18 +37,39 @@ public:
|
||||
OwncloudSetupPage();
|
||||
~OwncloudSetupPage();
|
||||
|
||||
enum SyncMode {
|
||||
SelectiveMode,
|
||||
BoxMode
|
||||
};
|
||||
|
||||
virtual bool isComplete() const;
|
||||
virtual void initializePage();
|
||||
virtual int nextId() const;
|
||||
void setOCUrl( const QString& );
|
||||
void setOCUser( const QString& );
|
||||
void setAllowPasswordStorage( bool );
|
||||
bool validatePage();
|
||||
QString url() const;
|
||||
void setConnected(bool complete);
|
||||
QString selectedLocalFolder() const;
|
||||
void setFolderNames( const QString&, const QString& remoteFolder = QString::null);
|
||||
|
||||
SyncMode syncMode();
|
||||
|
||||
public slots:
|
||||
void setErrorString( const QString& );
|
||||
void stopSpinner();
|
||||
|
||||
protected slots:
|
||||
void slotPwdStoreChanged( int );
|
||||
void slotSecureConChanged( int );
|
||||
void handleNewOcUrl(const QString& ocUrl);
|
||||
void setupCustomization();
|
||||
void slotToggleAdvanced(int state);
|
||||
void slotChangedSelective(QAbstractButton*);
|
||||
void slotSelectFolder();
|
||||
|
||||
signals:
|
||||
void connectToOCUrl( const QString& );
|
||||
|
||||
private:
|
||||
Ui_OwncloudSetupPage _ui;
|
||||
QString _oCUrl;
|
||||
@ -53,6 +77,7 @@ private:
|
||||
bool _checking;
|
||||
QProgressIndicator *_progressIndi;
|
||||
QButtonGroup *_selectiveSyncButtons;
|
||||
QString _remoteFolder;
|
||||
};
|
||||
|
||||
class OwncloudWizard: public QWizard
|
||||
@ -74,29 +99,35 @@ public:
|
||||
|
||||
void setOCUrl( const QString& );
|
||||
void setOCUser( const QString& );
|
||||
void setAllowPasswordStorage( bool );
|
||||
|
||||
void setupCustomMedia( QVariant, QLabel* );
|
||||
QString ocUrl() const;
|
||||
|
||||
void enableFinishOnResultWidget(bool enable);
|
||||
|
||||
public slots:
|
||||
void appendToResultWidget( const QString& msg, LogType type = LogParagraph );
|
||||
void slotCurrentPageChanged( int );
|
||||
void showOCUrlLabel( bool );
|
||||
void displayError( const QString& );
|
||||
OwncloudSetupPage::SyncMode syncMode();
|
||||
|
||||
public slots:
|
||||
void setFolderNames( const QString&, const QString& );
|
||||
void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph );
|
||||
void slotCurrentPageChanged( int );
|
||||
|
||||
void showConnectInfo( const QString& );
|
||||
void successfullyConnected(bool);
|
||||
|
||||
signals:
|
||||
void connectToOCUrl( const QString& );
|
||||
void installOCServer();
|
||||
void installOCLocalhost();
|
||||
void clearPendingRequests();
|
||||
void connectToOCUrl( const QString& );
|
||||
|
||||
private:
|
||||
OwncloudSetupPage *_setupPage;
|
||||
OwncloudWizardResultPage *_resultPage;
|
||||
|
||||
QString _configFile;
|
||||
QString _oCUrl;
|
||||
QString _oCUser;
|
||||
QStringList _setupLog;
|
||||
};
|
||||
|
||||
|
||||
@ -104,79 +135,6 @@ private:
|
||||
* page to ask for the type of Owncloud to connect to
|
||||
*/
|
||||
|
||||
class OwncloudWizardSelectTypePage: public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OwncloudWizardSelectTypePage();
|
||||
~OwncloudWizardSelectTypePage();
|
||||
|
||||
virtual bool isComplete() const;
|
||||
virtual void initializePage();
|
||||
int nextId() const;
|
||||
void setOCUrl( const QString& );
|
||||
void showOCUrlLabel( const QString& );
|
||||
|
||||
private:
|
||||
Ui_OwncloudWizardSelectTypePage _ui;
|
||||
};
|
||||
|
||||
class CreateAnOwncloudPage: public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreateAnOwncloudPage();
|
||||
~CreateAnOwncloudPage();
|
||||
|
||||
virtual bool isComplete() const;
|
||||
virtual void initializePage();
|
||||
virtual int nextId() const;
|
||||
|
||||
QString domain() const;
|
||||
|
||||
private:
|
||||
Ui_CreateAnOwncloudPage _ui;
|
||||
|
||||
};
|
||||
|
||||
class OwncloudCredentialsPage: public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OwncloudCredentialsPage();
|
||||
~OwncloudCredentialsPage();
|
||||
|
||||
virtual bool isComplete() const;
|
||||
virtual void initializePage();
|
||||
virtual int nextId() const;
|
||||
|
||||
protected slots:
|
||||
void slotPwdStoreChanged( int );
|
||||
|
||||
private:
|
||||
Ui_OwncloudCredentialsPage _ui;
|
||||
|
||||
};
|
||||
/**
|
||||
* page to ask for the ftp credentials etc. for ftp install
|
||||
*/
|
||||
class OwncloudFTPAccessPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OwncloudFTPAccessPage();
|
||||
~OwncloudFTPAccessPage();
|
||||
|
||||
virtual bool isComplete() const;
|
||||
virtual void initializePage();
|
||||
void setFTPUrl( const QString& );
|
||||
virtual int nextId() const;
|
||||
|
||||
private:
|
||||
Ui_OwncloudFTPAccessPage _ui;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* page to display the install result
|
||||
*/
|
||||
@ -187,16 +145,19 @@ public:
|
||||
OwncloudWizardResultPage();
|
||||
~OwncloudWizardResultPage();
|
||||
|
||||
bool isComplete() const;
|
||||
|
||||
public slots:
|
||||
void setComplete(bool complete);
|
||||
void setOwncloudUrl( const QString& );
|
||||
void setLocalFolder( const QString& );
|
||||
void setFolderNames( const QString&, const QString& );
|
||||
|
||||
protected:
|
||||
void setupCustomization();
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
QString _localFolder;
|
||||
bool _complete;
|
||||
|
||||
Ui_OwncloudWizardResultPage _ui;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user