1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2026-04-04 20:34:17 +02:00

Compare commits

..

41 Commits

Author SHA1 Message Date
Daniel Molkentin
7ddd3a36c7 Update ChangeLog 2014-09-02 16:41:41 +02:00
Markus Goetz
c46f1aba89 Sparkle: Keep permissions from bundle
(cherry picked from commit 0be4b59cff)
2014-09-02 16:38:45 +02:00
Daniel Molkentin
2ab19b23d7 Make Settings Window close on Ctrl+W
Fixes #2141
2014-09-02 13:58:55 +02:00
Daniel Molkentin
d770f9cc1a Account Migrator: Switch to string comparison for URLs.
QUrl does not normalize trailing slashes, so there is no benefit
of using QUrl here.
2014-08-31 19:50:20 +02:00
Daniel Molkentin
9d3b09159e Edit ChangeLog 2014-08-31 19:13:57 +02:00
Klaas Freitag
819cb74cc3 Changelog bumped for 1.6.3 2014-08-30 19:07:59 +02:00
Klaas Freitag
2407469104 Bump version to 1.6.3 beta1. 2014-08-30 18:18:53 +02:00
Klaas Freitag
c1faff513e Merge remote-tracking branch 'origin/reuse_oc_config' into 1.6 2014-08-29 20:07:27 +02:00
Daniel Molkentin
e5b4438d5c X11: Bring Settings window to front when launched
(cherry picked from commit 25c274a0bd)

Conflicts:
	src/mirall/owncloudgui.cpp
2014-08-28 18:14:27 +02:00
Olivier Goffart
7ec43e9f36 uploading: make sure to cast to uint64 to avoid integer overflow
(cherry picked from commit 302499b483)
2014-08-26 16:36:35 +02:00
Olivier Goffart
c4dabe7ed2 SSLButton: fix memleak
(cherry picked from commit 9b88c7d3c1)
2014-08-26 16:36:35 +02:00
Daniel Molkentin
6b4f11f4aa Fix backporting glitch the broke compilation 2014-08-14 16:36:03 +02:00
Daniel Molkentin
1edf3dd503 Always handle 401 requests, except for network jobs
It is not enough to only implement it for the QNAM returned
by the ShibbolethCredentials, because we sometimes need it
when we have no valid credentials set (and are using dummy
credentials in the course).  The main use case is the
Webview opened by Shibboleth for FBA.

But as a side-effect, we can use it to handle auth requests
from the updater and other places.

(cherry picked from commit 1544606bf0)

Conflicts:
	src/CMakeLists.txt
	src/creds/shibbolethcredentials.h
2014-08-13 15:04:31 +02:00
Markus Goetz
1daf9bc80b Tests: Give a more random name to test directories 2014-08-12 16:25:04 +02:00
Markus Goetz
b7a91a6998 Fix compile and adapt code to be similar to 1.7/master 2014-08-12 15:24:42 +02:00
Markus Goetz
69dffc8882 OS X: Finally(?) fix stay-on-top behaviour of settings dialog
Fixes #1795

Conflicts:
	.gitmodules
	src/mirall/owncloudgui.cpp
2014-08-12 14:54:59 +02:00
Klaas Freitag
753aa9132e Merge pull request #2013 from owncloud/fix-man-dir-16
Fix issue#2004 -- mandir must be man1, not man
2014-07-30 17:38:25 +02:00
Olivier Goffart
cfdfd6a860 wizard: don't call initializePage
It is called automatically by QWizard and do not need to be called explicitly

But setVisibla(false) don't really have an effect there since show() is going
to be called on the page
2014-07-30 12:36:30 +02:00
Jürgen Weigert
0c9d57228d Fix issue#2004 -- mandir must be man1, not man 2014-07-29 18:29:55 +02:00
Olivier Goffart
5254c9785c shibboleth: Fix connection when the URL do not have a path
When the url do not have a path (for example: "http://example.com" as
opposed to "http://example.com/"),  its path is not a prefix of the
root path of the cookie (usually '/')

By adding the dav path, we make sure the URL has a path.

This made a bug when the owncloud url was just a domain name and did not
have a path
2014-07-28 13:50:24 +02:00
Klaas Freitag
0f37484b8a Bumped the release number to 1.6.2, Changelog additions. 2014-07-28 11:44:10 +02:00
Olivier Goffart
3d0c009719 propagator_qnam: Limit the HTTP buffer size when downloading
Otherwise the buffer might fill up too quickly and get too large and consume
too much memory which could lead to crash in extreme cases

Should fix issue #1974
2014-07-24 15:43:28 +02:00
Olivier Goffart
208011f6ab propagator_qnam: add debug output in cae the file changed localy
In order to debug https://github.com/owncloud/core/issues/9781
2014-07-24 11:17:59 +02:00
Daniel Molkentin
f84e0010ee NSIS: ICU rebumped to 5.3 as per build service change 2014-07-24 10:07:46 +02:00
Klaas Freitag
c97f46d403 Bump version to 1.6.2 rc2 plus Changelog 2014-07-24 09:58:23 +02:00
Klaas Freitag
1fb52f0d8b HTTPCreds: Do delete the WritePasswordJob to not leak memory. 2014-07-23 17:59:02 +02:00
Klaas Freitag
d4de024f15 Propagator: Fix local file name clash detection.
Need to normalize the output of QFileInfo::canonicalFilePath() before
comparing to a server side path.
See https://bugreports.qt-project.org/browse/QTBUG-39622

This fixes #1998 and #1999
2014-07-23 17:56:46 +02:00
Olivier Goffart
1d9d88ca85 Always use the dummy crendential while trying to determine the credentials
Otherwise the SHibbolethCredential may be set and it has hook to intercept 401

This should fix issue #1908
2014-07-23 14:38:50 +02:00
Olivier Goffart
beb9300b4e network limit: Never wait more than 10 seconds
When using the "Limit automatically" limit, we wait for 25% of the time
it took to upload something.
However, if we go to sleep while uploading, the time it took to upload may take
days. And waiting for 25% of a day is too long.
So never wait for more than 10 seconds

This may be related to issue #1880
2014-07-18 12:27:02 +02:00
Olivier Goffart
c35880d4f1 Fix corruption while trying to resume and the server don't suport it
Issue #1982
2014-07-18 12:03:45 +02:00
Klaas Freitag
d8ebebaf12 WinInstaller: No hardcoded www in front of the url on final page. 2014-07-16 18:39:51 +02:00
Klaas Freitag
e17243bc1f AccountMigrator: Read path from QDir::fromNativeSeperators(), add debug. 2014-06-25 11:38:08 +02:00
Klaas Freitag
0e45dd7a3d AccountMigrator: Do not inherit from QObject as it is not needed yet.
As requested by Danimos review.
2014-06-25 11:38:08 +02:00
Klaas Freitag
65f313f1b4 Account: Added missing include statement. 2014-06-25 11:38:08 +02:00
Klaas Freitag
da4958c716 Account: Read settings from ownCloud config if no branded exists.
If there is not yet a config for a branded client, but one for the
"normal" client targetting the same URL, it will be migrated.
2014-06-25 11:38:08 +02:00
Klaas Freitag
653b8494f5 FolderMan: Migrate folderlist if no folder definitions can be found
and the account indicates that it was migrated. In that case,
read the folder definitions from the ownCloud config directory.
2014-06-25 11:38:08 +02:00
Klaas Freitag
6ed6f84f6e Account: Add a wasMigrated flag.
If an account in a branded client was migrated from a former ownCloud
configuration, the method wasMigrated() will return true.
2014-06-25 11:38:08 +02:00
Klaas Freitag
ff0ba56bc3 ownCloud Theme: Implement appName() and appNameGUI(). 2014-06-25 11:38:08 +02:00
Klaas Freitag
e795d04f30 cfg migration: Add a account migrator class. 2014-06-25 11:38:08 +02:00
Klaas Freitag
8d3806b080 folderman: make escapeAlias public as its now used in accountmigrator. 2014-06-25 11:38:08 +02:00
Klaas Freitag
5597ebe455 Account: Add a scoped pointer to the ownCloud theme. 2014-06-25 11:38:07 +02:00
41 changed files with 455 additions and 85 deletions

2
.gitmodules vendored
View File

@@ -3,4 +3,4 @@
url = https://github.com/owncloud/documentation
[submodule "src/3rdparty/qtmacgoodies"]
path = src/3rdparty/qtmacgoodies
url = git://github.com/shadone/qtmacgoodies.git
url = git://github.com/guruz/qtmacgoodies.git

View File

@@ -1,6 +1,20 @@
ChangeLog
=========
version 1.6.2 (release 2014-07-x )
version 1.6.3 (release 2014-09-xx)
* Fixed updater on OS X
* Fixed memory leak in SSL button that could lead to quick memory draining
* Fixed upload problem with files >4 GB
* MacOSX, Linux: Bring Settings window to front properly
* Branded clients: If no configuration is detected, try to import the data
from a previously configured community edition.
version 1.6.2 (release 2014-07-28 )
* Limit the HTTP buffer size when downloading to limit memory consumption.
* Another small mem leak fixed in HTTP Credentials.
* Fix local file name clash detection for MacOSX.
* Limit maximum wait time to ten seconds in network limiting.
* Fix data corruption while trying to resume and the server does
not support it.
* HTTP Credentials: Read password from legacy place if not found.
* Shibboleth: Fix the waiting curser that would not disapear (#1915)
* Limit memory usage to avoid mem wasting and crashes

View File

@@ -1,6 +1,6 @@
set( MIRALL_VERSION_MAJOR 1 )
set( MIRALL_VERSION_MINOR 6 )
set( MIRALL_VERSION_PATCH 2 )
set( MIRALL_VERSION_PATCH 3 )
set( MIRALL_SOVERSION 0 )
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )

View File

@@ -111,8 +111,8 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ${WIN_SETUP_BITMAP_PATH}/page_header.bmp
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_LINK "www.${APPLICATION_DOMAIN}"
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.${APPLICATION_DOMAIN}"
!define MUI_FINISHPAGE_LINK "${APPLICATION_DOMAIN}"
!define MUI_FINISHPAGE_LINK_LOCATION "http://${APPLICATION_DOMAIN}"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!ifdef OPTION_FINISHPAGE_RELEASE_NOTES
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
@@ -414,9 +414,9 @@ Section "${APPLICATION_NAME}" SEC_APPLICATION
;Qt deps
File "${MING_BIN}\libpng16-16.dll"
File "${MING_BIN}\icudata51.dll"
File "${MING_BIN}\icui18n51.dll"
File "${MING_BIN}\icuuc51.dll"
File "${MING_BIN}\icudata53.dll"
File "${MING_BIN}\icui18n53.dll"
File "${MING_BIN}\icuuc53.dll"
File "${MING_BIN}\libEGL.dll"
File "${MING_BIN}\libGLESv2.dll"
File "${MING_BIN}\libjpeg-8.dll"

View File

@@ -34,6 +34,7 @@ use LWP::UserAgent;
use LWP::Protocol::https;
use HTTP::Request::Common qw( POST GET DELETE );
use File::Basename;
use POSIX qw/strftime/;
use Encode qw(from_to);
use utf8;
@@ -128,8 +129,9 @@ sub initTesting(;$)
# $d->DebugLevel(3);
$prefix = "t1" unless( defined $prefix );
my $dirId = sprintf("%#.3o", rand(1000));
my $dir = sprintf( "%s-%s/", $prefix, $dirId );
my $dirId = sprintf("%02d", rand(100));
my $dateTime = strftime('%Y%m%d%H%M%S',localtime);
my $dir = sprintf( "%s-%s-%s/", $prefix, $dateTime, $dirId );
$localDir = $dir;
$localDir .= "/" unless( $localDir =~ /\/$/ );

View File

@@ -4,7 +4,7 @@ if(SPHINX_FOUND)
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
# HTML output directory
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
set(SPHINX_MAN_DIR "${CMAKE_CURRENT_BINARY_DIR}/man")
set(SPHINX_MAN_DIR "${CMAKE_CURRENT_BINARY_DIR}/man1")
set(SPHINX_PDF_DIR "${CMAKE_CURRENT_BINARY_DIR}/latex")
set(SPHINX_QCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/qthelp")
set(SPHINX_HTMLHELP_DIR "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")

View File

@@ -45,6 +45,7 @@ if (APPLE)
list(APPEND 3rdparty_SRC
3rdparty/qtmacgoodies/src/macpreferenceswindow.mm
3rdparty/qtmacgoodies/src/macstandardicon.mm
3rdparty/qtmacgoodies/src/macwindow.mm
)
endif()
@@ -82,6 +83,7 @@ set(libsync_SRCS
mirall/folderman.cpp
mirall/folder.cpp
mirall/folderwatcher.cpp
mirall/authenticationdialog.cpp
mirall/syncresult.cpp
mirall/mirallconfigfile.cpp
mirall/syncengine.cpp
@@ -105,6 +107,7 @@ set(libsync_SRCS
mirall/clientproxy.cpp
mirall/syncrunfilelog.cpp
mirall/cookiejar.cpp
mirall/accountmigrator.cpp
creds/dummycredentials.cpp
creds/abstractcredentials.cpp
creds/credentialsfactory.cpp
@@ -124,7 +127,6 @@ else()
creds/shibbolethcredentials.cpp
creds/shibboleth/shibbolethwebview.cpp
creds/shibboleth/shibbolethrefresher.cpp
creds/shibboleth/authenticationdialog.cpp
creds/shibboleth/shibbolethuserjob.cpp
)
endif()
@@ -246,7 +248,7 @@ else()
install(TARGETS ${synclib_NAME} DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/MacOS)
if (SPARKLE_FOUND)
install(DIRECTORY "${SPARKLE_LIBRARY}"
DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks")
DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks" USE_SOURCE_PERMISSIONS)
endif (SPARKLE_FOUND)
endif()

View File

@@ -366,6 +366,8 @@ void HttpCredentials::slotWriteJobDone(QKeychain::Job *job)
default:
qDebug() << "Error while writing password" << job->errorString();
}
WritePasswordJob *wjob = qobject_cast<WritePasswordJob*>(job);
wjob->deleteLater();
}
void HttpCredentials::slotAuthentication(QNetworkReply* reply, QAuthenticator* authenticator)

View File

@@ -20,7 +20,6 @@
#include <QDebug>
#include "creds/shibbolethcredentials.h"
#include "creds/shibboleth/authenticationdialog.h"
#include "creds/shibboleth/shibbolethwebview.h"
#include "creds/shibboleth/shibbolethrefresher.h"
#include "creds/shibbolethcredentials.h"
@@ -173,8 +172,6 @@ QNetworkAccessManager* ShibbolethCredentials::getQNAM() const
QNetworkAccessManager* qnam(new MirallAccessManager);
connect(qnam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(slotReplyFinished(QNetworkReply*)));
connect(qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(slotHandleAuthentication(QNetworkReply*,QAuthenticator*)));
return qnam;
}
@@ -319,23 +316,6 @@ void ShibbolethCredentials::invalidateAndFetch(Account* account)
job->start();
}
void ShibbolethCredentials::slotHandleAuthentication(QNetworkReply *reply, QAuthenticator *authenticator)
{
Q_UNUSED(reply)
QUrl url = reply->url();
// show only scheme, host and port
QUrl reducedUrl;
reducedUrl.setScheme(url.scheme());
reducedUrl.setHost(url.host());
reducedUrl.setPort(url.port());
AuthenticationDialog dialog(authenticator->realm(), reducedUrl.toString());
if (dialog.exec() == QDialog::Accepted) {
authenticator->setUser(dialog.user());
authenticator->setPassword(dialog.password());
}
}
void ShibbolethCredentials::slotInvalidateAndFetchInvalidateDone(QKeychain::Job* job)
{
Account *account = qvariant_cast<Account*>(job->property("account"));
@@ -405,7 +385,7 @@ void ShibbolethCredentials::showLoginWindow(Account* account)
QList<QNetworkCookie> ShibbolethCredentials::accountCookies(Account *account)
{
return account->networkAccessManager()->cookieJar()->cookiesForUrl(account->url());
return account->networkAccessManager()->cookieJar()->cookiesForUrl(account->davUrl());
}
QNetworkCookie ShibbolethCredentials::findShibCookie(Account *account, QList<QNetworkCookie> cookies)

View File

@@ -63,7 +63,6 @@ public:
public Q_SLOTS:
void invalidateAndFetch(Account *account);
void slotHandleAuthentication(QNetworkReply*,QAuthenticator*);
private Q_SLOTS:
void onShibbolethCookieReceived(const QNetworkCookie&, Account*);

View File

@@ -18,6 +18,7 @@
#include "mirall/mirallconfigfile.h"
#include "mirall/mirallaccessmanager.h"
#include "mirall/quotainfo.h"
#include "mirall/owncloudtheme.h"
#include "creds/abstractcredentials.h"
#include "creds/credentialsfactory.h"
@@ -27,6 +28,8 @@
#include <QNetworkAccessManager>
#include <QSslSocket>
#include <QNetworkCookieJar>
#include <QFileInfo>
#include <QDir>
#include <QDebug>
@@ -71,6 +74,7 @@ Account::Account(AbstractSslErrorHandler *sslErrorHandler, QObject *parent)
, _treatSslErrorsAsFailure(false)
, _state(Account::Disconnected)
, _davPath("remote.php/webdav/")
, _wasMigrated(false)
{
qRegisterMetaType<Account*>("Account*");
}
@@ -112,11 +116,52 @@ void Account::save()
Account* Account::restore()
{
// try to open the correctly themed settings
QScopedPointer<QSettings> settings(settingsWithGroup(Theme::instance()->appName()));
Account *acc = 0;
bool migratedCreds = false;
// if the settings file could not be opened, the childKeys list is empty
if( settings->childKeys().isEmpty() ) {
// Now try to open the original ownCloud settings to see if they exist.
QString oCCfgFile = QDir::fromNativeSeparators( settings->fileName() );
// replace the last two segments with ownCloud/owncloud.cfg
oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/'));
oCCfgFile += QLatin1String("/ownCloud/owncloud.cfg");
qDebug() << "Migrate: checking old config " << oCCfgFile;
QFileInfo fi( oCCfgFile );
if( fi.isReadable() ) {
QSettings *oCSettings = new QSettings(oCCfgFile, QSettings::IniFormat);
oCSettings->beginGroup(QLatin1String("ownCloud"));
// Check the theme url to see if it is the same url that the oC config was for
QString overrideUrl = Theme::instance()->overrideServerUrl();
if( !overrideUrl.isEmpty() ) {
if (overrideUrl.endsWith('/')) { overrideUrl.chop(1); }
QString oCUrl = oCSettings->value(QLatin1String(urlC)).toString();
if (oCUrl.endsWith('/')) { oCUrl.chop(1); }
// in case the urls are equal reset the settings object to read from
// the ownCloud settings object
qDebug() << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":"
<< (oCUrl == overrideUrl ? "Yes" : "No");
if( oCUrl == overrideUrl ) {
migratedCreds = true;
settings.reset( oCSettings );
} else {
delete oCSettings;
}
}
}
}
if (!settings->childKeys().isEmpty()) {
Account *acc = new Account;
MirallConfigFile cfg;
acc->setApprovedCerts(QSslCertificate::fromData(cfg.caCerts()));
acc = new Account;
acc->setUrl(settings->value(QLatin1String(urlC)).toUrl());
acc->setCredentials(CredentialsFactory::create(settings->value(QLatin1String(authTypeC)).toString()));
@@ -128,6 +173,11 @@ Account* Account::restore()
continue;
acc->_settingsMap.insert(key, settings->value(key));
}
// now the cert, it is in the general group
settings->beginGroup(QLatin1String("General"));
acc->setApprovedCerts(QSslCertificate::fromData(settings->value(QLatin1String("CaCertificates")).toByteArray()));
acc->setMigrated(migratedCreds);
return acc;
}
return 0;
@@ -364,4 +414,14 @@ void Account::slotHandleErrors(QNetworkReply *reply , QList<QSslError> errors)
}
}
bool Account::wasMigrated()
{
return _wasMigrated;
}
void Account::setMigrated(bool mig)
{
_wasMigrated = mig;
}
} // namespace Mirall

View File

@@ -108,6 +108,13 @@ public:
/** Returns webdav entry URL, based on url() */
QUrl davUrl() const;
/** set and retrieve the migration flag: if an account of a branded
* client was migrated from a former ownCloud Account, this is true
*/
void setMigrated(bool mig);
bool wasMigrated();
QList<QNetworkCookie> lastAuthCookies() const;
QNetworkReply* headRequest(const QString &relPath);
@@ -166,6 +173,7 @@ private:
int _state;
static QString _configFileName;
QString _davPath; // default "remote.php/webdav/";
bool _wasMigrated;
};
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* 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; version 2 of the License.
*
* 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/accountmigrator.h"
#include "mirall/mirallconfigfile.h"
#include "mirall/folderman.h"
#include "mirall/theme.h"
#include <QSettings>
#include <QStringList>
#include <QDir>
#include <QFileInfo>
#include <QDebug>
namespace Mirall {
// The purpose of this class is to migrate an existing account that
// was set up with an unbranded client to an branded one.
// The usecase is: Usually people try first with the community client,
// later they maybe switch to a branded client. When they install the
// branded client first, it should automatically pick the information
// from the already configured account.
AccountMigrator::AccountMigrator()
{
}
// the list of folder definitions which are files in the directory "folders"
// underneath the ownCloud configPath (with ownCloud as a last segment)
// need to be copied to the themed path and adjusted.
QStringList AccountMigrator::migrateFolderDefinitons()
{
MirallConfigFile cfg;
QStringList re;
QString themePath = cfg.configPath();
// create the original ownCloud config path out of the theme path
// by removing the theme folder and append ownCloud.
QString oCPath = themePath;
if( oCPath.endsWith(QLatin1Char('/')) ) {
oCPath.truncate( oCPath.length()-1 );
}
oCPath = oCPath.left( oCPath.lastIndexOf('/'));
themePath += QLatin1String( "folders");
oCPath += QLatin1String( "/ownCloud/folders" );
qDebug() << "Migrator: theme-path: " << themePath;
qDebug() << "Migrator: ownCloud path: " << oCPath;
// get a dir listing of the ownCloud folder definitions and copy
// them over to the theme dir
QDir oCDir(oCPath);
oCDir.setFilter( QDir::Files );
QStringList files = oCDir.entryList();
foreach( const QString& file, files ) {
QString escapedAlias = FolderMan::instance()->escapeAlias(file);
QString themeFile = themePath + QDir::separator() + file;
QString oCFile = oCPath+QDir::separator()+file;
if( QFile::copy( oCFile, themeFile ) ) {
re.append(file);
qDebug() << "Migrator: Folder definition migrated: " << file;
// fix the connection entry of the folder definition
QSettings settings(themeFile, QSettings::IniFormat);
settings.beginGroup( escapedAlias );
settings.setValue(QLatin1String("connection"), Theme::instance()->appName());
settings.sync();
}
}
return re;
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* 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; version 2 of the License.
*
* 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 ACCOUNTMIGRATOR_H
#define ACCOUNTMIGRATOR_H
#include <QStringList>
namespace Mirall {
class AccountMigrator {
public:
explicit AccountMigrator();
/**
* @brief migrateFolderDefinitons - migrate the folder definition files
* @return the list of migrated folder definitions
*/
QStringList migrateFolderDefinitons();
signals:
public slots:
};
}
#endif // ACCOUNTMIGRATOR_H

View File

@@ -713,7 +713,7 @@ void AccountSettings::slotIgnoreFilesEditor()
_ignoreEditor->setAttribute( Qt::WA_DeleteOnClose, true );
_ignoreEditor->open();
} else {
Utility::raiseDialog(_ignoreEditor);
ownCloudGui::raiseDialog(_ignoreEditor);
}
}

View File

@@ -13,10 +13,13 @@
*/
#include "mirall/folderman.h"
#include "mirall/account.h"
#include "mirall/mirallconfigfile.h"
#include "mirall/folder.h"
#include "mirall/syncresult.h"
#include "mirall/theme.h"
#include "mirall/accountmigrator.h"
#include <neon/ne_socket.h>
@@ -147,6 +150,15 @@ int FolderMan::setupFolders()
dir.setFilter(QDir::Files | QDir::Hidden);
QStringList list = dir.entryList();
if( list.count() == 0 ) {
// maybe the account was just migrated.
Account *acc = AccountManager::instance()->account();
if ( acc && acc->wasMigrated() ) {
AccountMigrator accMig;
list = accMig.migrateFolderDefinitons();
}
}
foreach ( const QString& alias, list ) {
Folder *f = setupFolderFromConfigFile( alias );
if( f ) {

View File

@@ -83,6 +83,8 @@ public:
void removeMonitorPath( const QString& alias, const QString& path );
void addMonitorPath( const QString& alias, const QString& path );
QString escapeAlias( const QString& ) const;
signals:
/**
* signal to indicate a folder named by alias has changed its sync state.
@@ -130,7 +132,6 @@ private:
// Escaping of the alias which is used in QSettings AND the file
// system, thus need to be escaped.
QString escapeAlias( const QString& ) const;
QString unescapeAlias( const QString& ) const;
void removeFolder( const QString& );

View File

@@ -12,6 +12,7 @@
*/
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkProxy>
#include <QAuthenticator>
#include <QSslConfiguration>
@@ -19,6 +20,8 @@
#include "mirall/cookiejar.h"
#include "mirall/mirallaccessmanager.h"
#include "mirall/utility.h"
#include "mirall/authenticationdialog.h"
namespace Mirall
{
@@ -33,8 +36,11 @@ MirallAccessManager::MirallAccessManager(QObject* parent)
setProxy(proxy);
#endif
setCookieJar(new CookieJar);
QObject::connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
}
QNetworkReply* MirallAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData)
@@ -60,5 +66,27 @@ void MirallAccessManager::slotProxyAuthenticationRequired(const QNetworkProxy &p
authenticator->setPassword(proxy.password());
}
}
void MirallAccessManager::slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
{
// do not handle 401 created by the networkjobs. We may want
// to eventually exempt some, but for now we need
// it only for other things, e.g. the browser. Would we handle
// network jobs, this would break the wizard logic
if (reply->property("doNotHandleAuth").toBool()) {
return;
}
QUrl url = reply->url();
// show only scheme, host and port
QUrl reducedUrl;
reducedUrl.setScheme(url.scheme());
reducedUrl.setHost(url.host());
reducedUrl.setPort(url.port());
AuthenticationDialog dialog(authenticator->realm(), reducedUrl.toString());
if (dialog.exec() == QDialog::Accepted) {
authenticator->setUser(dialog.user());
authenticator->setPassword(dialog.password());
}
}
} // ns Mirall

View File

@@ -31,6 +31,8 @@ protected:
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData = 0);
protected slots:
void slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
};
} // ns Mirall

View File

@@ -57,6 +57,7 @@ void AbstractNetworkJob::setReply(QNetworkReply *reply)
if (_reply) {
_reply->deleteLater();
}
reply->setProperty("doNotHandleAuth", true);
_reply = reply;
}

View File

@@ -21,6 +21,7 @@
#include "mirall/owncloudsetupwizard.h"
#if defined(Q_OS_MAC)
# include "mirall/settingsdialogmac.h"
# include "macwindow.h" // qtmacgoodies
#else
# include "mirall/settingsdialog.h"
#endif
@@ -33,6 +34,10 @@
#include <QMessageBox>
#include <QSignalMapper>
#if defined(Q_OS_X11)
#include <QX11Info>
#endif
namespace Mirall {
ownCloudGui::ownCloudGui(Application *parent) :
@@ -111,6 +116,14 @@ void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
if( reason == QSystemTrayIcon::Trigger ) {
slotOpenSettingsDialog(true); // start settings if config is existing.
}
#else
// On Mac, if the settings dialog is already visible but hidden
// by other applications, this will bring it to the front.
if( reason == QSystemTrayIcon::Trigger ) {
if (!_settingsDialog.isNull() && _settingsDialog->isVisible()) {
slotShowSettings();
}
}
#endif
}
@@ -475,7 +488,7 @@ void ownCloudGui::slotShowSettings()
_settingsDialog->show();
}
_settingsDialog->setGeneralErrors( _startupFails );
Utility::raiseDialog(_settingsDialog.data());
ownCloudGui::raiseDialog(_settingsDialog.data());
}
void ownCloudGui::slotShowSyncProtocol()
@@ -503,7 +516,7 @@ void ownCloudGui::slotToggleLogBrowser()
if (_logBrowser->isVisible() ) {
_logBrowser->hide();
} else {
Utility::raiseDialog(_logBrowser);
ownCloudGui::raiseDialog(_logBrowser);
}
}
@@ -519,5 +532,35 @@ void ownCloudGui::slotHelp()
QDesktopServices::openUrl(QUrl(Theme::instance()->helpUrl()));
}
void ownCloudGui::raiseDialog( QWidget *raiseWidget )
{
if( raiseWidget && raiseWidget->parentWidget() == 0) {
// Qt has a bug which causes parent-less dialogs to pop-under.
raiseWidget->showNormal();
raiseWidget->raise();
raiseWidget->activateWindow();
}
#if defined(Q_OS_MAC)
// viel hilft viel ;-)
MacWindow::bringToFront(raiseWidget);
#endif
#if defined(Q_OS_X11)
WId wid = widget->winId();
NETWM::init();
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = NETWM::NET_ACTIVE_WINDOW;
e.xclient.display = QX11Info::display();
e.xclient.window = wid;
e.xclient.format = 32;
e.xclient.data.l[0] = 2;
e.xclient.data.l[1] = QX11Info::appTime();
e.xclient.data.l[2] = 0;
e.xclient.data.l[3] = 0l;
e.xclient.data.l[4] = 0l;
#endif
}
} // end namespace

View File

@@ -43,6 +43,8 @@ public:
bool checkAccountExists(bool openSettings);
static void raiseDialog( QWidget *raiseWidget );
signals:
void setupProxy();

View File

@@ -337,8 +337,15 @@ bool OwncloudPropagator::localFileNameClash( const QString& relFile )
QFileInfo fileInfo(file);
if (!fileInfo.exists()) {
re = false;
qDebug() << Q_FUNC_INFO << "No valid fileinfo";
} else {
re = ( ! fileInfo.canonicalFilePath().endsWith(relFile, Qt::CaseSensitive) );
// Need to normalize to composited form because of
// https://bugreports.qt-project.org/browse/QTBUG-39622
const QString cName = fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_C);
// qDebug() << Q_FUNC_INFO << "comparing " << cName << " with " << file;
bool equal = (file == cName);
re = (!equal && ! cName.endsWith(relFile, Qt::CaseSensitive) );
// qDebug() << Q_FUNC_INFO << "Returning for localFileNameClash: " << re;
}
#elif defined(Q_OS_WIN)
const QString file( _localDir + relFile );

View File

@@ -144,6 +144,8 @@ void OwncloudSetupWizard::slotDetermineAuthType(const QString &urlString)
}
Account *account = _ocWizard->account();
account->setUrl(url);
// Set fake credentials beforfe we check what credidential it actually is.
account->setCredentials(CredentialsFactory::create("dummy"));
CheckServerJob *job = new CheckServerJob(_ocWizard->account(), false, this);
job->setIgnoreCredentialFailure(true);
connect(job, SIGNAL(instanceFound(QUrl,QVariantMap)), SLOT(slotOwnCloudFoundAuth(QUrl,QVariantMap)));

View File

@@ -124,6 +124,16 @@ QPixmap ownCloudTheme::wizardHeaderLogo() const
}
#endif
QString ownCloudTheme::appName() const
{
return QLatin1String("owncloud");
}
QString ownCloudTheme::appNameGUI() const
{
return QLatin1String("ownCloud");
}
}

View File

@@ -33,6 +33,9 @@ public:
QIcon trayFolderIcon( const QString& ) const;
QIcon folderDisabledIcon() const;
QIcon applicationIcon() const;
QString appName() const;
QString appNameGUI() const;
QVariant customMedia(CustomMediaType type);
QString helpUrl() const;

View File

@@ -328,8 +328,7 @@ void PropagateNeonJob::limitBandwidth(qint64 progress, qint64 bandwidth_limit)
// -bandwidth_limit is the % of bandwidth
int64_t wait_time = -diff * (1 + 100.0 / bandwidth_limit);
if (wait_time > 0) {
Mirall::Utility::usleep(wait_time);
Mirall::Utility::usleep(qMin(wait_time, int64_t(1000000*10)));
}
}
_lastTime.start();
@@ -397,24 +396,39 @@ void PropagateDownloadFileLegacy::install_content_reader( ne_request *req, void
if (etag.isEmpty()) {
qDebug() << Q_FUNC_INFO << "No E-Tag reply by server, considering it invalid" << ne_get_response_header(req, "etag");
that->errorString = tr("No E-Tag received from server, check Proxy/Gateway");
ne_set_error(that->_propagator->_session, "%s", that->errorString.toUtf8().data());
ne_add_response_body_reader( req, do_not_accept,
do_not_download_content_reader,
(void*) that );
that->abortTransfer(req, tr("No E-Tag received from server, check Proxy/Gateway"));
return;
} else if (!that->_expectedEtagForResume.isEmpty() && that->_expectedEtagForResume != etag) {
qDebug() << Q_FUNC_INFO << "We received a different E-Tag for resuming!"
<< QString::fromLatin1(that->_expectedEtagForResume.data()) << "vs"
<< QString::fromLatin1(etag.data());
that->errorString = tr("We received a different E-Tag for resuming. Retrying next time.");
ne_set_error(that->_propagator->_session, "%s", that->errorString.toUtf8().data());
ne_add_response_body_reader( req, do_not_accept,
do_not_download_content_reader,
(void*) that );
that->abortTransfer(req, tr("We received a different E-Tag for resuming. Retrying next time."));
return;
}
quint64 start = 0;
QByteArray ranges = ne_get_response_header(req, "content-range");
if (!ranges.isEmpty()) {
QRegExp rx("bytes (\\d+)-");
if (rx.indexIn(ranges) >= 0) {
start = rx.cap(1).toULongLong();
}
}
if (start != that->_resumeStart) {
qDebug() << Q_FUNC_INFO << "Wrong content-range: "<< ranges << " while expecting start was" << that->_resumeStart;
if (start == 0) {
// device don't support range, just stry again from scratch
that->_file->close();
if (!that->_file->open(QIODevice::WriteOnly)) {
that->abortTransfer(req, that->_file->errorString());
return;
}
} else {
that->abortTransfer(req, tr("Server returned wrong content-range"));
return;
}
}
const char *enc = ne_get_response_header( req, "Content-Encoding" );
qDebug("Content encoding ist <%s> with status %d", enc ? enc : "empty",
@@ -431,6 +445,16 @@ void PropagateDownloadFileLegacy::install_content_reader( ne_request *req, void
}
}
void PropagateDownloadFileLegacy::abortTransfer(ne_request* req, const QString& error)
{
errorString = error;
ne_set_error(_propagator->_session, "%s", errorString.toUtf8().data());
ne_add_response_body_reader( req, do_not_accept,
do_not_download_content_reader,
this);
}
void PropagateDownloadFileLegacy::notify_status_cb(void* userdata, ne_session_status status,
const ne_session_status_info* info)
{
@@ -521,6 +545,7 @@ void PropagateDownloadFileLegacy::start()
ne_add_request_header(req.data(), "Range", rangeRequest.constData());
ne_add_request_header(req.data(), "Accept-Ranges", "bytes");
qDebug() << "Retry with range " << rangeRequest;
_resumeStart = done;
}
/* hook called before the content is parsed to set the correct reader,

View File

@@ -53,13 +53,14 @@ class PropagateDownloadFileLegacy: public PropagateNeonJob {
Q_OBJECT
public:
explicit PropagateDownloadFileLegacy(OwncloudPropagator* propagator,const SyncFileItem& item)
: PropagateNeonJob(propagator, item), _file(0) {}
: PropagateNeonJob(propagator, item), _file(0), _resumeStart(0) {}
void start();
private:
QFile *_file;
QScopedPointer<ne_decompress, ScopedPointerHelpers> _decompress;
QString errorString;
QByteArray _expectedEtagForResume;
quint64 _resumeStart;
static int do_not_accept (void *userdata, ne_request *req, const ne_status *st)
{
@@ -78,6 +79,9 @@ private:
static void install_content_reader( ne_request *req, void *userdata, const ne_status *status );
static void notify_status_cb(void* userdata, ne_session_status status,
const ne_session_status_info* info);
/** To be called from install_content_reader if we want to abort the transfer */
void abortTransfer(ne_request *req, const QString &error);
};
}

View File

@@ -27,7 +27,7 @@
namespace Mirall {
static uint chunkSize() {
static qint64 chunkSize() {
static uint chunkSize;
if (!chunkSize) {
chunkSize = qgetenv("OWNCLOUD_CHUNK_SIZE").toUInt();
@@ -229,7 +229,7 @@ void PropagateUploadFileQNAM::startNextChunk()
currentChunkSize = chunkSize();
}
}
device = new ChunkDevice(_file, chunkSize() * sendingChunk, currentChunkSize);
device = new ChunkDevice(_file, chunkSize() * quint64(sendingChunk), currentChunkSize);
} else {
device = _file;
}
@@ -303,7 +303,7 @@ void PropagateUploadFileQNAM::slotPutFinished()
}
if (Utility::qDateTimeToTime_t(fi.lastModified()) != _item._modtime) {
/* Uh oh: The local file has changed during upload */
qDebug() << "The local file has changed during upload:" << _item._modtime << "!=" << Utility::qDateTimeToTime_t(fi.lastModified()) << fi.lastModified();
_propagator->_activeJobs--;
done(SyncFileItem::SoftError, tr("Local file changed during sync."));
// FIXME: the legacy code was retrying for a few seconds.
@@ -402,6 +402,7 @@ void GETFileJob::start() {
setReply(davRequest("GET", path(), req));
setupConnections(reply());
reply()->setReadBufferSize(128 * 1024);
if( reply()->error() != QNetworkReply::NoError ) {
qWarning() << Q_FUNC_INFO << " Network error: " << reply()->errorString();
@@ -438,6 +439,34 @@ void GETFileJob::slotMetaDataChanged()
reply()->abort();
return;
}
quint64 start = 0;
QByteArray ranges = parseEtag(reply()->rawHeader("Content-Range"));
if (!ranges.isEmpty()) {
QRegExp rx("bytes (\\d+)-");
if (rx.indexIn(ranges) >= 0) {
start = rx.cap(1).toULongLong();
}
}
if (start != _resumeStart) {
qDebug() << Q_FUNC_INFO << "Wrong content-range: "<< ranges << " while expecting start was" << _resumeStart;
if (start == 0) {
// device don't support range, just stry again from scratch
_device->close();
if (!_device->open(QIODevice::WriteOnly)) {
_errorString = _device->errorString();
_errorStatus = SyncFileItem::NormalError;
reply()->abort();
return;
}
} else {
_errorString = tr("Server returned wrong content-range");
_errorStatus = SyncFileItem::NormalError;
reply()->abort();
return;
}
}
}
void GETFileJob::slotReadyRead()
@@ -544,7 +573,7 @@ void PropagateDownloadFileQNAM::start()
_job = new GETFileJob(AccountManager::instance()->account(),
_propagator->_remoteFolder + _item._file,
&_tmpFile, headers, expectedEtagForResume);
&_tmpFile, headers, expectedEtagForResume, _startSize);
_job->setTimeout(_propagator->httpTimeout() * 1000);
connect(_job, SIGNAL(finishedSignal()), this, SLOT(slotGetFinished()));
connect(_job, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(slotDownloadProgress(qint64,qint64)));

View File

@@ -105,20 +105,21 @@ private slots:
class GETFileJob : public AbstractNetworkJob {
Q_OBJECT
QIODevice* _device;
QFile* _device;
QMap<QByteArray, QByteArray> _headers;
QString _errorString;
QByteArray _expectedEtagForResume;
quint64 _resumeStart;
SyncFileItem::Status _errorStatus;
public:
// DOES NOT take owncership of the device.
explicit GETFileJob(Account* account, const QString& path, QIODevice *device,
explicit GETFileJob(Account* account, const QString& path, QFile *device,
const QMap<QByteArray, QByteArray> &headers, QByteArray expectedEtagForResume,
QObject* parent = 0)
quint64 resumeStart, QObject* parent = 0)
: AbstractNetworkJob(account, path, parent),
_device(device), _headers(headers), _expectedEtagForResume(expectedEtagForResume),
_errorStatus(SyncFileItem::NoStatus) {}
_resumeStart(resumeStart), _errorStatus(SyncFileItem::NoStatus) {}
virtual void start();
virtual bool finished() {

View File

@@ -46,6 +46,13 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
_ui->setupUi(this);
// People perceive this as a Window, so also make Ctrl+W work
QAction *closeWindowAction = new QAction(this);
closeWindowAction->setShortcut(QKeySequence("Ctrl+W"));
connect(closeWindowAction, SIGNAL(triggered()), SLOT(accept()));
addAction(closeWindowAction);
setObjectName("Settings"); // required as group for saveGeometry call
setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI()));

View File

@@ -30,8 +30,13 @@ SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent)
// Emulate dialog behavior: Escape means close
QAction *closeDialogAction = new QAction(this);
closeDialogAction->setShortcut(QKeySequence(Qt::Key_Escape));
connect(closeDialogAction, SIGNAL(triggered()), SLOT(close()));
addAction(closeDialogAction);
// People perceive this as a Window, so also make Ctrl+W work
QAction *closeWindowAction = new QAction(this);
closeWindowAction->setShortcut(QKeySequence(Qt::Key_Escape));
closeWindowAction->setShortcut(QKeySequence("Ctrl+W"));
connect(closeWindowAction, SIGNAL(triggered()), SLOT(close()));
addAction(closeWindowAction);

View File

@@ -176,6 +176,11 @@ void SslButton::updateAccountInfo(Account *account)
} else {
setVisible(true);
}
if(QMenu *oldMenu = menu()) {
oldMenu->hide(); // Need to be hidden because the QToolButton would be left in invalid state if the menu is deleted while it is visible
setMenu(0);
oldMenu->deleteLater(); // setMenu do not delete the previous menu.
}
if (account->url().scheme() == QLatin1String("https")) {
setIcon(QIcon(QPixmap(":/mirall/resources/lock-https.png")));
QSslCipher cipher = account->sslConfiguration().sessionCipher();
@@ -212,7 +217,6 @@ void SslButton::updateAccountInfo(Account *account)
} else {
setIcon(QIcon(QPixmap(":/mirall/resources/lock-http.png")));
setToolTip(tr("This connection is NOT secure as it is not encrypted.\n"));
setMenu(0);
}
}

View File

@@ -164,18 +164,6 @@ QByteArray Utility::userAgentString()
.toLatin1();
}
void Utility::raiseDialog( QWidget *raiseWidget )
{
#ifndef TOKEN_AUTH_ONLY
if( raiseWidget && raiseWidget->parentWidget() == 0) {
// Qt has a bug which causes parent-less dialogs to pop-under.
raiseWidget->showNormal();
raiseWidget->raise();
raiseWidget->activateWindow();
}
#endif
}
bool Utility::hasLaunchOnStartup(const QString &appName)
{
return hasLaunchOnStartup_private(appName);

View File

@@ -36,7 +36,6 @@ namespace Utility
OWNCLOUDSYNC_EXPORT QString octetsToString( qint64 octets );
OWNCLOUDSYNC_EXPORT QString platform();
OWNCLOUDSYNC_EXPORT QByteArray userAgentString();
OWNCLOUDSYNC_EXPORT void raiseDialog(QWidget *);
OWNCLOUDSYNC_EXPORT bool hasLaunchOnStartup(const QString &appName);
OWNCLOUDSYNC_EXPORT void setLaunchOnStartup(const QString &appName, const QString& guiName, bool launch);
OWNCLOUDSYNC_EXPORT qint64 freeDiskSpace(const QString &path, bool *ok = 0);

View File

@@ -16,6 +16,7 @@
#include <QDir>
#include <QFileDialog>
#include <QUrl>
#include <QTimer>
#include <QPushButton>
#include <QMessageBox>
@@ -145,9 +146,12 @@ void OwncloudSetupPage::initializePage()
if (Theme::instance()->overrideServerUrl().isEmpty()) {
_ui.leUrl->setFocus();
} else {
setVisible(false);
setCommitPage(true);
validatePage();
setVisible(false);
// because the wizard will call show on us right after this call, we need to hide in the
// next event loop iteration.
QTimer::singleShot(0, this, SLOT(hide()));
}
}

View File

@@ -161,7 +161,6 @@ void OwncloudWizard::slotCurrentPageChanged( int id )
if( id == WizardCommon::Page_ServerSetup ) {
emit clearPendingRequests();
_setupPage->initializePage();
}
if( id == WizardCommon::Page_Result ) {