1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2026-04-22 13:06:02 +02:00

Compare commits

...

30 Commits

Author SHA1 Message Date
Daniel Molkentin
c1b92f9fed beta2 2013-05-31 16:25:57 +02:00
Daniel Molkentin
b028ca0738 Merge pull request #650 from manolopm/master
Fixes for windows client when setup server url customization
2013-05-31 07:25:09 -07:00
Daniel Molkentin
a9aab30d55 Display proxy errors 2013-05-31 16:16:56 +02:00
Daniel Molkentin
efbad3a3c8 Propagate proxy changes to csync at run time 2013-05-31 16:16:41 +02:00
Manuel Padron Martinez
b6ed959f98 Removes server url label if a custom url is defined
Signed-off-by: Manuel Padron Martinez <manolopm@gmail.com>
2013-05-31 04:46:26 +01:00
Manuel Padron Martinez
477953f965 Put wizard url customization before connect signals
Signed-off-by: Manuel Padron Martinez <manolopm@gmail.com>
2013-05-31 04:45:48 +01:00
Daniel Molkentin
aaf59cece5 Wizard: Normalize directory separators 2013-05-29 17:24:59 +02:00
Daniel Molkentin
e88b7e8ec2 Centralize User Agent string and use in UpdateDetector 2013-05-29 16:13:38 +02:00
Daniel Molkentin
078b09b5f4 Remove obsolete include 2013-05-29 16:12:42 +02:00
Daniel Molkentin
0d06fe764a Status dialog: Use correct font metrics
This avoids cutting charcters such as 'y'.
2013-05-29 14:46:02 +02:00
Daniel Molkentin
94f8c39a9e Proxy settings: Also keep proxy user/pwd
make sure not to use it when the user
has asked us not to.

Simplify setupProxy()
2013-05-29 12:56:23 +02:00
Daniel Molkentin
7d1bd9da86 Properly deal with SOCKS proxies
Fixes #10
2013-05-29 02:14:40 +02:00
Daniel Molkentin
ed8cdf6910 Remember proxy settings even after switching type
Fixes #649
2013-05-29 01:41:04 +02:00
Daniel Molkentin
7ee83847c8 Do not try to reset the wizard when visible 2013-05-29 01:30:00 +02:00
Daniel Molkentin
52eca1362f Delete QWizard on destruction 2013-05-29 01:29:56 +02:00
Daniel Molkentin
eec1af09c4 Wizard: Fix rich text label layouting 2013-05-29 01:17:12 +02:00
Daniel Molkentin
c651c8cbf9 Wizard: Improve wording. 2013-05-29 01:16:52 +02:00
Daniel Molkentin
da6a398624 Wizard: Warn on re-setup with multiple folders 2013-05-28 20:25:31 +02:00
Daniel Molkentin
1418512a9f More cheating on proxies: Add OS to User-Agent 2013-05-28 19:35:30 +02:00
Daniel Molkentin
dd2859880b Set User-Agent to contain Mozilla/5.0 string
A blatant lie for a blatant abuse of Firewall filters.
2013-05-28 15:44:41 +02:00
Daniel Molkentin
f38d8ba2e4 Improve wizard in edit mode 2013-05-28 14:51:49 +02:00
Daniel Molkentin
fdd52a2520 Kill non-boxed mode for now 2013-05-28 14:51:48 +02:00
Daniel Molkentin
e2c0792043 take local folder path from property
This gets set by slotSelectFolder() and from the wizards caller.
2013-05-28 14:51:41 +02:00
Daniel Molkentin
e8889530b0 Fix owncloud theme icon 2013-05-28 14:42:41 +02:00
Klaas Freitag
23f67d950a Handle password change correct, add "sync from scratch".
The setup wizard now destinguishes if there was already a configuration
or not. If yes, it's going to password-change mode. Also added a checkbox
that allows to start a sync from a cleared local directory.
2013-05-26 14:04:11 +02:00
Klaas Freitag
0bd1f507ab Added a checkbox "start sync from scratch". 2013-05-26 13:57:28 +02:00
Klaas Freitag
2bcfc143f6 Let the folderman create a new sync directory.
If a sync directory exists its moved to a backup path and created new.
That allows to start a sync "from scratch".
2013-05-26 13:56:51 +02:00
Klaas Freitag
9dc21bf8a3 Let the keychain return new creds during async save.
The credentials are asynchronously saved. The credentialstore now returns
the creds even if the saving has not yet finished but is running, for that
the new state AsyncWriting was added. That makes the start of the sync
after the password was changed more reliable.
2013-05-26 13:55:23 +02:00
Klaas Freitag
70f627ba06 Fix the folder setup wizard. 2013-05-24 09:54:48 +02:00
Daniel Molkentin
0683c26d41 Make setting custom folders work again
Also, ensure that opening the local directory from the wizard
will work on Windows.
2013-05-23 01:51:05 +02:00
26 changed files with 919 additions and 502 deletions

View File

@@ -1,6 +1,6 @@
set( VERSION_MAJOR 1 ) set( VERSION_MAJOR 1 )
set( VERSION_MINOR 3 ) set( VERSION_MINOR 3 )
set( VERSION_PATCH 0 ) set( VERSION_PATCH 0 )
set( VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX}beta1) set( VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX}beta2)
set( SOVERSION 0 ) set( SOVERSION 0 )

View File

@@ -29,7 +29,6 @@
#include "mirall/mirallconfigfile.h" #include "mirall/mirallconfigfile.h"
#include "mirall/updatedetector.h" #include "mirall/updatedetector.h"
#include "mirall/proxydialog.h" #include "mirall/proxydialog.h"
#include "mirall/version.h"
#include "mirall/credentialstore.h" #include "mirall/credentialstore.h"
#include "mirall/logger.h" #include "mirall/logger.h"
@@ -538,38 +537,43 @@ void Application::setupLogBrowser()
} }
void Application::setupProxy() QNetworkProxy proxyFromConfig(const MirallConfigFile& cfg)
{ {
// QNetworkProxy proxy;
Mirall::MirallConfigFile cfg; proxy.setHostName(cfg.proxyHostName());
int proxy = cfg.proxyType(); proxy.setPort(cfg.proxyPort());
if (cfg.proxyNeedsAuth()) {
switch(proxy) {
case QNetworkProxy::NoProxy: {
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
break;
}
case QNetworkProxy::DefaultProxy: {
QNetworkProxyFactory::setUseSystemConfiguration(true);
break;
}
case QNetworkProxy::Socks5Proxy: {
proxy = QNetworkProxy::HttpProxy;
cfg.setProxyType(proxy);
// fall through
}
case QNetworkProxy::HttpProxy:{
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(cfg.proxyHostName());
proxy.setPort(cfg.proxyPort());
proxy.setUser(cfg.proxyUser()); proxy.setUser(cfg.proxyUser());
proxy.setPassword(cfg.proxyPassword()); proxy.setPassword(cfg.proxyPassword());
}
return proxy;
}
void Application::setupProxy()
{
Mirall::MirallConfigFile cfg;
int proxyType = cfg.proxyType();
QNetworkProxy proxy = proxyFromConfig(cfg);
switch(proxyType) {
case QNetworkProxy::NoProxy:
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
break;
case QNetworkProxy::DefaultProxy:
QNetworkProxyFactory::setUseSystemConfiguration(true);
break;
case QNetworkProxy::Socks5Proxy:
proxy.setType(QNetworkProxy::Socks5Proxy);
QNetworkProxy::setApplicationProxy(proxy); QNetworkProxy::setApplicationProxy(proxy);
break; break;
case QNetworkProxy::HttpProxy:
proxy.setType(QNetworkProxy::HttpProxy);
QNetworkProxy::setApplicationProxy(proxy);
break;
default:
break;
} }
} _folderMan->setProxy();
} }
/* /*
@@ -637,30 +641,11 @@ void Application::slotAddFolder()
QString alias = _folderWizard->field(QLatin1String("alias")).toString(); QString alias = _folderWizard->field(QLatin1String("alias")).toString();
QString sourceFolder = _folderWizard->field(QLatin1String("sourceFolder")).toString(); QString sourceFolder = _folderWizard->field(QLatin1String("sourceFolder")).toString();
QString backend = QLatin1String("csync"); QString backend = QLatin1String("owncloud");
QString targetPath; QString targetPath;
bool onlyThisLAN = false; bool onlyThisLAN = false;
bool onlyOnline = false;
if (_folderWizard->field(QLatin1String("local?")).toBool()) { targetPath = _folderWizard->field(QLatin1String("OCFolderLineEdit")).toString();
// setup a local csync folder
targetPath = _folderWizard->field(QLatin1String("targetLocalFolder")).toString();
} else if (_folderWizard->field(QLatin1String("remote?")).toBool()) {
// setup a remote csync folder
targetPath = _folderWizard->field(QLatin1String("targetURLFolder")).toString();
onlyOnline = _folderWizard->field(QLatin1String("onlyOnline?")).toBool();
onlyThisLAN = _folderWizard->field(QLatin1String("onlyThisLAN?")).toBool();
(void) onlyOnline;
(void) onlyThisLAN;
} else if( _folderWizard->field(QLatin1String("OC?")).toBool() ||
Theme::instance()->singleSyncFolder()) {
// setup a ownCloud folder
backend = QLatin1String("owncloud");
targetPath = _folderWizard->field(QLatin1String("targetOCFolder")).toString(); //empty in single folder mode
} else {
qWarning() << "* Folder not local and note remote?";
goodData = false;
}
_folderMan->setSyncEnabled(true); // do start sync again. _folderMan->setSyncEnabled(true); // do start sync again.
@@ -810,7 +795,10 @@ void Application::slotEnableFolder(const QString& alias, const bool enable)
void Application::slotConfigure() void Application::slotConfigure()
{ {
_folderMan->setSyncEnabled(false); // do not start more syncs. _folderMan->setSyncEnabled(false); // do not start more syncs.
_owncloudSetupWizard->startWizard(); if (!_owncloudSetupWizard->wizard()->isVisible())
_owncloudSetupWizard->startWizard();
else
raiseDialog(_owncloudSetupWizard->wizard());
} }
void Application::slotConfigureProxy() void Application::slotConfigureProxy()

View File

@@ -76,23 +76,14 @@ bool CredentialStore::canTryAgain()
return false; return false;
} }
if( _state == NotFetched ) { /* Since QtKeyChain is required now, it makes to only
* query once. */
if( _state == NotFetched || _state == AsyncWriting ) {
return true; return true;
} else {
return false;
} }
switch( _type ) {
case CredentialStore::User:
canDoIt = true;
break;
case CredentialStore::Settings:
break;
case CredentialStore::KeyChain:
canDoIt = true;
break;
default:
break;
}
return canDoIt;
} }
void CredentialStore::fetchCredentials() void CredentialStore::fetchCredentials()
@@ -147,7 +138,7 @@ void CredentialStore::fetchCredentials()
} }
case CredentialStore::KeyChain: { case CredentialStore::KeyChain: {
// If the credentials are here already, return. // If the credentials are here already, return.
if( _state == Ok ) { if( _state == Ok || _state == AsyncWriting ) {
emit(fetchCredentialsFinished(true)); emit(fetchCredentialsFinished(true));
return; return;
} }
@@ -347,6 +338,7 @@ void CredentialStore::saveCredentials( )
connect( job, SIGNAL(finished(QKeychain::Job*)), this, connect( job, SIGNAL(finished(QKeychain::Job*)), this,
SLOT(slotKeyChainWriteFinished(QKeychain::Job*))); SLOT(slotKeyChainWriteFinished(QKeychain::Job*)));
_state = AsyncWriting;
job->start(); job->start();
#endif #endif
break; break;
@@ -373,15 +365,21 @@ void CredentialStore::slotKeyChainWriteFinished( QKeychain::Job *job )
pwdJob->errorString().contains(QLatin1String("Could not open wallet"))) { pwdJob->errorString().contains(QLatin1String("Could not open wallet"))) {
_type = Settings; _type = Settings;
saveCredentials(); saveCredentials();
_state = NoKeychainBackend;
} else {
_state = Error;
} }
} else { } else {
qDebug() << "Successfully stored password for user " << _user; qDebug() << "Successfully stored password for user " << _user;
// Try to remove password formerly stored in the config file. // Try to remove password formerly stored in the config file.
MirallConfigFile cfgFile; MirallConfigFile cfgFile;
cfgFile.clearPasswordFromConfig(); cfgFile.clearPasswordFromConfig();
_state = NotFetched;
_tries = 0;
} }
} else { } else {
qDebug() << "Error: KeyChain Write Password Job failed!"; qDebug() << "Error: KeyChain Write Password Job failed!";
_state = Error;
} }
#else #else
(void) job; (void) job;

View File

@@ -57,6 +57,7 @@ public:
AccessDenied, AccessDenied,
NoKeychainBackend, NoKeychainBackend,
Error, Error,
AsyncWriting,
TooManyAttempts }; TooManyAttempts };
enum CredentialType { enum CredentialType {

View File

@@ -173,6 +173,11 @@ public slots:
*/ */
void setPollInterval( int ); void setPollInterval( int );
/**
* If folder is network-based, reimplement to react to proxy changes
*/
virtual void setProxy() {}
protected: protected:
/** /**
* The minimum amounts of seconds to wait before * The minimum amounts of seconds to wait before

View File

@@ -455,4 +455,46 @@ void FolderMan::removeFolder( const QString& alias )
} }
} }
QString FolderMan::getBackupName( const QString& fullPathName ) const
{
if( fullPathName.isEmpty() ) return QString::null;
QString newName = fullPathName + QLatin1String(".oC_bak");
QFileInfo fi( newName );
int cnt = 1;
do {
if( fi.exists() ) {
newName += fullPathName + QString( ".oC_bak_%1").arg(cnt++);
fi.setFile(newName);
}
} while( fi.exists() );
return newName;
}
bool FolderMan::startFromScratch( const QString& localFolder )
{
if( localFolder.isEmpty() ) return false;
QFileInfo fi( localFolder );
if( fi.exists() && fi.isDir() ) {
QDir file = fi.dir();
QString newName = getBackupName( fi.absoluteFilePath() );
if( file.rename( fi.absoluteFilePath(), newName )) {
if( file.mkdir( fi.absoluteFilePath() ) ) {
return true;
}
}
}
return false;
}
void FolderMan::setProxy()
{
foreach( Folder *f, _folderMap.values() ) {
f->setProxy();
}
}
} }

View File

@@ -76,6 +76,16 @@ public:
*/ */
void wipeAllJournals(); void wipeAllJournals();
/**
* Creates a new and empty local directory.
*/
bool startFromScratch( const QString& );
/**
* called whenever proxy configuration changes
*/
void setProxy();
signals: signals:
/** /**
* signal to indicate a folder named by alias has changed its sync state. * signal to indicate a folder named by alias has changed its sync state.
@@ -112,6 +122,7 @@ private:
// and create the folders // and create the folders
int setupKnownFolders(); int setupKnownFolders();
void terminateCurrentSync(); void terminateCurrentSync();
QString getBackupName( const QString& ) const;
// Escaping of the alias which is used in QSettings AND the file // Escaping of the alias which is used in QSettings AND the file
// system, thus need to be escaped. // system, thus need to be escaped.

View File

@@ -166,7 +166,7 @@ FolderWizardTargetPage::FolderWizardTargetPage()
_ui.setupUi(this); _ui.setupUi(this);
_ui.warnFrame->hide(); _ui.warnFrame->hide();
registerField(QLatin1String("targetOCFolder"), _ui.OCFolderLineEdit); registerField(QLatin1String("OCFolderLineEdit"), _ui.OCFolderLineEdit);
connect( _ui.OCFolderLineEdit, SIGNAL(textChanged(QString)), connect( _ui.OCFolderLineEdit, SIGNAL(textChanged(QString)),
SLOT(slotFolderTextChanged(QString))); SLOT(slotFolderTextChanged(QString)));
@@ -213,11 +213,10 @@ void FolderWizardTargetPage::slotDirCheckReply(const QString &url, QNetworkReply
void FolderWizardTargetPage::slotCreateRemoteFolder() void FolderWizardTargetPage::slotCreateRemoteFolder()
{ {
_ui.OCFolderLineEdit->setEnabled( false );
const QString folder = _ui.OCFolderLineEdit->text(); const QString folder = _ui.OCFolderLineEdit->text();
if( folder.isEmpty() ) return; if( folder.isEmpty() ) return;
_ui.OCFolderLineEdit->setEnabled( false );
qDebug() << "creating folder on ownCloud: " << folder; qDebug() << "creating folder on ownCloud: " << folder;
ownCloudInfo::instance()->mkdirRequest( folder ); ownCloudInfo::instance()->mkdirRequest( folder );
} }
@@ -244,8 +243,8 @@ FolderWizardTargetPage::~FolderWizardTargetPage()
bool FolderWizardTargetPage::isComplete() const bool FolderWizardTargetPage::isComplete() const
{ {
QString dir = _ui.OCFolderLineEdit->text(); QString dir = _ui.OCFolderLineEdit->text();
if( dir.isEmpty() ) { if( dir.isEmpty() || dir == QLatin1String("/") ) {
showWarn( tr("Better do not use the remote root directory.<br/>If you do, you can <b>not</b> mirror another local folder."), false); showWarn( tr("If you sync the root folder, you can <b>not</b> configure another sync directory."), false);
return true; return true;
} else { } else {
if( _dirChecked ) { if( _dirChecked ) {

View File

@@ -515,7 +515,7 @@ void MirallConfigFile::acceptCustomConfig()
void MirallConfigFile::setProxyType(int proxyType, void MirallConfigFile::setProxyType(int proxyType,
const QString& host, const QString& host,
int port, int port, bool needsAuth,
const QString& user, const QString& user,
const QString& pass) const QString& pass)
{ {
@@ -524,11 +524,15 @@ void MirallConfigFile::setProxyType(int proxyType,
settings.beginGroup(QLatin1String("proxy")); settings.beginGroup(QLatin1String("proxy"));
settings.setValue(QLatin1String("type"), proxyType); settings.setValue(QLatin1String("type"), proxyType);
settings.setValue(QLatin1String("host"), host);
settings.setValue(QLatin1String("port"), port);
settings.setValue(QLatin1String("user"), user);
settings.setValue(QLatin1String("pass"), pass.toUtf8().toBase64());
if (proxyType == QNetworkProxy::HttpProxy ||
proxyType == QNetworkProxy::Socks5Proxy) {
settings.setValue(QLatin1String("host"), host);
settings.setValue(QLatin1String("port"), port);
settings.setValue(QLatin1String("needsAuth"), needsAuth);
settings.setValue(QLatin1String("user"), user);
settings.setValue(QLatin1String("pass"), pass.toUtf8().toBase64());
}
settings.sync(); settings.sync();
} }
@@ -556,6 +560,11 @@ int MirallConfigFile::proxyPort() const
return getValue(QLatin1String("port"), QLatin1String("proxy")).toInt(); return getValue(QLatin1String("port"), QLatin1String("proxy")).toInt();
} }
bool MirallConfigFile::proxyNeedsAuth() const
{
return getValue(QLatin1String("needsAuth"), QLatin1String("proxy")).toInt();
}
QString MirallConfigFile::proxyUser() const QString MirallConfigFile::proxyUser() const
{ {
return getValue(QLatin1String("user"), QLatin1String("proxy")).toString(); return getValue(QLatin1String("user"), QLatin1String("proxy")).toString();

View File

@@ -89,13 +89,14 @@ public:
// proxy settings // proxy settings
void setProxyType(int proxyType, void setProxyType(int proxyType,
const QString& host = QString(), const QString& host = QString(),
int port = 0, int port = 0, bool needsAuth = false,
const QString& user = QString(), const QString& user = QString(),
const QString& pass = QString()); const QString& pass = QString());
int proxyType() const; int proxyType() const;
QString proxyHostName() const; QString proxyHostName() const;
int proxyPort() const; int proxyPort() const;
bool proxyNeedsAuth() const;
QString proxyUser() const; QString proxyUser() const;
QString proxyPassword() const; QString proxyPassword() const;

View File

@@ -100,23 +100,8 @@ ownCloudFolder::ownCloudFolder(const QString &alias,
qDebug() << "Could not initialize csync!"; qDebug() << "Could not initialize csync!";
_csync_ctx = 0; _csync_ctx = 0;
} }
setProxy();
if( _csync_ctx ) {
/* Store proxy */
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(QUrl(cfgFile.ownCloudUrl()));
// We set at least one in Application
Q_ASSERT(proxies.count() > 0);
QNetworkProxy proxy = proxies.first();
int proxyPort = proxy.port();
csync_set_module_property(_csync_ctx, "proxy_type", (char*) proxyTypeToCStr(proxy.type()) );
csync_set_module_property(_csync_ctx, "proxy_host", proxy.hostName().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_port", &proxyPort );
csync_set_module_property(_csync_ctx, "proxy_user", proxy.user().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() );
csync_set_module_property(_csync_ctx, "csync_context", _csync_ctx);
}
} }
} }
@@ -131,6 +116,34 @@ ownCloudFolder::~ownCloudFolder()
csync_destroy(_csync_ctx); csync_destroy(_csync_ctx);
} }
void ownCloudFolder::setProxy()
{
if( _csync_ctx ) {
/* Store proxy */
MirallConfigFile cfgFile;
QUrl proxyUrl(cfgFile.ownCloudUrl());
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(proxyUrl);
// We set at least one in Application
Q_ASSERT(proxies.count() > 0);
QNetworkProxy proxy = proxies.first();
if (proxy.type() == QNetworkProxy::NoProxy) {
qDebug() << "Passing NO proxy to csync for" << cfgFile.ownCloudUrl();
} else {
qDebug() << "Passing" << proxy.hostName() << "of proxy type " << proxy.type()
<< " to csync for" << cfgFile.ownCloudUrl();
}
int proxyPort = proxy.port();
csync_set_module_property(_csync_ctx, "proxy_type", (char*) proxyTypeToCStr(proxy.type()) );
csync_set_module_property(_csync_ctx, "proxy_host", proxy.hostName().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_port", &proxyPort );
csync_set_module_property(_csync_ctx, "proxy_user", proxy.user().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() );
csync_set_module_property(_csync_ctx, "csync_context", _csync_ctx);
}
}
const char* ownCloudFolder::proxyTypeToCStr(QNetworkProxy::ProxyType type) const char* ownCloudFolder::proxyTypeToCStr(QNetworkProxy::ProxyType type)
{ {
switch (type) { switch (type) {

View File

@@ -72,6 +72,8 @@ public:
/* get status about a singel file. */ /* get status about a singel file. */
SyncFileStatus fileStatus( const QString& ); SyncFileStatus fileStatus( const QString& );
void setProxy();
public slots: public slots:
void startSync(); void startSync();
void slotTerminateSync(); void slotTerminateSync();

View File

@@ -14,8 +14,9 @@
#include "mirall/owncloudinfo.h" #include "mirall/owncloudinfo.h"
#include "mirall/mirallconfigfile.h" #include "mirall/mirallconfigfile.h"
#include "mirall/version.h"
#include "mirall/theme.h" #include "mirall/theme.h"
#include "mirall/utility.h"
#include "mirall/logger.h"
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
@@ -64,7 +65,8 @@ ownCloudInfo::ownCloudInfo() :
_manager(0) _manager(0)
{ {
_connection = Theme::instance()->appName(); _connection = Theme::instance()->appName();
connect(this, SIGNAL(guiLog(QString,QString)),
Logger::instance(), SIGNAL(guiLog(QString,QString)));
setNetworkAccessManager( new QNetworkAccessManager( this ) ); setNetworkAccessManager( new QNetworkAccessManager( this ) );
} }
@@ -164,10 +166,9 @@ QNetworkReply* ownCloudInfo::mkdirRequest( const QString& dir )
connect(qhttp, SIGNAL(requestFinished(int, bool)), this,SLOT(qhttpRequestFinished(int,bool))); connect(qhttp, SIGNAL(requestFinished(int, bool)), this,SLOT(qhttpRequestFinished(int,bool)));
connect(qhttp, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(qhttpResponseHeaderReceived(QHttpResponseHeader))); connect(qhttp, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), this, SLOT(qhttpResponseHeaderReceived(QHttpResponseHeader)));
//connect(qhttp, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)), this, SLOT(qhttpAuthenticationRequired(QString,quint16,QAuthenticator*))); //connect(qhttp, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)), this, SLOT(qhttpAuthenticationRequired(QString,quint16,QAuthenticator*)));
QHttpRequestHeader header("MKCOL", QString(url.encodedPath()), 1,1); /* header */ QHttpRequestHeader header("MKCOL", QString(url.encodedPath()), 1,1); /* header */
header.setValue("Host", QString(url.encodedHost())); header.setValue("Host", QString(url.encodedHost()));
header.setValue("User-Agent", QString("mirall-%1").arg(MIRALL_STRINGIFY(MIRALL_VERSION)).toAscii() ); header.setValue("User-Agent", Utility::userAgentString());
header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2"); header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
header.setValue("Connection", "keep-alive"); header.setValue("Connection", "keep-alive");
@@ -482,7 +483,36 @@ bool ownCloudInfo::certsUntrusted()
void ownCloudInfo::slotError( QNetworkReply::NetworkError err) void ownCloudInfo::slotError( QNetworkReply::NetworkError err)
{ {
qDebug() << "ownCloudInfo Network Error: " << err; qDebug() << "ownCloudInfo Network Error: " << err;
switch (err) {
case QNetworkReply::ProxyConnectionRefusedError:
emit guiLog(tr("Proxy Refused Connection "),
tr("The configured proxy has refused the connection. "
"Please check the proxy settings."));
break;
case QNetworkReply::ProxyConnectionClosedError:
emit guiLog(tr("Proxy Closed Connection"),
tr("The configured proxy has closed the connection. "
"Please check the proxy settings."));
break;
case QNetworkReply::ProxyNotFoundError:
emit guiLog(tr("Proxy Not Found"),
tr("The configured proxy could not be found. "
"Please check the proxy settings."));
break;
case QNetworkReply::ProxyAuthenticationRequiredError:
emit guiLog(tr("Proxy Authentication Error"),
tr("The configured proxy requires login but the proxy credentials "
"are invalid. Please check the proxy settings."));
break;
case QNetworkReply::ProxyTimeoutError:
emit guiLog(tr("Proxy Connection Timed Out"),
tr("The connection to the configured proxy has timed out."));
break;
default:
break;
}
} }
void ownCloudInfo::setCredentials( const QString& user, const QString& passwd, void ownCloudInfo::setCredentials( const QString& user, const QString& passwd,
@@ -511,8 +541,7 @@ void ownCloudInfo::setupHeaders( QNetworkRequest & req, quint64 size )
QUrl url( cfgFile.ownCloudUrl( QString::null, false ) ); QUrl url( cfgFile.ownCloudUrl( QString::null, false ) );
qDebug() << "Setting up host header: " << url.host(); qDebug() << "Setting up host header: " << url.host();
req.setRawHeader( QByteArray("Host"), url.host().toUtf8() ); req.setRawHeader( QByteArray("Host"), url.host().toUtf8() );
req.setRawHeader( QByteArray("User-Agent"), QString::fromLatin1("mirall-%1") req.setRawHeader( QByteArray("User-Agent"), Utility::userAgentString());
.arg(QLatin1String(MIRALL_STRINGIFY(MIRALL_VERSION))).toAscii());
QString con = _configHandle; QString con = _configHandle;
if( con.isEmpty() ) con = DEFAULT_CONNECTION; if( con.isEmpty() ) con = DEFAULT_CONNECTION;

View File

@@ -118,7 +118,7 @@ signals:
void webdavColCreated( QNetworkReply::NetworkError ); void webdavColCreated( QNetworkReply::NetworkError );
void sslFailed( QNetworkReply *reply, QList<QSslError> errors ); void sslFailed( QNetworkReply *reply, QList<QSslError> errors );
void guiLog( const QString& title, const QString& content );
public slots: public slots:
protected slots: protected slots:

View File

@@ -6,14 +6,39 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>540</width> <width>583</width>
<height>374</height> <height>448</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="topLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@@ -30,6 +55,194 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0" colspan="3">
<layout class="QHBoxLayout" name="resultLayout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
<item row="5" column="0" colspan="3">
<widget class="QWidget" name="advancedBox" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Local Folder</string>
</property>
<property name="buddy">
<cstring>pbSelectLocalFolder</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pbSelectLocalFolder">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>pbSelectLocalFolder</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="resolutionWidget" native="true">
<layout class="QFormLayout" name="formLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>&amp;Keep local data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;small&gt;Syncs your existing data to new location.&lt;/small&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="cbSyncFromScratch">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If this box is checked, existing content in the local directory will be erased to start a clean sync from the server.&lt;/p&gt;&lt;p&gt;Do not check this if the local content should be uploaded to the servers directory.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>&amp;Start a clean sync</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;small&gt;Erases the contents of the local folder before syncing using the new settings.&lt;/small&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
@@ -128,28 +341,12 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>TextLabel</string> <string>Error Label</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>58</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1"> <item row="2" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@@ -209,132 +406,10 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="8" column="0" colspan="3">
<widget class="QGroupBox" name="advancedBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Local Folder</string>
</property>
<property name="buddy">
<cstring>pbSelectLocalFolder</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pbSelectLocalFolder">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>/home/kf/ownCloud</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="selectiveSyncLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Selective Sync:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="selectiveSyncLayout">
<item>
<widget class="QPushButton" name="pbBoxMode">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sync Entire &amp;Account</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbSelectiveMode">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Choose &amp;Folders</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>43</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0" colspan="3">
<layout class="QHBoxLayout" name="resultLayout"/>
</item>
<item row="7" column="0" colspan="3">
<widget class="QLabel" name="syncModeLabel"> <widget class="QLabel" name="syncModeLabel">
<property name="text"> <property name="text">
<string>Street Creds Homie!</string> <string>Status message</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@@ -344,28 +419,44 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="3"> <item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>58</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0">
<widget class="QLabel" name="bottomLabel"> <widget class="QLabel" name="bottomLabel">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="3"> <item row="6" column="0">
<widget class="QLabel" name="topLabel"> <spacer name="verticalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text"> <property name="sizeType">
<string>TextLabel</string> <enum>QSizePolicy::Expanding</enum>
</property> </property>
<property name="alignment"> <property name="sizeHint" stdset="0">
<set>Qt::AlignCenter</set> <size>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@@ -34,7 +34,7 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
_checkInstallationRequest(0), _checkInstallationRequest(0),
_folderMan(folderMan) _folderMan(folderMan)
{ {
_ocWizard = new OwncloudWizard; _ocWizard = new OwncloudWizard();
connect( _ocWizard, SIGNAL(connectToOCUrl( const QString& ) ), connect( _ocWizard, SIGNAL(connectToOCUrl( const QString& ) ),
this, SLOT(slotConnectToOCUrl( const QString& ))); this, SLOT(slotConnectToOCUrl( const QString& )));
@@ -44,13 +44,12 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
connect( _ocWizard, SIGNAL(clearPendingRequests()), connect( _ocWizard, SIGNAL(clearPendingRequests()),
this, SLOT(slotClearPendingRequests())); this, SLOT(slotClearPendingRequests()));
_ocWizard->setWindowTitle( tr("%1 Connection Wizard").arg( theme ? theme->appNameGUI() : QLatin1String("Mirall") ) ); _ocWizard->setWindowTitle( tr("%1 Connection Wizard").arg( theme->appNameGUI() ) );
} }
OwncloudSetupWizard::~OwncloudSetupWizard() OwncloudSetupWizard::~OwncloudSetupWizard()
{ {
// delete _ocWizard; FIXME: this crashes! _ocWizard->deleteLater();
} }
OwncloudWizard *OwncloudSetupWizard::wizard() { OwncloudWizard *OwncloudSetupWizard::wizard() {
@@ -63,28 +62,37 @@ void OwncloudSetupWizard::startWizard()
MirallConfigFile cfgFile; MirallConfigFile cfgFile;
// Fill the entry fields with existing values. // Fill the entry fields with existing values.
QString url = cfgFile.ownCloudUrl(); QString url = cfgFile.ownCloudUrl();
if( !url.isEmpty() ) {
_ocWizard->setOCUrl( url );
}
QString user = cfgFile.ownCloudUser(); QString user = cfgFile.ownCloudUser();
bool configExists = !( url.isEmpty() || user.isEmpty() );
_ocWizard->setConfigExists( configExists );
if( !user.isEmpty() ) { if( !user.isEmpty() ) {
_ocWizard->setOCUser( user ); _ocWizard->setOCUser( user );
} }
if( !url.isEmpty() ) {
_ocWizard->setOCUrl( url );
}
_remoteFolder = Theme::instance()->defaultServerFolder(); _remoteFolder = Theme::instance()->defaultServerFolder();
// remoteFolder may be empty, which means / // remoteFolder may be empty, which means /
_localFolder = Theme::instance()->defaultClientFolder(); QString localFolder = Theme::instance()->defaultClientFolder();
// if its a relative path, prepend with users home dir, otherwise use as absolute path // if its a relative path, prepend with users home dir, otherwise use as absolute path
if( !_localFolder.startsWith(QLatin1Char('/')) ) { if( !localFolder.startsWith(QLatin1Char('/')) ) {
_localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder(); localFolder = QDir::homePath() + QDir::separator() + Theme::instance()->defaultClientFolder();
} }
_ocWizard->setFolderNames(_localFolder, _remoteFolder); _ocWizard->setProperty("localFolder", localFolder);
_ocWizard->setRemoteFolder(_remoteFolder);
_ocWizard->setStartId(OwncloudWizard::Page_oCSetup); _ocWizard->setStartId(OwncloudWizard::Page_oCSetup);
_ocWizard->restart(); _ocWizard->restart();
// settings re-initialized in initPage must be set here after restart
_ocWizard->setMultipleFoldersExist(_folderMan->map().count() > 1);
_ocWizard->show(); _ocWizard->show();
} }
@@ -105,22 +113,41 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
// go through all folders and remove the journals if the server changed. // go through all folders and remove the journals if the server changed.
MirallConfigFile prevCfg; MirallConfigFile prevCfg;
if( prevCfg.ownCloudUrl() != cfg.ownCloudUrl() ) { QUrl prevUrl( prevCfg.ownCloudUrl() );
qDebug() << "ownCloud URL has changed, journals needs to be wiped."; QUrl newUrl( cfg.ownCloudUrl() );
_folderMan->wipeAllJournals();
bool urlHasChanged = (prevUrl.host() != newUrl.host() || prevUrl.path() != newUrl.path());
// if the user changed, its also a changed url.
if( prevCfg.ownCloudUser() != cfg.ownCloudUser() ) {
urlHasChanged = true;
qDebug() << "The User has changed, same as url change.";
} }
// save the user credentials and afterwards clear the cred store. // save the user credentials and afterwards clear the cred store.
cfg.acceptCustomConfig(); cfg.acceptCustomConfig();
// Now write the resulting folder definition if folder names are set. // Now write the resulting folder definition if folder names are set.
if( !( _localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set. const QString localFolder = _ocWizard->localFolder();
if( _folderMan ) { if( !( localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set.
if( urlHasChanged ) {
_folderMan->removeAllFolderDefinitions();
_folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(), _folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(),
_localFolder, _remoteFolder, false ); localFolder, _remoteFolder, false );
_ocWizard->appendToConfigurationLog(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));
bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool();
if( startFromScratch ) {
// clean the entire directory.
if( _folderMan->startFromScratch( localFolder ) ) {
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully prepared syncing from scratch!</font>"));
} else {
_ocWizard->appendToConfigurationLog(tr("<font color=\"red\">Failed to prepare syncing from scratch!</font>"));
}
}
} else { } else {
qDebug() << "WRN: Folderman is zero in Setup Wizzard."; // url is unchanged. Only the password was changed.
qDebug() << "Only password was changed, no changes to folder configuration.";
} }
} }
} else { } else {
@@ -194,7 +221,7 @@ void OwncloudSetupWizard::testOwnCloudConnect()
MirallConfigFile prevCfg; MirallConfigFile prevCfg;
if( prevCfg.proxyType() != QNetworkProxy::DefaultProxy ) { if( prevCfg.proxyType() != QNetworkProxy::DefaultProxy ) {
cfgFile.setProxyType( prevCfg.proxyType(), prevCfg.proxyHostName(), prevCfg.proxyPort(), cfgFile.setProxyType( prevCfg.proxyType(), prevCfg.proxyHostName(), prevCfg.proxyPort(),
prevCfg.proxyUser(), prevCfg.proxyPassword() ); prevCfg.proxyNeedsAuth(), prevCfg.proxyUser(), prevCfg.proxyPassword() );
} }
} }
@@ -251,26 +278,27 @@ void OwncloudSetupWizard::setupLocalSyncFolder()
{ {
if( ! _folderMan ) return; if( ! _folderMan ) return;
qDebug() << "Setup local sync folder for new oC connection " << _localFolder; const QString localFolder = _ocWizard->property("localFolder").toString();
QDir fi( _localFolder ); qDebug() << "Setup local sync folder for new oC connection " << localFolder;
QDir fi( localFolder );
// FIXME: Show problems with local folder properly. // FIXME: Show problems with local folder properly.
bool localFolderOk = true; bool localFolderOk = true;
if( fi.exists() ) { if( fi.exists() ) {
// there is an existing local folder. If its non empty, it can only be synced if the // there is an existing local folder. If its non empty, it can only be synced if the
// ownCloud is newly created. // ownCloud is newly created.
_ocWizard->appendToConfigurationLog( 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 { } else {
QString res = tr("Creating local sync folder %1... ").arg(_localFolder); QString res = tr("Creating local sync folder %1... ").arg(localFolder);
if( fi.mkpath( _localFolder ) ) { if( fi.mkpath( localFolder ) ) {
Utility::setupFavLink( _localFolder ); Utility::setupFavLink( localFolder );
// FIXME: Create a local sync folder. // FIXME: Create a local sync folder.
res += tr("ok"); res += tr("ok");
} else { } else {
res += tr("failed."); res += tr("failed.");
qDebug() << "Failed to create " << fi.path(); qDebug() << "Failed to create " << fi.path();
localFolderOk = false; localFolderOk = false;
_ocWizard->displayError(tr("Could not create local folder %1").arg(_localFolder)); _ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder));
} }
_ocWizard->appendToConfigurationLog( res ); _ocWizard->appendToConfigurationLog( res );
} }
@@ -305,7 +333,7 @@ void OwncloudSetupWizard::slotAuthCheckReply( const QString&, QNetworkReply *rep
qDebug() << "******** Remote folder found, all cool!"; qDebug() << "******** Remote folder found, all cool!";
} else if( errId == QNetworkReply::AuthenticationRequiredError ) { // returned if the user is wrong. } else if( errId == QNetworkReply::AuthenticationRequiredError ) { // returned if the user is wrong.
qDebug() << "******** Password is wrong!"; qDebug() << "******** Password is wrong!";
error = tr("Credentials are wrong!"); error = tr("The given credentials do not authenticate.");
ok = false; ok = false;
} else if( errId == QNetworkReply::OperationCanceledError ) { } else if( errId == QNetworkReply::OperationCanceledError ) {
// the username was wrong and ownCloudInfo was closing the request after a couple of auth tries. // the username was wrong and ownCloudInfo was closing the request after a couple of auth tries.
@@ -328,7 +356,7 @@ void OwncloudSetupWizard::slotAuthCheckReply( const QString&, QNetworkReply *rep
if( !ok ) { if( !ok ) {
_ocWizard->displayError(error); _ocWizard->displayError(error);
} else { } else {
_ocWizard->setFolderNames( _localFolder, _remoteFolder ); _ocWizard->setRemoteFolder( _remoteFolder );
} }
finalizeSetup( ok ); finalizeSetup( ok );
@@ -369,13 +397,11 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::Network
"<br/>Please go back and check your credentials.</p>")); "<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>" _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>")); "<br/>Please go back and check your credentials.</p>"));
_localFolder.clear();
_remoteFolder.clear(); _remoteFolder.clear();
success = false; success = false;
} else { } else {
_ocWizard->appendToConfigurationLog( 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) ); _ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error) );
_localFolder.clear();
_remoteFolder.clear(); _remoteFolder.clear();
success = false; success = false;
} }
@@ -388,10 +414,11 @@ void OwncloudSetupWizard::finalizeSetup( bool success )
// enable/disable the finish button. // enable/disable the finish button.
_ocWizard->enableFinishOnResultWidget(success); _ocWizard->enableFinishOnResultWidget(success);
const QString localFolder = _ocWizard->property("localFolder").toString();
if( success ) { if( success ) {
if( !(_localFolder.isEmpty() || _remoteFolder.isEmpty() )) { if( !(localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
_ocWizard->appendToConfigurationLog( 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)); .arg(localFolder).arg(_remoteFolder));
} }
_ocWizard->appendToConfigurationLog( QLatin1String(" ")); _ocWizard->appendToConfigurationLog( QLatin1String(" "));
_ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>") _ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>")

View File

@@ -95,7 +95,6 @@ private:
FolderMan *_folderMan; FolderMan *_folderMan;
QString _configHandle; QString _configHandle;
QString _localFolder;
QString _remoteFolder; QString _remoteFolder;
}; };

View File

@@ -118,7 +118,7 @@ QIcon ownCloudTheme::folderDisabledIcon( ) const
QIcon ownCloudTheme::applicationIcon( ) const QIcon ownCloudTheme::applicationIcon( ) const
{ {
return themeIcon( QLatin1String("owncloud") ); return themeIcon( QLatin1String("owncloud-icon") );
} }
QColor ownCloudTheme::wizardHeaderBackgroundColor() const QColor ownCloudTheme::wizardHeaderBackgroundColor() const

View File

@@ -15,7 +15,8 @@
#include "mirall/owncloudwizard.h" #include "mirall/owncloudwizard.h"
#include "mirall/mirallconfigfile.h" #include "mirall/mirallconfigfile.h"
#include "mirall/theme.h" #include "mirall/theme.h"
#include <QProgressIndicator.h>
#include "QProgressIndicator.h"
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
@@ -52,26 +53,23 @@ OwncloudSetupPage::OwncloudSetupPage()
_ui.setupUi(this); _ui.setupUi(this);
Theme *theme = Theme::instance(); Theme *theme = Theme::instance();
setTitle( tr("<font color=\"%1\" size=\"5\">Connect to your %2 Server</font>") setTitle( tr("<font color=\"%1\" size=\"5\">Connect to %2</font>")
.arg(theme->wizardHeaderTitleColor().name()).arg( theme->appNameGUI())); .arg(theme->wizardHeaderTitleColor().name()).arg( theme->appNameGUI()));
setSubTitle( tr("<font color=\"%1\">Enter user credentials to access your %2</font>") setSubTitle( tr("<font color=\"%1\">Enter user credentials</font>")
.arg(theme->wizardHeaderTitleColor().name()).arg(theme->appNameGUI())); .arg(theme->wizardHeaderTitleColor().name()));
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("OCUser"), _ui.leUsername );
registerField( QLatin1String("OCPasswd"), _ui.lePassword); registerField( QLatin1String("OCPasswd"), _ui.lePassword);
connect( _ui.lePassword, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); registerField( QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch);
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()));
_ui.errorLabel->setVisible(true); _ui.errorLabel->setVisible(true);
_ui.advancedBox->setVisible(false); _ui.advancedBox->setVisible(false);
_progressIndi = new QProgressIndicator; _progressIndi = new QProgressIndicator;
_ui.resultLayout->addWidget( _progressIndi ); _ui.resultLayout->addWidget( _progressIndi );
_progressIndi->setVisible(false); _progressIndi->setVisible(false);
_ui.resultLayout->setEnabled(false);
// Error label // Error label
QString style = QLatin1String("border: 1px solid #eed3d7; border-radius: 5px; padding: 3px;" QString style = QLatin1String("border: 1px solid #eed3d7; border-radius: 5px; padding: 3px;"
@@ -82,20 +80,17 @@ OwncloudSetupPage::OwncloudSetupPage()
_ui.errorLabel->setWordWrap(true); _ui.errorLabel->setWordWrap(true);
_ui.errorLabel->setVisible(false); _ui.errorLabel->setVisible(false);
// ButtonGroup for
_selectiveSyncButtons = new QButtonGroup;
_selectiveSyncButtons->addButton( _ui.pbBoxMode );
_selectiveSyncButtons->addButton( _ui.pbSelectiveMode );
connect( _selectiveSyncButtons, SIGNAL(buttonClicked (QAbstractButton*)),
SLOT(slotChangedSelective(QAbstractButton*)));
_ui.selectiveSyncLabel->setVisible(false);
_ui.pbBoxMode->setVisible(false);
_ui.pbSelectiveMode->setVisible(false);
_checking = false; _checking = false;
setupCustomization(); 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() OwncloudSetupPage::~OwncloudSetupPage()
@@ -106,34 +101,30 @@ OwncloudSetupPage::~OwncloudSetupPage()
void OwncloudSetupPage::slotToggleAdvanced(int state) void OwncloudSetupPage::slotToggleAdvanced(int state)
{ {
_ui.advancedBox->setVisible( state == Qt::Checked ); _ui.advancedBox->setVisible( state == Qt::Checked );
wizard()->resize(wizard()->sizeHint()); slotHandleUserInput();
} QSize size = wizard()->sizeHint();
// need to substract header for some reason
size -= QSize(0, 63);
void OwncloudSetupPage::slotChangedSelective(QAbstractButton* button) wizard()->setMinimumSize(size);
{ wizard()->resize(size);
if( button = _ui.pbBoxMode ) {
// box mode - sync the entire oC
} else {
// content mode, select folder list.
}
} }
void OwncloudSetupPage::setOCUser( const QString & user ) void OwncloudSetupPage::setOCUser( const QString & user )
{ {
if( _ui.leUsername->text().isEmpty() ) { _ocUser = user;
_ui.leUsername->setText(user); _ui.leUsername->setText(user);
}
} }
void OwncloudSetupPage::setServerUrl( const QString& newUrl ) void OwncloudSetupPage::setServerUrl( const QString& newUrl )
{ {
QString url( newUrl ); _oCUrl = newUrl;
if( url.isEmpty() ) { if( _oCUrl.isEmpty() ) {
_ui.leUrl->clear(); _ui.leUrl->clear();
return; return;
} }
_ui.leUrl->setText( url ); _ui.leUrl->setText( _oCUrl );
} }
void OwncloudSetupPage::setupCustomization() void OwncloudSetupPage::setupCustomization()
@@ -157,19 +148,27 @@ void OwncloudSetupPage::setupCustomization()
QString fixUrl = theme->overrideServerUrl(); QString fixUrl = theme->overrideServerUrl();
if( !fixUrl.isEmpty() ) { if( !fixUrl.isEmpty() ) {
_ui.label_2->hide();
setServerUrl( fixUrl ); setServerUrl( fixUrl );
_ui.leUrl->setEnabled( false ); _ui.leUrl->setEnabled( false );
_ui.leUrl->hide(); _ui.leUrl->hide();
} }
} }
// slot hit from textChanged of the url entry field. void OwncloudSetupPage::slotUserChanged(const QString& user )
void OwncloudSetupPage::handleNewOcUrl(const QString& ocUrl)
{ {
QString url = ocUrl; slotHandleUserInput();
int len = 0; }
bool visible = false;
// slot hit from textChanged of the url entry field.
void OwncloudSetupPage::slotUrlChanged(const QString& ocUrl)
{
slotHandleUserInput();
#if 0 #if 0
QString url = ocUrl;
bool visible = false;
if (url.startsWith(QLatin1String("https://"))) { if (url.startsWith(QLatin1String("https://"))) {
_ui.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-high.png")); _ui.urlLabel->setPixmap( QPixmap(":/mirall/resources/security-high.png"));
_ui.urlLabel->setToolTip(tr("This url is secure. You can use it.")); _ui.urlLabel->setToolTip(tr("This url is secure. You can use it."));
@@ -181,7 +180,6 @@ void OwncloudSetupPage::handleNewOcUrl(const QString& ocUrl)
visible = true; visible = true;
} }
#endif #endif
} }
bool OwncloudSetupPage::isComplete() const bool OwncloudSetupPage::isComplete() const
@@ -196,6 +194,104 @@ void OwncloudSetupPage::initializePage()
{ {
_connected = false; _connected = false;
_checking = false; _checking = false;
_multipleFoldersExist = false;
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() ||
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(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("<p><small><strong>Warning:</strong> 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!</small></p>");
}
if( entries.count() > 0) {
// the directory is not empty
if (!_ui.cbAdvanced->isChecked()) {
t += tr("<p><small><strong>Warning:</strong> The local directory is not empty. "
"Pick a resolution in the advanced settings!</small></p>");
}
_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 int OwncloudSetupPage::nextId() const
@@ -209,9 +305,16 @@ QString OwncloudSetupPage::url() const
return url; return url;
} }
QString OwncloudSetupPage::localFolder() const
{
QString folder = wizard()->property("localFolder").toString();
return folder;
}
void OwncloudSetupPage::setConnected( bool comp ) void OwncloudSetupPage::setConnected( bool comp )
{ {
_connected = comp; _connected = comp;
_ui.resultLayout->setEnabled(true);
_progressIndi->setVisible(false); _progressIndi->setVisible(false);
_progressIndi->stopAnimation(); _progressIndi->stopAnimation();
} }
@@ -223,6 +326,7 @@ bool OwncloudSetupPage::validatePage()
if( ! _connected) { if( ! _connected) {
setErrorString(QString::null); setErrorString(QString::null);
_checking = true; _checking = true;
_ui.resultLayout->setEnabled(true);
_progressIndi->setVisible(true); _progressIndi->setVisible(true);
_progressIndi->startAnimation(); _progressIndi->startAnimation();
emit completeChanged(); emit completeChanged();
@@ -253,40 +357,26 @@ void OwncloudSetupPage::setErrorString( const QString& err )
void OwncloudSetupPage::stopSpinner() void OwncloudSetupPage::stopSpinner()
{ {
// _ui.addressLayout->removeWidget( _progressIndi ); _ui.resultLayout->setEnabled(false);
_progressIndi->setVisible(false); _progressIndi->setVisible(false);
_progressIndi->stopAnimation(); _progressIndi->stopAnimation();
} }
OwncloudSetupPage::SyncMode OwncloudSetupPage::syncMode() OwncloudSetupPage::SyncMode OwncloudSetupPage::syncMode()
{ {
if( _selectiveSyncButtons->checkedButton() &&
_selectiveSyncButtons->checkedButton() == _ui.pbSelectiveMode ) {
return SelectiveMode;
}
return BoxMode; return BoxMode;
} }
void OwncloudSetupPage::setFolderNames( const QString& localFolder, const QString& remoteFolder ) void OwncloudSetupPage::setRemoteFolder( const QString& remoteFolder )
{ {
_ui.pbSelectLocalFolder->setText(localFolder); if( !remoteFolder.isEmpty() ) {
if( !remoteFolder.isEmpty() )
_remoteFolder = remoteFolder; _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);
} }
_ui.syncModeLabel->setText(t);
} }
QString OwncloudSetupPage::selectedLocalFolder() const void OwncloudSetupPage::setMultipleFoldersExist(bool exist)
{ {
return _ui.pbSelectLocalFolder->text(); _multipleFoldersExist = exist;
} }
void OwncloudSetupPage::slotSelectFolder() void OwncloudSetupPage::slotSelectFolder()
@@ -294,7 +384,9 @@ void OwncloudSetupPage::slotSelectFolder()
QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath()); QString dir = QFileDialog::getExistingDirectory(0, tr("Local Sync Folder"), QDir::homePath());
if( !dir.isEmpty() ) { if( !dir.isEmpty() ) {
setFolderNames(dir); _ui.pbSelectLocalFolder->setText(dir);
wizard()->setProperty("localFolder", dir);
slotHandleUserInput();
} }
} }
@@ -304,6 +396,18 @@ OwncloudSetupPage::SyncMode OwncloudWizard::syncMode()
return OwncloudSetupPage::BoxMode; return OwncloudSetupPage::BoxMode;
} }
void OwncloudWizard::setMultipleFoldersExist(bool exist)
{
_setupPage->setMultipleFoldersExist(exist);
}
void OwncloudSetupPage::setConfigExists( bool config )
{
_configExists = config;
setSubTitle( tr("<font color=\"%1\">Change your user credentials</font>")
.arg(Theme::instance()->wizardHeaderTitleColor().name()));
}
// ====================================================================== // ======================================================================
OwncloudWizardResultPage::OwncloudWizardResultPage() OwncloudWizardResultPage::OwncloudWizardResultPage()
@@ -314,8 +418,8 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
Theme *theme = Theme::instance(); Theme *theme = Theme::instance();
setTitle( tr("<font color=\"%1\" size=\"5\">Everything set up!</font>") setTitle( tr("<font color=\"%1\" size=\"5\">Everything set up!</font>")
.arg(theme->wizardHeaderTitleColor().name())); .arg(theme->wizardHeaderTitleColor().name()));
setSubTitle( tr("<font color=\"%1\">Enter user credentials to access your %2</font>") // required to show header in QWizard's modern style
.arg(theme->wizardHeaderTitleColor().name()).arg(theme->appNameGUI())); setSubTitle( QLatin1String(" ") );
_ui.pbOpenLocal->setText("Open local folder"); _ui.pbOpenLocal->setText("Open local folder");
_ui.pbOpenServer->setText(tr("Open %1").arg(Theme::instance()->appNameGUI())); _ui.pbOpenServer->setText(tr("Open %1").arg(Theme::instance()->appNameGUI()));
@@ -327,8 +431,8 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
_ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); _ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
// _ui.pbOpenServer->setIcon(QIcon(":/mirall/resources/owncloud_logo_blue.png")); QIcon appIcon = theme->applicationIcon();
_ui.pbOpenServer->setIcon(theme->applicationIcon().pixmap(48)); _ui.pbOpenServer->setIcon(appIcon.pixmap(48));
_ui.pbOpenServer->setText(tr("Open %1").arg(theme->appNameGUI())); _ui.pbOpenServer->setText(tr("Open %1").arg(theme->appNameGUI()));
_ui.pbOpenServer->setIconSize(QSize(48, 48)); _ui.pbOpenServer->setIconSize(QSize(48, 48));
_ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); _ui.pbOpenServer->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@@ -351,19 +455,25 @@ bool OwncloudWizardResultPage::isComplete() const
return _complete; return _complete;
} }
void OwncloudWizardResultPage::setFolderNames( const QString& localFolder, const QString& remoteFolder ) void OwncloudWizardResultPage::initializePage()
{ {
_localFolder = localFolder; const QString localFolder = wizard()->property("localFolder").toString();
QString text; QString text;
if( remoteFolder == QLatin1String("/") || if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) {
remoteFolder.isEmpty() ) { text = tr("Your entire account is synced to the local folder <i>%1</i>")
text = tr("Your entire account is synced to the local folder <i>%1</i>").arg(localFolder); .arg(QDir::toNativeSeparators(localFolder));
} else { } else {
text = tr("ownCloud folder <i>%1</i> is synced to local folder <i>%2</i>").arg(remoteFolder).arg(localFolder); text = tr("ownCloud folder <i>%1</i> is synced to local folder <i>%2</i>")
.arg(_remoteFolder).arg(QDir::toNativeSeparators(localFolder));
} }
_ui.localFolderLabel->setText( text ); _ui.localFolderLabel->setText( text );
} }
void OwncloudWizardResultPage::setRemoteFolder(const QString &remoteFolder)
{
_remoteFolder = remoteFolder;
}
void OwncloudWizardResultPage::setupCustomization() void OwncloudWizardResultPage::setupCustomization()
{ {
@@ -382,7 +492,8 @@ void OwncloudWizardResultPage::setupCustomization()
*/ */
OwncloudWizard::OwncloudWizard(QWidget *parent) OwncloudWizard::OwncloudWizard(QWidget *parent)
: QWizard(parent) : QWizard(parent),
_configExists(false)
{ {
_setupPage = new OwncloudSetupPage; _setupPage = new OwncloudSetupPage;
_resultPage = new OwncloudWizardResultPage; _resultPage = new OwncloudWizardResultPage;
@@ -409,6 +520,11 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
setSubTitleFormat(Qt::RichText); setSubTitleFormat(Qt::RichText);
} }
QString OwncloudWizard::localFolder() const
{
return(_setupPage->localFolder());
}
QString OwncloudWizard::ocUrl() const QString OwncloudWizard::ocUrl() const
{ {
QString url = field("OCUrl").toString().simplified(); QString url = field("OCUrl").toString().simplified();
@@ -420,10 +536,10 @@ void OwncloudWizard::enableFinishOnResultWidget(bool enable)
_resultPage->setComplete(enable); _resultPage->setComplete(enable);
} }
void OwncloudWizard::setFolderNames( const QString& localFolder, const QString& remoteFolder ) void OwncloudWizard::setRemoteFolder( const QString& remoteFolder )
{ {
_setupPage->setFolderNames( localFolder, remoteFolder ); _setupPage->setRemoteFolder( remoteFolder );
_resultPage->setFolderNames( localFolder, remoteFolder ); _resultPage->setRemoteFolder( remoteFolder );
} }
void OwncloudWizard::showConnectInfo( const QString& msg ) void OwncloudWizard::showConnectInfo( const QString& msg )
@@ -471,7 +587,6 @@ void OwncloudWizard::appendToConfigurationLog( const QString& msg, LogType type
void OwncloudWizard::setOCUrl( const QString& url ) void OwncloudWizard::setOCUrl( const QString& url )
{ {
_oCUrl = url;
_setupPage->setServerUrl( url ); _setupPage->setServerUrl( url );
} }
@@ -481,9 +596,21 @@ void OwncloudWizard::setOCUser( const QString& user )
_setupPage->setOCUser( user ); _setupPage->setOCUser( user );
} }
void OwncloudWizard::setConfigExists( bool config )
{
_configExists = config;
_setupPage->setConfigExists( config );
}
bool OwncloudWizard::configExists()
{
return _configExists;
}
void OwncloudWizardResultPage::slotOpenLocal() void OwncloudWizardResultPage::slotOpenLocal()
{ {
QDesktopServices::openUrl(QUrl(_localFolder)); const QString localFolder = wizard()->property("localFolder").toString();
QDesktopServices::openUrl(QUrl::fromLocalFile(localFolder));
} }
void OwncloudWizardResultPage::slotOpenServer() void OwncloudWizardResultPage::slotOpenServer()
@@ -493,4 +620,5 @@ void OwncloudWizardResultPage::slotOpenServer()
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
} // end namespace } // end namespace

View File

@@ -50,31 +50,46 @@ public:
void setAllowPasswordStorage( bool ); void setAllowPasswordStorage( bool );
bool validatePage(); bool validatePage();
QString url() const; QString url() const;
QString localFolder() const;
void setConnected(bool complete); void setConnected(bool complete);
QString selectedLocalFolder() const; void setRemoteFolder( const QString& remoteFolder);
void setFolderNames( const QString&, const QString& remoteFolder = QString::null); void setMultipleFoldersExist( bool exist );
SyncMode syncMode(); SyncMode syncMode();
public slots: public slots:
void setErrorString( const QString& ); void setErrorString( const QString& );
void setConfigExists( bool );
void stopSpinner(); void stopSpinner();
protected slots: protected slots:
void handleNewOcUrl(const QString& ocUrl); void slotUrlChanged(const QString&);
void slotUserChanged(const QString&);
void setupCustomization(); void setupCustomization();
void slotToggleAdvanced(int state); void slotToggleAdvanced(int state);
void slotChangedSelective(QAbstractButton*);
void slotSelectFolder(); void slotSelectFolder();
signals: signals:
void connectToOCUrl( const QString& ); void connectToOCUrl( const QString& );
protected:
void updateFoldersInfo();
private slots:
void slotHandleUserInput();
private: private:
bool urlHasChanged();
Ui_OwncloudSetupPage _ui; Ui_OwncloudSetupPage _ui;
QString _oCUrl; QString _oCUrl;
QString _ocUser;
bool _connected; bool _connected;
bool _checking; bool _checking;
bool _configExists;
bool _multipleFoldersExist;
QProgressIndicator *_progressIndi; QProgressIndicator *_progressIndi;
QButtonGroup *_selectiveSyncButtons; QButtonGroup *_selectiveSyncButtons;
QString _remoteFolder; QString _remoteFolder;
@@ -95,21 +110,25 @@ public:
LogParagraph LogParagraph
}; };
OwncloudWizard(QWidget *parent = 0L); OwncloudWizard(QWidget *parent = 0);
void setOCUrl( const QString& ); void setOCUrl( const QString& );
void setOCUser( const QString& ); void setOCUser( const QString& );
void setupCustomMedia( QVariant, QLabel* ); void setupCustomMedia( QVariant, QLabel* );
QString ocUrl() const; QString ocUrl() const;
QString localFolder() const;
void enableFinishOnResultWidget(bool enable); void enableFinishOnResultWidget(bool enable);
void displayError( const QString& ); void displayError( const QString& );
OwncloudSetupPage::SyncMode syncMode(); OwncloudSetupPage::SyncMode syncMode();
void setMultipleFoldersExist( bool );
void setConfigExists( bool );
bool configExists();
public slots: public slots:
void setFolderNames( const QString&, const QString& ); void setRemoteFolder( const QString& );
void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph ); void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph );
void slotCurrentPageChanged( int ); void slotCurrentPageChanged( int );
@@ -125,9 +144,9 @@ private:
OwncloudWizardResultPage *_resultPage; OwncloudWizardResultPage *_resultPage;
QString _configFile; QString _configFile;
QString _oCUrl;
QString _oCUser; QString _oCUser;
QStringList _setupLog; QStringList _setupLog;
bool _configExists;
}; };
@@ -146,10 +165,11 @@ public:
~OwncloudWizardResultPage(); ~OwncloudWizardResultPage();
bool isComplete() const; bool isComplete() const;
void initializePage();
void setRemoteFolder( const QString& remoteFolder);
public slots: public slots:
void setComplete(bool complete); void setComplete(bool complete);
void setFolderNames( const QString&, const QString& );
protected slots: protected slots:
void slotOpenLocal(); void slotOpenLocal();
@@ -160,6 +180,7 @@ protected:
private: private:
QString _localFolder; QString _localFolder;
QString _remoteFolder;
bool _complete; bool _complete;
Ui_OwncloudWizardResultPage _ui; Ui_OwncloudWizardResultPage _ui;

View File

@@ -35,21 +35,31 @@ Mirall::ProxyDialog::ProxyDialog( QWidget* parent )
// load current proxy settings // load current proxy settings
Mirall::MirallConfigFile cfgFile; Mirall::MirallConfigFile cfgFile;
if (cfgFile.proxyType() == QNetworkProxy::NoProxy) switch (cfgFile.proxyType()) {
case QNetworkProxy::NoProxy:
noProxyRadioButton->setChecked(true); noProxyRadioButton->setChecked(true);
if (cfgFile.proxyType() == QNetworkProxy::DefaultProxy) break;
case QNetworkProxy::DefaultProxy:
systemProxyRadioButton->setChecked(true); systemProxyRadioButton->setChecked(true);
if (cfgFile.proxyType() == QNetworkProxy::HttpProxy) break;
{ case QNetworkProxy::Socks5Proxy:
cbSocks->setChecked(true);
// fall through
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
manualProxyRadioButton->setChecked(true); manualProxyRadioButton->setChecked(true);
hostLineEdit->setText(cfgFile.proxyHostName()); break;
portSpinBox->setValue(cfgFile.proxyPort()); default:
if (!cfgFile.proxyUser().isEmpty()) break;
{ }
authRequiredcheckBox->setChecked(true);
userLineEdit->setText(cfgFile.proxyUser()); hostLineEdit->setText(cfgFile.proxyHostName());
passwordLineEdit->setText(cfgFile.proxyPassword()); portSpinBox->setValue(cfgFile.proxyPort());
} if (!cfgFile.proxyUser().isEmpty())
{
authRequiredcheckBox->setChecked(true);
userLineEdit->setText(cfgFile.proxyUser());
passwordLineEdit->setText(cfgFile.proxyPassword());
} }
} }
@@ -67,18 +77,14 @@ void Mirall::ProxyDialog::saveSettings()
} }
if (manualProxyRadioButton->isChecked()) if (manualProxyRadioButton->isChecked())
{ {
if (authRequiredcheckBox->isChecked()) int proxyType = cbSocks->isChecked() ? QNetworkProxy::Socks5Proxy
{ : QNetworkProxy::HttpProxy;
QString user = userLineEdit->text(); QString user = userLineEdit->text();
QString pass = passwordLineEdit->text(); QString pass = passwordLineEdit->text();
cfgFile.setProxyType(QNetworkProxy::HttpProxy, hostLineEdit->text(), cfgFile.setProxyType(proxyType, hostLineEdit->text(),
portSpinBox->value(), user, pass); portSpinBox->value(),
} authRequiredcheckBox->isChecked(),
else user, pass);
{
cfgFile.setProxyType(QNetworkProxy::HttpProxy, hostLineEdit->text(),
portSpinBox->value(), QString::null, QString::null);
}
} }
} }

View File

@@ -6,38 +6,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>465</width> <width>405</width>
<height>291</height> <height>319</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Proxy Settings</string> <string>Proxy Settings</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item row="1" column="0"> <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@@ -76,18 +53,82 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <item row="0" column="0">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> <widget class="QLabel" name="hostLabel">
</property> <property name="text">
<property name="verticalSpacing"> <string>Host</string>
<number>6</number> </property>
</property> </widget>
<property name="leftMargin"> </item>
<number>40</number> <item row="0" column="1">
</property> <widget class="QLineEdit" name="hostLineEdit">
<property name="topMargin"> <property name="maximumSize">
<number>0</number> <size>
</property> <width>300</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="portSpinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSocks">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use as SOCKSv5 proxy</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="authRequiredcheckBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Proxy server requires password</string>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="proxyUserLabel"> <widget class="QLabel" name="proxyUserLabel">
<property name="enabled"> <property name="enabled">
@@ -143,70 +184,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="portLabel">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="hostLabel">
<property name="text">
<string>Host</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="hostLineEdit">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="authRequiredcheckBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Proxy server requires password</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="portSpinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@@ -146,7 +146,7 @@ void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
aliasRect.setLeft(iconRect.right()+margin); aliasRect.setLeft(iconRect.right()+margin);
aliasRect.setTop(aliasRect.top() + aliasFm.height()/2 ); aliasRect.setTop(aliasRect.top() + aliasFm.height()/2 );
aliasRect.setBottom(aliasRect.top()+subFm.height()); aliasRect.setBottom(aliasRect.top()+aliasFm.height());
// local directory box // local directory box
QRect localPathRect = aliasRect; QRect localPathRect = aliasRect;

View File

@@ -17,6 +17,7 @@
#include "mirall/version.h" #include "mirall/version.h"
#include "mirall/mirallconfigfile.h" #include "mirall/mirallconfigfile.h"
#include "mirall/occinfo.h" #include "mirall/occinfo.h"
#include "mirall/utility.h"
#include <QtCore> #include <QtCore>
#include <QtNetwork> #include <QtNetwork>
@@ -56,9 +57,13 @@ void UpdateDetector::versionCheck( Theme *theme )
} }
url.addQueryItem( QLatin1String("version"), ver ); url.addQueryItem( QLatin1String("version"), ver );
url.addQueryItem( QLatin1String("platform"), platform ); url.addQueryItem( QLatin1String("platform"), platform );
url.addQueryItem( QLatin1String("oem"), theme->appName()); url.addQueryItem( QLatin1String("oem"), theme->appName() );
_accessManager->get( QNetworkRequest( url )); QNetworkRequest req( url );
req.setRawHeader( QByteArray("Host"), url.host().toUtf8() );
req.setRawHeader( QByteArray("User-Agent"), Utility::userAgentString() );
_accessManager->get( req );
} }
void UpdateDetector::slotOpenUpdateUrl() void UpdateDetector::slotOpenUpdateUrl()

View File

@@ -13,6 +13,9 @@
#include "utility.h" #include "utility.h"
#include "mirall/version.h"
#include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QUrl> #include <QUrl>
@@ -90,4 +93,36 @@ void Utility::setupFavLink(const QString &folder)
#endif #endif
} }
// Qtified version of get_platforms() in csync_owncloud.c
QString Utility::platform()
{
#if defined(Q_OS_WIN32)
return QLatin1String("Windows");
#elif defined(Q_OS_MAC)
return QLatin1String("Macintosh");
#elif defined(Q_OS_LINUX)
return QLatin1String("Linux");
#elif defined(__DragonFly__) // Q_OS_FREEBSD also defined
return "DragonFlyBSD";
#elif defined(Q_OS_FREEBSD)
return QLatin1String("FreeBSD");
#elif defined(Q_OS_NETBSD)
return QLatin1String("NetBSD");
#elif defined(Q_OS_OPENBSD)
return QLatin1String("OpenBSD");
#elif defined(Q_OS_SOLARIS)
return "Solaris";
#else
return "Unknown OS"
#endif
} }
QByteArray Utility::userAgentString()
{
return QString::fromLatin1("Mozilla/5.0 (%1) mirall/%2")
.arg(Utility::platform())
.arg(QLatin1String(MIRALL_STRINGIFY(MIRALL_VERSION)))
.toLatin1();
}
} // namespace Mirall

View File

@@ -25,6 +25,8 @@ class Utility
public: public:
static QString formatFingerprint( const QByteArray& ); static QString formatFingerprint( const QByteArray& );
static void setupFavLink( const QString &folder ); static void setupFavLink( const QString &folder );
static QString platform();
static QByteArray userAgentString();
}; };
} }