From 4d85f1daecd8e562c5287761a3f9aeb56bc7e282 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 3 Mar 2015 16:01:41 +0100 Subject: [PATCH] setup wizard: use a PROPFIND instead of a GET on the webdav url In order to initiate the conneciton, we should not send a GET on the webdav URL because that is not a valid webdav command on a collection. Issue #2911 --- src/gui/owncloudsetupwizard.cpp | 28 +++++----------------------- src/gui/owncloudsetupwizard.h | 11 ----------- src/gui/wizard/owncloudwizard.h | 2 +- 3 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index f4709f3e5..13c3b5544 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -211,9 +211,11 @@ void OwncloudSetupWizard::testOwnCloudConnect() { AccountPtr account = _ocWizard->account(); - ValidateDavAuthJob *job = new ValidateDavAuthJob(account, this); + auto *job = new PropfindJob(account, "/", this); job->setIgnoreCredentialFailure(true); - connect(job, SIGNAL(authResult(QNetworkReply*)), SLOT(slotConnectionCheck(QNetworkReply*))); + job->setProperties(QList() << "getlastmodified"); + connect(job, SIGNAL(result(QVariantMap)), _ocWizard, SLOT(successfulStep())); + connect(job, SIGNAL(networkError(QNetworkReply*)), this, SLOT(slotConnectionCheck(QNetworkReply*))); job->start(); } @@ -249,7 +251,7 @@ void OwncloudSetupWizard::slotConnectionCheck(QNetworkReply* reply) _ocWizard->successfulStep(); break; default: - if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 403) { + if (!_ocWizard->account()->credentials()->stillValid(reply)) { msg = tr("Access forbidden by server. To verify that you have proper access, " "click here to access the service with your browser.") .arg(_ocWizard->account()->url().toString()); @@ -534,24 +536,4 @@ bool DetermineAuthTypeJob::finished() return true; } -ValidateDavAuthJob::ValidateDavAuthJob(AccountPtr account, QObject *parent) - : AbstractNetworkJob(account, QString(), parent) -{ -} - -void ValidateDavAuthJob::start() -{ - QString p = account()->davPath(); - QNetworkReply *reply = getRequest(p); - setReply(reply); - setupConnections(reply); - AbstractNetworkJob::start(); -} - -bool ValidateDavAuthJob::finished() -{ - emit authResult(reply()); - return true; -} - } // namespace OCC diff --git a/src/gui/owncloudsetupwizard.h b/src/gui/owncloudsetupwizard.h index 60a683d91..961d63f00 100644 --- a/src/gui/owncloudsetupwizard.h +++ b/src/gui/owncloudsetupwizard.h @@ -31,17 +31,6 @@ namespace OCC { class OwncloudWizard; -class ValidateDavAuthJob : public AbstractNetworkJob { - Q_OBJECT -public: - ValidateDavAuthJob(AccountPtr account, QObject *parent = 0); - void start() Q_DECL_OVERRIDE; -signals: - void authResult(QNetworkReply*); -private slots: - bool finished() Q_DECL_OVERRIDE; -}; - class DetermineAuthTypeJob : public AbstractNetworkJob { Q_OBJECT public: diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index 06515a240..ebf42f9ef 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -58,7 +58,6 @@ public: void setMultipleFoldersExist( bool ); void setConfigExists( bool ); bool configExists(); - void successfulStep(); AbstractCredentials* getCredentials() const; void raiseCertificatePopup(); @@ -72,6 +71,7 @@ public slots: void setRemoteFolder( const QString& ); void appendToConfigurationLog( const QString& msg, LogType type = LogParagraph ); void slotCurrentPageChanged( int ); + void successfulStep(); signals: void clearPendingRequests();