Enforce VFS. Disable 'Make always available locally'.
authoralex-z <blackslayer4@gmail.com>
Mon, 13 Dec 2021 15:07:29 +0000 (17:07 +0200)
committeralex-z <blackslayer4@gmail.com>
Tue, 14 Dec 2021 13:03:57 +0000 (15:03 +0200)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/gui/accountsettings.cpp
src/gui/socketapi/socketapi.cpp
src/libsync/vfs/cfapi/cfapiwrapper.cpp

index a0ef19f1cdade6b3ad367b6841629cfb88d10f55..05e48d0c56967b056e92ad4655282298335cef2f 100644 (file)
@@ -587,6 +587,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
 
         ac = availabilityMenu->addAction(Utility::vfsPinActionText());
         connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::AlwaysLocal); });
+        ac->setDisabled(Theme::instance()->enforceVirtualFilesSyncFolder());
 
         ac = availabilityMenu->addAction(Utility::vfsFreeSpaceActionText());
         connect(ac, &QAction::triggered, this, [this]() { slotSetCurrentFolderAvailability(PinState::OnlineOnly); });
index 9be00d22fb66764a3524e84c5a2f45e474031cee..6eaa3a6b515a062bf983a116b534bdbb0da1282b 100644 (file)
@@ -1225,9 +1225,11 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
         auto makePinContextMenu = [&](bool makeAvailableLocally, bool freeSpace) {
             listener->sendMessage(QLatin1String("MENU_ITEM:CURRENT_PIN:d:")
                 + Utility::vfsCurrentAvailabilityText(*combined));
-            listener->sendMessage(QLatin1String("MENU_ITEM:MAKE_AVAILABLE_LOCALLY:")
-                + (makeAvailableLocally ? QLatin1String(":") : QLatin1String("d:"))
-                + Utility::vfsPinActionText());
+            if (!Theme::instance()->enforceVirtualFilesSyncFolder()) {
+                listener->sendMessage(QLatin1String("MENU_ITEM:MAKE_AVAILABLE_LOCALLY:")
+                    + (makeAvailableLocally ? QLatin1String(":") : QLatin1String("d:")) + Utility::vfsPinActionText());
+            }
+            
             listener->sendMessage(QLatin1String("MENU_ITEM:MAKE_ONLINE_ONLY:")
                 + (freeSpace ? QLatin1String(":") : QLatin1String("d:"))
                 + Utility::vfsFreeSpaceActionText());
index 16b9d8f7e392ef53051df6db551b04eecf08dfd7..398fe1bd12e72f03a0d58695289f41449b441b4e 100644 (file)
@@ -17,6 +17,7 @@
 #include "common/utility.h"
 #include "common/filesystembase.h"
 #include "hydrationjob.h"
+#include "theme.h"
 #include "vfs_cfapi.h"
 
 #include <QCoreApplication>
@@ -40,6 +41,9 @@ Q_LOGGING_CATEGORY(lcCfApiWrapper, "nextcloud.sync.vfs.cfapi.wrapper", QtInfoMsg
       FIELD_SIZE( CF_OPERATION_PARAMETERS, field ) )
 
 namespace {
+constexpr auto syncRootFlagsFull = 34;
+constexpr auto syncRootFlagsNoCfApiContextMenu = 2;
+
 void cfApiSendTransferInfo(const CF_CONNECTION_KEY &connectionKey, const CF_TRANSFER_KEY &transferKey, NTSTATUS status, void *buffer, qint64 offset, qint64 currentBlockLength, qint64 totalLength)
 {
 
@@ -428,8 +432,10 @@ bool createSyncRootRegistryKeys(const QString &providerName, const QString &fold
         QVariant value;
     };
 
+    const auto flags = OCC::Theme::instance()->enforceVirtualFilesSyncFolder() ? syncRootFlagsNoCfApiContextMenu : syncRootFlagsFull;
+
     const QVector<RegistryKeyInfo> registryKeysToSet = {
-        { providerSyncRootIdRegistryKey, QStringLiteral("Flags"), REG_DWORD, 34 },
+        { providerSyncRootIdRegistryKey, QStringLiteral("Flags"), REG_DWORD, flags },
         { providerSyncRootIdRegistryKey, QStringLiteral("DisplayNameResource"), REG_EXPAND_SZ, displayName },
         { providerSyncRootIdRegistryKey, QStringLiteral("IconResource"), REG_EXPAND_SZ, QString(QDir::toNativeSeparators(qApp->applicationFilePath()) + QStringLiteral(",0")) },
         { providerSyncRootIdUserSyncRootsRegistryKey, windowsSid, REG_SZ, syncRootPath }