Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,11 +1160,16 @@ void AccountSettings::refreshSelectiveSyncStatus()
ui->bigFolderUi->setVisible(false);
} else {
ConfigFile cfg;
QString info = !cfg.confirmExternalStorage()
? tr("There are folders that were not synchronized because they are too big: ")
: !cfg.newBigFolderSizeLimit().first
? tr("There are folders that were not synchronized because they are external storages: ")
: tr("There are folders that were not synchronized because they are too big or external storages: ");
QString info;
if (cfg.confirmExternalStorage() && !cfg.newBigFolderSizeLimit().first && !cfg.confirmSharedFolder()) {
info = tr("There are folders that were not synchronized because they are external storages: ");
} else if (cfg.newBigFolderSizeLimit().first && !cfg.confirmExternalStorage() && !cfg.confirmSharedFolder()) {
info = tr("There are folders that were not synchronized because they are too big: ");
} else if (cfg.confirmSharedFolder() && !cfg.newBigFolderSizeLimit().first && !cfg.confirmExternalStorage()) {
info = tr("There are folders that were not synchronized because they were shared with you: ");
} else {
info = tr("There are folders that were excluded as per your settings: ");
}

ui->selectiveSyncNotification->setText(info + msg);
ui->selectiveSyncButtons->setVisible(false);
Expand Down
28 changes: 21 additions & 7 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "common/syncjournalfilerecord.h"
#include "syncresult.h"
#include "clientproxy.h"
#include "syncengine.h"
#include "syncrunfilelog.h"
#include "socketapi.h"
#include "theme.h"
Expand Down Expand Up @@ -96,8 +95,8 @@ Folder::Folder(const FolderDefinition &definition,
connect(_engine.data(), &SyncEngine::transmissionProgress, this, &Folder::slotTransmissionProgress);
connect(_engine.data(), &SyncEngine::itemCompleted,
this, &Folder::slotItemCompleted);
connect(_engine.data(), &SyncEngine::newBigFolder,
this, &Folder::slotNewBigFolderDiscovered);
connect(_engine.data(), &SyncEngine::newProblematicFolder,
this, &Folder::slotNewProblematicFolderDiscovered);
connect(_engine.data(), &SyncEngine::seenLockedFile, FolderMan::instance(), &FolderMan::slotSyncOnceFileUnlocks);
connect(_engine.data(), &SyncEngine::aboutToPropagate,
this, &Folder::slotLogPropagationStart);
Expand Down Expand Up @@ -689,6 +688,7 @@ void Folder::setSyncOptions()
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
opt._confirmSharedFolder = cfgFile.confirmSharedFolder();
opt._moveFilesToTrash = cfgFile.moveToTrash();

QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE");
Expand Down Expand Up @@ -929,7 +929,7 @@ void Folder::slotItemCompleted(const SyncFileItemPtr &item)
emit ProgressDispatcher::instance()->itemCompleted(alias(), item);
}

void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
void Folder::slotNewProblematicFolderDiscovered(const QString &newF, SyncEngine::ProblemReason reason)
{
auto newFolder = newF;
if (!newFolder.endsWith(QLatin1Char('/'))) {
Expand All @@ -954,10 +954,24 @@ void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
emit newBigFolderDiscovered(newFolder);
}
QString message = !isExternal ? (tr("A new folder larger than %1 MB has been added: %2.\n")
QString message;

switch (reason) {
case DiscoveryJob::IsBig:
message = tr("A new folder larger than %1 MB has been added: %2.\n")
.arg(ConfigFile().newBigFolderSizeLimit().second)
.arg(newF))
: (tr("A folder from an external storage has been added.\n"));
.arg(newF);
break;

case DiscoveryJob::IsExternal:
message = tr("A folder from an external storage has been added.\n");
break;

case DiscoveryJob::IsShared:
message = tr("A folder has been shared with you.\n");
break;
}

message += tr("Please go in the settings to select it if you wish to download it.");

auto logger = Logger::instance();
Expand Down
5 changes: 2 additions & 3 deletions src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define MIRALL_FOLDER_H

#include "syncresult.h"
#include "syncengine.h"
#include "progressdispatcher.h"
#include "common/syncjournaldb.h"
#include "networkjobs.h"
Expand All @@ -34,8 +35,6 @@ class QThread;
class QSettings;

namespace OCC {

class SyncEngine;
class AccountState;
class SyncRunFileLog;
class FolderWatcher;
Expand Down Expand Up @@ -303,7 +302,7 @@ private slots:

void slotEmitFinishedDelayed();

void slotNewBigFolderDiscovered(const QString &, bool isExternal);
void slotNewProblematicFolderDiscovered(const QString &newF, SyncEngine::ProblemReason reason);

void slotLogPropagationStart();

Expand Down
3 changes: 3 additions & 0 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ GeneralSettings::GeneralSettings(QWidget *parent)
connect(_ui->newFolderLimitCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
connect(_ui->newFolderLimitSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &GeneralSettings::saveMiscSettings);
connect(_ui->newExternalStorage, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
connect(_ui->newSharedFolder, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);

#ifndef WITH_CRASHREPORTER
_ui->crashreporterCheckBox->setVisible(false);
Expand Down Expand Up @@ -123,6 +124,7 @@ void GeneralSettings::loadMiscSettings()
_ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first);
_ui->newFolderLimitSpinBox->setValue(newFolderLimit.second);
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->newSharedFolder->setChecked(cfgFile.confirmSharedFolder());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
}

Expand Down Expand Up @@ -159,6 +161,7 @@ void GeneralSettings::saveMiscSettings()
cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(),
_ui->newFolderLimitSpinBox->value());
cfgFile.setConfirmExternalStorage(_ui->newExternalStorage->isChecked());
cfgFile.setConfirmSharedFolder(_ui->newSharedFolder->isChecked());
}

void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
Expand Down
11 changes: 11 additions & 0 deletions src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="newSharedFolder">
<property name="text">
<string>Ask for confirmation before synchronizing s&amp;hared storages</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
Expand Down
5 changes: 5 additions & 0 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
_ui.confSpinBox->hide();
_ui.confTraillingSizeLabel->hide();
}
if (theme->wizardHideSharedFoldersConfirmationCheckbox()) {
_ui.confCheckBoxShared->hide();
}
}

void OwncloudAdvancedSetupPage::setupCustomization()
Expand Down Expand Up @@ -135,6 +138,7 @@ void OwncloudAdvancedSetupPage::initializePage()
_ui.confCheckBoxSize->setChecked(newFolderLimit.first);
_ui.confSpinBox->setValue(newFolderLimit.second);
_ui.confCheckBoxExternal->setChecked(cfgFile.confirmExternalStorage());
_ui.confCheckBoxShared->setChecked(cfgFile.confirmSharedFolder());
}

// Called if the user changes the user- or url field. Adjust the texts and
Expand Down Expand Up @@ -252,6 +256,7 @@ bool OwncloudAdvancedSetupPage::validatePage()
cfgFile.setNewBigFolderSizeLimit(_ui.confCheckBoxSize->isChecked(),
_ui.confSpinBox->value());
cfgFile.setConfirmExternalStorage(_ui.confCheckBoxExternal->isChecked());
cfgFile.setConfirmSharedFolder(_ui.confCheckBoxShared->isChecked());
}

emit createLocalAndRemoteFolders(localFolder(), _remoteFolder);
Expand Down
39 changes: 23 additions & 16 deletions src/gui/wizard/owncloudadvancedsetuppage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,6 @@
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
Expand Down Expand Up @@ -168,13 +152,36 @@
</item>
</layout>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="confCheckBoxExternal">
<property name="text">
<string>Ask for confirmation before synchronizing e&amp;xternal storages</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="confCheckBoxShared">
<property name="text">
<string>Ask for confirmation before synchronizing s&amp;hared storages</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
11 changes: 11 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static const char downloadLimitC[] = "BWLimit/downloadLimit";
static const char newBigFolderSizeLimitC[] = "newBigFolderSizeLimit";
static const char useNewBigFolderSizeLimitC[] = "useNewBigFolderSizeLimit";
static const char confirmExternalStorageC[] = "confirmExternalStorage";
static const char confirmSharedFolderC[] = "confirmSharedFolder";
static const char moveToTrashC[] = "moveToTrash";

static const char maxLogLinesC[] = "Logging/maxLogLines";
Expand Down Expand Up @@ -737,6 +738,16 @@ void ConfigFile::setConfirmExternalStorage(bool isChecked)
setValue(confirmExternalStorageC, isChecked);
}

bool ConfigFile::confirmSharedFolder() const
{
return getValue(confirmSharedFolderC, QString(), false).toBool();
}

void ConfigFile::setConfirmSharedFolder(bool isChecked)
{
setValue(confirmSharedFolderC, isChecked);
}

bool ConfigFile::moveToTrash() const
{
return getValue(moveToTrashC, QString(), false).toBool();
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
void setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes);
bool confirmExternalStorage() const;
void setConfirmExternalStorage(bool);
bool confirmSharedFolder() const;
void setConfirmSharedFolder(bool);

/** If we should move the files deleted on the server in the trash */
bool moveToTrash() const;
Expand Down
10 changes: 8 additions & 2 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString &path, RemotePermis
return false;
}

emit newBigFolder(path, true);
emit newProblematicFolder(path, IsExternal);
return true;
}

Expand All @@ -112,6 +112,12 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString &path, RemotePermis
return false;
}

if (_syncOptions._confirmSharedFolder
&& remotePerm.hasPermission(RemotePermissions::IsShared)) {
emit newProblematicFolder(path, IsShared);
return true;
}

auto limit = _syncOptions._newBigFolderSizeLimit;
if (limit < 0) {
// no limit, everything is allowed;
Expand All @@ -129,7 +135,7 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString &path, RemotePermis

if (result >= limit) {
// we tell the UI there is a new folder
emit newBigFolder(path, false);
emit newProblematicFolder(path, IsBig);
return true;
} else {
// it is not too big, put it in the white list (so we will not do more query for the children)
Expand Down
7 changes: 6 additions & 1 deletion src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class DiscoveryJob : public QObject


public:
enum ProblemReason {
IsBig = 1,
IsExternal = 2,
IsShared = 3
};
explicit DiscoveryJob(CSYNC *ctx, QObject *parent = nullptr)
: QObject(parent)
, _csync_ctx(ctx)
Expand All @@ -205,6 +210,6 @@ class DiscoveryJob : public QObject
void doGetSizeSignal(const QString &path, qint64 *result);

// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder, bool isExternal);
void newProblematicFolder(const QString &folder, ProblemReason reason);
};
}
5 changes: 3 additions & 2 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ SyncEngine::SyncEngine(AccountPtr account, const QString &localPath,
qRegisterMetaType<SyncFileStatus>("SyncFileStatus");
qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector");
qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction");
qRegisterMetaType<ProblemReason>("ProblemReason");

// Everything in the SyncEngine expects a trailing slash for the localPath.
ASSERT(localPath.endsWith(QLatin1Char('/')));
Expand Down Expand Up @@ -913,8 +914,8 @@ void SyncEngine::startSync()
connect(discoveryJob, &DiscoveryJob::folderDiscovered,
this, &SyncEngine::slotFolderDiscovered);

connect(discoveryJob, &DiscoveryJob::newBigFolder,
this, &SyncEngine::newBigFolder);
connect(discoveryJob, &DiscoveryJob::newProblematicFolder,
this, &SyncEngine::newProblematicFolder);


// This is used for the DiscoveryJob to be able to request the main thread/
Expand Down
4 changes: 3 additions & 1 deletion src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
{
Q_OBJECT
public:
using ProblemReason = DiscoveryJob::ProblemReason;

SyncEngine(AccountPtr account, const QString &localPath,
const QString &remotePath, SyncJournalDb *journal);
~SyncEngine();
Expand Down Expand Up @@ -159,7 +161,7 @@ class OWNCLOUDSYNC_EXPORT SyncEngine : public QObject
void aboutToRestoreBackup(bool *restore);

// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder, bool isExternal);
void newProblematicFolder(const QString &folder, DiscoveryJob::ProblemReason reason);

/** Emitted when propagation has problems with a locked file.
*
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/syncoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct SyncOptions
/** If a confirmation should be asked for external storages */
bool _confirmExternalStorage = false;

/** If a confirmation should be asked for shared folders */
bool _confirmSharedFolder = false;

/** If remotely deleted files are needed to move to trash */
bool _moveFilesToTrash = false;

Expand Down
5 changes: 5 additions & 0 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ bool Theme::wizardHideFolderSizeLimitCheckbox() const
return false;
}

bool Theme::wizardHideSharedFoldersConfirmationCheckbox() const
{
return false;
}

QString Theme::gitSHA1() const
{
QString devString;
Expand Down
5 changes: 5 additions & 0 deletions src/libsync/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
* in the account wizard
*/
virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
/**
* Hide the checkbox that says "Ask for confirmation before synchronizing shared folders"
* in the account wizard
*/
virtual bool wizardHideSharedFoldersConfirmationCheckbox() const;

/**
* Alternative path on the server that provides access to the webdav capabilities
Expand Down