Get rid of now unused GetFolderEncryptStatusJob
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 8 Dec 2020 15:23:31 +0000 (16:23 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:23 +0000 (10:59 +0100)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/clientsideencryptionjobs.cpp
src/libsync/clientsideencryptionjobs.h

index 505bd99f5af8e741b1fd3873345865a0fffcd61e..490f9f077c39b20f0c05dbe3357081d76b85ddca 100644 (file)
@@ -24,103 +24,6 @@ Q_LOGGING_CATEGORY(lcCseJob, "nextcloud.sync.networkjob.clientsideencrypt", QtIn
 
 namespace OCC {
 
-GetFolderEncryptStatusJob::GetFolderEncryptStatusJob(const AccountPtr& account, const QString& folder, QObject *parent)
-       : OCC::AbstractNetworkJob(account, QStringLiteral("remote.php/webdav"), parent), _folder(folder)
-{
-}
-
-QString GetFolderEncryptStatusJob::folder() const
-{
-    return _folder;
-}
-
-void GetFolderEncryptStatusJob::start()
-{
-       QNetworkRequest req;
-       req.setPriority(QNetworkRequest::HighPriority);
-       req.setRawHeader("OCS-APIREQUEST", "true");
-    req.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/xml"));
-    req.setRawHeader("Depth", "1");
-
-       QByteArray xml = R"(<d:propfind xmlns:d="DAV:"> <d:prop xmlns:nc="http://nextcloud.org/ns"> <nc:is-encrypted/> </d:prop> </d:propfind>)";
-       auto *buf = new QBuffer(this);
-       buf->setData(xml);
-       buf->open(QIODevice::ReadOnly);
-  QString tmpPath = path() + (!_folder.isEmpty() ? "/" + _folder : QString());
-       sendRequest("PROPFIND", Utility::concatUrlPath(account()->url(), tmpPath), req, buf);
-
-       AbstractNetworkJob::start();
-}
-
-bool GetFolderEncryptStatusJob::finished()
-{
-    qCInfo(lcCseJob()) << "GetFolderEncryptStatus of" << reply()->request().url() << "finished with status"
-                          << reply()->error()
-                          << (reply()->error() == QNetworkReply::NoError ? QLatin1String("") : errorString());
-
-    int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
-
-    if (http_result_code == 207) {
-        // Parse DAV response
-        QXmlStreamReader reader(reply());
-        reader.addExtraNamespaceDeclaration(QXmlStreamNamespaceDeclaration("d", "DAV:"));
-
-        /* Example Xml
-        <?xml version="1.0"?>
-          <d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
-            <d:response>
-              <d:href>/remote.php/webdav/</d:href>
-              <d:propstat>
-                <d:prop>
-                  <nc:is-encrypted>0</nc:is-encrypted>
-                </d:prop>
-                <d:status>HTTP/1.1 200 OK</d:status>
-              </d:propstat>
-            </d:response>
-          </d:multistatus>
-        */
-        QString base = account()->url().path();
-        if (base.endsWith(QLatin1Char('/')))
-            base.chop(1);
-
-        QString currFile;
-        int currEncryptedStatus = -1;
-        QHash<QString, bool> folderStatus;
-        while (!reader.atEnd()) {
-            auto type = reader.readNext();
-            if (type == QXmlStreamReader::StartElement) {
-                if (reader.name() == QLatin1String("href")) {
-                    // If the current file is not a folder, ignore it.
-                    currFile = QUrl::fromPercentEncoding(reader.readElementText(QXmlStreamReader::SkipChildElements).toUtf8());
-                    currFile.remove(base + QLatin1String("/remote.php/webdav/"));
-                    if (!currFile.endsWith('/'))
-                        currFile.clear();
-                    currEncryptedStatus = -1;
-                }
-                if (!currFile.isEmpty() && reader.name() == QLatin1String("is-encrypted")) {
-                  currEncryptedStatus = (bool) reader.readElementText(QXmlStreamReader::SkipChildElements).toInt();
-                }
-            }
-
-            if (!currFile.isEmpty() && currEncryptedStatus != -1) {
-              folderStatus.insert(currFile, currEncryptedStatus);
-              currFile.clear();
-              currEncryptedStatus = -1;
-            }
-        }
-
-        emit encryptStatusReceived(folderStatus);
-        emit encryptStatusFolderReceived(_folder, folderStatus.value(_folder + QLatin1Char('/')));
-    } else {
-        qCWarning(lcCseJob()) << "*not* successful, http result code is" << http_result_code
-                                 << (http_result_code == 302 ? reply()->header(QNetworkRequest::LocationHeader).toString() : QLatin1String(""));
-        emit encryptStatusError(http_result_code);
-        // emit finishedWithError(reply());
-    }
-    return true;
-}
-
-
 GetMetadataApiJob::GetMetadataApiJob(const AccountPtr& account,
                                     const QByteArray& fileId,
                                     QObject* parent)
index 4a78db8c725924197bb94c3c0eb36bff9e386bea..a64a59b43abcb413427c386d44a6206e4a35f536 100644 (file)
@@ -277,30 +277,5 @@ private:
     QByteArray _fileId;
 };
 
-/* I cant use the propfind network job because it defaults to the
- * wrong dav url.
- */
-class OWNCLOUDSYNC_EXPORT GetFolderEncryptStatusJob : public AbstractNetworkJob
-{
-       Q_OBJECT
-public:
-       explicit GetFolderEncryptStatusJob (const AccountPtr &account, const QString& folder, QObject *parent = nullptr);
-
-    QString folder() const;
-
-public slots:
-       void start() override;
-
-protected:
-       bool finished() override;
-
-signals:
-    void encryptStatusReceived(const QHash<QString, bool> folderMetadata2EncryptionStatus);
-    void encryptStatusFolderReceived(const QString &folder, bool isEncrypted);
-       void encryptStatusError(int statusCode);
-private:
-  QString _folder;
-};
-
 }
 #endif