Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaas Freitag <freitag@owncloud.com>2012-08-24 13:16:58 +0400
committerKlaas Freitag <freitag@owncloud.com>2012-08-24 13:16:58 +0400
commit5294f446a21a5981d2bd2106a304eb085dc3718b (patch)
treef9f2f445ea721e366af38dfcdb5ce2c1bc17d2fc /src
parent62d1f281c3da1977f52811bbc089eb8b76dd1f88 (diff)
parentdd2ac612003d09f454799af524197ebc2acf5864 (diff)
Merge branch 'master' of gitorious.org:owncloud/mirall
Conflicts: src/mirall/owncloudinfo.cpp src/mirall/owncloudsetupwizard.cpp src/mirall/owncloudwizard.cpp
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/mirall/application.cpp149
-rw-r--r--src/mirall/csyncfolder.cpp2
-rw-r--r--src/mirall/csyncthread.cpp91
-rw-r--r--src/mirall/csyncthread.h12
-rw-r--r--src/mirall/folder.cpp10
-rw-r--r--src/mirall/folder.h5
-rw-r--r--src/mirall/folderman.cpp43
-rw-r--r--src/mirall/folderwatcher.cpp8
-rw-r--r--src/mirall/folderwizard.cpp47
-rw-r--r--src/mirall/logbrowser.cpp6
-rw-r--r--src/mirall/mirallconfigfile.cpp163
-rw-r--r--src/mirall/mirallconfigfile.h6
-rw-r--r--src/mirall/miralltheme.cpp32
-rw-r--r--src/mirall/networklocation.cpp6
-rw-r--r--src/mirall/occinfo.cpp18
-rw-r--r--src/mirall/owncloudfolder.cpp35
-rw-r--r--src/mirall/owncloudinfo.cpp106
-rw-r--r--src/mirall/owncloudinfo.h4
-rw-r--r--src/mirall/owncloudsetupwizard.cpp91
-rw-r--r--src/mirall/owncloudtheme.cpp50
-rw-r--r--src/mirall/owncloudwizard.cpp110
-rw-r--r--src/mirall/owncloudwizard.h1
-rw-r--r--src/mirall/proxydialog.cpp22
-rw-r--r--src/mirall/proxydialog.ui359
-rw-r--r--src/mirall/sslerrordialog.cpp35
-rw-r--r--src/mirall/statusdialog.cpp37
-rw-r--r--src/mirall/syncresult.cpp2
-rw-r--r--src/mirall/temporarydir.cpp70
-rw-r--r--src/mirall/temporarydir.h37
-rw-r--r--src/mirall/theme.cpp2
-rw-r--r--src/mirall/unisonfolder.cpp10
-rw-r--r--src/mirall/updatedetector.cpp17
33 files changed, 859 insertions, 728 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5b1558fd..3977e0afd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,7 +65,6 @@ set(libsync_SRCS
mirall/owncloudfolder.cpp
mirall/csyncthread.cpp
mirall/fileutils.cpp
- mirall/temporarydir.cpp
mirall/theme.cpp
mirall/owncloudtheme.cpp
mirall/miralltheme.cpp
diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index b879f6454..6656c47b6 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -58,7 +58,7 @@ namespace Mirall {
void mirallLogCatcher(QtMsgType type, const char *msg)
{
Q_UNUSED(type)
- Logger::instance()->mirallLog( msg );
+ Logger::instance()->mirallLog( QString::fromUtf8(msg) );
}
void csyncLogCatcher(const char *msg)
@@ -87,33 +87,33 @@ Application::Application(int &argc, char **argv) :
setApplicationName( _theme->appName() );
setWindowIcon( _theme->applicationIcon() );
- if( arguments().contains("--help")) {
+ if( arguments().contains(QLatin1String("--help"))) {
showHelp();
}
setupLogBrowser();
processEvents();
QTranslator *qtTranslator = new QTranslator(this);
- qtTranslator->load("qt_" + QLocale::system().name(),
+ qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
installTranslator(qtTranslator);
QTranslator *mirallTranslator = new QTranslator(this);
#ifdef Q_OS_LINUX
// FIXME - proper path!
- mirallTranslator->load("mirall_" + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/"));
+ mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/"));
#endif
#ifdef Q_OS_MAC
- mirallTranslator->load("mirall_" + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir.
+ mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN32
- mirallTranslator->load("mirall_" + QLocale::system().name()); // path defaults to app dir.
+ mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name()); // path defaults to app dir.
#endif
installTranslator(mirallTranslator);
// create folder manager for sync folder management
- _folderMan = new FolderMan();
+ _folderMan = new FolderMan(this);
connect( _folderMan, SIGNAL(folderSyncStateChange(QString)),
this,SLOT(slotSyncStateChange(QString)));
@@ -126,15 +126,6 @@ Application::Application(int &argc, char **argv) :
_folderWizard = new FolderWizard( 0, _theme );
- connect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
- SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
-
- connect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
- SLOT(slotNoOwnCloudFound(QNetworkReply*)));
-
- connect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
- this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
-
_owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this );
connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), SLOT(slotStartFolderSetup(int)));
@@ -146,12 +137,6 @@ Application::Application(int &argc, char **argv) :
connect( _statusDialog, SIGNAL(openLogBrowser()), this, SLOT(slotOpenLogBrowser()));
-#if 0
- connect( _statusDialog, SIGNAL(fetchFolderAlias(const QString&)),
- SLOT(slotFetchFolder( const QString&)));
- connect( _statusDialog, SIGNAL(pushFolderAlias(const QString&)),
- SLOT(slotPushFolder( const QString&)));
-#endif
connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
SLOT(slotEnableFolder(QString,bool)));
connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
@@ -187,12 +172,6 @@ Application::Application(int &argc, char **argv) :
Application::~Application()
{
qDebug() << "* Mirall shutdown";
-
-#if QT_VERSION >= 0x040700
- delete _networkMgr;
-#endif
- delete _folderMan;
- delete _tray;
}
void Application::slotStartUpdateDetector()
@@ -206,6 +185,16 @@ void Application::slotStartFolderSetup( int result )
{
if( result == QDialog::Accepted ) {
if( ownCloudInfo::instance()->isConfigured() ) {
+ connect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
+ SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
+
+ connect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
+ SLOT(slotNoOwnCloudFound(QNetworkReply*)));
+
+ connect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
+ this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
+
+
ownCloudInfo::instance()->checkInstallation();
} else {
QMessageBox::warning(0, tr("No ownCloud Configuration"),
@@ -227,7 +216,6 @@ void Application::slotOwnCloudFound( const QString& url, const QString& versionS
// now check the authentication
MirallConfigFile cfgFile;
cfgFile.setOwnCloudVersion( version );
-
// disconnect from ownCloudInfo
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
@@ -244,7 +232,7 @@ void Application::slotNoOwnCloudFound( QNetworkReply* reply )
QString msg;
if( reply ) {
QString url( reply->url().toString() );
- url.remove( "/status.php" );
+ url.remove( QLatin1String("/status.php") );
msg = tr("<p>The ownCloud at %1 could not be reached.</p>").arg( url );
msg += tr("<p>The detailed error message is<br/><tt>%1</tt></p>").arg( reply->errorString() );
}
@@ -252,13 +240,24 @@ void Application::slotNoOwnCloudFound( QNetworkReply* reply )
QMessageBox::warning(0, tr("ownCloud Connection Failed"), msg );
_actionAddFolder->setEnabled( false );
+
+ // Disconnect.
+ disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
+ this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
+
+ disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
+ this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
+
+ disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
+ this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
+
setupContextMenu();
}
void Application::slotCheckAuthentication()
{
qDebug() << "# checking for authentication settings.";
- ownCloudInfo::instance()->getRequest("/", true ); // this call needs to be authenticated.
+ ownCloudInfo::instance()->getRequest(QLatin1String("/"), true ); // this call needs to be authenticated.
// simply GET the webdav root, will fail if credentials are wrong.
// continue in slotAuthCheck here :-)
}
@@ -288,6 +287,8 @@ void Application::slotAuthCheck( const QString& ,QNetworkReply *reply )
if( _tray )
_tray->showMessage(tr("ownCloud Sync Started"), tr("Sync started for %1 configured sync folder(s).").arg(cnt));
+
+ _statusDialog->setFolderList( _folderMan->map() );
}
_actionAddFolder->setEnabled( true );
}
@@ -310,14 +311,13 @@ void Application::setupActions()
QObject::connect(_actionConfigure, SIGNAL(triggered(bool)), SLOT(slotConfigure()));
_actionConfigureProxy = new QAction(tr("Configure proxy..."), this);
QObject::connect(_actionConfigureProxy, SIGNAL(triggered(bool)), SLOT(slotConfigureProxy()));
-
_actionQuit = new QAction(tr("Quit"), this);
QObject::connect(_actionQuit, SIGNAL(triggered(bool)), SLOT(quit()));
}
void Application::setupSystemTray()
{
- _tray = new QSystemTrayIcon();
+ _tray = new QSystemTrayIcon(this);
_tray->setIcon( _theme->applicationIcon() ); // load the grey icon
connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
@@ -338,14 +338,15 @@ void Application::setupContextMenu()
_contextMenu->setTitle(_theme->appName() );
_contextMenu->addAction(_actionOpenStatus);
_contextMenu->addAction(_actionOpenoC);
- _contextMenu->addAction(_actionConfigure);
- _contextMenu->addAction(_actionConfigureProxy);
- _contextMenu->addAction(_actionAddFolder);
+
_contextMenu->addSeparator();
+ if (!_folderMan->map().isEmpty())
+ _contextMenu->addAction(tr("Managed Folders:"))->setDisabled(true);
+
// here all folders should be added
foreach (Folder *folder, _folderMan->map() ) {
- QAction *action = new QAction( tr("open folder %1").arg( folder->alias()), this );
+ QAction *action = new QAction( folder->alias(), this );
action->setIcon( _theme->trayFolderIcon( folder->backend()) );
connect( action, SIGNAL(triggered()),_folderOpenActionMapper,SLOT(map()));
@@ -353,8 +354,12 @@ void Application::setupContextMenu()
_contextMenu->addAction(action);
}
+ _contextMenu->addAction(_actionAddFolder);
_contextMenu->addSeparator();
+ _contextMenu->addAction(_actionConfigure);
+ _contextMenu->addAction(_actionConfigureProxy);
+ _contextMenu->addSeparator();
_contextMenu->addAction(_actionQuit);
_tray->setContextMenu(_contextMenu);
@@ -367,24 +372,25 @@ void Application::setupLogBrowser()
qInstallMsgHandler( mirallLogCatcher );
csync_set_log_callback( csyncLogCatcher );
- if( arguments().contains("--logwindow") || arguments().contains("-l")) {
+ if( arguments().contains(QLatin1String("--logwindow"))
+ || arguments().contains(QLatin1String("-l"))) {
slotOpenLogBrowser();
}
// check for command line option for a log file.
- int lf = arguments().indexOf("--logfile");
+ int lf = arguments().indexOf(QLatin1String("--logfile"));
if( lf > -1 && lf+1 < arguments().count() ) {
QString logfile = arguments().at( lf+1 );
bool flush = false;
- if( arguments().contains("--logflush")) flush = true;
+ if( arguments().contains(QLatin1String("--logflush"))) flush = true;
qDebug() << "Logging into logfile: " << logfile << " with flush " << flush;
_logBrowser->setLogFile( logfile, flush );
}
- qDebug() << QString( "################## %1 %2 %3 ").arg(_theme->appName())
+ qDebug() << QString::fromLatin1( "################## %1 %2 %3 ").arg(_theme->appName())
.arg( QLocale::system().name() )
.arg(_theme->version());
}
@@ -392,25 +398,21 @@ void Application::setupLogBrowser()
void Application::setupProxy()
{
//
- // TODO: push proxy information to csync
- //
Mirall::MirallConfigFile cfg;
- switch(cfg.proxyType())
- {
- case QNetworkProxy::NoProxy:
- {
+ int proxy = cfg.proxyType();
+
+ switch(proxy) {
+ case QNetworkProxy::NoProxy: {
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::NoProxy);
QNetworkProxy::setApplicationProxy(proxy);
break;
}
- case QNetworkProxy::DefaultProxy:
- {
+ case QNetworkProxy::DefaultProxy: {
QNetworkProxyFactory::setUseSystemConfiguration(true);
break;
}
- case QNetworkProxy::Socks5Proxy:
- {
+ case QNetworkProxy::Socks5Proxy: {
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(cfg.proxyHostName());
@@ -432,13 +434,13 @@ void Application::slotFolderOpenAction( const QString& alias )
qDebug() << "opening local url " << f->path();
if( f ) {
QUrl url(f->path(), QUrl::TolerantMode);
- url.setScheme( "file" );
+ url.setScheme( QLatin1String("file") );
#ifdef Q_OS_WIN32
// work around a bug in QDesktopServices on Win32, see i-net
QString filePath = f->path();
- if (filePath.startsWith("\\\\") || filePath.startsWith("//"))
+ if (filePath.startsWith(QLatin1String("\\\\")) || filePath.startsWith(QLatin1String("//")))
url.setUrl(QDir::toNativeSeparators(filePath));
else
url = QUrl::fromLocalFile(filePath);
@@ -481,25 +483,25 @@ void Application::slotAddFolder()
bool goodData = true;
- QString alias = _folderWizard->field("alias").toString();
- QString sourceFolder = _folderWizard->field("sourceFolder").toString();
- QString backend = QString::fromLocal8Bit("csync");
+ QString alias = _folderWizard->field(QLatin1String("alias")).toString();
+ QString sourceFolder = _folderWizard->field(QLatin1String("sourceFolder")).toString();
+ QString backend = QLatin1String("csync");
QString targetPath;
bool onlyThisLAN = false;
bool onlyOnline = false;
- if (_folderWizard->field("local?").toBool()) {
+ if (_folderWizard->field(QLatin1String("local?")).toBool()) {
// setup a local csync folder
- targetPath = _folderWizard->field("targetLocalFolder").toString();
- } else if (_folderWizard->field("remote?").toBool()) {
+ targetPath = _folderWizard->field(QLatin1String("targetLocalFolder")).toString();
+ } else if (_folderWizard->field(QLatin1String("remote?")).toBool()) {
// setup a remote csync folder
- targetPath = _folderWizard->field("targetURLFolder").toString();
- onlyOnline = _folderWizard->field("onlyOnline?").toBool();
- onlyThisLAN = _folderWizard->field("onlyThisLAN?").toBool();
- } else if( _folderWizard->field("OC?").toBool()) {
+ targetPath = _folderWizard->field(QLatin1String("targetURLFolder")).toString();
+ onlyOnline = _folderWizard->field(QLatin1String("onlyOnline?")).toBool();
+ onlyThisLAN = _folderWizard->field(QLatin1String("onlyThisLAN?")).toBool();
+ } else if( _folderWizard->field(QLatin1String("OC?")).toBool()) {
// setup a ownCloud folder
- backend = QString::fromLocal8Bit("owncloud");
- targetPath = _folderWizard->field("targetOCFolder").toString();
+ backend = QLatin1String("owncloud");
+ targetPath = _folderWizard->field(QLatin1String("targetOCFolder")).toString();
} else {
qWarning() << "* Folder not local and note remote?";
goodData = false;
@@ -573,7 +575,8 @@ void Application::slotOpenLogBrowser()
*/
void Application::slotRemoveFolder( const QString& alias )
{
- int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"), tr("Do you really want to remove upload folder <i>%1</i>?").arg(alias),
+ int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"),
+ tr("Do you really want to remove upload folder <i>%1</i>?").arg(alias),
QMessageBox::Yes|QMessageBox::No );
if( ret == QMessageBox::No ) {
@@ -632,7 +635,7 @@ void Application::slotInfoFolder( const QString& alias )
QMessageBox infoBox( QMessageBox::Information, tr( "Folder information" ), alias, QMessageBox::Ok );
QStringList li = folderResult.errorStrings();
foreach( const QString& l, li ) {
- folderMessage += QString("<p>%1</p>").arg( l );
+ folderMessage += QString::fromLatin1("<p>%1</p>").arg( l );
}
infoBox.setText( folderMessage );
@@ -645,18 +648,18 @@ void Application::slotInfoFolder( const QString& alias )
QHash< QString, QStringList >::const_iterator change_it = changes.constBegin();
for(; change_it != changes.constEnd(); ++change_it ) {
QString changeType = tr( "Unknown" );
- if ( change_it.key() == "changed" ) {
+ if ( change_it.key() == QLatin1String("changed") ) {
changeType = tr( "Changed files:\n" );
- } else if ( change_it.key() == "added" ) {
+ } else if ( change_it.key() == QLatin1String("added") ) {
changeType = tr( "Added files:\n" );
- } else if ( change_it.key() == "deleted" ) {
+ } else if ( change_it.key() == QLatin1String("deleted") ) {
changeType = tr( "New files in the server, or files deleted locally:\n");
}
QStringList files = change_it.value();
QString fileList;
foreach( const QString& file, files) {
- fileList += file + QChar('\n');
+ fileList += file + QLatin1Char('\n');
}
details += changeType + fileList;
}
@@ -776,7 +779,7 @@ void Application::computeOverallSyncStatus()
}
}
qDebug() << "Folder in overallStatus Message: " << syncedFolder << " with name " << syncedFolder->alias();
- QString msg = QString("Folder %1: %2").arg(syncedFolder->alias()).arg(folderMessage);
+ QString msg = QString::fromLatin1("Folder %1: %2").arg(syncedFolder->alias()).arg(folderMessage);
if( msg != _overallStatusStrings[syncedFolder->alias()] ) {
_overallStatusStrings[syncedFolder->alias()] = msg;
}
@@ -786,7 +789,7 @@ void Application::computeOverallSyncStatus()
if( overallResult.status() != SyncResult::Undefined ) {
QStringList allStatusStrings = _overallStatusStrings.values();
if( ! allStatusStrings.isEmpty() )
- trayMessage = allStatusStrings.join("\n");
+ trayMessage = allStatusStrings.join(QLatin1String("\n"));
else
trayMessage = tr("No sync folders configured.");
diff --git a/src/mirall/csyncfolder.cpp b/src/mirall/csyncfolder.cpp
index 5e7fb0da5..e3579ff62 100644
--- a/src/mirall/csyncfolder.cpp
+++ b/src/mirall/csyncfolder.cpp
@@ -83,7 +83,7 @@ void CSyncFolder::slotCSyncFinished()
SyncResult res(SyncResult::Success);
if( _csyncError ) {
res.setStatus( SyncResult::Error );
- res.setErrorString( _errors.join("\\n"));
+ res.setErrorString( _errors.join(QLatin1String("\\n")));
}
emit syncFinished( res );
}
diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp
index 135396b2b..a97f36d84 100644
--- a/src/mirall/csyncthread.cpp
+++ b/src/mirall/csyncthread.cpp
@@ -29,10 +29,25 @@ namespace Mirall {
/* static variables to hold the credentials */
QString CSyncThread::_user;
QString CSyncThread::_passwd;
+QString CSyncThread::_proxyType;
+QString CSyncThread::_proxyPwd;
+QString CSyncThread::_proxyPort;
+QString CSyncThread::_proxyHost;
+QString CSyncThread::_proxyUser;
+
QString CSyncThread::_csyncConfigDir; // to be able to remove the lock file.
QMutex CSyncThread::_mutex;
+
+struct ProxyInfo {
+ char *proxyType;
+ char *proxyHost;
+ char *proxyPort;
+ char *proxyUser;
+ char *proxyPwd;
+};
+
int CSyncThread::checkPermissions( TREE_WALK_FILE* file, void *data )
{
WalkStats *wStats = static_cast<WalkStats*>(data);
@@ -84,19 +99,20 @@ QMutex CSyncThread::_mutex;
}
if( file ) {
- QString source(wStats->sourcePath);
- source.append(file->path);
+ QString source = QString::fromLocal8Bit(wStats->sourcePath);
+ source.append(QString::fromLocal8Bit(file->path));
QFileInfo fi(source);
if( fi.isDir()) { // File type directory.
- if( !(fi.isWritable() && fi.isExecutable()) ) {
+ if( !(fi.isWritable() && fi.isExecutable()) ) {
+ wStats->dirPermErrors++;
wStats->errorType = WALK_ERROR_DIR_PERMS;
}
}
}
// qDebug() << wStats->seenFiles << ". Path: " << file->path << ": uid= " << file->uid << " - type: " << file->type;
- if( wStats->errorType != WALK_ERROR_NONE ) {
+ if( !( wStats->errorType == WALK_ERROR_NONE || wStats->errorType == WALK_ERROR_DIR_PERMS )) {
return -1;
}
return 0;
@@ -110,7 +126,7 @@ CSyncThread::CSyncThread(const QString &source, const QString &target, bool loca
{
_mutex.lock();
- if( ! _source.endsWith('/')) _source.append('/');
+ if( ! _source.endsWith(QLatin1Char('/'))) _source.append(QLatin1Char('/'));
_mutex.unlock();
}
@@ -122,7 +138,6 @@ CSyncThread::~CSyncThread()
void CSyncThread::run()
{
CSYNC *csync;
-
WalkStats *wStats = new WalkStats;
QTime walkTime;
@@ -137,9 +152,17 @@ void CSyncThread::run()
wStats->seenFiles = 0;
wStats->conflicts = 0;
wStats->error = 0;
- const char *statedb = 0;
+ wStats->dirPermErrors = 0;
+
+ ProxyInfo *proxyInfo = new ProxyInfo;
_mutex.lock();
+ proxyInfo->proxyType = qstrdup( _proxyType.toAscii().constData() );
+ proxyInfo->proxyHost = qstrdup( _proxyHost.toAscii().constData() );
+ proxyInfo->proxyPort = qstrdup( _proxyPort.toAscii().constData() );
+ proxyInfo->proxyUser = qstrdup( _proxyUser.toAscii().constData() );
+ proxyInfo->proxyPwd = qstrdup( _proxyPwd.toAscii().constData() );
+
if( csync_create(&csync,
_source.toUtf8().data(),
_target.toUtf8().data()) < 0 ) {
@@ -170,6 +193,7 @@ void CSyncThread::run()
if( _localCheckOnly ) {
csync_set_local_only( csync, true );
}
+ csync_set_userdata(csync, (void*) proxyInfo);
_mutex.unlock();
if( csync_init(csync) < 0 ) {
@@ -221,23 +245,30 @@ void CSyncThread::run()
emitStateDb(csync);
- qDebug() << "############################################################### >>";
+ qDebug() << "#### Update start #################################################### >>";
if( csync_update(csync) < 0 ) {
- emit csyncError(tr("CSync Update failed."));
+ CSYNC_ERROR_CODE err = csync_get_error( csync );
+ QString errStr;
+
+ switch( err ) {
+ case CSYNC_ERR_PROXY:
+ errStr = tr("CSync failed to reach the host. Either host or proxy settings are not valid.");
+ break;
+ default:
+ errStr = tr("CSync Update failed.");
+ break;
+ }
+ emit csyncError( errStr );
goto cleanup;
}
- qDebug() << "<<###############################################################";
+ qDebug() << "<<#### Update end ###########################################################";
csync_set_userdata(csync, wStats);
walkTime.start();
if( csync_walk_local_tree(csync, &checkPermissions, 0) < 0 ) {
qDebug() << "Error in treewalk.";
- if( wStats->errorType == WALK_ERROR_DIR_PERMS ) {
- emit csyncError(tr("The local filesystem has directories which are write protected.\n"
- "That prevents ownCloud from successful syncing.\n"
- "Please make sure that all directories are writeable."));
- } else if( wStats->errorType == WALK_ERROR_WALK ) {
+ if( wStats->errorType == WALK_ERROR_WALK ) {
emit csyncError(tr("CSync encountered an error while examining the file system.\n"
"Syncing is not possible."));
} else if( wStats->errorType == WALK_ERROR_INSTRUCTIONS ) {
@@ -246,6 +277,13 @@ void CSyncThread::run()
}
emit csyncError(tr("Local filesystem problems. Better disable Syncing and check."));
goto cleanup;
+ } else {
+ // only warn, do not stop the sync process.
+ if( wStats->errorType == WALK_ERROR_DIR_PERMS ) {
+ emit csyncError(tr("The local filesystem has %1 write protected directories."
+ "That can hinder successful syncing.<p/>"
+ "Please make sure that all local directories are writeable.").arg(wStats->dirPermErrors));
+ }
}
// emit the treewalk results. Do not touch the wStats after this.
@@ -272,6 +310,15 @@ void CSyncThread::run()
}
cleanup:
csync_destroy(csync);
+
+ if( proxyInfo->proxyType ) free( proxyInfo->proxyType );
+ if( proxyInfo->proxyHost ) free( proxyInfo->proxyHost );
+ if( proxyInfo->proxyPort ) free( proxyInfo->proxyPort );
+ if( proxyInfo->proxyUser ) free( proxyInfo->proxyUser );
+ if( proxyInfo->proxyPwd ) free( proxyInfo->proxyPwd );
+
+ free( proxyInfo );
+
/*
* Attention: do not delete the wStat memory here. it is deleted in the
* slot catching the signel treeWalkResult because this thread can faster
@@ -294,11 +341,19 @@ void CSyncThread::emitStateDb( CSYNC *csync )
}
}
-void CSyncThread::setUserPwd( const QString& user, const QString& passwd )
+void CSyncThread::setConnectionDetails( const QString& user, const QString& passwd,
+ const QString& proxyType, const QString& proxyHost,
+ int proxyPort , const QString& proxyUser, const QString& proxyPwd )
{
_mutex.lock();
_user = user;
_passwd = passwd;
+ _proxyType = proxyType;
+ _proxyHost = proxyHost;
+ _proxyPort = QString::number(proxyPort);
+ qDebug() << "Proxy-Port: " << _proxyPort;
+ _proxyUser = proxyUser;
+ _proxyPwd = proxyPwd;
_mutex.unlock();
}
@@ -320,10 +375,10 @@ int CSyncThread::getauth(const char *prompt,
QString qPrompt = QString::fromLocal8Bit( prompt ).trimmed();
_mutex.lock();
- if( qPrompt == QString::fromLocal8Bit("Enter your username:") ) {
+ if( qPrompt == QLatin1String("Enter your username:") ) {
// qDebug() << "OOO Username requested!";
qstrncpy( buf, _user.toUtf8().constData(), len );
- } else if( qPrompt == QString::fromLocal8Bit("Enter your password:") ) {
+ } else if( qPrompt == QLatin1String("Enter your password:") ) {
// qDebug() << "OOO Password requested!";
qstrncpy( buf, _passwd.toUtf8().constData(), len );
} else {
diff --git a/src/mirall/csyncthread.h b/src/mirall/csyncthread.h
index 0ae99d948..fbb231a5d 100644
--- a/src/mirall/csyncthread.h
+++ b/src/mirall/csyncthread.h
@@ -48,6 +48,8 @@ struct walkStats_s {
ulong sync;
ulong error;
+ ulong dirPermErrors;
+
ulong seenFiles;
};
@@ -62,7 +64,9 @@ public:
virtual void run();
- static void setUserPwd( const QString&, const QString& );
+ static void setConnectionDetails( const QString&, const QString&,
+ const QString&, const QString&, int,
+ const QString&, const QString& );
static int checkPermissions( TREE_WALK_FILE* file, void *data);
static QString csyncConfigDir();
@@ -87,6 +91,12 @@ private:
static QMutex _mutex;
static QString _user;
static QString _passwd;
+ static QString _proxyType;
+ static QString _proxyHost;
+ static QString _proxyPort;
+ static QString _proxyUser;
+ static QString _proxyPwd;
+
static QString _csyncConfigDir;
QString _source;
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 49835df15..164cbd6fa 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -97,6 +97,16 @@ QString Folder::secondPath() const
return _secondPath;
}
+QString Folder::nativePath() const
+{
+ return QDir::toNativeSeparators(_path);
+}
+
+QString Folder::nativeSecondPath() const
+{
+ return QDir::toNativeSeparators(_secondPath);
+}
+
bool Folder::syncEnabled() const
{
return _enabled;
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index 1f5c0546b..992fc3494 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -61,6 +61,11 @@ public:
virtual QString secondPath() const;
/**
+ * local folder path with native separators
+ */
+ QString nativePath() const;
+ virtual QString nativeSecondPath() const;
+ /**
* switch sync on or off
* If the sync is switched off, the startSync method is not going to
* be called.
diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index 0f91c2876..45ac50e01 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -31,8 +31,8 @@ FolderMan::FolderMan(QObject *parent) :
// if QDir::mkpath would not be so stupid, I would not need to have this
// duplication of folderConfigPath() here
QDir storageDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
- storageDir.mkpath("folders");
- _folderConfigPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/folders";
+ storageDir.mkpath(QLatin1String("folders"));
+ _folderConfigPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/folders");
_folderChangeSignalMapper = new QSignalMapper(this);
connect(_folderChangeSignalMapper, SIGNAL(mapped(const QString &)),
@@ -98,12 +98,12 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
Folder *folder = 0L;
qDebug() << " ` -> setting up:" << file;
- QSettings settings( _folderConfigPath + QChar('/') + file, QSettings::IniFormat);
- qDebug() << " -> file path: " + settings.fileName();
+ QSettings settings( _folderConfigPath + QLatin1Char('/') + file, QSettings::IniFormat);
+ qDebug() << " -> file path: " << settings.fileName();
settings.beginGroup( file ); // read the group with the same name as the file which is the folder alias
- QString path = settings.value("localpath").toString();
+ QString path = settings.value(QLatin1String("localpath")).toString();
if ( path.isNull() || !QFileInfo( path ).isDir() ) {
qWarning() << " `->" << path << "does not exist. Skipping folder" << file;
// _tray->showMessage(tr("Unknown folder"),
@@ -112,30 +112,31 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
return folder;
}
- QString backend = settings.value("backend").toString();
- QString targetPath = settings.value( "targetPath" ).toString();
- QString connection = settings.value( "connection" ).toString();
+ QString backend = settings.value(QLatin1String("backend")).toString();
+ QString targetPath = settings.value( QLatin1String("targetPath") ).toString();
+ QString connection = settings.value( QLatin1String("connection") ).toString();
if (!backend.isEmpty()) {
- if (backend == "unison") {
+ if (backend == QLatin1String("unison")) {
folder = new UnisonFolder(file, path, targetPath, this );
- } else if (backend == "csync") {
+ } else if (backend == QLatin1String("csync")) {
#ifdef WITH_CSYNC
folder = new CSyncFolder(file, path, targetPath, this );
#else
qCritical() << "* csync support not enabled!! ignoring:" << file;
#endif
- } else if( backend == "owncloud" ) {
+ } else if( backend == QLatin1String("owncloud") ) {
#ifdef WITH_CSYNC
MirallConfigFile cfgFile;
// assemble the owncloud url to pass to csync, incl. webdav
- QString oCUrl = cfgFile.ownCloudUrl( QString(), true );
+ QString oCUrl = cfgFile.ownCloudUrl( QString::null, true );
// cut off the leading slash, oCUrl always has a trailing.
- if( targetPath.startsWith('/') ) {
+ if( targetPath.startsWith(QLatin1Char('/')) ) {
+
targetPath.remove(0,1);
}
@@ -150,7 +151,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
}
folder->setBackend( backend );
// folder->setOnlyOnlineEnabled(settings.value("folder/onlyOnline", false).toBool());
- folder->setOnlyThisLANEnabled(settings.value("folder/onlyThisLAN", false).toBool());
+ folder->setOnlyThisLANEnabled(settings.value(QLatin1String("folder/onlyThisLAN"), false).toBool());
_folderMap[file] = folder;
@@ -305,13 +306,13 @@ void FolderMan::addFolderDefinition( const QString& backend, const QString& alia
bool onlyThisLAN )
{
// Create a settings file named after the alias
- QSettings settings( _folderConfigPath + QChar('/') + alias, QSettings::IniFormat);
+ QSettings settings( _folderConfigPath + QLatin1Char('/') + alias, QSettings::IniFormat);
- settings.setValue(QString("%1/localPath").arg(alias), sourceFolder );
- settings.setValue(QString("%1/targetPath").arg(alias), targetPath );
- settings.setValue(QString("%1/backend").arg(alias), backend );
- settings.setValue(QString("%1/connection").arg(alias), QString::fromLocal8Bit("ownCloud"));
- settings.setValue(QString("%1/onlyThisLAN").arg(alias), onlyThisLAN );
+ settings.setValue(QString::fromLatin1("%1/localPath").arg(alias), sourceFolder );
+ settings.setValue(QString::fromLatin1("%1/targetPath").arg(alias), targetPath );
+ settings.setValue(QString::fromLatin1("%1/backend").arg(alias), backend );
+ settings.setValue(QString::fromLatin1("%1/connection").arg(alias), QLatin1String("ownCloud"));
+ settings.setValue(QString::fromLatin1("%1/onlyThisLAN").arg(alias), onlyThisLAN );
settings.sync();
}
@@ -349,7 +350,7 @@ void FolderMan::removeFolder( const QString& alias )
qDebug() << "!! Can not remove " << alias << ", not in folderMap.";
}
- QFile file( _folderConfigPath + QChar('/') + alias );
+ QFile file( _folderConfigPath + QLatin1Char('/') + alias );
if( file.exists() ) {
qDebug() << "Remove folder config file " << file.fileName();
file.remove();
diff --git a/src/mirall/folderwatcher.cpp b/src/mirall/folderwatcher.cpp
index 837ca0c88..9ea962d50 100644
--- a/src/mirall/folderwatcher.cpp
+++ b/src/mirall/folderwatcher.cpp
@@ -87,7 +87,7 @@ void FolderWatcher::setIgnoreListFile( const QString& file )
while (!infile.atEnd()) {
QString line = QString::fromLocal8Bit( infile.readLine() ).trimmed();
- if( !line.startsWith( '#' )) {
+ if( !line.startsWith( QLatin1Char('#') )) {
addIgnore(line);
}
}
@@ -281,7 +281,11 @@ void FolderWatcher::slotProcessTimerTimeout()
void FolderWatcher::setProcessTimer()
{
if (!_processTimer->isActive()) {
- qDebug() << "* Pending events for" << root() << "will be processed after events stop for" << eventInterval() << "seconds (" << QTime::currentTime().addSecs(eventInterval()).toString("HH:mm:ss") << ")." << _pendingPathes.size() << "events until now )";
+ qDebug() << "* Pending events for" << root()
+ << "will be processed after events stop for"
+ << eventInterval() << "seconds ("
+ << QTime::currentTime().addSecs(eventInterval()).toString(QLatin1String("HH:mm:ss"))
+ << ")." << _pendingPathes.size() << "events until now )";
}
_processTimer->start(eventInterval());
}
diff --git a/src/mirall/folderwizard.cpp b/src/mirall/folderwizard.cpp
index 27df00b27..f90ca334e 100644
--- a/src/mirall/folderwizard.cpp
+++ b/src/mirall/folderwizard.cpp
@@ -35,9 +35,9 @@ FolderWizardSourcePage::FolderWizardSourcePage()
:_folderMap(0)
{
_ui.setupUi(this);
- registerField("sourceFolder*", _ui.localFolderLineEdit);
- _ui.localFolderLineEdit->setText( QString( "%1/%2").arg( QDir::homePath() ).arg("ownCloud" ) );
- registerField("alias*", _ui.aliasLineEdit);
+ registerField(QLatin1String("sourceFolder*"), _ui.localFolderLineEdit);
+ _ui.localFolderLineEdit->setText( QString::fromLatin1( "%1/%2").arg( QDir::homePath() ).arg(QLatin1String("ownCloud") ) );
+ registerField(QLatin1String("alias*"), _ui.aliasLineEdit);
_ui.aliasLineEdit->setText( QString::fromLatin1("ownCloud") );
_ui.warnLabel->hide();
@@ -82,7 +82,7 @@ bool FolderWizardSourcePage::isComplete() const
while( isOk && i != map->constEnd() ) {
Folder *f = static_cast<Folder*>(i.value());
QString folderDir = QDir( f->path() ).canonicalPath();
- if( ! folderDir.endsWith('/') ) folderDir.append('/');
+ if( ! folderDir.endsWith(QLatin1Char('/')) ) folderDir.append(QLatin1Char('/'));
qDebug() << "Checking local path: " << folderDir << " <-> " << userInput;
if( QFileInfo( f->path() ) == userInput ) {
@@ -127,7 +127,7 @@ bool FolderWizardSourcePage::isComplete() const
if( isOk ) {
_ui.warnLabel->hide();
- _ui.warnLabel->setText( QString() );
+ _ui.warnLabel->setText( QString::null );
} else {
_ui.warnLabel->show();
_ui.warnLabel->setText( warnString );
@@ -159,12 +159,12 @@ FolderWizardTargetPage::FolderWizardTargetPage()
_ui.setupUi(this);
_ui.warnFrame->hide();
- registerField("local?", _ui.localFolderRadioBtn);
- registerField("remote?", _ui.urlFolderRadioBtn);
- registerField("OC?", _ui.OCRadioBtn);
- registerField("targetLocalFolder", _ui.localFolder2LineEdit);
- registerField("targetURLFolder", _ui.urlFolderLineEdit);
- registerField("targetOCFolder", _ui.OCFolderLineEdit);
+ registerField(QLatin1String("local?"), _ui.localFolderRadioBtn);
+ registerField(QLatin1String("remote?"), _ui.urlFolderRadioBtn);
+ registerField(QLatin1String("OC?"), _ui.OCRadioBtn);
+ registerField(QLatin1String("targetLocalFolder"), _ui.localFolder2LineEdit);
+ registerField(QLatin1String("targetURLFolder"), _ui.urlFolderLineEdit);
+ registerField(QLatin1String("targetOCFolder"), _ui.OCFolderLineEdit);
connect( _ui.OCFolderLineEdit, SIGNAL(textChanged(QString)),
SLOT(slotFolderTextChanged(QString)));
@@ -255,7 +255,8 @@ bool FolderWizardTargetPage::isComplete() const
return QFileInfo(_ui.localFolder2LineEdit->text()).isDir();
} else if (_ui.urlFolderRadioBtn->isChecked()) {
QUrl url(_ui.urlFolderLineEdit->text());
- return url.isValid() && (url.scheme() == "sftp" || url.scheme() == "smb");
+ return url.isValid() && (url.scheme() == QLatin1String("sftp")
+ || url.scheme() == QLatin1String("smb"));
} else if( _ui.OCRadioBtn->isChecked()) {
/* owncloud selected */
QString dir = _ui.OCFolderLineEdit->text();
@@ -399,8 +400,8 @@ void FolderWizardTargetPage::on_localFolder2ChooseBtn_clicked()
FolderWizardNetworkPage::FolderWizardNetworkPage()
{
_ui.setupUi(this);
- registerField("onlyNetwork*", _ui.checkBoxOnlyOnline);
- registerField("onlyLocalNetwork*", _ui.checkBoxOnlyThisLAN );
+ registerField(QLatin1String("onlyNetwork*"), _ui.checkBoxOnlyOnline);
+ registerField(QLatin1String("onlyLocalNetwork*"), _ui.checkBoxOnlyThisLAN );
}
FolderWizardNetworkPage::~FolderWizardNetworkPage()
@@ -415,10 +416,10 @@ bool FolderWizardNetworkPage::isComplete() const
FolderWizardOwncloudPage::FolderWizardOwncloudPage()
{
_ui.setupUi(this);
- registerField("OCUrl*", _ui.lineEditOCUrl);
- registerField("OCUser*", _ui.lineEditOCUser );
- registerField("OCPasswd", _ui.lineEditOCPasswd);
- registerField("OCSiteAlias*", _ui.lineEditOCAlias);
+ registerField(QLatin1String("OCUrl*"), _ui.lineEditOCUrl);
+ registerField(QLatin1String("OCUser*"), _ui.lineEditOCUser );
+ registerField(QLatin1String("OCPasswd"), _ui.lineEditOCPasswd);
+ registerField(QLatin1String("OCSiteAlias*"), _ui.lineEditOCAlias);
}
FolderWizardOwncloudPage::~FolderWizardOwncloudPage()
@@ -427,9 +428,9 @@ FolderWizardOwncloudPage::~FolderWizardOwncloudPage()
void FolderWizardOwncloudPage::initializePage()
{
- _ui.lineEditOCAlias->setText( "ownCloud" );
- _ui.lineEditOCUrl->setText( "http://localhost/owncloud" );
- QString user( qgetenv("USER"));
+ _ui.lineEditOCAlias->setText( QLatin1String("ownCloud") );
+ _ui.lineEditOCUrl->setText( QLatin1String("http://localhost/owncloud") );
+ QString user = QString::fromLocal8Bit(qgetenv("USER"));
_ui.lineEditOCUser->setText( user );
}
@@ -456,7 +457,9 @@ FolderWizard::FolderWizard( QWidget *parent, Theme *theme )
setPage(Page_Target, new FolderWizardTargetPage());
// setPage(Page_Network, new FolderWizardNetworkPage());
// setPage(Page_Owncloud, new FolderWizardOwncloudPage());
- setWindowTitle( tr( "%1 Folder Wizard").arg( theme ? theme->appName() : "Mirall" ) );
+ setWindowTitle( tr( "%1 Folder Wizard")
+ .arg( theme ? theme->appName()
+ : QLatin1String("Mirall") ) );
#ifdef Q_WS_MAC
setWizardStyle( QWizard::ModernStyle );
#endif
diff --git a/src/mirall/logbrowser.cpp b/src/mirall/logbrowser.cpp
index 9672b8792..caad4529b 100644
--- a/src/mirall/logbrowser.cpp
+++ b/src/mirall/logbrowser.cpp
@@ -60,7 +60,7 @@ void Logger::log(Log log)
{
QString msg;
if( _showTime ) {
- msg = log.timeStamp.toString("MM-dd hh:mm:ss:zzz") + " ";
+ msg = log.timeStamp.toString(QLatin1String("MM-dd hh:mm:ss:zzz")) + QLatin1Char(' ');
}
if( log.source == Log::CSync ) {
@@ -102,7 +102,7 @@ LogWidget::LogWidget(QWidget *parent)
setReadOnly( true );
setLineWrapMode( QTextEdit::NoWrap );
QFont font;
- font.setFamily("Courier New");
+ font.setFamily(QLatin1String("Courier New"));
font.setFixedPitch(true);
document()->setDefaultFont( font );
@@ -240,7 +240,7 @@ void LogBrowser::search( const QString& str )
extraSelections.append(extra);
}
- QString stat = QString("Search term %1 with %2 search results.").arg(str).arg(extraSelections.count());
+ QString stat = QString::fromLatin1("Search term %1 with %2 search results.").arg(str).arg(extraSelections.count());
_statusLabel->setText(stat);
_logWidget->setExtraSelections(extraSelections);
diff --git a/src/mirall/mirallconfigfile.cpp b/src/mirall/mirallconfigfile.cpp
index 54c5ebddc..7f91449c3 100644
--- a/src/mirall/mirallconfigfile.cpp
+++ b/src/mirall/mirallconfigfile.cpp
@@ -19,18 +19,6 @@
#include <QtCore>
#include <QtGui>
-#ifdef Q_WS_WIN
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <windef.h>
-#include <winbase.h>
-#endif
-
-#ifdef Q_OS_MAC
-#include <mach-o/dyld.h>
-#endif
-
#define DEFAULT_REMOTE_POLL_INTERVAL 30000 // default remote poll time in milliseconds
#define DEFAULT_LOCAL_POLL_INTERVAL 10000 // default local poll time in milliseconds
#define DEFAULT_POLL_TIMER_EXEED 10
@@ -38,6 +26,8 @@
#define OC_ORGANIZATION QLatin1String("ownCloud")
#define OC_APPLICATION QLatin1String("ownCloudClient")
+#define CA_CERTS_KEY QLatin1String("CaCertificates")
+
namespace Mirall {
QString MirallConfigFile::_passwd;
@@ -52,13 +42,13 @@ MirallConfigFile::MirallConfigFile( const QString& appendix )
QString MirallConfigFile::configPath() const
{
QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
- if( !dir.endsWith('/') ) dir.append('/');
+ if( !dir.endsWith(QLatin1Char('/')) ) dir.append(QLatin1Char('/'));
return dir;
}
QString MirallConfigFile::excludeFile() const
{
- const QString exclFile("exclude.lst");
+ const QString exclFile(QLatin1String("exclude.lst"));
QString dir = configPath();
dir += exclFile;
@@ -66,37 +56,25 @@ QString MirallConfigFile::excludeFile() const
if( fi.isReadable() ) {
return dir;
}
+
// Check alternative places...
#ifdef Q_OS_WIN32
- /* For win32, try to copy the conf file from the directory from where the app was started. */
- TCHAR buf[MAX_PATH+1];
- int len = 0;
-
- /* Get the path from where the application was started */
- len = GetModuleFileNameW(NULL, buf, MAX_PATH);
- QString exePath = QString::fromUtf16((ushort*)buf);
- exePath.remove("owncloud.exe");
- fi.setFile(exePath, exclFile );
+ fi.setFile( QApplication::applicationDirPath(), exclFile );
#endif
#ifdef Q_OS_LINUX
fi.setFile( QString("/etc"), exclFile );
#endif
#ifdef Q_OS_MAC
- char buf[1024];
- uint32_t size = sizeof(buf);
- if (_NSGetExecutablePath(buf, &size) == 0) {
- qDebug() << " Executable path: <" << buf;
- QString execFile = QString::fromLocal8Bit(buf);
- QFileInfo fi2(execFile);
- fi.setFile( fi2.canonicalPath(), "../Resources/exclude.lst");
- }
+ // exec path is inside the bundle
+ fi.setFile( QApplication::applicationDirPath(),
+ QLatin1String("../Resources/") + exclFile );
#endif
if( fi.isReadable() ) {
qDebug() << " ==> returning exclude file path: " << fi.absoluteFilePath();
return fi.absoluteFilePath();
}
qDebug() << "EMPTY exclude file path!";
- return QString();
+ return QString::null;
}
QString MirallConfigFile::configFile() const
@@ -111,7 +89,7 @@ QString MirallConfigFile::configFile() const
}
QString dir = configPath() + theme.configFileName();
if( !_customHandle.isEmpty() ) {
- dir.append( QChar('_'));
+ dir.append( QLatin1Char('_'));
dir.append( _customHandle );
qDebug() << " OO Custom config file in use: " << dir;
}
@@ -126,7 +104,7 @@ bool MirallConfigFile::exists()
QString MirallConfigFile::defaultConnection() const
{
- return QString::fromLocal8Bit("ownCloud");
+ return QLatin1String("ownCloud");
}
bool MirallConfigFile::connectionExists( const QString& conn )
@@ -137,7 +115,7 @@ bool MirallConfigFile::connectionExists( const QString& conn )
QSettings settings( configFile(), QSettings::IniFormat);
settings.setIniCodec( "UTF-8" );
- return settings.contains( QString("%1/url").arg( conn ) );
+ return settings.contains( QString::fromLatin1("%1/url").arg( conn ) );
}
@@ -163,15 +141,15 @@ void MirallConfigFile::writeOwncloudConfig( const QString& connection,
}
settings.beginGroup( connection );
- settings.setValue("url", cloudsUrl );
- settings.setValue("user", user );
+ settings.setValue( QLatin1String("url"), cloudsUrl );
+ settings.setValue( QLatin1String("user"), user );
if( skipPwd ) {
pwd.clear();
}
QByteArray pwdba = pwd.toUtf8();
- settings.setValue( "passwd", QVariant(pwdba.toBase64()) );
- settings.setValue( "nostoredpassword", QVariant(skipPwd) );
+ settings.setValue( QLatin1String("passwd"), QVariant(pwdba.toBase64()) );
+ settings.setValue( QLatin1String("nostoredpassword"), QVariant(skipPwd) );
settings.sync();
// check the perms, only read-write for the owner.
@@ -179,6 +157,41 @@ void MirallConfigFile::writeOwncloudConfig( const QString& connection,
}
+// set the url, called from redirect handling.
+void MirallConfigFile::setOwnCloudUrl( const QString& connection, const QString & url )
+{
+ const QString file = configFile();
+
+ QSettings settings( file, QSettings::IniFormat);
+ settings.setIniCodec( "UTF-8" );
+ settings.beginGroup( connection );
+ settings.setValue( QLatin1String("url"), url );
+
+ settings.sync();
+}
+
+QByteArray MirallConfigFile::caCerts( )
+{
+ QSettings settings( configFile(), QSettings::IniFormat );
+ settings.setIniCodec( "UTF-8" );
+
+ QByteArray certs = settings.value( CA_CERTS_KEY ).toByteArray();
+
+ return certs;
+}
+
+void MirallConfigFile::setCaCerts( const QByteArray & certs )
+{
+ const QString file = configFile();
+
+ QSettings settings( file, QSettings::IniFormat);
+ settings.setIniCodec( "UTF-8" );
+ settings.setValue( CA_CERTS_KEY, certs );
+
+ settings.sync();
+}
+
+
void MirallConfigFile::removeConnection( const QString& connection )
{
QString con( connection );
@@ -190,7 +203,7 @@ void MirallConfigFile::removeConnection( const QString& connection )
QSettings settings( configFile(), QSettings::IniFormat);
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- settings.remove(""); // removes all content from the group
+ settings.remove(QString::null); // removes all content from the group
settings.sync();
}
@@ -216,10 +229,10 @@ QString MirallConfigFile::ownCloudUrl( const QString& connection, bool webdav )
qDebug() << "###################### THIS SHOULD NOT HAPPEN! ########################";
}
- QString url = settings.value( "url" ).toString();
+ QString url = settings.value( QLatin1String("url") ).toString();
if( ! url.isEmpty() ) {
- if( ! url.endsWith('/')) url.append('/');
- if( webdav ) url.append( "files/webdav.php/" );
+ if( ! url.endsWith(QLatin1Char('/'))) url.append(QLatin1String("/"));
+ if( webdav ) url.append( QLatin1String("files/webdav.php/") );
}
// qDebug() << "Returning configured owncloud url: " << url;
@@ -236,7 +249,7 @@ QString MirallConfigFile::ownCloudUser( const QString& connection ) const
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- QString user = settings.value( "user" ).toString();
+ QString user = settings.value( QLatin1String("user") ).toString();
// qDebug() << "Returning configured owncloud user: " << user;
return user;
@@ -251,8 +264,8 @@ int MirallConfigFile::remotePollInterval( const QString& connection ) const
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- int remoteInterval = settings.value( "remotePollInterval", DEFAULT_REMOTE_POLL_INTERVAL ).toInt();
- int localInterval = settings.value("localPollInterval", DEFAULT_LOCAL_POLL_INTERVAL ).toInt();
+ int remoteInterval = settings.value( QLatin1String("remotePollInterval"), DEFAULT_REMOTE_POLL_INTERVAL ).toInt();
+ int localInterval = settings.value(QLatin1String("localPollInterval"), DEFAULT_LOCAL_POLL_INTERVAL ).toInt();
if( remoteInterval < 2*localInterval ) {
qDebug() << "WARN: remote poll Interval should at least be twice as local poll interval!";
}
@@ -272,8 +285,8 @@ int MirallConfigFile::localPollInterval( const QString& connection ) const
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- int remoteInterval = settings.value( "remotePollInterval", DEFAULT_REMOTE_POLL_INTERVAL ).toInt();
- int localInterval = settings.value("localPollInterval", DEFAULT_LOCAL_POLL_INTERVAL ).toInt();
+ int remoteInterval = settings.value( QLatin1String("remotePollInterval"), DEFAULT_REMOTE_POLL_INTERVAL ).toInt();
+ int localInterval = settings.value(QLatin1String("localPollInterval"), DEFAULT_LOCAL_POLL_INTERVAL ).toInt();
if( remoteInterval < 2*localInterval ) {
qDebug() << "WARN: remote poll Interval should at least be twice as local poll interval!";
}
@@ -293,7 +306,7 @@ int MirallConfigFile::pollTimerExceedFactor( const QString& connection ) const
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- int pte = settings.value( "pollTimerExeedFactor", DEFAULT_POLL_TIMER_EXEED).toInt();
+ int pte = settings.value( QLatin1String("pollTimerExeedFactor"), DEFAULT_POLL_TIMER_EXEED).toInt();
if( pte < 1 ) pte = DEFAULT_POLL_TIMER_EXEED;
@@ -311,14 +324,14 @@ QString MirallConfigFile::ownCloudPasswd( const QString& connection ) const
QString pwd;
- bool boolfalse( false );
- bool skipPwd = settings.value( "nostoredpassword", QVariant(boolfalse) ).toBool();
+ bool skipPwd = settings.value( QLatin1String("nostoredpassword"), false ).toBool();
if( skipPwd ) {
if( ! _askedUser ) {
bool ok;
- QString text = QInputDialog::getText(0, QObject::tr("ownCloud Password Required"),
- QObject::tr("Please enter your ownCloud password:"), QLineEdit::Password,
- QString(), &ok);
+ QString text = QInputDialog::getText(0, QApplication::translate("MirallConfigFile","ownCloud Password Required"),
+ QApplication::translate("MirallConfigFile","Please enter your ownCloud password:"),
+ QLineEdit::Password,
+ QString::null, &ok);
if( ok && !text.isEmpty() ) { // empty password is not allowed on ownCloud
_passwd = text;
_askedUser = true;
@@ -326,18 +339,18 @@ QString MirallConfigFile::ownCloudPasswd( const QString& connection ) const
}
pwd = _passwd;
} else {
- QByteArray pwdba = settings.value("passwd").toByteArray();
+ QByteArray pwdba = settings.value(QLatin1String("passwd")).toByteArray();
if( pwdba.isEmpty() ) {
// check the password entry, cleartext from before
// read it and convert to base64, delete the cleartext entry.
- QString p = settings.value("password").toString();
+ QString p = settings.value(QLatin1String("password")).toString();
if( ! p.isEmpty() ) {
// its there, save base64-encoded and delete.
pwdba = p.toUtf8();
- settings.setValue( "passwd", QVariant(pwdba.toBase64()) );
- settings.remove( "password" );
+ settings.setValue( QLatin1String("passwd"), QVariant(pwdba.toBase64()) );
+ settings.remove( QLatin1String("password") );
settings.sync();
}
}
@@ -368,7 +381,7 @@ bool MirallConfigFile::ownCloudSkipUpdateCheck( const QString& connection ) cons
settings.setIniCodec( "UTF-8" );
settings.beginGroup( con );
- bool skipIt = settings.value( "skipUpdateCheck", false ).toBool();
+ bool skipIt = settings.value( QLatin1String("skipUpdateCheck"), false ).toBool();
return skipIt;
}
@@ -377,15 +390,15 @@ int MirallConfigFile::maxLogLines() const
{
QSettings settings( configFile(), QSettings::IniFormat );
settings.setIniCodec( "UTF-8" );
- settings.beginGroup("Logging");
- int logLines = settings.value( "maxLogLines", 20000 ).toInt();
+ settings.beginGroup(QLatin1String("Logging"));
+ int logLines = settings.value( QLatin1String("maxLogLines"), 20000 ).toInt();
return logLines;
}
QByteArray MirallConfigFile::basicAuthHeader() const
{
- QString concatenated = ownCloudUser() + QChar(':') + ownCloudPasswd();
- const QString b("Basic ");
+ QString concatenated = ownCloudUser() + QLatin1Char(':') + ownCloudPasswd();
+ const QString b(QLatin1String("Basic "));
QByteArray data = b.toLocal8Bit() + concatenated.toLocal8Bit().toBase64();
return data;
@@ -461,7 +474,7 @@ QVariant MirallConfigFile::customMedia( customMediaType type )
settings.setIniCodec( "UTF-8" );
settings.beginGroup(QLatin1String("GUICustomize"));
- QString val = settings.value( key, QString() ).toString();
+ QString val = settings.value( key ).toString();
if( !val.isEmpty() ) {
QPixmap pix( val );
@@ -484,13 +497,13 @@ void MirallConfigFile::setProxyType(int proxyType,
{
QSettings settings( configFile(), QSettings::IniFormat );
settings.setIniCodec( "UTF-8" );
- settings.beginGroup("proxy");
+ settings.beginGroup(QLatin1String("proxy"));
- settings.setValue("type", proxyType);
- settings.setValue("host", host);
- settings.setValue("port", port);
- settings.setValue("user", user);
- settings.setValue("pass", pass);
+ 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);
settings.sync();
}
@@ -506,27 +519,27 @@ QVariant MirallConfigFile::getValue(const QString& param, const QString& group)
int MirallConfigFile::proxyType() const
{
- return getValue("type", "proxy").toInt();
+ return getValue(QLatin1String("type"), QLatin1String("proxy")).toInt();
}
QString MirallConfigFile::proxyHostName() const
{
- return getValue("host", "proxy").toString();
+ return getValue(QLatin1String("host"), QLatin1String("proxy")).toString();
}
int MirallConfigFile::proxyPort() const
{
- return getValue("port", "proxy").toInt();
+ return getValue(QLatin1String("port"), QLatin1String("proxy")).toInt();
}
QString MirallConfigFile::proxyUser() const
{
- return getValue("user", "proxy").toString();
+ return getValue(QLatin1String("user"), QLatin1String("proxy")).toString();
}
QString MirallConfigFile::proxyPassword() const
{
- QByteArray pass = getValue("pass", "proxy").toByteArray();
+ QByteArray pass = getValue(QLatin1String("pass"), QLatin1String("proxy")).toByteArray();
return QString::fromUtf8(QByteArray::fromBase64(pass));
}
diff --git a/src/mirall/mirallconfigfile.h b/src/mirall/mirallconfigfile.h
index 3c48c5ff7..c583170cb 100644
--- a/src/mirall/mirallconfigfile.h
+++ b/src/mirall/mirallconfigfile.h
@@ -54,6 +54,12 @@ public:
QString ownCloudUrl( const QString& connection = QString(), bool webdav = false ) const;
+ void setOwnCloudUrl(const QString &connection, const QString& );
+
+ // the certs do not depend on a connection.
+ QByteArray caCerts();
+ void setCaCerts( const QByteArray& );
+
QString ownCloudUser( const QString& connection = QString() ) const;
QString ownCloudPasswd( const QString& connection = QString() ) const;
diff --git a/src/mirall/miralltheme.cpp b/src/mirall/miralltheme.cpp
index a8f03e391..6c89ea234 100644
--- a/src/mirall/miralltheme.cpp
+++ b/src/mirall/miralltheme.cpp
@@ -28,17 +28,17 @@ mirallTheme::mirallTheme()
QString mirallTheme::appName() const
{
- return QString::fromLocal8Bit("Mirall");
+ return QLatin1String("Mirall");
}
QString mirallTheme::configFileName() const
{
- return QString::fromLocal8Bit("mirall.cfg");
+ return QLatin1String("mirall.cfg");
}
QPixmap mirallTheme::splashScreen() const
{
- return QPixmap(":/mirall/resources/owncloud_splash.png"); // FIXME: mirall splash!
+ return QPixmap(QLatin1String(":/mirall/resources/owncloud_splash.png")); // FIXME: mirall splash!
}
QIcon mirallTheme::folderIcon( const QString& backend ) const
@@ -46,16 +46,16 @@ QIcon mirallTheme::folderIcon( const QString& backend ) const
QString name;
if( backend == QString::fromLatin1("owncloud")) {
- name = QString( "mirall" );
+ name = QLatin1String( "mirall" );
}
if( backend == QString::fromLatin1("unison" )) {
- name = QString( "folder-sync" );
+ name = QLatin1String( "folder-sync" );
}
if( backend == QString::fromLatin1("csync" )) {
- name = QString( "folder-remote" );
+ name = QLatin1String( "folder-remote" );
}
if( backend.isEmpty() || backend == QString::fromLatin1("none") ) {
- name = QString("folder-grey.png");
+ name = QLatin1String("folder-grey.png");
}
qDebug() << "==> load folder icon " << name;
@@ -68,25 +68,25 @@ QIcon mirallTheme::syncStateIcon( SyncResult::Status status ) const
switch( status ) {
case SyncResult::Undefined:
- statusIcon = "dialog-close";
+ statusIcon = QLatin1String("dialog-close");
break;
case SyncResult::NotYetStarted:
- statusIcon = "task-ongoing";
+ statusIcon = QLatin1String("task-ongoing");
break;
case SyncResult::SyncRunning:
- statusIcon = "view-refresh";
+ statusIcon = QLatin1String("view-refresh");
break;
case SyncResult::Success:
- statusIcon = "dialog-ok";
+ statusIcon = QLatin1String("dialog-ok");
break;
case SyncResult::Error:
- statusIcon = "dialog-close";
+ statusIcon = QLatin1String("dialog-close");
break;
case SyncResult::SetupError:
- statusIcon = "dialog-cancel";
+ statusIcon = QLatin1String("dialog-cancel");
break;
default:
- statusIcon = "dialog-close";
+ statusIcon = QLatin1String("dialog-close");
}
return themeIcon( statusIcon );
}
@@ -95,12 +95,12 @@ QIcon mirallTheme::syncStateIcon( SyncResult::Status status ) const
QIcon mirallTheme::folderDisabledIcon() const
{
// Fixme: Do we really want the dialog-canel from theme here?
- return themeIcon( "dialog-cancel" );
+ return themeIcon( QLatin1String("dialog-cancel") );
}
QIcon mirallTheme::applicationIcon( ) const
{
- return themeIcon( "mirall");
+ return themeIcon( QLatin1String("mirall"));
}
}
diff --git a/src/mirall/networklocation.cpp b/src/mirall/networklocation.cpp
index b98565bd0..75683db11 100644
--- a/src/mirall/networklocation.cpp
+++ b/src/mirall/networklocation.cpp
@@ -38,7 +38,7 @@ NetworkLocation::~NetworkLocation()
NetworkLocation NetworkLocation::currentLocation()
{
QProcess ip;
- ip.start("/sbin/ip", QStringList() << "route");
+ ip.start(QLatin1String("/sbin/ip"), QStringList() << QLatin1String("route"));
if (!ip.waitForStarted())
return NetworkLocation();
@@ -59,7 +59,7 @@ NetworkLocation NetworkLocation::currentLocation()
return NetworkLocation();
QProcess arp;
- arp.start("/sbin/arp", QStringList() << "-a");
+ arp.start(QLatin1String("/sbin/arp"), QStringList() << QLatin1String("-a"));
if (!arp.waitForStarted())
return NetworkLocation();
@@ -79,7 +79,7 @@ NetworkLocation NetworkLocation::currentLocation()
if (gwMAC.isEmpty())
return NetworkLocation();
- return NetworkLocation(gwMAC);
+ return NetworkLocation(QString::fromLatin1(gwMAC));
}
diff --git a/src/mirall/occinfo.cpp b/src/mirall/occinfo.cpp
index 183abc89e..9c61d7a3a 100644
--- a/src/mirall/occinfo.cpp
+++ b/src/mirall/occinfo.cpp
@@ -41,7 +41,7 @@ QString Owncloudclient::web() const
Owncloudclient Owncloudclient::parseElement( const QDomElement &element, bool *ok )
{
- if ( element.tagName() != "owncloudclient" ) {
+ if ( element.tagName() != QLatin1String("owncloudclient") ) {
qCritical() << "Expected 'owncloudclient', got '" << element.tagName() << "'.";
if ( ok ) *ok = false;
return Owncloudclient();
@@ -52,13 +52,13 @@ Owncloudclient Owncloudclient::parseElement( const QDomElement &element, bool *o
QDomNode n;
for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
QDomElement e = n.toElement();
- if ( e.tagName() == "version" ) {
+ if ( e.tagName() == QLatin1String("version") ) {
result.setVersion( e.text() );
}
- else if ( e.tagName() == "versionstring" ) {
+ else if ( e.tagName() == QLatin1String("versionstring") ) {
result.setVersionstring( e.text() );
}
- else if ( e.tagName() == "web" ) {
+ else if ( e.tagName() == QLatin1String("web") ) {
result.setWeb( e.text() );
}
}
@@ -70,15 +70,15 @@ Owncloudclient Owncloudclient::parseElement( const QDomElement &element, bool *o
void Owncloudclient::writeElement( QXmlStreamWriter &xml )
{
- xml.writeStartElement( "owncloudclient" );
+ xml.writeStartElement( QLatin1String("owncloudclient") );
if ( !version().isEmpty() ) {
- xml.writeTextElement( "version", version() );
+ xml.writeTextElement( QLatin1String("version"), version() );
}
if ( !versionstring().isEmpty() ) {
- xml.writeTextElement( "versionstring", versionstring() );
+ xml.writeTextElement( QLatin1String("versionstring"), versionstring() );
}
if ( !web().isEmpty() ) {
- xml.writeTextElement( "web", web() );
+ xml.writeTextElement( QLatin1String("web"), web() );
}
xml.writeEndElement();
}
@@ -139,7 +139,7 @@ bool Owncloudclient::writeFile( const QString &filename )
QXmlStreamWriter xml( &file );
xml.setAutoFormatting( true );
xml.setAutoFormattingIndent( 2 );
- xml.writeStartDocument( "1.0" );
+ xml.writeStartDocument( QLatin1String("1.0") );
writeElement( xml );
xml.writeEndDocument();
file.close();
diff --git a/src/mirall/owncloudfolder.cpp b/src/mirall/owncloudfolder.cpp
index 284622819..511997ed2 100644
--- a/src/mirall/owncloudfolder.cpp
+++ b/src/mirall/owncloudfolder.cpp
@@ -26,6 +26,7 @@
#include <QStringList>
#include <QTextStream>
#include <QTimer>
+#include <QNetworkProxy>
namespace Mirall {
@@ -88,7 +89,7 @@ QString ownCloudFolder::secondPath() const
{
QString re(_secondPath);
MirallConfigFile cfg;
- const QString ocUrl = cfg.ownCloudUrl(QString(), true);
+ const QString ocUrl = cfg.ownCloudUrl(QString::null, true);
// qDebug() << "**** " << ocUrl << " <-> " << re;
if( re.startsWith( ocUrl ) ) {
re.remove( ocUrl );
@@ -117,10 +118,10 @@ void ownCloudFolder::startSync(const QStringList &pathList)
QUrl url( _secondPath );
if( url.scheme() == QLatin1String("http") ) {
- url.setScheme( "owncloud" );
+ url.setScheme( QLatin1String("owncloud") );
} else {
// connect SSL!
- url.setScheme( "ownclouds" );
+ url.setScheme( QLatin1String("ownclouds") );
}
#ifdef USE_INOTIFY
@@ -141,8 +142,31 @@ void ownCloudFolder::startSync(const QStringList &pathList)
qDebug() << "*** Start syncing url to ownCloud: " << url.toString() << ", with localOnly: " << _localCheckOnly;
+
_csync = new CSyncThread( path(), url.toString(), _localCheckOnly );
- _csync->setUserPwd( cfgFile.ownCloudUser(), cfgFile.ownCloudPasswd() );
+
+ // Proxy settings. Proceed them as strings to csync thread.
+ int intProxy = cfgFile.proxyType();
+ QString proxyType;
+
+ if( intProxy == QNetworkProxy::NoProxy )
+ proxyType = QLatin1String("NoProxy");
+ else if( intProxy == QNetworkProxy::DefaultProxy )
+ proxyType = QLatin1String("DefaultProxy");
+ else if( intProxy == QNetworkProxy::Socks5Proxy )
+ proxyType = QLatin1String("Socks5Proxy");
+ else if( intProxy == QNetworkProxy::HttpProxy )
+ proxyType = QLatin1String("HttpProxy");
+ else if( intProxy == QNetworkProxy::HttpCachingProxy )
+ proxyType = QLatin1String("HttpCachingProxy");
+ else if( intProxy == QNetworkProxy::FtpCachingProxy )
+ proxyType = QLatin1String("FtpCachingProxy");
+ else proxyType = QLatin1String("NoProxy");
+
+ _csync->setConnectionDetails( cfgFile.ownCloudUser(), cfgFile.ownCloudPasswd(), proxyType,
+ cfgFile.proxyHostName(), cfgFile.proxyPort(), cfgFile.proxyUser(),
+ cfgFile.proxyPassword() );
+
QObject::connect(_csync, SIGNAL(started()), SLOT(slotCSyncStarted()));
QObject::connect(_csync, SIGNAL(finished()), SLOT(slotCSyncFinished()));
QObject::connect(_csync, SIGNAL(terminated()), SLOT(slotCSyncTerminated()));
@@ -227,7 +251,6 @@ void ownCloudFolder::slotCSyncFinished()
qDebug() << "-> CSync Finished slot with error " << _csyncError;
if (_csyncError) {
-
_syncResult.setStatus(SyncResult::Error);
qDebug() << " ** error Strings: " << _errors;
@@ -312,7 +335,7 @@ void ownCloudFolder::wipe()
qDebug() << "WRN: statedb is empty, can not remove.";
}
// Check if the tmp database file also exists
- QString ctmpName = _csyncStateDbFile + ".ctmp";
+ QString ctmpName = _csyncStateDbFile + QLatin1String(".ctmp");
QFile ctmpFile( ctmpName );
if( ctmpFile.exists() ) {
ctmpFile.remove();
diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp
index 7fe34a996..e97a9017b 100644
--- a/src/mirall/owncloudinfo.cpp
+++ b/src/mirall/owncloudinfo.cpp
@@ -55,17 +55,22 @@ ownCloudInfo::ownCloudInfo( const QString& connectionName, QObject *parent ) :
else
_connection = connectionName;
- _manager = new QNetworkAccessManager;
+ _manager = new QNetworkAccessManager( this );
+
+ MirallConfigFile cfg( _configHandle );
+ QSettings settings( cfg.configFile(), QSettings::IniFormat);
+ QByteArray certs = settings.value(QLatin1String("CaCertificates")).toByteArray();
+ QSslSocket::addDefaultCaCertificates(QSslCertificate::fromData(certs));
+
connect( _manager, SIGNAL( sslErrors(QNetworkReply*, QList<QSslError>)),
- SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)) );
+ this, SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)) );
connect( _manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
- SLOT(slotAuthentication(QNetworkReply*,QAuthenticator*)));
+ this, SLOT(slotAuthentication(QNetworkReply*,QAuthenticator*)));
}
ownCloudInfo::~ownCloudInfo()
{
- delete _manager;
delete _sslErrorDialog;
}
@@ -84,7 +89,7 @@ bool ownCloudInfo::isConfigured()
void ownCloudInfo::checkInstallation()
{
- getRequest( "status.php", false );
+ getRequest( QLatin1String("status.php"), false );
}
void ownCloudInfo::getWebDAVPath( const QString& path )
@@ -186,7 +191,7 @@ void ownCloudInfo::mkdirRequest( const QString& dir )
MirallConfigFile cfgFile( _configHandle );
QNetworkRequest req;
req.setUrl( QUrl( cfgFile.ownCloudUrl( _connection, true ) + dir ) );
- QNetworkReply *reply = davRequest("MKCOL", req, 0);
+ QNetworkReply *reply = davRequest(QLatin1String("MKCOL"), req, 0);
// remember the confighandle used for this request
if( ! _configHandle.isEmpty() )
@@ -254,14 +259,15 @@ void ownCloudInfo::slotSSLFailed( QNetworkReply *reply, QList<QSslError> errors
qDebug() << "SSL-Warnings happened for url " << reply->url().toString();
QString configHandle;
- if( !configHandle.isEmpty() ) {
- qDebug() << "Custom config handle: " << configHandle;
- }
+
// an empty config handle is ok for the default config.
if( _configHandleMap.contains(reply) ) {
configHandle = _configHandleMap[reply];
qDebug() << "SSL: Have a custom config handle: " << configHandle;
}
+ if( !configHandle.isEmpty() ) {
+ qDebug() << "Custom config handle: " << configHandle;
+ }
if( _certsUntrusted ) {
// User decided once to untrust. Honor this decision.
@@ -270,7 +276,7 @@ void ownCloudInfo::slotSSLFailed( QNetworkReply *reply, QList<QSslError> errors
}
if( _sslErrorDialog == 0 ) {
- _sslErrorDialog = new SslErrorDialog();
+ _sslErrorDialog = new SslErrorDialog;
}
// make the ssl dialog aware of the custom config. It loads known certs.
@@ -294,6 +300,21 @@ void ownCloudInfo::slotSSLFailed( QNetworkReply *reply, QList<QSslError> errors
}
}
+
+QUrl ownCloudInfo::redirectUrl(const QUrl& possibleRedirectUrl,
+ const QUrl& oldRedirectUrl) const {
+ QUrl redirectUrl;
+ /*
+ * Check if the URL is empty and
+ * that we aren't being fooled into a infinite redirect loop.
+ */
+ if(!possibleRedirectUrl.isEmpty() &&
+ possibleRedirectUrl != oldRedirectUrl) {
+ redirectUrl = possibleRedirectUrl;
+ }
+ return redirectUrl;
+}
+
//
// There have been problems with the finish-signal coming from the networkmanager.
// To avoid that, the reply-signals were connected and the data is taken from the
@@ -308,7 +329,46 @@ void ownCloudInfo::slotReplyFinished()
return;
}
- const QString version( reply->readAll() );
+ // Detect redirect url
+ QVariant possibleRedirUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ /* We'll deduct if the redirection is valid in the redirectUrl function */
+ _urlRedirectedTo = redirectUrl( possibleRedirUrl.toUrl(),
+ _urlRedirectedTo );
+
+ if(!_urlRedirectedTo.isEmpty()) {
+ QString configHandle;
+
+ qDebug() << "Redirected to " << possibleRedirUrl;
+
+ // We'll do another request to the redirection url.
+ // an empty config handle is ok for the default config.
+ if( _configHandleMap.contains(reply) ) {
+ configHandle = _configHandleMap[reply];
+ qDebug() << "Redirect: Have a custom config handle: " << configHandle;
+ }
+
+ QString path = _directories[reply];
+ qDebug() << "This path was redirected: " << path;
+
+ MirallConfigFile cfgFile( configHandle );
+ QString newUrl = _urlRedirectedTo.toString();
+ if( newUrl.endsWith( path )) {
+ // cut off the trailing path
+ newUrl.chop( path.length() );
+ cfgFile.setOwnCloudUrl( _connection, newUrl );
+
+ qDebug() << "Update the config file url to " << newUrl;
+ getRequest( path, false ); // FIXME: Redirect for webdav!
+ reply->deleteLater();
+ return;
+ } else {
+ qDebug() << "WRN: Path is not part of the redirect URL. NO redirect.";
+ }
+ }
+ _urlRedirectedTo.clear();
+
+ // TODO: check if this is always the correct encoding
+ const QString version = QString::fromUtf8( reply->readAll() );
const QString url = reply->url().toString();
QString plainUrl(url);
plainUrl.remove( QLatin1String("/status.php"));
@@ -327,21 +387,23 @@ void ownCloudInfo::slotReplyFinished()
return;
}
qDebug() << "status.php returns: " << info << " " << reply->error() << " Reply: " << reply;
- if( info.contains("installed") && info.contains("version") && info.contains("versionstring") ) {
+ if( info.contains(QLatin1String("installed"))
+ && info.contains(QLatin1String("version"))
+ && info.contains(QLatin1String("versionstring")) ) {
info.remove(0,1); // remove first char which is a "{"
info.remove(-1,1); // remove the last char which is a "}"
- QStringList li = info.split( QChar(',') );
+ QStringList li = info.split( QLatin1Char(',') );
QString versionStr;
QString version;
QString edition;
foreach ( const QString& infoString, li ) {
- QStringList touple = infoString.split( QChar(':'));
+ QStringList touple = infoString.split( QLatin1Char(':'));
QString key = touple[0];
- key.remove(QChar('"'));
+ key.remove(QLatin1Char('"'));
QString val = touple[1];
- val.remove(QChar('"'));
+ val.remove(QLatin1Char('"'));
if( key == QLatin1String("versionstring") ) {
// get the versionstring out.
@@ -359,11 +421,12 @@ void ownCloudInfo::slotReplyFinished()
emit ownCloudInfoFound( plainUrl, versionStr, version, edition );
} else {
qDebug() << "No proper answer on " << url;
+
emit noOwncloudFound( reply );
}
} else {
// it was a general GET request.
- QString dir("unknown");
+ QString dir(QLatin1String("unknown"));
if( _directories.contains(reply) ) {
dir = _directories[reply];
_directories.remove(reply);
@@ -392,15 +455,16 @@ void ownCloudInfo::setupHeaders( QNetworkRequest & req, quint64 size )
{
MirallConfigFile cfgFile(_configHandle );
- QUrl url( cfgFile.ownCloudUrl( QString(), false ) );
+ QUrl url( cfgFile.ownCloudUrl( QString::null, false ) );
qDebug() << "Setting up host header: " << url.host();
req.setRawHeader( QByteArray("Host"), url.host().toUtf8() );
- req.setRawHeader( QByteArray("User-Agent"), QString("mirall-%1").arg(MIRALL_STRINGIFY(MIRALL_VERSION)).toAscii());
+ req.setRawHeader( QByteArray("User-Agent"), QString::fromLatin1("mirall-%1")
+ .arg(QLatin1String(MIRALL_STRINGIFY(MIRALL_VERSION))).toAscii());
req.setRawHeader( QByteArray("Authorization"), cfgFile.basicAuthHeader() );
if (size) {
- req.setHeader( QNetworkRequest::ContentLengthHeader, QVariant(size));
- req.setHeader( QNetworkRequest::ContentTypeHeader, QVariant("text/xml; charset=utf-8"));
+ req.setHeader( QNetworkRequest::ContentLengthHeader, size);
+ req.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml; charset=utf-8"));
}
}
diff --git a/src/mirall/owncloudinfo.h b/src/mirall/owncloudinfo.h
index 17ac67146..583d1185a 100644
--- a/src/mirall/owncloudinfo.h
+++ b/src/mirall/owncloudinfo.h
@@ -97,6 +97,9 @@ protected slots:
private:
explicit ownCloudInfo( const QString& = QString(), QObject *parent = 0);
+
+ QUrl redirectUrl(const QUrl&, const QUrl& ) const;
+
~ownCloudInfo();
void setupHeaders(QNetworkRequest &req, quint64 size );
@@ -110,6 +113,7 @@ private:
QNetworkAccessManager *_manager;
QString _connection;
QString _configHandle;
+ QUrl _urlRedirectedTo;
QHash<QNetworkReply*, QString> _directories;
QHash<QNetworkReply*, QString> _configHandleMap;
SslErrorDialog *_sslErrorDialog;
diff --git a/src/mirall/owncloudsetupwizard.cpp b/src/mirall/owncloudsetupwizard.cpp
index 550d321c0..19e382f8e 100644
--- a/src/mirall/owncloudsetupwizard.cpp
+++ b/src/mirall/owncloudsetupwizard.cpp
@@ -67,12 +67,8 @@ OwncloudSetupWizard::OwncloudSetupWizard( FolderMan *folderMan, Theme *theme, QO
// in case of cancel, terminate the owncloud-admin script.
connect( _ocWizard, SIGNAL(rejected()), _process, SLOT(terminate()));
- _ocWizard->setWindowTitle( tr("%1 Connection Wizard").arg( theme ? theme->appName() : "Mirall" ) );
+ _ocWizard->setWindowTitle( tr("%1 Connection Wizard").arg( theme ? theme->appName() : QLatin1String("Mirall") ) );
- // create the ocInfo object
- connect(ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
- connect(ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),SLOT(slotNoOwnCloudFound(QNetworkReply*)));
- connect(ownCloudInfo::instance(),SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
}
OwncloudSetupWizard::~OwncloudSetupWizard()
@@ -112,7 +108,15 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
// clear the custom config handle
_configHandle.clear();
- ownCloudInfo::instance()->setCustomConfigHandle( QString() );
+ ownCloudInfo::instance()->setCustomConfigHandle( QString::null );
+
+ // disconnect the ocInfo object
+ disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
+ this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
+ disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
+ this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
+ disconnect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
+ this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
// notify others.
emit ownCloudWizardDone( result );
@@ -121,7 +125,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
void OwncloudSetupWizard::slotConnectToOCUrl( const QString& url )
{
qDebug() << "Connect to url: " << url;
- _ocWizard->setField("OCUrl", url );
+ _ocWizard->setField(QLatin1String("OCUrl"), url );
_ocWizard->appendToResultWidget(tr("Trying to connect to ownCloud at %1...").arg(url ));
testOwnCloudConnect();
}
@@ -130,16 +134,16 @@ void OwncloudSetupWizard::testOwnCloudConnect()
{
// write a temporary config.
QDateTime now = QDateTime::currentDateTime();
- _configHandle = now.toString("MMddyyhhmmss");
+ _configHandle = now.toString(QLatin1String("MMddyyhhmmss"));
MirallConfigFile cfgFile( _configHandle );
- cfgFile.writeOwncloudConfig( QString::fromLocal8Bit("ownCloud"),
- _ocWizard->field("OCUrl").toString(),
- _ocWizard->field("OCUser").toString(),
- _ocWizard->field("OCPasswd").toString(),
- _ocWizard->field("cbSecureConnect").toBool(),
- _ocWizard->field("PwdNoLocalStore").toBool() );
+ cfgFile.writeOwncloudConfig( QLatin1String("ownCloud"),
+ _ocWizard->field(QLatin1String("OCUrl")).toString(),
+ _ocWizard->field(QLatin1String("OCUser")).toString(),
+ _ocWizard->field(QLatin1String("OCPasswd")).toString(),
+ _ocWizard->field(QLatin1String("secureConnect")).toBool(),
+ _ocWizard->field(QLatin1String("PwdNoLocalStore")).toBool() );
// now start ownCloudInfo to check the connection.
ownCloudInfo::instance()->setCustomConfigHandle( _configHandle );
@@ -195,20 +199,20 @@ void OwncloudSetupWizard::slotCreateOCLocalhost()
QStringList args;
- args << "install";
- args << "--server-type" << "local";
- args << "--root_helper" << "kdesu -c";
+ args << QLatin1String("install");
+ args << QLatin1String("--server-type") << QLatin1String("local");
+ args << QLatin1String("--root_helper") << QLatin1String("kdesu -c");
- const QString adminUser = _ocWizard->field("OCUser").toString();
- const QString adminPwd = _ocWizard->field("OCPasswd").toString();
+ const QString adminUser = _ocWizard->field(QLatin1String("OCUser")).toString();
+ const QString adminPwd = _ocWizard->field(QLatin1String("OCPasswd")).toString();
- args << "--admin-user" << adminUser;
- args << "--admin-password" << adminPwd;
+ args << QLatin1String("--admin-user") << adminUser;
+ args << QLatin1String("--admin-password") << adminPwd;
runOwncloudAdmin( args );
// define
- _ocWizard->setField( "OCUrl", QString( "http://localhost/owncloud/") );
+ _ocWizard->setField( QLatin1String("OCUrl"), QLatin1String( "http://localhost/owncloud/") );
}
void OwncloudSetupWizard::slotInstallOCServer()
@@ -218,32 +222,33 @@ void OwncloudSetupWizard::slotInstallOCServer()
return;
}
- const QString server = _ocWizard->field("ftpUrl").toString();
- const QString user = _ocWizard->field("ftpUser").toString();
- const QString passwd = _ocWizard->field("ftpPasswd").toString();
- const QString adminUser = _ocWizard->field("OCUser").toString();
- const QString adminPwd = _ocWizard->field("OCPasswd").toString();
+ const QString server = _ocWizard->field(QLatin1String("ftpUrl")).toString();
+ const QString user = _ocWizard->field(QLatin1String("ftpUser")).toString();
+ const QString passwd = _ocWizard->field(QLatin1String("ftpPasswd")).toString();
+ const QString adminUser = _ocWizard->field(QLatin1String("OCUser")).toString();
+ const QString adminPwd = _ocWizard->field(QLatin1String("OCPasswd")).toString();
qDebug() << "Install OC on " << server << " as user " << user;
QStringList args;
- args << "install";
- args << "--server-type" << "ftp";
- args << "--server" << server;
- args << "--ftp-user" << user;
+ args << QLatin1String("install");
+ args << QLatin1String("--server-type") << QLatin1String("ftp");
+ args << QLatin1String("--server") << server;
+ args << QLatin1String("--ftp-user") << user;
if( ! passwd.isEmpty() ) {
- args << "--ftp-password" << passwd;
+ args << QLatin1String("--ftp-password") << passwd;
}
- args << "--admin-user" << adminUser;
- args << "--admin-password" << adminPwd;
+ args << QLatin1String("--admin-user") << adminUser;
+ args << QLatin1String("--admin-password") << adminPwd;
runOwncloudAdmin( args );
- _ocWizard->setField( "OCUrl", QString( "%1/owncloud/").arg(_ocWizard->field("myOCDomain").toString() ));
+ _ocWizard->setField( QLatin1String("OCUrl"), QString::fromLatin1( "%1/owncloud/")
+ .arg(_ocWizard->field(QLatin1String("myOCDomain")).toString() ));
}
void OwncloudSetupWizard::runOwncloudAdmin( const QStringList& args )
{
- const QString bin("/usr/bin/owncloud-admin");
+ const QString bin(QLatin1String("/usr/bin/owncloud-admin"));
qDebug() << "starting " << bin << " with args. " << args;
if( _process->state() != QProcess::NotRunning ) {
qDebug() << "Owncloud admin is still running, skip!";
@@ -315,6 +320,11 @@ void OwncloudSetupWizard::slotProcessFinished( int res, QProcess::ExitStatus )
void OwncloudSetupWizard::startWizard()
{
+ // create the ocInfo object
+ connect(ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
+ connect(ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),SLOT(slotNoOwnCloudFound(QNetworkReply*)));
+ connect(ownCloudInfo::instance(),SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
+
MirallConfigFile cfgFile;
QString url = cfgFile.ownCloudUrl();
@@ -343,7 +353,7 @@ bool OwncloudSetupWizard::checkOwncloudAdmin( const QString& bin )
void OwncloudSetupWizard::setupLocalSyncFolder()
{
- _localFolder = QDir::homePath() + QString::fromLocal8Bit("/ownCloud");
+ _localFolder = QDir::homePath() + QLatin1String("/ownCloud");
if( ! _folderMan ) return;
@@ -396,23 +406,28 @@ bool OwncloudSetupWizard::createRemoteFolder( const QString& folder )
void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::NetworkError error )
{
qDebug() << "** webdav mkdir request finished " << error;
+ bool success = true;
if( error == QNetworkReply::NoError ) {
_ocWizard->appendToResultWidget( tr("Remote folder %1 created successfully.").arg(_remoteFolder));
} else if( error == 202 ) {
_ocWizard->appendToResultWidget( tr("The remote folder %1 already exists. Connecting it for syncing.").arg(_remoteFolder));
+ } else if( error > 202 && error < 300 ) {
+ _ocWizard->appendToResultWidget( tr("The folder creation resulted in HTTP error code %d").arg((int)error) );
} else if( error == QNetworkReply::OperationCanceledError ) {
_ocWizard->appendToResultWidget( tr("<p><font color=\"red\">Remote folder creation failed probably because the provided credentials are wrong.</font>"
"<br/>Please go back and check your credentials.</p>"));
_localFolder.clear();
_remoteFolder.clear();
+ success = false;
} else {
_ocWizard->appendToResultWidget( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
_localFolder.clear();
_remoteFolder.clear();
+ success = false;
}
- finalizeSetup( true );
+ finalizeSetup( success );
}
void OwncloudSetupWizard::finalizeSetup( bool success )
diff --git a/src/mirall/owncloudtheme.cpp b/src/mirall/owncloudtheme.cpp
index 864c7e778..1aa4c2fc4 100644
--- a/src/mirall/owncloudtheme.cpp
+++ b/src/mirall/owncloudtheme.cpp
@@ -18,6 +18,7 @@
#include <QDebug>
#include <QPixmap>
#include <QIcon>
+#include <QApplication>
namespace Mirall {
@@ -28,34 +29,38 @@ ownCloudTheme::ownCloudTheme()
QString ownCloudTheme::appName() const
{
- return QString::fromLocal8Bit("ownCloud");
+ /* If this is changed, existing configs are not found any more
+ * because the value is used by QDesktopServices to find the config
+ * file. Be aware.
+ */
+ return QApplication::translate("appname", "ownCloud");
}
QString ownCloudTheme::configFileName() const
{
- return QString::fromLocal8Bit("owncloud.cfg");
+ return QLatin1String("owncloud.cfg");
}
QPixmap ownCloudTheme::splashScreen() const
{
- return QPixmap(":/mirall/resources/owncloud_splash.png");
+ return QPixmap(QLatin1String(":/mirall/resources/owncloud_splash.png"));
}
QIcon ownCloudTheme::folderIcon( const QString& backend ) const
{
QString name;
- if( backend == QString::fromLatin1("owncloud")) {
- name = QString( "owncloud-icon-framed" );
+ if( backend == QLatin1String("owncloud")) {
+ name = QLatin1String( "owncloud-icon-framed" );
}
- if( backend == QString::fromLatin1("unison" )) {
- name = QString( "folder-sync" );
+ if( backend == QLatin1String("unison" )) {
+ name = QLatin1String( "folder-sync" );
}
- if( backend == QString::fromLatin1("csync" )) {
- name = QString( "folder-remote" );
+ if( backend == QLatin1String("csync" )) {
+ name = QLatin1String( "folder-remote" );
}
- if( backend.isEmpty() || backend == QString::fromLatin1("none") ) {
- name = QString("folder-grey.png");
+ if( backend.isEmpty() || backend == QLatin1String("none") ) {
+ name = QLatin1String("folder-grey");
}
qDebug() << "==> load folder icon " << name;
@@ -64,10 +69,9 @@ QIcon ownCloudTheme::folderIcon( const QString& backend ) const
QIcon ownCloudTheme::trayFolderIcon( const QString& ) const
{
- return themeIcon( "owncloud-icon" );
+ return themeIcon( QLatin1String("owncloud-icon") );
}
-
QIcon ownCloudTheme::syncStateIcon( SyncResult::Status status ) const
{
// FIXME: Mind the size!
@@ -75,42 +79,40 @@ QIcon ownCloudTheme::syncStateIcon( SyncResult::Status status ) const
switch( status ) {
case SyncResult::Undefined:
- statusIcon = "owncloud-icon-error";
+ statusIcon = QLatin1String("owncloud-icon-error");
break;
case SyncResult::NotYetStarted:
- statusIcon = "owncloud-icon";
+ statusIcon = QLatin1String("owncloud-icon");
break;
case SyncResult::SyncRunning:
- statusIcon = "owncloud-icon-sync";
+ statusIcon = QLatin1String("owncloud-icon-sync");
break;
case SyncResult::Success:
- statusIcon = "owncloud-icon-sync-ok";
+ statusIcon = QLatin1String("owncloud-icon-sync-ok");
break;
case SyncResult::Error:
- statusIcon = "owncloud-icon-error";
+ statusIcon = QLatin1String("owncloud-icon-error");
break;
case SyncResult::SetupError:
- statusIcon = "owncloud-icon-error";
+ statusIcon = QLatin1String("owncloud-icon-error");
break;
default:
- statusIcon = "owncloud-icon-error";
+ statusIcon = QLatin1String("owncloud-icon-error");
}
return themeIcon( statusIcon );
}
-
QIcon ownCloudTheme::folderDisabledIcon( ) const
{
// Fixme: Do we really want the dialog-canel from theme here?
- return themeIcon( "owncloud-icon-error" );
+ return themeIcon( QLatin1String("owncloud-icon-error") );
}
QIcon ownCloudTheme::applicationIcon( ) const
{
- return themeIcon( "owncloud-icon" );
+ return themeIcon( QLatin1String("owncloud-icon") );
}
-
}
diff --git a/src/mirall/owncloudwizard.cpp b/src/mirall/owncloudwizard.cpp
index eca882845..3a9e18d14 100644
--- a/src/mirall/owncloudwizard.cpp
+++ b/src/mirall/owncloudwizard.cpp
@@ -24,6 +24,7 @@
#include <QWizardPage>
#include <QDir>
#include <QScrollBar>
+#include <QSslSocket>
#include <stdlib.h>
@@ -56,12 +57,12 @@ void setupCustomMedia( QVariant variant, QLabel *label )
OwncloudSetupPage::OwncloudSetupPage()
{
_ui.setupUi(this);
- registerField( "OCUrl", _ui.leUrl );
- registerField( "OCUser", _ui.leUsername );
- registerField( "OCPasswd", _ui.lePassword);
- registerField( "connectMyOC", _ui.cbConnectOC );
- registerField( "cbSecureConnect", _ui.cbSecureConnect );
- registerField( "PwdNoLocalStore", _ui.cbNoPasswordStore );
+ registerField( QLatin1String("OCUrl"), _ui.leUrl );
+ registerField( QLatin1String("OCUser"), _ui.leUsername );
+ registerField( QLatin1String("OCPasswd"), _ui.lePassword);
+ registerField( QLatin1String("connectMyOC"), _ui.cbConnectOC );
+ registerField( QLatin1String("secureConnect"), _ui.cbSecureConnect );
+ registerField( QLatin1String("PwdNoLocalStore"), _ui.cbNoPasswordStore );
_ui.cbSecureConnect->setEnabled(QSslSocket::supportsSsl());
@@ -72,14 +73,15 @@ OwncloudSetupPage::OwncloudSetupPage()
_ui.cbConnectOC->hide();
setupCustomization();
+
+#if QT_VERSION >= 0x040700
+ _ui.leUsername->setPlaceholderText(tr("john"));
+ _ui.lePassword->setPlaceholderText(tr("secret"));
+#endif
}
OwncloudSetupPage::~OwncloudSetupPage()
{
-#if QT_VERSION >= 0x040700
- _ui.leUsername->setPlaceholderText(QApplication::translate("OwncloudSetupPage", "john", 0, QApplication::UnicodeUTF8));
- _ui.lePassword->setPlaceholderText(QApplication::translate("OwncloudSetupPage", "secret", 0, QApplication::UnicodeUTF8));
-#endif
}
void OwncloudSetupPage::setOCUrl( const QString& newUrl )
@@ -104,7 +106,7 @@ void OwncloudSetupPage::setOCUrl( const QString& newUrl )
void OwncloudSetupPage::setupCustomization()
{
// set defaults for the customize labels.
- _ui.sideLabel->setText( QString() );
+ _ui.sideLabel->setText( QString::null );
_ui.sideLabel->setFixedWidth(160);
_ui.topLabel->hide();
@@ -157,7 +159,7 @@ bool OwncloudSetupPage::isComplete() const
void OwncloudSetupPage::initializePage()
{
- QString user = qgetenv( "USER" );
+ QString user = QString::fromLocal8Bit(qgetenv( "USER" ));
_ui.leUsername->setText( user );
}
@@ -171,9 +173,9 @@ int OwncloudSetupPage::nextId() const
OwncloudWizardSelectTypePage::OwncloudWizardSelectTypePage()
{
_ui.setupUi(this);
- registerField( "connectMyOC", _ui.connectMyOCRadioBtn );
- registerField( "createNewOC", _ui.createNewOCRadioBtn );
- registerField( "OCUrl", _ui.OCUrlLineEdit );
+ registerField( QLatin1String("connectMyOC"), _ui.connectMyOCRadioBtn );
+ registerField( QLatin1String("createNewOC"), _ui.createNewOCRadioBtn );
+ registerField( QLatin1String("OCUrl"), _ui.OCUrlLineEdit );
connect( _ui.connectMyOCRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
connect( _ui.createNewOCRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
@@ -183,13 +185,14 @@ OwncloudWizardSelectTypePage::OwncloudWizardSelectTypePage()
_ui.createNewOCRadioBtn->setVisible( false );
_ui.createNewOwncloudLabel->setVisible( false );
#endif
+
+#if QT_VERSION >= 0x040700
+ _ui.OCUrlLineEdit->setPlaceholderText(tr("http://owncloud.mydomain.org"));
+#endif
}
OwncloudWizardSelectTypePage::~OwncloudWizardSelectTypePage()
{
-#if QT_VERSION >= 0x040700
- _ui.OCUrlLineEdit->setPlaceholderText(QApplication::translate("OwncloudWizardSelectTypePage", "http://owncloud.mydomain.org", 0, QApplication::UnicodeUTF8));
-#endif
}
void OwncloudWizardSelectTypePage::initializePage()
@@ -230,21 +233,22 @@ void OwncloudWizardSelectTypePage::setOCUrl( const QString& url )
OwncloudCredentialsPage::OwncloudCredentialsPage()
{
_ui.setupUi(this);
- registerField( "OCUser", _ui.OCUserEdit );
- registerField( "OCPasswd", _ui.OCPasswdEdit );
- registerField( "PwdNoLocalStore", _ui.cbPwdNoLocalStore );
+ registerField( QLatin1String("OCUser"), _ui.OCUserEdit );
+ registerField( QLatin1String("OCPasswd"), _ui.OCPasswdEdit );
+ registerField( QLatin1String("PwdNoLocalStore"), _ui.cbPwdNoLocalStore );
connect( _ui.OCPasswdEdit, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
connect( _ui.cbPwdNoLocalStore, SIGNAL(stateChanged(int)), this, SLOT(slotPwdStoreChanged(int)));
+
+#if QT_VERSION >= 0x040700
+ _ui.OCUserEdit->setPlaceholderText(tr("john"));
+ _ui.OCPasswdEdit->setPlaceholderText(tr("secret"));
+#endif
}
OwncloudCredentialsPage::~OwncloudCredentialsPage()
{
-#if QT_VERSION >= 0x040700
- _ui.OCUserEdit->setPlaceholderText(QApplication::translate("OwncloudCredentialsPage", "john", 0, QApplication::UnicodeUTF8));
- _ui.OCPasswdEdit->setPlaceholderText(QApplication::translate("OwncloudCredentialsPage", "secret", 0, QApplication::UnicodeUTF8));
-#endif
}
void OwncloudCredentialsPage::slotPwdStoreChanged( int state )
@@ -263,7 +267,7 @@ bool OwncloudCredentialsPage::isComplete() const
void OwncloudCredentialsPage::initializePage()
{
- QString user = qgetenv( "USER" );
+ QString user = QString::fromLocal8Bit(qgetenv( "USER" ));
_ui.OCUserEdit->setText( user );
}
@@ -278,15 +282,15 @@ int OwncloudCredentialsPage::nextId() const
OwncloudFTPAccessPage::OwncloudFTPAccessPage()
{
_ui.setupUi(this);
- registerField( "ftpUrl", _ui.ftpUrlEdit );
- registerField( "ftpUser", _ui.ftpUserEdit );
- registerField( "ftpPasswd", _ui.ftpPasswdEdit );
- // registerField( "ftpDir", _ui.ftpDir );
+ registerField( QLatin1String("ftpUrl"), _ui.ftpUrlEdit );
+ registerField( QLatin1String("ftpUser"), _ui.ftpUserEdit );
+ registerField( QLatin1String("ftpPasswd"), _ui.ftpPasswdEdit );
+ // registerField( QLatin1String("ftpDir"), _ui.ftpDir );
#if QT_VERSION >= 0x040700
- _ui.ftpUrlEdit->setPlaceholderText(QApplication::translate("OwncloudFTPAccessPage", "ftp.mydomain.org", 0, QApplication::UnicodeUTF8));
- _ui.ftpUserEdit->setPlaceholderText(QApplication::translate("OwncloudFTPAccessPage", "john", 0, QApplication::UnicodeUTF8));
- _ui.ftpPasswdEdit->setPlaceholderText(QApplication::translate("OwncloudFTPAccessPage", "john", 0, QApplication::UnicodeUTF8));
+ _ui.ftpUrlEdit->setPlaceholderText(tr("ftp.mydomain.org"));
+ _ui.ftpUserEdit->setPlaceholderText(tr("john"));
+ _ui.ftpPasswdEdit->setPlaceholderText(tr("secret"));
#endif
}
@@ -319,16 +323,16 @@ bool OwncloudFTPAccessPage::isComplete() const
CreateAnOwncloudPage::CreateAnOwncloudPage()
{
_ui.setupUi(this);
- registerField("createLocalOC", _ui.createLocalRadioBtn );
- registerField("createOnDomain", _ui.createPerFTPRadioBtn );
- registerField("myOCDomain", _ui.myDomainEdit );
+ registerField(QLatin1String("createLocalOC"), _ui.createLocalRadioBtn );
+ registerField(QLatin1String("createOnDomain"), _ui.createPerFTPRadioBtn );
+ registerField(QLatin1String("myOCDomain"), _ui.myDomainEdit );
connect( _ui.createLocalRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
connect( _ui.createPerFTPRadioBtn, SIGNAL(clicked()), SIGNAL(completeChanged()));
connect( _ui.myDomainEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
#if QT_VERSION >= 0x040700
- _ui.myDomainEdit->setPlaceholderText(QApplication::translate("CreateAnOwncloudPage", "mydomain.org", 0, QApplication::UnicodeUTF8));
+ _ui.myDomainEdit->setPlaceholderText(tr("mydomain.org"));
#endif
}
@@ -356,8 +360,8 @@ bool CreateAnOwncloudPage::isComplete() const
if( _ui.createPerFTPRadioBtn->isChecked() ) {
QString dom = _ui.myDomainEdit->text();
qDebug() << "check is Complete with " << dom;
- return (!dom.isEmpty() && dom.contains( QChar('.'))
- && dom.lastIndexOf('.') < dom.length()-2 );
+ return (!dom.isEmpty() && dom.contains( QLatin1Char('.'))
+ && dom.lastIndexOf(QLatin1Char('.')) < dom.length()-2 );
}
return true;
}
@@ -422,7 +426,7 @@ void OwncloudWizardResultPage::showOCUrlLabel( const QString& url, bool show )
void OwncloudWizardResultPage::setupCustomization()
{
// set defaults for the customize labels.
- _ui.topLabel->setText( QString() );
+ _ui.topLabel->setText( QString::null );
_ui.topLabel->hide();
MirallConfigFile cfg;
@@ -453,12 +457,24 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
#ifdef Q_WS_MAC
setWizardStyle( QWizard::ModernStyle );
#endif
- setField("connectMyOC", true);
+ setField(QLatin1String("connectMyOC"), true);
connect( this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentPageChanged(int)));
}
+QString OwncloudWizard::ocUrl() const
+{
+ QString url = field("OCUrl").toString();
+
+ if( field("secureConnect").toBool() ) {
+ url.prepend(QLatin1String("https://"));
+ } else {
+ url.prepend(QLatin1String("http://"));
+ }
+ return url;
+}
+
void OwncloudWizard::slotCurrentPageChanged( int id )
{
qDebug() << "Current Wizard page changed to " << id;
@@ -475,21 +491,21 @@ void OwncloudWizard::slotCurrentPageChanged( int id )
domain = domain.right( domain.length()-8 );
}
- QString host = "ftp." +domain;
+ QString host = QLatin1String("ftp.") +domain;
OwncloudFTPAccessPage *p1 = static_cast<OwncloudFTPAccessPage*> (page( Page_FTP ));
p1->setFTPUrl( host );
}
if( id == Page_Install ) {
- appendToResultWidget( QString() );
+ appendToResultWidget( QString::null );
showOCUrlLabel( false );
- if( field("connectMyOC").toBool() ) {
+ if( field(QLatin1String("connectMyOC")).toBool() ) {
// check the url and connect.
- _oCUrl = field("OCUrl").toString();
+ _oCUrl = ocUrl();
emit connectToOCUrl( _oCUrl);
- } else if( field("createLocalOC").toBool() ) {
+ } else if( field(QLatin1String("createLocalOC")).toBool() ) {
qDebug() << "Connect to local!";
emit installOCLocalhost();
- } else if( field("createNewOC").toBool() ) {
+ } else if( field(QLatin1String("createNewOC")).toBool() ) {
// call in installation mode and install to ftp site.
emit installOCServer();
} else {
diff --git a/src/mirall/owncloudwizard.h b/src/mirall/owncloudwizard.h
index 272ef1ce8..d0427c0bf 100644
--- a/src/mirall/owncloudwizard.h
+++ b/src/mirall/owncloudwizard.h
@@ -75,6 +75,7 @@ public:
void setOCUrl( const QString& );
void setupCustomMedia( QVariant, QLabel* );
+ QString ocUrl() const;
public slots:
void appendToResultWidget( const QString& msg, LogType type = LogParagraph );
diff --git a/src/mirall/proxydialog.cpp b/src/mirall/proxydialog.cpp
index fe220ee09..639e4f57b 100644
--- a/src/mirall/proxydialog.cpp
+++ b/src/mirall/proxydialog.cpp
@@ -24,9 +24,13 @@ Mirall::ProxyDialog::ProxyDialog( QWidget* parent )
{
setupUi(this);
+ // designer is buggy, so do it programmatically
+ manualSettings->setEnabled(false);
+
#if QT_VERSION >= 0x040700
- hostLineEdit->setPlaceholderText(QApplication::translate("proxyDialog", "Hostname of proxy server"));
- userLineEdit->setPlaceholderText(QApplication::translate("proxyDialog", "Username to authenticate on proxy server"));
+ hostLineEdit->setPlaceholderText(tr("Hostname of proxy server"));
+ userLineEdit->setPlaceholderText(tr("Username for proxy server"));
+ passwordLineEdit->setPlaceholderText(tr("Password for proxy server"));
#endif
// load current proxy settings
@@ -40,7 +44,7 @@ Mirall::ProxyDialog::ProxyDialog( QWidget* parent )
manualProxyRadioButton->setChecked(true);
hostLineEdit->setText(cfgFile.proxyHostName());
portSpinBox->setValue(cfgFile.proxyPort());
- if (cfgFile.proxyUser() != QString())
+ if (!cfgFile.proxyUser().isEmpty())
{
authRequiredcheckBox->setChecked(true);
userLineEdit->setText(cfgFile.proxyUser());
@@ -67,11 +71,13 @@ void Mirall::ProxyDialog::saveSettings()
{
QString user = userLineEdit->text();
QString pass = passwordLineEdit->text();
- cfgFile.setProxyType(QNetworkProxy::Socks5Proxy, hostLineEdit->text(), portSpinBox->value(), user, pass);
+ cfgFile.setProxyType(QNetworkProxy::Socks5Proxy, hostLineEdit->text(),
+ portSpinBox->value(), user, pass);
}
else
{
- cfgFile.setProxyType(QNetworkProxy::Socks5Proxy, hostLineEdit->text(), portSpinBox->value(), QString(), QString());
+ cfgFile.setProxyType(QNetworkProxy::Socks5Proxy, hostLineEdit->text(),
+ portSpinBox->value(), QString::null, QString::null);
}
}
@@ -83,13 +89,13 @@ void Mirall::ProxyDialog::on_authRequiredcheckBox_stateChanged(int state)
bool e = (state == Qt::Checked);
userLineEdit->setEnabled(e);
passwordLineEdit->setEnabled(e);
+ proxyUserLabel->setEnabled(e);
+ proxyPasswordLabel->setEnabled(e);
}
void Mirall::ProxyDialog::on_manualProxyRadioButton_toggled(bool checked)
{
- hostLineEdit->setEnabled(checked);
- portSpinBox->setEnabled(checked);
- authRequiredcheckBox->setEnabled(checked);
+ manualSettings->setEnabled(checked);
}
void Mirall::ProxyDialog::on_buttonBox_accepted()
diff --git a/src/mirall/proxydialog.ui b/src/mirall/proxydialog.ui
index 55d363dab..b6b9a6e79 100644
--- a/src/mirall/proxydialog.ui
+++ b/src/mirall/proxydialog.ui
@@ -6,204 +6,201 @@
<rect>
<x>0</x>
<y>0</y>
- <width>509</width>
- <height>360</height>
+ <width>465</width>
+ <height>291</height>
</rect>
</property>
<property name="windowTitle">
<string>Proxy Settings</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Configure Proxies to access your ownCloud</string>
+ </property>
+ <property name="buddy">
+ <cstring>manualSettings</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QLabel" name="label_2">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Configure Proxies to access your ownCloud</string>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>20</number>
</property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <widget class="QRadioButton" name="noProxyRadioButton">
+ <property name="text">
+ <string>No Proxy</string>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
+ <property name="checked">
+ <bool>true</bool>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="systemProxyRadioButton">
+ <property name="text">
+ <string>Use system proxy</string>
</property>
- </spacer>
+ </widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QRadioButton" name="noProxyRadioButton">
- <property name="text">
- <string>No Proxy</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="systemProxyRadioButton">
- <property name="text">
- <string>Use system proxy</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QRadioButton" name="manualProxyRadioButton">
- <property name="text">
- <string>Manual proxy configuration:</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Proxy User:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLineEdit" name="userLineEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_5">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QLineEdit" name="passwordLineEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- </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="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="portSpinBox">
- <property name="enabled">
- <bool>false</bool>
- </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 row="2" column="1">
- <widget class="QCheckBox" name="authRequiredcheckBox">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Authentication required</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
+ <widget class="QRadioButton" name="manualProxyRadioButton">
+ <property name="text">
+ <string>Manual proxy configuration</string>
+ </property>
+ </widget>
</item>
</layout>
</item>
+ <item>
+ <widget class="QWidget" name="manualSettings" native="true">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <property name="verticalSpacing">
+ <number>-1</number>
+ </property>
+ <property name="leftMargin">
+ <number>40</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item row="3" column="0">
+ <widget class="QLabel" name="proxyUserLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>User</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="userLineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>300</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="proxyPasswordLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="passwordLineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>300</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </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>
+ </widget>
+ </item>
</layout>
</item>
- <item>
+ <item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -216,7 +213,7 @@
</property>
</spacer>
</item>
- <item>
+ <item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/mirall/sslerrordialog.cpp b/src/mirall/sslerrordialog.cpp
index 861414154..95b8ef967 100644
--- a/src/mirall/sslerrordialog.cpp
+++ b/src/mirall/sslerrordialog.cpp
@@ -19,11 +19,10 @@
namespace Mirall
{
-
+#define CA_CERTS_KEY QLatin1String("CaCertificates")
SslErrorDialog::SslErrorDialog(QWidget *parent) :
- QDialog(parent)
- ,_allTrusted(false)
+ QDialog(parent), _allTrusted(false)
{
setupUi( this );
setWindowTitle( tr("SSL Connection") );
@@ -38,9 +37,8 @@ SslErrorDialog::SslErrorDialog(QWidget *parent) :
QList<QSslCertificate> SslErrorDialog::storedCACerts()
{
MirallConfigFile cfg( _customConfigHandle );
- QSettings settings( cfg.configFile(), QSettings::IniFormat);
- QList<QSslCertificate> cacerts = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());
+ QList<QSslCertificate> cacerts = QSslCertificate::fromData(cfg.caCerts());
return cacerts;
}
@@ -95,7 +93,7 @@ bool SslErrorDialog::setErrorList( QList<QSslError> errors )
// add the errors for this cert
foreach( QSslError err, errors ) {
if( err.certificate() == cert ) {
- msg += "<p>" + err.errorString() + "</p>";
+ msg += QL("<p>") + err.errorString() + QL("</p>");
}
}
msg += QL("</div>");
@@ -111,7 +109,7 @@ bool SslErrorDialog::setErrorList( QList<QSslError> errors )
QTextDocument *doc = new QTextDocument(0);
QString style = styleSheet();
qDebug() << "Style: " << style;
- doc->addResource( QTextDocument::StyleSheetResource, QUrl( "format.css" ), style);
+ doc->addResource( QTextDocument::StyleSheetResource, QUrl( QL("format.css") ), style);
doc->setHtml( msg );
_tbErrors->setDocument( doc );
@@ -131,7 +129,7 @@ QString SslErrorDialog::certDiv( QSslCertificate cert ) const
li << tr("Organization: %1").arg( cert.subjectInfo( QSslCertificate::Organization) );
li << tr("Unit: %1").arg( cert.subjectInfo( QSslCertificate::OrganizationalUnitName) );
li << tr("Country: %1").arg(cert.subjectInfo( QSslCertificate::CountryName));
- msg += QL("<p>") + li.join("<br/>") + QL("</p>");
+ msg += QL("<p>") + li.join(QL("<br/>")) + QL("</p>");
msg += QL("<p>");
msg += tr("Effective Date: %1").arg( cert.effectiveDate().toString()) + QL("<br/>");
@@ -140,12 +138,12 @@ QString SslErrorDialog::certDiv( QSslCertificate cert ) const
msg += QL("</div>" );
msg += QL("<h3>") + tr("Issuer: %1").arg( cert.issuerInfo( QSslCertificate::CommonName )) + QL("</h3>");
- msg += "<div id=\"issuer\">";
+ msg += QL("<div id=\"issuer\">");
li.clear();
li << tr("Organization: %1").arg( cert.issuerInfo( QSslCertificate::Organization) );
li << tr("Unit: %1").arg( cert.issuerInfo( QSslCertificate::OrganizationalUnitName) );
li << tr("Country: %1").arg(cert.issuerInfo( QSslCertificate::CountryName));
- msg += QL("<p>") + li.join("<br/>") + QL("</p>");
+ msg += QL("<p>") + li.join(QL("<br/>")) + QL("</p>");
msg += QL("</div>" );
msg += QL("</div>" );
@@ -166,26 +164,17 @@ void SslErrorDialog::accept()
{
// Save the contents of _unknownCerts to the settings file.
if( trustConnection() && _unknownCerts.count() > 0 ) {
- MirallConfigFile cfg( _customConfigHandle );
+ QSslSocket::addDefaultCaCertificates(_unknownCerts);
- QSettings settings( cfg.configFile(), QSettings::IniFormat);
+ MirallConfigFile cfg( _customConfigHandle );
- QByteArray certs = settings.value(QLatin1String("CaCertificates")).toByteArray();
+ QByteArray certs = cfg.caCerts();
qDebug() << "Saving " << _unknownCerts.count() << " unknown certs.";
-
- // update the ssl config.
- QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
- QList<QSslCertificate> ca_list = sslCfg.caCertificates();
- ca_list += _unknownCerts;
- sslCfg.setCaCertificates(ca_list);
- QSslConfiguration::setDefaultConfiguration(sslCfg);
-
foreach( const QSslCertificate& cert, _unknownCerts ) {
certs += cert.toPem() + '\n';
}
-
- settings.setValue(QLatin1String("CaCertificates"), certs);
+ cfg.setCaCerts( certs );
}
QDialog::accept();
diff --git a/src/mirall/statusdialog.cpp b/src/mirall/statusdialog.cpp
index 53e3af3f8..769b872e2 100644
--- a/src/mirall/statusdialog.cpp
+++ b/src/mirall/statusdialog.cpp
@@ -170,7 +170,7 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_theme( theme )
{
setupUi( this );
- setWindowTitle( _theme->appName() + QString (" %1" ).arg( _theme->version() ) );
+ setWindowTitle( QString::fromLatin1( "%1 %2" ).arg(_theme->appName(), _theme->version() ) );
_model = new FolderStatusModel();
FolderViewDelegate *delegate = new FolderViewDelegate();
@@ -179,7 +179,6 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_folderList->setModel( _model );
_folderList->setMinimumWidth( 300 );
_folderList->setEditTriggers( QAbstractItemView::NoEditTriggers );
-
connect(_ButtonClose, SIGNAL(clicked()), this, SLOT(accept()));
connect(_ButtonRemove, SIGNAL(clicked()), this, SLOT(slotRemoveFolder()));
@@ -198,11 +197,6 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_ButtonInfo->setEnabled(false);
_ButtonAdd->setEnabled(true);
- connect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
- this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
- connect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
- this, SLOT(slotOCInfoFail(QNetworkReply*)));
-
#if defined Q_WS_X11
connect(_folderList, SIGNAL(activated(QModelIndex)), SLOT(slotFolderActivated(QModelIndex)));
connect( _folderList,SIGNAL(doubleClicked(QModelIndex)),SLOT(slotDoubleClicked(QModelIndex)));
@@ -295,16 +289,16 @@ void StatusDialog::folderToModelItem( QStandardItem *item, Folder *f )
if( ! item || !f ) return;
QIcon icon = _theme->folderIcon( f->backend() );
- item->setData( icon, FolderViewDelegate::FolderIconRole );
- item->setData( f->path(), FolderViewDelegate::FolderPathRole );
- item->setData( f->secondPath(), FolderViewDelegate::FolderSecondPathRole );
- item->setData( f->alias(), FolderViewDelegate::FolderAliasRole );
- item->setData( f->syncEnabled(), FolderViewDelegate::FolderSyncEnabled );
+ item->setData( icon, FolderViewDelegate::FolderIconRole );
+ item->setData( f->nativePath(), FolderViewDelegate::FolderPathRole );
+ item->setData( f->nativeSecondPath(), FolderViewDelegate::FolderSecondPathRole );
+ item->setData( f->alias(), FolderViewDelegate::FolderAliasRole );
+ item->setData( f->syncEnabled(), FolderViewDelegate::FolderSyncEnabled );
SyncResult res = f->syncResult();
SyncResult::Status status = res.status();
- QString errors = res.errorStrings().join("<br/>");
+ QString errors = res.errorStrings().join(QLatin1String("<br/>"));
item->setData( _theme->statusHeaderText( status ), Qt::ToolTipRole );
if( f->syncEnabled() ) {
@@ -399,6 +393,11 @@ void StatusDialog::slotAddSync()
void StatusDialog::slotCheckConnection()
{
if( ownCloudInfo::instance()->isConfigured() ) {
+ connect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
+ this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
+ connect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
+ this, SLOT(slotOCInfoFail(QNetworkReply*)));
+
_ocUrlLabel->setText( tr("Checking ownCloud connection..."));
qDebug() << "Check status.php from statusdialog.";
ownCloudInfo::instance()->checkInstallation();
@@ -430,6 +429,12 @@ void StatusDialog::slotOCInfo( const QString& url, const QString& versionStr, co
_ocUrlLabel->setToolTip( tr("Version: %1").arg(version));
_ButtonAdd->setEnabled(true);
+ disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
+ this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
+ disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
+ this, SLOT(slotOCInfoFail(QNetworkReply*)));
+
+
}
void StatusDialog::slotOCInfoFail( QNetworkReply *reply)
@@ -439,6 +444,12 @@ void StatusDialog::slotOCInfoFail( QNetworkReply *reply)
_ocUrlLabel->setText( tr("<p>Failed to connect to ownCloud: <tt>%1</tt></p>").arg(errStr) );
_ButtonAdd->setEnabled( false);
+
+ disconnect(ownCloudInfo::instance(), SIGNAL(ownCloudInfoFound(const QString&, const QString&, const QString&, const QString&)),
+ this, SLOT(slotOCInfo( const QString&, const QString&, const QString&, const QString& )));
+ disconnect(ownCloudInfo::instance(), SIGNAL(noOwncloudFound(QNetworkReply*)),
+ this, SLOT(slotOCInfoFail(QNetworkReply*)));
+
}
void StatusDialog::slotOpenOC()
diff --git a/src/mirall/syncresult.cpp b/src/mirall/syncresult.cpp
index 20ab78815..78f50dd57 100644
--- a/src/mirall/syncresult.cpp
+++ b/src/mirall/syncresult.cpp
@@ -84,7 +84,7 @@ void SyncResult::setErrorString( const QString& err )
QString SyncResult::errorString() const
{
- if( _errors.isEmpty() ) return QString();
+ if( _errors.isEmpty() ) return QString::null;
return _errors.first();
}
diff --git a/src/mirall/temporarydir.cpp b/src/mirall/temporarydir.cpp
deleted file mode 100644
index 07caef19d..000000000
--- a/src/mirall/temporarydir.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
- *
- * 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/temporarydir.h"
-#include "mirall/fileutils.h"
-
-#include <cstdlib>
-#include <cerrno>
-#include <cstring>
-
-#include <QDebug>
-#include <QDir>
-#include <QDateTime>
-
-namespace Mirall
-{
-
-static const QString dirTemplate = QDir::tempPath() + "/mirall-XXXXXX";
-
-/*
- * This class creates a temporary directory as Qt 4.x does not provide an
- * implementation yet. It will come with Qt5, don't forget to PORT
- *
- * This class is only used in the test suite of mirall.
- * As the mkdtemp function is problematic on non linux platforms, I change
- * the filename generation to something more predictable using the timestamp.
- *
- * Note: This is not allowed for cases where the dir name needs to be
- * unpredictable for security reasons.
- */
-
-TemporaryDir::TemporaryDir()
-{
-#ifdef Q_WS_WIN
- QDateTime dt = QDateTime::currentDateTime();
- QString p( QDir::tempPath() + "/mirall-" + dt.toString( Qt::ISODate ) );
- QDir dir( p );
- if( dir.mkpath( p ) ) {
- _path = p;
- }
-#else
- char *buff = ::strdup(dirTemplate.toLocal8Bit().data());
- char *tmp = ::mkdtemp(buff);
- _path = QString((const char *) tmp);
- ::free(buff);
-#endif
-}
-
-TemporaryDir::~TemporaryDir()
-{
- FileUtils::removeDir(_path);
-}
-
-QString TemporaryDir::path() const
-{
- return _path;
-}
-
-}
diff --git a/src/mirall/temporarydir.h b/src/mirall/temporarydir.h
deleted file mode 100644
index ee878409d..000000000
--- a/src/mirall/temporarydir.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
- *
- * 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_TEMPORARYDIR_H
-#define MIRALL_TEMPORARYDIR_H
-
-#include <QString>
-
-namespace Mirall
-{
-
-class TemporaryDir
-{
-public:
- TemporaryDir();
- ~TemporaryDir();
-
- QString path() const;
-
-private:
- QString _path;
-};
-
-}
-
-#endif
diff --git a/src/mirall/theme.cpp b/src/mirall/theme.cpp
index 2dcd0037b..d505472ff 100644
--- a/src/mirall/theme.cpp
+++ b/src/mirall/theme.cpp
@@ -78,7 +78,7 @@ QIcon Theme::themeIcon( const QString& name ) const
QList<int> sizes;
sizes <<16 << 24 << 32 << 48 << 64 << 128;
foreach (int size, sizes) {
- QString pixmapName = QString(":/mirall/resources/%1-%2.png").arg(name).arg(size);
+ QString pixmapName = QString::fromLatin1(":/mirall/resources/%1-%2.png").arg(name).arg(size);
if (QFile::exists(pixmapName)) {
icon.addFile(pixmapName, QSize(size, size));
}
diff --git a/src/mirall/unisonfolder.cpp b/src/mirall/unisonfolder.cpp
index 3e4eb56d3..c5b722fde 100644
--- a/src/mirall/unisonfolder.cpp
+++ b/src/mirall/unisonfolder.cpp
@@ -64,12 +64,12 @@ void UnisonFolder::startSync(const QStringList &pathList)
emit syncStarted();
- QString program = "unison";
+ QString program = QLatin1String("unison");
QStringList args;
- args << "-ui" << "text";
- args << "-auto" << "-batch";
+ args << QLatin1String("-ui") << QLatin1String("text");
+ args << QLatin1String("-auto") << QLatin1String("-batch");
- args << "-confirmbigdel=false";
+ args << QLatin1String("-confirmbigdel=false");
// only use -path in after a full synchronization
// already happened, which we do only on the first
@@ -78,7 +78,7 @@ void UnisonFolder::startSync(const QStringList &pathList)
// may be we should use a QDir in the API itself?
QDir root(path());
foreach( const QString& changedPath, pathList) {
- args << "-path" << root.relativeFilePath(changedPath);
+ args << QLatin1String("-path") << root.relativeFilePath(changedPath);
}
}
diff --git a/src/mirall/updatedetector.cpp b/src/mirall/updatedetector.cpp
index fb3610fa8..800774c7a 100644
--- a/src/mirall/updatedetector.cpp
+++ b/src/mirall/updatedetector.cpp
@@ -35,8 +35,8 @@ void UpdateDetector::versionCheck( Theme *theme )
_accessManager = new QNetworkAccessManager(this);
connect(_accessManager, SIGNAL(finished(QNetworkReply*)), this,
SLOT(slotVersionInfoArrived(QNetworkReply*)) );
- QUrl url("http://download.owncloud.com/clientupdater.php");
- QString ver = QString("%1.%2.%3").arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO);
+ QUrl url(QLatin1String("http://download.owncloud.com/clientupdater.php"));
+ QString ver = QString::fromLatin1("%1.%2.%3").arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO);
QString platform = QLatin1String("stranger");
#ifdef Q_OS_LINUX
@@ -52,10 +52,10 @@ void UpdateDetector::versionCheck( Theme *theme )
QString sysInfo = getSystemInfo();
if( !sysInfo.isEmpty() ) {
- url.addQueryItem("client", sysInfo );
+ url.addQueryItem(QLatin1String("client"), sysInfo );
}
- url.addQueryItem( "version", ver );
- url.addQueryItem( "platform", platform );
+ url.addQueryItem( QLatin1String("version"), ver );
+ url.addQueryItem( QLatin1String("platform"), platform );
_accessManager->get( QNetworkRequest( url ));
}
@@ -64,7 +64,7 @@ QString UpdateDetector::getSystemInfo()
{
#ifdef Q_OS_LINUX
QProcess process;
- process.start( "lsb_release -a" );
+ process.start( QLatin1String("lsb_release -a") );
process.waitForFinished();
QByteArray output = process.readAllStandardOutput();
qDebug() << "Sys Info size: " << output.length();
@@ -72,7 +72,7 @@ QString UpdateDetector::getSystemInfo()
return QString::fromLocal8Bit( output.toBase64() );
#else
- return QString();
+ return QString::null;
#endif
}
@@ -108,7 +108,8 @@ void UpdateDetector::slotVersionInfoArrived( QNetworkReply* reply )
qDebug() << "Client is on latest version!";
} else {
// if the version tag is set, there is a newer version.
- QString ver = QString("%1.%2.%3").arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO);
+ QString ver = QString::fromLatin1("%1.%2.%3")
+ .arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO);
QMessageBox msgBox;
msgBox.setTextFormat( Qt::RichText );
msgBox.setWindowTitle(tr("Client Version Check"));