From ba4138a13dff47904947042b55358660ffa08026 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 19 Nov 2024 15:58:18 +0100 Subject: [PATCH] improve files explorer context menu by removing obsolete commands remove any commands related to publi share links because they either got replaced by the use of the share dialog or are better achieved by showing the share dialog Signed-off-by: Matthieu Gallien --- src/gui/socketapi/socketapi.cpp | 46 --------------------------------- src/gui/socketapi/socketapi.h | 2 -- 2 files changed, 48 deletions(-) diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index bd68063fa2978..ae32d0c6be3aa 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -696,11 +696,6 @@ void SocketApi::command_ENCRYPT(const QString &localFile, SocketListener *listen processEncryptRequest(localFile); } -void SocketApi::command_MANAGE_PUBLIC_LINKS(const QString &localFile, SocketListener *listener) -{ - processShareRequest(localFile, listener); -} - void SocketApi::command_VERSION(const QString &, SocketListener *listener) { listener->sendMessage(QLatin1String("VERSION:" MIRALL_VERSION_STRING ":" MIRALL_SOCKET_API_VERSION)); @@ -897,24 +892,6 @@ void SocketApi::command_COPY_SECUREFILEDROP_LINK(const QString &localFile, Socke getOrCreatePublicLinkShareJob->run(); } -void SocketApi::command_COPY_PUBLIC_LINK(const QString &localFile, SocketListener *) -{ - const auto fileData = FileData::get(localFile); - if (!fileData.folder) { - return; - } - - const auto account = fileData.folder->accountState()->account(); - const auto getOrCreatePublicLinkShareJob = new GetOrCreatePublicLinkShare(account, fileData.serverRelativePath, false, this); - connect(getOrCreatePublicLinkShareJob, &GetOrCreatePublicLinkShare::done, this, [](const QString &url) { - copyUrlToClipboard(url); - }); - connect(getOrCreatePublicLinkShareJob, &GetOrCreatePublicLinkShare::error, this, [=]() { - emit shareCommandReceived(fileData.localPath); - }); - getOrCreatePublicLinkShareJob->run(); -} - // Windows Shell / Explorer pinning fallbacks, see issue: https://github.com/nextcloud/desktop/issues/1599 #ifdef Q_OS_WIN void SocketApi::command_COPYASPATH(const QString &localFile, SocketListener *) @@ -1198,29 +1175,6 @@ void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketLi listener->sendMessage(QLatin1String("MENU_ITEM:DISABLED:d:") + (!record.isDirectory() ? tr("Resharing this file is not allowed") : tr("Resharing this folder is not allowed"))); } else { listener->sendMessage(QLatin1String("MENU_ITEM:SHARE") + flagString + tr("Share options")); - - // Do we have public links? - bool publicLinksEnabled = theme->linkSharing() && capabilities.sharePublicLink(); - - // Is is possible to create a public link without user choices? - bool canCreateDefaultPublicLink = publicLinksEnabled - && !capabilities.sharePublicLinkEnforceExpireDate() - && !capabilities.sharePublicLinkAskOptionalPassword() - && !capabilities.sharePublicLinkEnforcePassword(); - - if (canCreateDefaultPublicLink) { - if (isSecureFileDropSupported) { - listener->sendMessage(QLatin1String("MENU_ITEM:COPY_SECUREFILEDROP_LINK") + QLatin1String("::") + tr("Copy secure file drop link")); - } else { - listener->sendMessage(QLatin1String("MENU_ITEM:COPY_PUBLIC_LINK") + flagString + tr("Copy public link")); - } - } else if (publicLinksEnabled) { - if (isSecureFileDropSupported) { - listener->sendMessage(QLatin1String("MENU_ITEM:MANAGE_PUBLIC_LINKS") + QLatin1String("::") + tr("Copy secure filedrop link")); - } else { - listener->sendMessage(QLatin1String("MENU_ITEM:MANAGE_PUBLIC_LINKS") + flagString + tr("Copy public link")); - } - } } if (itemEncryptionFlag == SharingContextItemEncryptedFlag::NotEncryptedItem) { diff --git a/src/gui/socketapi/socketapi.h b/src/gui/socketapi/socketapi.h index bf95d780cd821..b981da3f18d01 100644 --- a/src/gui/socketapi/socketapi.h +++ b/src/gui/socketapi/socketapi.h @@ -129,9 +129,7 @@ private slots: Q_INVOKABLE void command_ENCRYPT(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_SHARE(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_LEAVESHARE(const QString &localFile, OCC::SocketListener *listener); - Q_INVOKABLE void command_MANAGE_PUBLIC_LINKS(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_COPY_SECUREFILEDROP_LINK(const QString &localFile, OCC::SocketListener *listener); - Q_INVOKABLE void command_COPY_PUBLIC_LINK(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_COPY_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_EMAIL_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener); Q_INVOKABLE void command_OPEN_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener);