();
- if( !pix.isNull() ) {
- label->setPixmap(pix);
- label->setAlignment( Qt::AlignTop | Qt::AlignRight );
- label->setVisible(true);
- } else {
- QString str = variant.toString();
- if( !str.isEmpty() ) {
- label->setText( str );
- label->setTextFormat( Qt::RichText );
- label->setVisible(true);
- label->setOpenExternalLinks(true);
- }
- }
-}
-
-// ======================================================================
-
-OwncloudSetupPage::OwncloudSetupPage()
-{
- _ui.setupUi(this);
-
- Theme *theme = Theme::instance();
- setTitle( tr("Connect to %2")
- .arg(theme->wizardHeaderTitleColor().name()).arg( theme->appNameGUI()));
- setSubTitle( tr("Enter user credentials")
- .arg(theme->wizardHeaderTitleColor().name()));
-
- registerField( QLatin1String("OCUrl"), _ui.leUrl );
- registerField( QLatin1String("OCUser"), _ui.leUsername );
- registerField( QLatin1String("OCPasswd"), _ui.lePassword);
- registerField( QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch);
-
- _ui.errorLabel->setVisible(true);
- _ui.advancedBox->setVisible(false);
-
- _progressIndi = new QProgressIndicator;
- _ui.resultLayout->addWidget( _progressIndi );
- _progressIndi->setVisible(false);
- _ui.resultLayout->setEnabled(false);
-
- // Error label
- QString style = QLatin1String("border: 1px solid #eed3d7; border-radius: 5px; padding: 3px;"
- "background-color: #f2dede; color: #b94a48;");
-
-
- _ui.errorLabel->setStyleSheet( style );
- _ui.errorLabel->setWordWrap(true);
- _ui.errorLabel->setVisible(false);
-
- _checking = false;
-
- setupCustomization();
-
- connect(_ui.leUrl, SIGNAL(textChanged(QString)), SLOT(slotUrlChanged(QString)));
- connect( _ui.leUsername, SIGNAL(textChanged(QString)), this, SLOT(slotUserChanged(QString)));
-
- 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)));
- connect( _ui.pbSelectLocalFolder, SIGNAL(clicked()), SLOT(slotSelectFolder()));
-}
-
-OwncloudSetupPage::~OwncloudSetupPage()
-{
- delete _progressIndi;
-}
-
-void OwncloudSetupPage::slotToggleAdvanced(int state)
-{
- _ui.advancedBox->setVisible( state == Qt::Checked );
- slotHandleUserInput();
- QSize size = wizard()->sizeHint();
- // need to substract header for some reason
- size -= QSize(0, 63);
-
- wizard()->setMinimumSize(size);
- wizard()->resize(size);
-}
-
-void OwncloudSetupPage::setOCUser( const QString & user )
-{
- _ocUser = user;
- _ui.leUsername->setText(user);
-}
-
-void OwncloudSetupPage::setServerUrl( const QString& newUrl )
-{
- _oCUrl = newUrl;
- if( _oCUrl.isEmpty() ) {
- _ui.leUrl->clear();
- return;
- }
-
- _ui.leUrl->setText( _oCUrl );
-}
-
-void OwncloudSetupPage::setupCustomization()
-{
- // set defaults for the customize labels.
- _ui.topLabel->hide();
- _ui.bottomLabel->hide();
-
- Theme *theme = Theme::instance();
- QVariant variant = theme->customMedia( Theme::oCSetupTop );
- if( !variant.isNull() ) {
- setupCustomMedia( variant, _ui.topLabel );
- }
-
- variant = theme->customMedia( Theme::oCSetupBottom );
- setupCustomMedia( variant, _ui.bottomLabel );
-
- QString fixUrl = theme->overrideServerUrl();
- if( !fixUrl.isEmpty() ) {
- _ui.label_2->hide();
- setServerUrl( fixUrl );
- _ui.leUrl->setEnabled( false );
- _ui.leUrl->hide();
- }
-}
-
-void OwncloudSetupPage::slotUserChanged(const QString& user )
-{
- slotHandleUserInput();
-}
-
-// slot hit from textChanged of the url entry field.
-void OwncloudSetupPage::slotUrlChanged(const QString& ocUrl)
-{
- slotHandleUserInput();
-
-#if 0
- QString url = ocUrl;
- bool visible = false;
-
- if (url.startsWith(QLatin1String("https://"))) {
- _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.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-low.png"));
- _ui.urlLabel->setToolTip(tr("This url is NOT secure. You should not use it."));
- visible = true;
- }
-#endif
-}
-
-bool OwncloudSetupPage::isComplete() const
-{
- if( _ui.leUrl->text().isEmpty() ) return false;
- if( _checking ) return false;
-
- return !( _ui.lePassword->text().isEmpty() || _ui.leUsername->text().isEmpty() );
-}
-
-void OwncloudSetupPage::initializePage()
-{
- _connected = false;
- _checking = false;
- _multipleFoldersExist = false;
-
- // call to init label
- slotHandleUserInput();
-
- if( _configExists ) {
- _ui.lePassword->setFocus();
- } else {
- _ui.leUrl->setFocus();
- }
-}
-
-bool OwncloudSetupPage::urlHasChanged()
-{
- bool change = false;
- const QChar slash('/');
-
- QUrl currentUrl( url() );
- QUrl initialUrl( _oCUrl );
-
- QString currentPath = currentUrl.path();
- QString initialPath = initialUrl.path();
-
- // add a trailing slash.
- if( ! currentPath.endsWith( slash )) currentPath += slash;
- if( ! initialPath.endsWith( slash )) initialPath += slash;
-
- if( currentUrl.host() != initialUrl.host() ||
- currentUrl.port() != initialUrl.port() ||
- currentPath != initialPath ) {
- change = true;
- }
-
- if( !change) { // no change yet, check the user.
- QString user = _ui.leUsername->text().simplified();
- if( user != _ocUser ) change = true;
- }
-
- return change;
-}
-
-// Called if the user changes the user- or url field. Adjust the texts and
-// evtl. warnings on the dialog.
-void OwncloudSetupPage::slotHandleUserInput()
-{
- // if the url has not changed, return.
- if( ! urlHasChanged() ) {
- // disable the advanced button as nothing has changed.
- _ui.cbAdvanced->setEnabled(false);
- _ui.advancedBox->setEnabled(false);
- } else {
- // Enable advanced stuff for new connection configuration.
- _ui.cbAdvanced->setEnabled(true);
- _ui.advancedBox->setEnabled(true);
- }
-
- const QString locFolder = localFolder();
-
- // check if the local folder exists. If so, and if its not empty, show a warning.
- QDir dir( locFolder );
- QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
-
- QString t;
-
- if( !urlHasChanged() && _configExists ) {
- // This is the password change mode: No change to the url and a config
- // to an ownCloud exists.
- t = tr("Change the Password for your configured account.");
- } else {
- // Complete new setup.
- _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder));
-
- if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
- t = tr("Your entire account will be synced to the local folder '%1'.")
- .arg(QDir::toNativeSeparators(locFolder));
- } else {
- t = tr("%1 folder '%2' is synced to local folder '%3'")
- .arg(Theme::instance()->appName()).arg(_remoteFolder)
- .arg(QDir::toNativeSeparators(locFolder));
- }
-
- if ( _multipleFoldersExist ) {
- t += tr("Warning: You currently have multiple folders "
- "configured. If you continue with the current settings, the folder configurations "
- "will be discarded and a single root folder sync will be created!
");
- }
-
- if( entries.count() > 0) {
- // the directory is not empty
- if (!_ui.cbAdvanced->isChecked()) {
- t += tr("Warning: The local directory is not empty. "
- "Pick a resolution in the advanced settings!
");
- }
- _ui.resolutionWidget->setVisible(true);
- } else {
- // the dir is empty, which means that there is no problem.
- _ui.resolutionWidget->setVisible(false);
- }
- }
-
- _ui.syncModeLabel->setText(t);
- _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height());
-}
-
-int OwncloudSetupPage::nextId() const
-{
- return OwncloudWizard::Page_Result;
-}
-
-QString OwncloudSetupPage::url() const
-{
- QString url = _ui.leUrl->text().simplified();
- return url;
-}
-
-QString OwncloudSetupPage::localFolder() const
-{
- QString folder = wizard()->property("localFolder").toString();
- return folder;
-}
-
-void OwncloudSetupPage::setConnected( bool comp )
-{
- _connected = comp;
- _ui.resultLayout->setEnabled(true);
- _progressIndi->setVisible(false);
- _progressIndi->stopAnimation();
-}
-
-bool OwncloudSetupPage::validatePage()
-{
- bool re = false;
-
- if( ! _connected) {
- setErrorString(QString::null);
- _checking = true;
- _ui.resultLayout->setEnabled(true);
- _progressIndi->setVisible(true);
- _progressIndi->startAnimation();
- emit completeChanged();
-
- emit connectToOCUrl( url() );
- return false;
- } else {
- // connecting is running
- stopSpinner();
- _checking = false;
- emit completeChanged();
- return true;
- }
-}
-
-void OwncloudSetupPage::setErrorString( const QString& err )
-{
- if( err.isEmpty()) {
- _ui.errorLabel->setVisible(false);
- } else {
- _ui.errorLabel->setVisible(true);
- _ui.errorLabel->setText(err);
- }
- _checking = false;
- emit completeChanged();
- stopSpinner();
-}
-
-void OwncloudSetupPage::stopSpinner()
-{
- _ui.resultLayout->setEnabled(false);
- _progressIndi->setVisible(false);
- _progressIndi->stopAnimation();
-}
-
-OwncloudSetupPage::SyncMode OwncloudSetupPage::syncMode()
-{
- return BoxMode;
-}
-
-void OwncloudSetupPage::setRemoteFolder( const QString& remoteFolder )
-{
- if( !remoteFolder.isEmpty() ) {
- _remoteFolder = remoteFolder;
- }
-}
-
-void OwncloudSetupPage::setMultipleFoldersExist(bool exist)
-{
- _multipleFoldersExist = exist;
-}
-
-void OwncloudSetupPage::slotSelectFolder()
-{
-
- QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath());
- if( !dir.isEmpty() ) {
- _ui.pbSelectLocalFolder->setText(dir);
- wizard()->setProperty("localFolder", dir);
- slotHandleUserInput();
- }
-}
-
-OwncloudSetupPage::SyncMode OwncloudWizard::syncMode()
-{
- return _setupPage->syncMode();
- return OwncloudSetupPage::BoxMode;
-}
-
-void OwncloudWizard::setMultipleFoldersExist(bool exist)
-{
- _setupPage->setMultipleFoldersExist(exist);
-}
-
-void OwncloudSetupPage::setConfigExists( bool config )
-{
- _configExists = config;
-
- if (config == true) {
- setSubTitle( tr("Change your user credentials")
- .arg(Theme::instance()->wizardHeaderTitleColor().name()));
- }
-}
-
-// ======================================================================
-
-OwncloudWizardResultPage::OwncloudWizardResultPage()
-{
- _ui.setupUi(this);
- // no fields to register.
-
- Theme *theme = Theme::instance();
- setTitle( tr("Everything set up!")
- .arg(theme->wizardHeaderTitleColor().name()));
- // required to show header in QWizard's modern style
- setSubTitle( QLatin1String(" ") );
-
- _ui.pbOpenLocal->setText("Open local folder");
- _ui.pbOpenServer->setText(tr("Open %1").arg(Theme::instance()->appNameGUI()));
-
- _ui.pbOpenLocal->setIcon(QIcon(":/mirall/resources/folder-sync.png"));
- _ui.pbOpenLocal->setText(tr("Open Local Folder"));
- _ui.pbOpenLocal->setIconSize(QSize(48, 48));
- connect(_ui.pbOpenLocal, SIGNAL(clicked()), SLOT(slotOpenLocal()));
-
- _ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
-
- QIcon appIcon = theme->applicationIcon();
- _ui.pbOpenServer->setIcon(appIcon.pixmap(48));
- _ui.pbOpenServer->setText(tr("Open %1").arg(theme->appNameGUI()));
- _ui.pbOpenServer->setIconSize(QSize(48, 48));
- _ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- connect(_ui.pbOpenServer, SIGNAL(clicked()), SLOT(slotOpenServer()));
- setupCustomization();
-}
-
-OwncloudWizardResultPage::~OwncloudWizardResultPage()
-{
-}
-
-void OwncloudWizardResultPage::setComplete(bool complete)
-{
- _complete = complete;
- emit completeChanged();
-}
-
-bool OwncloudWizardResultPage::isComplete() const
-{
- return _complete;
-}
-
-void OwncloudWizardResultPage::initializePage()
-{
- const QString localFolder = wizard()->property("localFolder").toString();
- QString text;
- if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) {
- text = tr("Your entire account is synced to the local folder %1")
- .arg(QDir::toNativeSeparators(localFolder));
- } else {
- text = tr("ownCloud folder %1 is synced to local folder %2")
- .arg(_remoteFolder).arg(QDir::toNativeSeparators(localFolder));
- }
- _ui.localFolderLabel->setText( text );
-
-}
-
-void OwncloudWizardResultPage::setRemoteFolder(const QString &remoteFolder)
-{
- _remoteFolder = remoteFolder;
-}
-
-void OwncloudWizardResultPage::setupCustomization()
-{
- // set defaults for the customize labels.
- _ui.topLabel->setText( QString::null );
- _ui.topLabel->hide();
-
- QVariant variant = Theme::instance()->customMedia( Theme::oCSetupResultTop );
- setupCustomMedia( variant, _ui.topLabel );
-}
-
-// ======================================================================
-
-/**
- * Folder wizard itself
- */
-
-OwncloudWizard::OwncloudWizard(QWidget *parent)
- : QWizard(parent),
- _configExists(false)
-{
- _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)));
-
- connect( _setupPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
-
-
- Theme *theme = Theme::instance();
- 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);
-}
-
-QString OwncloudWizard::localFolder() const
-{
- return(_setupPage->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 )
-{
- _setupPage->setRemoteFolder( remoteFolder );
- _resultPage->setRemoteFolder( 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;
-
- if( id == Page_oCSetup ) {
- setButtonText( QWizard::NextButton, tr("Connect...") );
- emit clearPendingRequests();
- _setupPage->initializePage();
-
- }
-
- if( id == Page_Result ) {
- appendToConfigurationLog( QString::null );
- }
-}
-
-void OwncloudWizard::displayError( const QString& msg )
-{
- _setupPage->setErrorString( msg );
-}
-
-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::setOCUser( const QString& user )
-{
- _oCUser = user;
- _setupPage->setOCUser( user );
-}
-
-void OwncloudWizard::setConfigExists( bool config )
-{
- _configExists = config;
- _setupPage->setConfigExists( config );
-}
-
-bool OwncloudWizard::configExists()
-{
- return _configExists;
-}
-
-void OwncloudWizardResultPage::slotOpenLocal()
-{
- const QString localFolder = wizard()->property("localFolder").toString();
- QDesktopServices::openUrl(QUrl::fromLocalFile(localFolder));
-}
-
-void OwncloudWizardResultPage::slotOpenServer()
-{
- QUrl url = field("OCUrl").toUrl();
- qDebug() << Q_FUNC_INFO << url;
- QDesktopServices::openUrl(url);
-}
-
-
-} // end namespace
diff --git a/src/mirall/owncloudwizard.h b/src/mirall/owncloudwizard.h
deleted file mode 100644
index ceccf12093..0000000000
--- a/src/mirall/owncloudwizard.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) by Duncan Mac-Vicar P.
- * Copyright (C) by Klaas Freitag
- *
- * 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.
- */
-
-#ifndef MIRALL_OWNCLOUDWIZARD_H
-#define MIRALL_OWNCLOUDWIZARD_H
-
-#include
-
-#include "ui_owncloudsetuppage_ng.h"
-#include "ui_owncloudwizardresultpage.h"
-
-class QLabel;
-class QVariant;
-class QProgressIndicator;
-
-namespace Mirall {
-
-class OwncloudSetupPage;
-class OwncloudWizardResultPage;
-
-class OwncloudSetupPage: public QWizardPage
-{
- Q_OBJECT
-public:
- OwncloudSetupPage();
- ~OwncloudSetupPage();
-
- enum SyncMode {
- SelectiveMode,
- BoxMode
- };
-
- virtual bool isComplete() const;
- virtual void initializePage();
- virtual int nextId() const;
- void setServerUrl( const QString& );
- void setOCUser( const QString& );
- void setAllowPasswordStorage( bool );
- bool validatePage();
- QString url() const;
- QString localFolder() const;
- void setConnected(bool complete);
- void setRemoteFolder( const QString& remoteFolder);
- void setMultipleFoldersExist( bool exist );
-
- SyncMode syncMode();
-
-public slots:
- void setErrorString( const QString& );
- void setConfigExists( bool );
- void stopSpinner();
-
-protected slots:
- void slotUrlChanged(const QString&);
- void slotUserChanged(const QString&);
-
- void setupCustomization();
- void slotToggleAdvanced(int state);
- void slotSelectFolder();
-
-signals:
- void connectToOCUrl( const QString& );
-
-protected:
- void updateFoldersInfo();
-
-private slots:
- void slotHandleUserInput();
-
-private:
- bool urlHasChanged();
-
- Ui_OwncloudSetupPage _ui;
- QString _oCUrl;
- QString _ocUser;
- bool _connected;
- bool _checking;
- bool _configExists;
- bool _multipleFoldersExist;
-
- QProgressIndicator *_progressIndi;
- QButtonGroup *_selectiveSyncButtons;
- QString _remoteFolder;
-};
-
-class OwncloudWizard: public QWizard
-{
- Q_OBJECT
-public:
-
- enum {
- Page_oCSetup,
- Page_Result
- };
-
- enum LogType {
- LogPlain,
- LogParagraph
- };
-
- OwncloudWizard(QWidget *parent = 0);
-
- void setOCUrl( const QString& );
- void setOCUser( const QString& );
-
- void setupCustomMedia( QVariant, QLabel* );
- QString ocUrl() const;
- QString localFolder() const;
-
- void enableFinishOnResultWidget(bool enable);
-
- void displayError( const QString& );
- OwncloudSetupPage::SyncMode syncMode();
- void setMultipleFoldersExist( bool );
- void setConfigExists( bool );
- bool configExists();
-
-public slots:
- void setRemoteFolder( const QString& );
- void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph );
- void slotCurrentPageChanged( int );
-
- void showConnectInfo( const QString& );
- void successfullyConnected(bool);
-
-signals:
- void clearPendingRequests();
- void connectToOCUrl( const QString& );
-
-private:
- OwncloudSetupPage *_setupPage;
- OwncloudWizardResultPage *_resultPage;
-
- QString _configFile;
- QString _oCUser;
- QStringList _setupLog;
- bool _configExists;
-};
-
-
-/**
- * page to ask for the type of Owncloud to connect to
- */
-
-/**
- * page to display the install result
- */
-class OwncloudWizardResultPage : public QWizardPage
-{
- Q_OBJECT
-public:
- OwncloudWizardResultPage();
- ~OwncloudWizardResultPage();
-
- bool isComplete() const;
- void initializePage();
- void setRemoteFolder( const QString& remoteFolder);
-
-public slots:
- void setComplete(bool complete);
-
-protected slots:
- void slotOpenLocal();
- void slotOpenServer();
-
-protected:
- void setupCustomization();
-
-private:
- QString _localFolder;
- QString _remoteFolder;
- bool _complete;
-
- Ui_OwncloudWizardResultPage _ui;
-};
-
-} // ns Mirall
-
-#endif
diff --git a/src/mirall/wizard/owncloudhttpcredspage.cpp b/src/mirall/wizard/owncloudhttpcredspage.cpp
new file mode 100644
index 0000000000..99d06acccf
--- /dev/null
+++ b/src/mirall/wizard/owncloudhttpcredspage.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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 "QProgressIndicator.h"
+
+#include "mirall/wizard/owncloudhttpcredspage.h"
+#include "mirall/theme.h"
+#include "mirall/wizard/owncloudwizardcommon.h"
+
+namespace Mirall
+{
+
+OwncloudHttpCredsPage::OwncloudHttpCredsPage()
+ : QWizardPage(),
+ _ui(),
+ _connected(false),
+ _checking(false),
+ _progressIndi(new QProgressIndicator (this))
+{
+ _ui.setupUi(this);
+
+ registerField( QLatin1String("OCUser*"), _ui.leUsername);
+ registerField( QLatin1String("OCPasswd*"), _ui.lePassword);
+
+ setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
+ setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Enter user credentials")));
+
+ _ui.resultLayout->addWidget( _progressIndi );
+ stopSpinner();
+ setupCustomization();
+}
+
+void OwncloudHttpCredsPage::setupCustomization()
+{
+ // set defaults for the customize labels.
+ _ui.topLabel->hide();
+ _ui.bottomLabel->hide();
+
+ Theme *theme = Theme::instance();
+ QVariant variant = theme->customMedia( Theme::oCSetupTop );
+ if( !variant.isNull() ) {
+ WizardCommon::setupCustomMedia( variant, _ui.topLabel );
+ }
+
+ variant = theme->customMedia( Theme::oCSetupBottom );
+ WizardCommon::setupCustomMedia( variant, _ui.bottomLabel );
+}
+
+void OwncloudHttpCredsPage::initializePage()
+{
+ WizardCommon::initErrorLabel(_ui.errorLabel);
+ _ui.leUsername->setFocus();
+}
+
+void OwncloudHttpCredsPage::cleanupPage()
+{
+ _ui.leUsername->clear();
+ _ui.lePassword->clear();
+}
+
+bool OwncloudHttpCredsPage::validatePage()
+{
+ if (_ui.leUsername->text().isEmpty() || _ui.lePassword->text().isEmpty()) {
+ return false;
+ }
+
+ if (!_connected) {
+ _checking = true;
+ emit completeChanged();
+ emit connectToOCUrl(field("OCUrl").toString().simplified());
+
+ return false;
+ } else {
+ _checking = false;
+ emit completeChanged();
+ return true;
+ }
+ return true;
+}
+
+int OwncloudHttpCredsPage::nextId() const
+{
+ return WizardCommon::Page_Result;
+}
+
+void OwncloudHttpCredsPage::setConnected( bool comp )
+{
+ _connected = comp;
+ stopSpinner ();
+}
+
+void OwncloudHttpCredsPage::startSpinner()
+{
+ _ui.resultLayout->setEnabled(true);
+ _progressIndi->setVisible(true);
+ _progressIndi->startAnimation();
+}
+
+void OwncloudHttpCredsPage::stopSpinner()
+{
+ _ui.resultLayout->setEnabled(false);
+ _progressIndi->setVisible(false);
+ _progressIndi->stopAnimation();
+}
+
+void OwncloudHttpCredsPage::setOCUser(const QString& user)
+{
+ _ui.leUsername->setText(user);
+}
+
+void OwncloudHttpCredsPage::setErrorString(const QString& err)
+{
+ if( err.isEmpty()) {
+ _ui.errorLabel->setVisible(false);
+ } else {
+ _ui.errorLabel->setVisible(true);
+ _ui.errorLabel->setText(err);
+ }
+ _checking = false;
+ emit completeChanged();
+ stopSpinner();
+}
+
+} // ns Mirall
diff --git a/src/mirall/wizard/owncloudhttpcredspage.h b/src/mirall/wizard/owncloudhttpcredspage.h
new file mode 100644
index 0000000000..c9eadbd9f4
--- /dev/null
+++ b/src/mirall/wizard/owncloudhttpcredspage.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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.
+ */
+
+#ifndef MIRALL_OWNCLOUD_HTTP_CREDS_PAGE_H
+#define MIRALL_OWNCLOUD_HTTP_CREDS_PAGE_H
+
+#include
+
+#include "ui_owncloudhttpcredspage.h"
+
+class QProgressIndicator;
+
+namespace Mirall {
+
+class OwncloudHttpCredsPage : public QWizardPage
+{
+ Q_OBJECT
+public:
+ OwncloudHttpCredsPage();
+
+ void setOCUser(const QString& user);
+ void initializePage();
+ void cleanupPage();
+ bool validatePage();
+ int nextId() const;
+ void setConnected(bool connected);
+ void setErrorString( const QString& err );
+
+Q_SIGNALS:
+ void connectToOCUrl(const QString&);
+
+private:
+ void startSpinner();
+ void stopSpinner();
+ void setupCustomization();
+
+ Ui_OwncloudHttpCredsPage _ui;
+ bool _connected;
+ bool _checking;
+ QProgressIndicator* _progressIndi;
+};
+
+} // ns Mirall
+
+#endif
diff --git a/src/mirall/wizard/owncloudsetuppage.cpp b/src/mirall/wizard/owncloudsetuppage.cpp
new file mode 100644
index 0000000000..e32381a520
--- /dev/null
+++ b/src/mirall/wizard/owncloudsetuppage.cpp
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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
+#include
+#include
+
+#include "QProgressIndicator.h"
+
+#include "mirall/wizard/owncloudwizardcommon.h"
+#include "mirall/wizard/owncloudsetuppage.h"
+#include "mirall/theme.h"
+
+namespace Mirall
+{
+
+OwncloudSetupPage::OwncloudSetupPage()
+ : QWizardPage(),
+ _ui(),
+ _oCUrl(),
+ _ocUser(),
+ _authTypeKnown(false),
+ _checking(false),
+ _multipleFoldersExist(false),
+ _authType(WizardCommon::HttpCreds),
+ _progressIndi(new QProgressIndicator (this)),
+ _selectiveSyncButtons(0),
+ _remoteFolder()
+{
+ _ui.setupUi(this);
+
+ Theme *theme = Theme::instance();
+ setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI())));
+ setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Setup ownCloud server")));
+
+ registerField( QLatin1String("OCUrl*"), _ui.leUrl );
+ registerField( QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch);
+
+ _ui.advancedBox->setVisible(false);
+
+ _ui.resultLayout->addWidget( _progressIndi );
+ stopSpinner();
+
+ setupCustomization();
+
+ connect(_ui.leUrl, SIGNAL(textChanged(QString)), SLOT(slotUrlChanged(QString)));
+ connect( _ui.cbAdvanced, SIGNAL(stateChanged (int)), SLOT(slotToggleAdvanced(int)));
+ connect( _ui.pbSelectLocalFolder, SIGNAL(clicked()), SLOT(slotSelectFolder()));
+}
+
+void OwncloudSetupPage::slotToggleAdvanced(int state)
+{
+ _ui.advancedBox->setVisible( state == Qt::Checked );
+ slotHandleUserInput();
+ QSize size = wizard()->sizeHint();
+ // need to substract header for some reason
+ size -= QSize(0, 63);
+
+ wizard()->setMinimumSize(size);
+ wizard()->resize(size);
+}
+
+void OwncloudSetupPage::setServerUrl( const QString& newUrl )
+{
+ _oCUrl = newUrl;
+ if( _oCUrl.isEmpty() ) {
+ _ui.leUrl->clear();
+ return;
+ }
+
+ _ui.leUrl->setText( _oCUrl );
+}
+
+void OwncloudSetupPage::setupCustomization()
+{
+ // set defaults for the customize labels.
+ _ui.topLabel->hide();
+ _ui.bottomLabel->hide();
+
+ Theme *theme = Theme::instance();
+ QVariant variant = theme->customMedia( Theme::oCSetupTop );
+ if( !variant.isNull() ) {
+ WizardCommon::setupCustomMedia( variant, _ui.topLabel );
+ }
+
+ variant = theme->customMedia( Theme::oCSetupBottom );
+ WizardCommon::setupCustomMedia( variant, _ui.bottomLabel );
+
+ QString fixUrl = theme->overrideServerUrl();
+ if( !fixUrl.isEmpty() ) {
+ _ui.label_2->hide();
+ setServerUrl( fixUrl );
+ _ui.leUrl->setEnabled( false );
+ _ui.leUrl->hide();
+ }
+}
+
+// slot hit from textChanged of the url entry field.
+void OwncloudSetupPage::slotUrlChanged(const QString& ocUrl)
+{
+ slotHandleUserInput();
+
+#if 0
+ QString url = ocUrl;
+ bool visible = false;
+
+ if (url.startsWith(QLatin1String("https://"))) {
+ _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.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-low.png"));
+ _ui.urlLabel->setToolTip(tr("This url is NOT secure. You should not use it."));W
+ visible = true;
+ }
+#endif
+}
+
+bool OwncloudSetupPage::isComplete() const
+{
+ return !_ui.leUrl->text().isEmpty() && !_checking;
+}
+
+void OwncloudSetupPage::initializePage()
+{
+ WizardCommon::initErrorLabel(_ui.errorLabel);
+
+ _authTypeKnown = false;
+ _checking = false;
+ _multipleFoldersExist = false;
+
+ // call to init label
+ slotHandleUserInput();
+
+ _ui.leUrl->setFocus();
+}
+
+bool OwncloudSetupPage::urlHasChanged()
+{
+ bool change = false;
+ const QChar slash('/');
+
+ QUrl currentUrl( url() );
+ QUrl initialUrl( _oCUrl );
+
+ QString currentPath = currentUrl.path();
+ QString initialPath = initialUrl.path();
+
+ // add a trailing slash.
+ if( ! currentPath.endsWith( slash )) currentPath += slash;
+ if( ! initialPath.endsWith( slash )) initialPath += slash;
+
+ if( currentUrl.host() != initialUrl.host() ||
+ currentUrl.port() != initialUrl.port() ||
+ currentPath != initialPath ) {
+ change = true;
+ }
+
+ return change;
+}
+
+// Called if the user changes the user- or url field. Adjust the texts and
+// evtl. warnings on the dialog.
+void OwncloudSetupPage::slotHandleUserInput()
+{
+ // if the url has not changed, return.
+ if( ! urlHasChanged() ) {
+ // disable the advanced button as nothing has changed.
+ _ui.cbAdvanced->setEnabled(false);
+ _ui.advancedBox->setEnabled(false);
+ } else {
+ // Enable advanced stuff for new connection configuration.
+ _ui.cbAdvanced->setEnabled(true);
+ _ui.advancedBox->setEnabled(true);
+ }
+
+ const QString locFolder = localFolder();
+
+ // check if the local folder exists. If so, and if its not empty, show a warning.
+ QDir dir( locFolder );
+ QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
+
+ QString t;
+
+ if( !urlHasChanged() && _configExists ) {
+ // This is the password change mode: No change to the url and a config
+ // to an ownCloud exists.
+ t = tr("Press Next to change the Password for your configured account.");
+ } else {
+ // Complete new setup.
+ _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder));
+
+ if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
+ t = tr("Your entire account will be synced to the local folder '%1'.")
+ .arg(QDir::toNativeSeparators(locFolder));
+ } else {
+ t = tr("%1 folder '%2' is synced to local folder '%3'")
+ .arg(Theme::instance()->appName()).arg(_remoteFolder)
+ .arg(QDir::toNativeSeparators(locFolder));
+ }
+
+ if ( _multipleFoldersExist ) {
+ t += tr("Warning: You currently have multiple folders "
+ "configured. If you continue with the current settings, the folder configurations "
+ "will be discarded and a single root folder sync will be created!
");
+ }
+
+ if( entries.count() > 0) {
+ // the directory is not empty
+ if (!_ui.cbAdvanced->isChecked()) {
+ t += tr("Warning: The local directory is not empty. "
+ "Pick a resolution in the advanced settings!
");
+ }
+ _ui.resolutionWidget->setVisible(true);
+ } else {
+ // the dir is empty, which means that there is no problem.
+ _ui.resolutionWidget->setVisible(false);
+ }
+ }
+
+ _ui.syncModeLabel->setText(t);
+ _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height());
+}
+
+int OwncloudSetupPage::nextId() const
+{
+ if (_authType == WizardCommon::HttpCreds) {
+ return WizardCommon::Page_HttpCreds;
+ } else {
+ // TODO: rather display some browser component. maybe different page.
+ return WizardCommon::Page_Result;
+ }
+}
+
+QString OwncloudSetupPage::url() const
+{
+ QString url = _ui.leUrl->text().simplified();
+ return url;
+}
+
+QString OwncloudSetupPage::localFolder() const
+{
+ QString folder = wizard()->property("localFolder").toString();
+ return folder;
+}
+
+bool OwncloudSetupPage::validatePage()
+{
+ bool re = false;
+
+ if( ! _authTypeKnown) {
+ setErrorString(QString::null);
+ _checking = true;
+ startSpinner ();
+ emit completeChanged();
+
+ emit determineAuthType(url());
+ return false;
+ } else {
+ // connecting is running
+ stopSpinner();
+ _checking = false;
+ emit completeChanged();
+ return true;
+ }
+}
+
+void OwncloudSetupPage::setAuthType (WizardCommon::AuthType type)
+{
+ _authTypeKnown = true;
+ _authType = type;
+ stopSpinner();
+}
+
+void OwncloudSetupPage::setErrorString( const QString& err )
+{
+ if( err.isEmpty()) {
+ _ui.errorLabel->setVisible(false);
+ } else {
+ _ui.errorLabel->setVisible(true);
+ _ui.errorLabel->setText(err);
+ }
+ _checking = false;
+ emit completeChanged();
+ stopSpinner();
+}
+
+void OwncloudSetupPage::startSpinner()
+{
+ _ui.resultLayout->setEnabled(true);
+ _progressIndi->setVisible(true);
+ _progressIndi->startAnimation();
+}
+
+void OwncloudSetupPage::stopSpinner()
+{
+ _ui.resultLayout->setEnabled(false);
+ _progressIndi->setVisible(false);
+ _progressIndi->stopAnimation();
+}
+
+WizardCommon::SyncMode OwncloudSetupPage::syncMode()
+{
+ return WizardCommon::BoxMode;
+}
+
+void OwncloudSetupPage::setRemoteFolder( const QString& remoteFolder )
+{
+ if( !remoteFolder.isEmpty() ) {
+ _remoteFolder = remoteFolder;
+ }
+}
+
+void OwncloudSetupPage::setMultipleFoldersExist(bool exist)
+{
+ _multipleFoldersExist = exist;
+}
+
+void OwncloudSetupPage::slotSelectFolder()
+{
+ QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath());
+ if( !dir.isEmpty() ) {
+ _ui.pbSelectLocalFolder->setText(dir);
+ wizard()->setProperty("localFolder", dir);
+ slotHandleUserInput();
+ }
+}
+
+void OwncloudSetupPage::setConfigExists( bool config )
+{
+ _configExists = config;
+
+ if (config == true) {
+ setSubTitle( tr("Change your user credentials")
+ .arg(Theme::instance()->wizardHeaderTitleColor().name()));
+ }
+}
+
+} // ns Mirall
diff --git a/src/mirall/wizard/owncloudsetuppage.h b/src/mirall/wizard/owncloudsetuppage.h
new file mode 100644
index 0000000000..c56dd15504
--- /dev/null
+++ b/src/mirall/wizard/owncloudsetuppage.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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.
+ */
+
+#ifndef MIRALL_OWNCLOUD_SETUP_PAGE_H
+#define MIRALL_OWNCLOUD_SETUP_PAGE_H
+
+#include
+
+#include "mirall/wizard/owncloudwizardcommon.h"
+#include "ui_owncloudsetupnocredspage.h"
+
+class QLabel;
+class QVariant;
+class QProgressIndicator;
+
+namespace Mirall {
+
+class OwncloudSetupPage: public QWizardPage
+{
+ Q_OBJECT
+public:
+ OwncloudSetupPage();
+
+ virtual bool isComplete() const;
+ virtual void initializePage();
+ virtual int nextId() const;
+ void setServerUrl( const QString& );
+ void setAllowPasswordStorage( bool );
+ bool validatePage();
+ QString url() const;
+ QString localFolder() const;
+ void setRemoteFolder( const QString& remoteFolder);
+ void setMultipleFoldersExist( bool exist );
+
+ WizardCommon::SyncMode syncMode();
+ void setAuthType(WizardCommon::AuthType type);
+
+public slots:
+ void setErrorString( const QString& );
+ void setConfigExists( bool );
+ void startSpinner();
+ void stopSpinner();
+
+protected slots:
+ void slotUrlChanged(const QString&);
+
+ void setupCustomization();
+ void slotToggleAdvanced(int state);
+ void slotSelectFolder();
+
+signals:
+ void determineAuthType(const QString&);
+
+protected:
+ void updateFoldersInfo();
+
+private slots:
+ void slotHandleUserInput();
+
+private:
+ bool urlHasChanged();
+
+ Ui_OwncloudSetupPage _ui;
+ QString _oCUrl;
+ QString _ocUser;
+ bool _authTypeKnown;
+ bool _checking;
+ bool _configExists;
+ bool _multipleFoldersExist;
+ WizardCommon::AuthType _authType;
+
+ QProgressIndicator* _progressIndi;
+ QButtonGroup* _selectiveSyncButtons;
+ QString _remoteFolder;
+};
+
+} // ns Mirall
+
+#endif
diff --git a/src/mirall/wizard/owncloudwizard.cpp b/src/mirall/wizard/owncloudwizard.cpp
new file mode 100644
index 0000000000..b5d21e0078
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizard.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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/wizard/owncloudwizard.h"
+#include "mirall/mirallconfigfile.h"
+#include "mirall/theme.h"
+#include "mirall/wizard/owncloudsetuppage.h"
+#include "mirall/wizard/owncloudhttpcredspage.h"
+#include "mirall/wizard/owncloudwizardresultpage.h"
+
+#include "QProgressIndicator.h"
+
+#include
+#include
+
+#include
+
+namespace Mirall
+{
+
+WizardCommon::SyncMode OwncloudWizard::syncMode()
+{
+ return _setupPage->syncMode();
+ return WizardCommon::BoxMode;
+}
+
+void OwncloudWizard::setMultipleFoldersExist(bool exist)
+{
+ _setupPage->setMultipleFoldersExist(exist);
+}
+
+OwncloudWizard::OwncloudWizard(QWidget *parent)
+ : QWizard(parent),
+ _configExists(false)
+{
+ _setupPage = new OwncloudSetupPage;
+ _httpCredsPage = new OwncloudHttpCredsPage;
+ _resultPage = new OwncloudWizardResultPage;
+ setPage(WizardCommon::Page_oCSetup, _setupPage );
+ setPage(WizardCommon::Page_HttpCreds, _httpCredsPage);
+ setPage(WizardCommon::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)));
+ connect( _setupPage, SIGNAL(determineAuthType(QString)), SIGNAL(determineAuthType(QString)));
+ connect( _httpCredsPage, SIGNAL(connectToOCUrl(QString)), SIGNAL(connectToOCUrl(QString)));
+
+
+ Theme *theme = Theme::instance();
+ 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);
+}
+
+QString OwncloudWizard::localFolder() const
+{
+ return(_setupPage->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 )
+{
+ _setupPage->setRemoteFolder( remoteFolder );
+ _resultPage->setRemoteFolder( remoteFolder );
+}
+
+void OwncloudWizard::showConnectInfo( const QString& msg )
+{
+ if( _setupPage ) {
+ _setupPage->setErrorString( msg );
+ }
+}
+
+void OwncloudWizard::successfullyConnected(bool enable)
+{
+ _httpCredsPage->setConnected( enable );
+
+ if( enable ) {
+ next();
+ }
+}
+
+void OwncloudWizard::setAuthType(WizardCommon::AuthType type)
+{
+ _setupPage->setAuthType(type);
+ next();
+}
+
+void OwncloudWizard::slotCurrentPageChanged( int id )
+{
+ qDebug() << "Current Wizard page changed to " << id;
+
+ if( id == WizardCommon::Page_oCSetup ) {
+ setButtonText( QWizard::NextButton, tr("Connect...") );
+ emit clearPendingRequests();
+ _setupPage->initializePage();
+
+ }
+
+ if( id == WizardCommon::Page_Result ) {
+ appendToConfigurationLog( QString::null );
+ }
+}
+
+void OwncloudWizard::displayError( const QString& msg )
+{
+ if (currentId() == WizardCommon::Page_oCSetup) {
+ _setupPage->setErrorString( msg );
+ } else {
+ _httpCredsPage->setErrorString(msg);
+ }
+}
+
+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::setOCUser( const QString& user )
+{
+ _oCUser = user;
+ _httpCredsPage->setOCUser( user );
+}
+
+void OwncloudWizard::setConfigExists( bool config )
+{
+ _configExists = config;
+ _setupPage->setConfigExists( config );
+}
+
+bool OwncloudWizard::configExists()
+{
+ return _configExists;
+}
+
+} // end namespace
diff --git a/src/mirall/wizard/owncloudwizard.h b/src/mirall/wizard/owncloudwizard.h
new file mode 100644
index 0000000000..bd6cf6814a
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizard.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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.
+ */
+
+#ifndef MIRALL_OWNCLOUD_WIZARD_H
+#define MIRALL_OWNCLOUD_WIZARD_H
+
+#include
+
+#include "owncloudwizardcommon.h"
+
+namespace Mirall {
+
+class OwncloudSetupPage;
+class OwncloudHttpCredsPage;
+class OwncloudWizardResultPage;
+
+class OwncloudWizard: public QWizard
+{
+ Q_OBJECT
+public:
+
+ enum LogType {
+ LogPlain,
+ LogParagraph
+ };
+
+ OwncloudWizard(QWidget *parent = 0);
+
+ void setOCUrl( const QString& );
+ void setOCUser( const QString& );
+
+ void setupCustomMedia( QVariant, QLabel* );
+ QString ocUrl() const;
+ QString localFolder() const;
+
+ void enableFinishOnResultWidget(bool enable);
+
+ void displayError( const QString& );
+ WizardCommon::SyncMode syncMode();
+ void setMultipleFoldersExist( bool );
+ void setConfigExists( bool );
+ bool configExists();
+
+public slots:
+ void setRemoteFolder( const QString& );
+ void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph );
+ void slotCurrentPageChanged( int );
+
+ void showConnectInfo( const QString& );
+
+public:
+ void successfullyConnected(bool);
+ void setAuthType(WizardCommon::AuthType type);
+
+signals:
+ void clearPendingRequests();
+ void connectToOCUrl( const QString& );
+ void determineAuthType(const QString&);
+
+private:
+ OwncloudSetupPage* _setupPage;
+ OwncloudHttpCredsPage* _httpCredsPage;
+ OwncloudWizardResultPage* _resultPage;
+
+ QString _configFile;
+ QString _oCUser;
+ QStringList _setupLog;
+ bool _configExists;
+};
+
+} // ns Mirall
+
+#endif
diff --git a/src/mirall/wizard/owncloudwizardcommon.cpp b/src/mirall/wizard/owncloudwizardcommon.cpp
new file mode 100644
index 0000000000..10e66bb1b4
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizardcommon.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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
+#include
+#include
+
+#include "mirall/wizard/owncloudwizardcommon.h"
+#include "mirall/theme.h"
+
+namespace Mirall
+{
+
+namespace WizardCommon
+{
+
+void setupCustomMedia( const QVariant& variant, QLabel *label )
+{
+ if( !label ) return;
+
+ QPixmap pix = variant.value();
+ if( !pix.isNull() ) {
+ label->setPixmap(pix);
+ label->setAlignment( Qt::AlignTop | Qt::AlignRight );
+ label->setVisible(true);
+ } else {
+ QString str = variant.toString();
+ if( !str.isEmpty() ) {
+ label->setText( str );
+ label->setTextFormat( Qt::RichText );
+ label->setVisible(true);
+ label->setOpenExternalLinks(true);
+ }
+ }
+}
+
+QString titleTemplate()
+{
+ return QString::fromLatin1("").arg(Theme::instance()->wizardHeaderTitleColor().name()) + QString::fromLatin1("%1");
+}
+
+QString subTitleTemplate()
+{
+ return QString::fromLatin1("").arg(Theme::instance()->wizardHeaderTitleColor().name()) + QString::fromLatin1("%1");
+}
+
+void initErrorLabel(QLabel* errorLabel)
+{
+ QString style = QLatin1String("border: 1px solid #eed3d7; border-radius: 5px; padding: 3px;"
+ "background-color: #f2dede; color: #b94a48;");
+
+ errorLabel->setStyleSheet(style);
+ errorLabel->setWordWrap(true);
+ errorLabel->setVisible(false);
+}
+
+} // ns WizardCommon
+
+} // ns Mirall
diff --git a/src/mirall/wizard/owncloudwizardcommon.h b/src/mirall/wizard/owncloudwizardcommon.h
new file mode 100644
index 0000000000..d4b0ec21c9
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizardcommon.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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.
+ */
+
+#ifndef MIRALL_OWNCLOUD_WIZARD_COMMON_H
+#define MIRALL_OWNCLOUD_WIZARD_COMMON_H
+
+class QVariant;
+class QLabel;
+
+namespace Mirall
+{
+
+namespace WizardCommon
+{
+
+void setupCustomMedia( const QVariant& variant, QLabel *label );
+QString titleTemplate();
+QString subTitleTemplate();
+void initErrorLabel(QLabel* errorLabel);
+
+enum AuthType {
+ HttpCreds,
+ Shibboleth
+};
+
+enum SyncMode {
+ SelectiveMode,
+ BoxMode
+};
+
+enum Pages {
+ Page_oCSetup,
+ Page_HttpCreds,
+ Page_Result
+};
+
+} // ns WizardCommon
+
+} // ns Mirall
+
+#endif // MIRALL_OWNCLOUD_WIZARD_COMMON_H
diff --git a/src/mirall/wizard/owncloudwizardresultpage.cpp b/src/mirall/wizard/owncloudwizardresultpage.cpp
new file mode 100644
index 0000000000..a4ece42365
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizardresultpage.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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
+#include
+#include
+#include
+
+#include "mirall/wizard/owncloudwizardresultpage.h"
+#include "mirall/wizard/owncloudwizardcommon.h"
+#include "mirall/theme.h"
+
+namespace Mirall
+{
+
+OwncloudWizardResultPage::OwncloudWizardResultPage()
+ : QWizardPage(),
+ _localFolder(),
+ _remoteFolder(),
+ _complete(false),
+ _ui()
+{
+ _ui.setupUi(this);
+ // no fields to register.
+
+ setTitle(WizardCommon::subTitleTemplate().arg(tr("Everything set up!")));
+ // required to show header in QWizard's modern style
+ setSubTitle( QLatin1String(" ") );
+
+ _ui.pbOpenLocal->setText(tr("Open Local Folder"));
+ _ui.pbOpenLocal->setIcon(QIcon(":/mirall/resources/folder-sync.png"));
+ _ui.pbOpenLocal->setIconSize(QSize(48, 48));
+ _ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ connect(_ui.pbOpenLocal, SIGNAL(clicked()), SLOT(slotOpenLocal()));
+
+ Theme* theme = Theme::instance();
+ QIcon appIcon = theme->applicationIcon();
+ _ui.pbOpenServer->setText(tr("Open %1").arg(theme->appNameGUI()));
+ _ui.pbOpenServer->setIcon(appIcon.pixmap(48));
+ _ui.pbOpenServer->setIconSize(QSize(48, 48));
+ _ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ connect(_ui.pbOpenServer, SIGNAL(clicked()), SLOT(slotOpenServer()));
+ setupCustomization();
+}
+
+OwncloudWizardResultPage::~OwncloudWizardResultPage()
+{}
+
+void OwncloudWizardResultPage::setComplete(bool complete)
+{
+ _complete = complete;
+ emit completeChanged();
+}
+
+bool OwncloudWizardResultPage::isComplete() const
+{
+ return _complete;
+}
+
+void OwncloudWizardResultPage::initializePage()
+{
+ const QString localFolder = wizard()->property("localFolder").toString();
+ QString text;
+ if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) {
+ text = tr("Your entire account is synced to the local folder %1")
+ .arg(QDir::toNativeSeparators(localFolder));
+ } else {
+ text = tr("ownCloud folder %1 is synced to local folder %2")
+ .arg(_remoteFolder).arg(QDir::toNativeSeparators(localFolder));
+ }
+ _ui.localFolderLabel->setText( text );
+
+}
+
+void OwncloudWizardResultPage::setRemoteFolder(const QString &remoteFolder)
+{
+ _remoteFolder = remoteFolder;
+}
+
+void OwncloudWizardResultPage::setupCustomization()
+{
+ // set defaults for the customize labels.
+ _ui.topLabel->setText( QString::null );
+ _ui.topLabel->hide();
+
+ QVariant variant = Theme::instance()->customMedia( Theme::oCSetupResultTop );
+ WizardCommon::setupCustomMedia( variant, _ui.topLabel );
+}
+
+void OwncloudWizardResultPage::slotOpenLocal()
+{
+ const QString localFolder = wizard()->property("localFolder").toString();
+ QDesktopServices::openUrl(QUrl::fromLocalFile(localFolder));
+}
+
+void OwncloudWizardResultPage::slotOpenServer()
+{
+ QUrl url = field("OCUrl").toUrl();
+ qDebug() << Q_FUNC_INFO << url;
+ QDesktopServices::openUrl(url);
+}
+
+} // ns Mirall
diff --git a/src/mirall/wizard/owncloudwizardresultpage.h b/src/mirall/wizard/owncloudwizardresultpage.h
new file mode 100644
index 0000000000..64158e130c
--- /dev/null
+++ b/src/mirall/wizard/owncloudwizardresultpage.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) by Duncan Mac-Vicar P.
+ * Copyright (C) by Klaas Freitag
+ * Copyright (C) by Krzesimir Nowak
+ *
+ * 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.
+ */
+
+#ifndef MIRALL_OWNCLOUD_WIZARD_RESULT_PAGE_H
+#define MIRALL_OWNCLOUD_WIZARD_RESULT_PAGE_H
+
+#include
+
+#include "ui_owncloudwizardresultpage.h"
+
+namespace Mirall {
+
+class OwncloudWizardResultPage : public QWizardPage
+{
+ Q_OBJECT
+public:
+ OwncloudWizardResultPage();
+ ~OwncloudWizardResultPage();
+
+ bool isComplete() const;
+ void initializePage();
+ void setRemoteFolder( const QString& remoteFolder);
+
+public slots:
+ void setComplete(bool complete);
+
+protected slots:
+ void slotOpenLocal();
+ void slotOpenServer();
+
+protected:
+ void setupCustomization();
+
+private:
+ QString _localFolder;
+ QString _remoteFolder;
+ bool _complete;
+
+ Ui_OwncloudWizardResultPage _ui;
+};
+
+} // ns Mirall
+
+#endif