mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 04:08:54 +03:00
Merge pull request #3955 from nextcloud/feature/enforceVFS
add an option to enforce use of virtual files sync folder
This commit is contained in:
commit
4bd9972d46
12 changed files with 53 additions and 1 deletions
|
@ -34,6 +34,7 @@ option( BUILD_UPDATER "Build updater" OFF )
|
||||||
|
|
||||||
option( WITH_PROVIDERS "Build with providers list" ON )
|
option( WITH_PROVIDERS "Build with providers list" ON )
|
||||||
|
|
||||||
|
option( ENFORCE_VIRTUAL_FILES_SYNC_FOLDER "Enforce use of virtual files sync folder when available" OFF )
|
||||||
|
|
||||||
## Theming options
|
## Theming options
|
||||||
set(NEXTCLOUD_BACKGROUND_COLOR "#0082c9" CACHE STRING "Default Nextcloud background color")
|
set(NEXTCLOUD_BACKGROUND_COLOR "#0082c9" CACHE STRING "Default Nextcloud background color")
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#cmakedefine APPLICATION_OCSP_STAPLING_ENABLED "@APPLICATION_OCSP_STAPLING_ENABLED@"
|
#cmakedefine APPLICATION_OCSP_STAPLING_ENABLED "@APPLICATION_OCSP_STAPLING_ENABLED@"
|
||||||
#cmakedefine APPLICATION_FORBID_BAD_SSL "@APPLICATION_FORBID_BAD_SSL@"
|
#cmakedefine APPLICATION_FORBID_BAD_SSL "@APPLICATION_FORBID_BAD_SSL@"
|
||||||
#define APPLICATION_DOTVIRTUALFILE_SUFFIX "." APPLICATION_VIRTUALFILE_SUFFIX
|
#define APPLICATION_DOTVIRTUALFILE_SUFFIX "." APPLICATION_VIRTUALFILE_SUFFIX
|
||||||
|
#cmakedefine01 ENFORCE_VIRTUAL_FILES_SYNC_FOLDER
|
||||||
|
|
||||||
#cmakedefine ZLIB_FOUND @ZLIB_FOUND@
|
#cmakedefine ZLIB_FOUND @ZLIB_FOUND@
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
|
@ -593,6 +593,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
||||||
|
|
||||||
ac = menu->addAction(tr("Disable virtual file support …"));
|
ac = menu->addAction(tr("Disable virtual file support …"));
|
||||||
connect(ac, &QAction::triggered, this, &AccountSettings::slotDisableVfsCurrentFolder);
|
connect(ac, &QAction::triggered, this, &AccountSettings::slotDisableVfsCurrentFolder);
|
||||||
|
ac->setDisabled(Theme::instance()->enforceVirtualFilesSyncFolder());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Theme::instance()->showVirtualFilesOption()
|
if (Theme::instance()->showVirtualFilesOption()
|
||||||
|
|
|
@ -671,7 +671,7 @@ void Folder::setVirtualFilesEnabled(bool enabled)
|
||||||
startVfs();
|
startVfs();
|
||||||
if (newMode != Vfs::Off) {
|
if (newMode != Vfs::Off) {
|
||||||
_saveInFoldersWithPlaceholders = true;
|
_saveInFoldersWithPlaceholders = true;
|
||||||
SyncEngine::switchToVirtualFiles(path(), _journal, *_vfs);
|
switchToVirtualFiles();
|
||||||
}
|
}
|
||||||
saveToSettings();
|
saveToSettings();
|
||||||
}
|
}
|
||||||
|
@ -688,6 +688,11 @@ void Folder::setRootPinState(PinState state)
|
||||||
slotNextSyncFullLocalDiscovery();
|
slotNextSyncFullLocalDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Folder::switchToVirtualFiles()
|
||||||
|
{
|
||||||
|
SyncEngine::switchToVirtualFiles(path(), _journal, *_vfs);
|
||||||
|
}
|
||||||
|
|
||||||
bool Folder::supportsSelectiveSync() const
|
bool Folder::supportsSelectiveSync() const
|
||||||
{
|
{
|
||||||
return !virtualFilesEnabled() && !isVfsOnOffSwitchPending();
|
return !virtualFilesEnabled() && !isVfsOnOffSwitchPending();
|
||||||
|
|
|
@ -287,6 +287,8 @@ public:
|
||||||
bool isVfsOnOffSwitchPending() const { return _vfsOnOffPending; }
|
bool isVfsOnOffSwitchPending() const { return _vfsOnOffPending; }
|
||||||
void setVfsOnOffSwitchPending(bool pending) { _vfsOnOffPending = pending; }
|
void setVfsOnOffSwitchPending(bool pending) { _vfsOnOffPending = pending; }
|
||||||
|
|
||||||
|
void switchToVirtualFiles();
|
||||||
|
|
||||||
/** Whether this folder should show selective sync ui */
|
/** Whether this folder should show selective sync ui */
|
||||||
bool supportsSelectiveSync() const;
|
bool supportsSelectiveSync() const;
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,11 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
|
||||||
SyncJournalDb::maybeMigrateDb(folderDefinition.localPath, folderDefinition.absoluteJournalPath());
|
SyncJournalDb::maybeMigrateDb(folderDefinition.localPath, folderDefinition.absoluteJournalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto switchToVfs = isSwitchToVfsNeeded(folderDefinition);
|
||||||
|
if (switchToVfs) {
|
||||||
|
folderDefinition.virtualFilesMode = bestAvailableVfsMode();
|
||||||
|
}
|
||||||
|
|
||||||
auto vfs = createVfsFromPlugin(folderDefinition.virtualFilesMode);
|
auto vfs = createVfsFromPlugin(folderDefinition.virtualFilesMode);
|
||||||
if (!vfs) {
|
if (!vfs) {
|
||||||
// TODO: Must do better error handling
|
// TODO: Must do better error handling
|
||||||
|
@ -300,6 +305,9 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
|
||||||
|
|
||||||
Folder *f = addFolderInternal(std::move(folderDefinition), account.data(), std::move(vfs));
|
Folder *f = addFolderInternal(std::move(folderDefinition), account.data(), std::move(vfs));
|
||||||
if (f) {
|
if (f) {
|
||||||
|
if (switchToVfs) {
|
||||||
|
f->switchToVirtualFiles();
|
||||||
|
}
|
||||||
// Migrate the old "usePlaceholders" setting to the root folder pin state
|
// Migrate the old "usePlaceholders" setting to the root folder pin state
|
||||||
if (settings.value(QLatin1String(versionC), 1).toInt() == 1
|
if (settings.value(QLatin1String(versionC), 1).toInt() == 1
|
||||||
&& settings.value(QLatin1String("usePlaceholders"), false).toBool()) {
|
&& settings.value(QLatin1String("usePlaceholders"), false).toBool()) {
|
||||||
|
@ -837,6 +845,19 @@ bool FolderMan::pushNotificationsFilesReady(Account *account)
|
||||||
return pushFilesAvailable && pushNotifications && pushNotifications->isReady();
|
return pushFilesAvailable && pushNotifications && pushNotifications->isReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FolderMan::isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const
|
||||||
|
{
|
||||||
|
auto result = false;
|
||||||
|
if (ENFORCE_VIRTUAL_FILES_SYNC_FOLDER &&
|
||||||
|
folderDefinition.virtualFilesMode != bestAvailableVfsMode() &&
|
||||||
|
folderDefinition.virtualFilesMode == Vfs::Off &&
|
||||||
|
OCC::Theme::instance()->showVirtualFilesOption()) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void FolderMan::slotEtagPollTimerTimeout()
|
void FolderMan::slotEtagPollTimerTimeout()
|
||||||
{
|
{
|
||||||
qCInfo(lcFolderMan) << "Etag poll timer timeout";
|
qCInfo(lcFolderMan) << "Etag poll timer timeout";
|
||||||
|
|
|
@ -324,6 +324,8 @@ private:
|
||||||
|
|
||||||
bool pushNotificationsFilesReady(Account *account);
|
bool pushNotificationsFilesReady(Account *account);
|
||||||
|
|
||||||
|
bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const;
|
||||||
|
|
||||||
QSet<Folder *> _disabledFolders;
|
QSet<Folder *> _disabledFolders;
|
||||||
Folder::Map _folderMap;
|
Folder::Map _folderMap;
|
||||||
QString _folderConfigPath;
|
QString _folderConfigPath;
|
||||||
|
|
|
@ -545,6 +545,11 @@ void FolderWizardSelectiveSync::initializePage()
|
||||||
_virtualFilesCheckBox->setChecked(bestAvailableVfsMode() == Vfs::WindowsCfApi);
|
_virtualFilesCheckBox->setChecked(bestAvailableVfsMode() == Vfs::WindowsCfApi);
|
||||||
_virtualFilesCheckBox->setEnabled(true);
|
_virtualFilesCheckBox->setEnabled(true);
|
||||||
_virtualFilesCheckBox->setText(tr("Use virtual files instead of downloading content immediately %1").arg(bestAvailableVfsMode() == Vfs::WindowsCfApi ? QString() : tr("(experimental)")));
|
_virtualFilesCheckBox->setText(tr("Use virtual files instead of downloading content immediately %1").arg(bestAvailableVfsMode() == Vfs::WindowsCfApi ? QString() : tr("(experimental)")));
|
||||||
|
|
||||||
|
if (Theme::instance()->enforceVirtualFilesSyncFolder()) {
|
||||||
|
_virtualFilesCheckBox->setChecked(true);
|
||||||
|
_virtualFilesCheckBox->setDisabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,11 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage(OwncloudWizard *wizard)
|
||||||
connect(_ui.pbSelectLocalFolder, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectFolder);
|
connect(_ui.pbSelectLocalFolder, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectFolder);
|
||||||
setButtonText(QWizard::FinishButton, tr("Connect"));
|
setButtonText(QWizard::FinishButton, tr("Connect"));
|
||||||
|
|
||||||
|
if (Theme::instance()->enforceVirtualFilesSyncFolder()) {
|
||||||
|
_ui.rSyncEverything->setDisabled(true);
|
||||||
|
_ui.rSelectiveSync->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
connect(_ui.rSyncEverything, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSyncEverythingClicked);
|
connect(_ui.rSyncEverything, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSyncEverythingClicked);
|
||||||
connect(_ui.rSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
|
connect(_ui.rSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
|
||||||
connect(_ui.rVirtualFileSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked);
|
connect(_ui.rVirtualFileSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked);
|
||||||
|
|
|
@ -859,6 +859,12 @@ bool Theme::showVirtualFilesOption() const
|
||||||
return ConfigFile().showExperimentalOptions() || vfsMode == Vfs::WindowsCfApi;
|
return ConfigFile().showExperimentalOptions() || vfsMode == Vfs::WindowsCfApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Theme::enforceVirtualFilesSyncFolder() const
|
||||||
|
{
|
||||||
|
const auto vfsMode = bestAvailableVfsMode();
|
||||||
|
return ENFORCE_VIRTUAL_FILES_SYNC_FOLDER && vfsMode != OCC::Vfs::Off;
|
||||||
|
}
|
||||||
|
|
||||||
QColor Theme::errorBoxTextColor() const
|
QColor Theme::errorBoxTextColor() const
|
||||||
{
|
{
|
||||||
return QColor{"white"};
|
return QColor{"white"};
|
||||||
|
|
|
@ -565,6 +565,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool showVirtualFilesOption() const;
|
virtual bool showVirtualFilesOption() const;
|
||||||
|
|
||||||
|
virtual bool enforceVirtualFilesSyncFolder() const;
|
||||||
|
|
||||||
/** @return color for the ErrorBox text. */
|
/** @return color for the ErrorBox text. */
|
||||||
virtual QColor errorBoxTextColor() const;
|
virtual QColor errorBoxTextColor() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue