From: Kevin Ottens Date: Thu, 20 Aug 2020 12:13:56 +0000 (+0200) Subject: Disable context menu actions for E2EE files and folders X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~217^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=07388e0f220d8960bf8f727c6ff40a682574c155;p=nextcloud-desktop.git Disable context menu actions for E2EE files and folders Those files and folders are not shareable and the "Edit" or "Open in browser" actions will lead to showing an error in the web GUI. No need to lead users there so just disable them. Signed-off-by: Kevin Ottens --- diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 47f03425a..f58c38e4e 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -718,11 +718,11 @@ void SocketApi::command_GET_STRINGS(const QString &argument, SocketListener *lis listener->sendMessage(QString("GET_STRINGS:END")); } -void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener) +void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener, bool enabled) { auto record = fileData.journalRecord(); bool isOnTheServer = record.isValid(); - auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:"); + auto flagString = isOnTheServer && enabled ? QLatin1String("::") : QLatin1String(":d:"); auto capabilities = fileData.folder->accountState()->account()->capabilities(); auto theme = Theme::instance(); @@ -798,7 +798,8 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe bool hasSeveralFiles = argument.contains(QLatin1Char('\x1e')); // Record Separator FileData fileData = hasSeveralFiles ? FileData{} : FileData::get(argument); bool isOnTheServer = fileData.journalRecord().isValid(); - auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:"); + const auto isE2eEncryptedPath = fileData.journalRecord()._isE2eEncrypted || !fileData.journalRecord()._e2eMangledName.isEmpty(); + auto flagString = isOnTheServer && !isE2eEncryptedPath ? QLatin1String("::") : QLatin1String(":d:"); if (fileData.folder && fileData.folder->accountState()->isConnected()) { DirectEditor* editor = getDirectEditorForLocalFile(fileData.localPath); @@ -809,7 +810,7 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser")); } - sendSharingContextMenuOptions(fileData, listener); + sendSharingContextMenuOptions(fileData, listener, !isE2eEncryptedPath); } listener->sendMessage(QString("GET_MENU_ITEMS:END")); } diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h index 4822629d5..ddacc5620 100644 --- a/src/gui/socketapi.h +++ b/src/gui/socketapi.h @@ -120,7 +120,7 @@ private: Q_INVOKABLE void command_GET_STRINGS(const QString &argument, SocketListener *listener); // Sends the context menu options relating to sharing to listener - void sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener); + void sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener, bool enabled); /** Send the list of menu item. (added in version 1.1) * argument is a list of files for which the menu should be shown, separated by '\x1e'