static const char propertyParentIndexC[] = "oc_parentIndex";
static const char propertyPermissionMap[] = "oc_permissionMap";
+static const char propertyEncryptionMap[] = "nc_encryptionMap";
static QString removeTrailingSlash(const QString &s)
{
auto *job = new LsColJob(_accountState->account(), path, this);
info->_fetchingJob = job;
- job->setProperties(QList<QByteArray>() << "resourcetype"
- << "http://owncloud.org/ns:size"
- << "http://owncloud.org/ns:permissions"
- << "http://owncloud.org/ns:fileid");
+ auto props = QList<QByteArray>() << "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,
this, &FolderStatusModel::slotLscolFinishedWithError);
connect(job, &LsColJob::directoryListingIterated,
this, &FolderStatusModel::slotGatherPermissions);
+ connect(job, &LsColJob::directoryListingIterated,
+ this, &FolderStatusModel::slotGatherEncryptionStatus);
job->start();
job->setProperty(propertyPermissionMap, permissionMap);
}
+void FolderStatusModel::slotGatherEncryptionStatus(const QString &href, const QMap<QString, QString> &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<LsColJob *>(sender());
}
}
const auto permissionMap = job->property(propertyPermissionMap).toMap();
+ const auto encryptionMap = job->property(propertyEncryptionMap).toMap();
QStringList sortedSubfolders = list;
if (!sortedSubfolders.isEmpty())
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;
QVector<SubFolderInfo> _subs;
qint64 _size = 0;
bool _isExternal = false;
+ bool _isEncrypted = false;
bool _fetched = false; // If we did the LSCOL for this folder already
QPointer<LsColJob> _fetchingJob; // Currently running LsColJob
private slots:
void slotUpdateDirectories(const QStringList &);
void slotGatherPermissions(const QString &name, const QMap<QString, QString> &properties);
+ void slotGatherEncryptionStatus(const QString &href, const QMap<QString, QString> &properties);
void slotLscolFinishedWithError(QNetworkReply *r);
void slotFolderSyncStateChange(Folder *f);
void slotFolderScheduleQueueChanged();