Merge pull request #3802 from owncloud/alt_webdav_url2

Branding option: Alternative WebDAV URL
This commit is contained in:
Klaas Freitag 2015-09-10 17:44:46 +02:00
commit eb154de2a1
10 changed files with 66 additions and 25 deletions

View file

@ -185,15 +185,7 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
}
options->target_url = args.takeLast();
// check if the remote.php/webdav tail was added and append if not.
if(!options->target_url.endsWith("/")) {
options->target_url.append("/");
}
if( !options->target_url.contains("remote.php/webdav/")) {
options->target_url.append("remote.php/webdav/");
}
if (options->target_url.startsWith("http"))
options->target_url.replace(0, 4, "owncloud");
options->source_dir = args.takeLast();
if (!options->source_dir.endsWith('/')) {
options->source_dir.append('/');
@ -280,6 +272,21 @@ int main(int argc, char **argv) {
parseOptions( app.arguments(), &options );
AccountPtr account = Account::create();
if( !account ) {
qFatal("Could not initialize account!");
return EXIT_FAILURE;
}
// check if the webDAV path was added to the url and append if not.
if(!options.target_url.endsWith("/")) {
options.target_url.append("/");
}
if( !options.target_url.contains( account->davPath() )) {
options.target_url.append(account->davPath());
}
if (options.target_url.startsWith("http"))
options.target_url.replace(0, 4, "owncloud");
QUrl url = QUrl::fromUserInput(options.target_url);
// Order of retrieval attempt (later attempts override earlier ones):
@ -331,8 +338,6 @@ int main(int argc, char **argv) {
// take the unmodified url to pass to csync_create()
QByteArray remUrl = options.target_url.toUtf8();
AccountPtr account = Account::create();
// Find the folder and the original owncloud url
QStringList splitted = url.path().split(account->davPath());
url.setPath(splitted.value(0));

View file

@ -26,6 +26,7 @@
#include "syncfileitem.h"
#include "filesystem.h"
#include "version.h"
#include "account.h"
#include "accountstate.h"
#include <QDebug>
@ -655,7 +656,7 @@ SyncFileStatus SocketApi::fileStatus(Folder *folder, const QString& systemFileNa
if (rec._remotePerm.isNull()) {
// probably owncloud 6, that does not have permissions flag yet.
QString url = folder->remoteUrl().toString() + fileName;
if (url.contains(QLatin1String("/remote.php/webdav/Shared/"))) {
if (url.contains( folder->accountState()->account()->davPath() + QLatin1String("Shared/") )) {
status.setSharedWithMe(true);
}
} else if (rec._remotePerm.contains("S")) {

View file

@ -45,6 +45,7 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
_progressIndi(new QProgressIndicator (this))
{
_ui.setupUi(this);
_ocWizard = qobject_cast<OwncloudWizard *>(parent);
Theme *theme = Theme::instance();
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(theme->appNameGUI())));
@ -66,7 +67,6 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent)
connect(_ui.leUrl, SIGNAL(editingFinished()), SLOT(slotUrlEditFinished()));
addCertDial = new AddCertificateDialog(this);
_ocWizard = qobject_cast<OwncloudWizard *>(parent);
connect(_ocWizard,SIGNAL(needCertificate()),this,SLOT(slotAskSSLClientCertificate()));
}
@ -106,11 +106,17 @@ void OwncloudSetupPage::slotUrlChanged(const QString& url)
if (url.endsWith("index.php")) {
newUrl.chop(9);
}
if (url.endsWith("remote.php/webdav")) {
newUrl.chop(17);
}
if (url.endsWith("remote.php/webdav/")) {
newUrl.chop(18);
if( _ocWizard && _ocWizard->account() ) {
QString webDavPath = _ocWizard->account()->davPath();
if (url.endsWith(webDavPath)) {
newUrl.chop( webDavPath.length() );
}
if( webDavPath.endsWith(QLatin1Char('/')) ) {
webDavPath.chop(1); // cut off the slash
if( url.endsWith(webDavPath)) {
newUrl.chop(webDavPath.length());
}
}
}
if (newUrl != url) {
_ui.leUrl->setText(newUrl);

View file

@ -19,6 +19,7 @@
#include "creds/abstractcredentials.h"
#include "../3rdparty/certificates/p12topem.h"
#include "capabilities.h"
#include "theme.h"
#include <QSettings>
#include <QMutex>
@ -40,7 +41,7 @@ Account::Account(QObject *parent)
, _am(0)
, _credentials(0)
, _treatSslErrorsAsFailure(false)
, _davPath("remote.php/webdav/")
, _davPath( Theme::instance()->webDavPath() )
, _wasMigrated(false)
{
qRegisterMetaType<AccountPtr>("AccountPtr");
@ -60,6 +61,17 @@ Account::~Account()
delete _am;
}
QString Account::davPath() const
{
// make sure to have a trailing slash
if( !_davPath.endsWith('/') ) {
QString dp(_davPath);
dp.append('/');
return dp;
}
return _davPath;
}
void Account::setSharedThis(AccountPtr sharedThis)
{
_sharedThis = sharedThis.toWeakRef();

View file

@ -60,7 +60,12 @@ public:
class OWNCLOUDSYNC_EXPORT Account : public QObject {
Q_OBJECT
public:
QString davPath() const { return _davPath; }
/**
* @brief The possibly themed dav path for the account. It has
* a trailing slash.
* @returns the (themeable) dav path for the account.
*/
QString davPath() const;
void setDavPath(const QString&s) { _davPath = s; }
static AccountPtr create();
@ -193,7 +198,7 @@ private:
static QString _configFileName;
QByteArray _pemCertificate;
QString _pemPrivateKey;
QString _davPath; // default "remote.php/webdav/";
QString _davPath; // defaults to value from theme, might be overwritten in brandings
bool _wasMigrated;
friend class AccountManager;
};

View file

@ -300,7 +300,7 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file,QMap
}
} else {
// Remove /remote.php/webdav/folder/ from /remote.php/webdav/folder/subfile.txt
// Remove <webDAV-Url>/folder/ from <webDAV-Url>/folder/subfile.txt
file.remove(0, _lsColJob->reply()->request().url().path().length());
// remove trailing slash
while (file.endsWith('/')) {

View file

@ -368,7 +368,7 @@ void OwncloudPropagator::start(const SyncFileItemVector& items)
bool OwncloudPropagator::isInSharedDirectory(const QString& file)
{
bool re = false;
if( _remoteDir.contains("remote.php/webdav/Shared") ) {
if( _remoteDir.contains( _account->davPath() + QLatin1String("Shared") ) ) {
// The Shared directory is synced as its own sync connection
re = true;
} else {

View file

@ -249,8 +249,8 @@ public:
ne_session_s * const _session;
const QString _localDir; // absolute path to the local directory. ends with '/'
const QString _remoteDir; // path to the root of the remote. ends with '/' (include remote.php/webdav)
const QString _remoteFolder; // folder. (same as remoteDir but without remote.php/webdav)
const QString _remoteDir; // path to the root of the remote. ends with '/' (include WebDAV path)
const QString _remoteFolder; // folder. (same as remoteDir but without the WebDAV path)
SyncJournalDb * const _journal;
bool _finishedEmited; // used to ensure that finished is only emit once

View file

@ -407,6 +407,10 @@ bool Theme::wizardSelectiveSyncDefaultNothing() const
return false;
}
QString Theme::webDavPath() const
{
return QLatin1String("remote.php/webdav/");
}
} // end namespace client

View file

@ -219,6 +219,14 @@ public:
**/
virtual qint64 newBigFolderSizeLimit() const;
/**
* Alternative path on the server that provides access to the webdav capabilities
*
* Attention: Make sure that this string does NOT have a leading slash and that
* it has a trailing slash, for example "remote.php/webdav/".
*/
virtual QString webDavPath() const;
protected:
#ifndef TOKEN_AUTH_ONLY
QIcon themeIcon(const QString& name, bool sysTray = false) const;