From: Kevin Ottens Date: Mon, 7 Dec 2020 18:12:21 +0000 (+0100) Subject: FolderStatusModel LSCOL job now gets the is-encrypted property X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~40 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8e5a8d9fb9fa5c882d8ab047e36f538736977617;p=nextcloud-desktop.git FolderStatusModel LSCOL job now gets the is-encrypted property Signed-off-by: Kevin Ottens --- diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 0ebab24b8..2543a48d7 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -32,6 +32,7 @@ Q_LOGGING_CATEGORY(lcFolderStatus, "nextcloud.gui.folder.model", QtInfoMsg) static const char propertyParentIndexC[] = "oc_parentIndex"; static const char propertyPermissionMap[] = "oc_permissionMap"; +static const char propertyEncryptionMap[] = "nc_encryptionMap"; static QString removeTrailingSlash(const QString &s) { @@ -581,10 +582,14 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent) auto *job = new LsColJob(_accountState->account(), path, this); info->_fetchingJob = job; - job->setProperties(QList() << "resourcetype" - << "http://owncloud.org/ns:size" - << "http://owncloud.org/ns:permissions" - << "http://owncloud.org/ns:fileid"); + auto props = QList() << "resourcetype" + << "http://owncloud.org/ns:size" + << "http://owncloud.org/ns:permissions" + << "http://owncloud.org/ns:fileid"; + if (_accountState->account()->capabilities().clientSideEncryptionAvailable()) { + props << "http://nextcloud.org/ns:is-encrypted"; + } + job->setProperties(props); job->setTimeout(60 * 1000); connect(job, &LsColJob::directoryListingSubfolders, @@ -593,6 +598,8 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent) this, &FolderStatusModel::slotLscolFinishedWithError); connect(job, &LsColJob::directoryListingIterated, this, &FolderStatusModel::slotGatherPermissions); + connect(job, &LsColJob::directoryListingIterated, + this, &FolderStatusModel::slotGatherEncryptionStatus); job->start(); @@ -625,6 +632,20 @@ void FolderStatusModel::slotGatherPermissions(const QString &href, const QMapsetProperty(propertyPermissionMap, permissionMap); } +void FolderStatusModel::slotGatherEncryptionStatus(const QString &href, const QMap &properties) +{ + auto it = properties.find("is-encrypted"); + if (it == properties.end()) + return; + + auto job = sender(); + auto encryptionMap = job->property(propertyEncryptionMap).toMap(); + job->setProperty(propertyEncryptionMap, QVariant()); // avoid a detach of the map while it is modified + ASSERT(!href.endsWith(QLatin1Char('/')), "LsColXMLParser::parse should remove the trailing slash before calling us."); + encryptionMap[href] = *it; + job->setProperty(propertyEncryptionMap, encryptionMap); +} + void FolderStatusModel::slotUpdateDirectories(const QStringList &list) { auto job = qobject_cast(sender()); @@ -676,6 +697,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) } } const auto permissionMap = job->property(propertyPermissionMap).toMap(); + const auto encryptionMap = job->property(propertyEncryptionMap).toMap(); QStringList sortedSubfolders = list; if (!sortedSubfolders.isEmpty()) @@ -697,6 +719,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) newInfo._pathIdx = parentInfo->_pathIdx; newInfo._pathIdx << newSubs.size(); newInfo._isExternal = permissionMap.value(removeTrailingSlash(path)).toString().contains("M"); + newInfo._isEncrypted = encryptionMap.value(removeTrailingSlash(path)).toString() == QStringLiteral("1"); newInfo._path = relativePath; SyncJournalFileRecord rec; diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index ecc13c209..147411ca9 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -66,6 +66,7 @@ public: QVector _subs; qint64 _size = 0; bool _isExternal = false; + bool _isEncrypted = false; bool _fetched = false; // If we did the LSCOL for this folder already QPointer _fetchingJob; // Currently running LsColJob @@ -126,6 +127,7 @@ public slots: private slots: void slotUpdateDirectories(const QStringList &); void slotGatherPermissions(const QString &name, const QMap &properties); + void slotGatherEncryptionStatus(const QString &href, const QMap &properties); void slotLscolFinishedWithError(QNetworkReply *r); void slotFolderSyncStateChange(Folder *f); void slotFolderScheduleQueueChanged();