diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 8451c6b9e6..d16bae32b9 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -272,9 +272,8 @@ void AccountSettings::slotEncryptionFlagError(const QByteArray& fileId, int http void AccountSettings::slotLockFolderSuccess(const QByteArray& fileId, const QByteArray &token) { - qCInfo(lcAccountSettings()) << "Locked Successfully"; - FolderMetadata emptyMetadata(accountsState()->account()); - +// FolderMetadata emptyMetadata(accountsState()->account()); + qCInfo(lcAccountSettings()) << "Folder Locked Successfully" << fileId << token; auto unlockJob = new UnlockEncryptFolderApiJob(accountsState()->account(), fileId, token); connect(unlockJob, &UnlockEncryptFolderApiJob::success, this, &AccountSettings::slotUnlockFolderSuccess); diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 7aa3e331e6..e12d6a2501 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -1026,7 +1026,7 @@ UnlockEncryptFolderApiJob::UnlockEncryptFolderApiJob(const AccountPtr& account, const QByteArray& fileId, const QByteArray& token, QObject* parent) -: AbstractNetworkJob(account, baseUrl() + QStringLiteral("lock/") + fileId, parent), _fileId(fileId), _token(token) +: AbstractNetworkJob(account, baseUrl() + QStringLiteral("unlock/") + fileId, parent), _fileId(fileId), _token(token) { } @@ -1035,17 +1035,20 @@ void UnlockEncryptFolderApiJob::start() QNetworkRequest req; req.setRawHeader("OCS-APIREQUEST", "true"); QUrl url = Utility::concatUrlPath(account()->url(), path()); - QList> params = { - qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")), - }; - url.setQueryItems(params); - // TODO: This should be a data parameter. - // qMakePair(QString::fromLatin1("token"), _token) + QByteArray bufferData("token=" + _token); + _tokenBuf = new QBuffer(); + _tokenBuf->setData(bufferData); + + qCInfo(lcCseJob()) << "================"; + qCInfo(lcCseJob()) << "unlocking the folder with id" << _fileId << "with token" << _token; + qCInfo(lcCseJob()) << url; + qCInfo(lcCseJob()) << bufferData; + qCInfo(lcCseJob()) << "==================="; + sendRequest("POST", url, req, _tokenBuf); - qCInfo(lcCseJob()) << "unlocking the folder with id" << _fileId << "as encrypted"; - sendRequest("DELETE", url, req); AbstractNetworkJob::start(); + qCInfo(lcCseJob()) << "Starting the request to unlock."; } bool UnlockEncryptFolderApiJob::finished() @@ -1053,6 +1056,7 @@ bool UnlockEncryptFolderApiJob::finished() int retCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (retCode != 200) { qCInfo(lcCseJob()) << "error unlocking file" << path() << errorString() << retCode; + qCInfo(lcCseJob()) << "Full Error Log" << reply()->readAll(); emit error(_fileId, retCode); return true; } diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index 04f54f562d..a5484cfdfc 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -243,6 +243,7 @@ signals: private: QByteArray _fileId; QByteArray _token; + QBuffer *_tokenBuf; }; class OWNCLOUDSYNC_EXPORT StoreMetaDataApiJob : public AbstractNetworkJob