Comparar commits

...

8 Commits

Autor SHA1 Mensagem Data
Olivier Goffart 7e63849fcb Account Wizard: don't whitelist everything on the first sync if we still want to confirm big folder
Issue: https://github.com/owncloud/client/pull/5340#issuecomment-274564441
2017-01-27 09:43:15 +01:00
Olivier Goffart de53732629 General Settings: Make sure to reload the settings when an account is added
The Size limit, or confirmation checkboxes might have changed.

We need to guard against saving if the control changes while we are loading

Issue: https://github.com/owncloud/client/pull/5340#issuecomment-274878023
2017-01-27 09:43:15 +01:00
Olivier Goffart dc3accacfc Confirm External Storage: adjust the notification message
We need to forward the information that the folder is an external storage
for the notification message.

Issue: https://github.com/owncloud/client/pull/5340#issuecomment-274878023
2017-01-27 09:43:15 +01:00
Olivier Goffart 1b9c49e8f5 Wizard: Increase the size
The advanced page has become quite complex and does not fit on the screen
anymore if the fonts are too big
2017-01-27 09:43:15 +01:00
Olivier Goffart ed15842eb9 FolderStatusModel: Different icon for external storages
Issue: https://github.com/owncloud/client/pull/5340#issuecomment-274564441
2017-01-24 16:25:38 +01:00
Olivier Goffart c24c3d559d Discovery: Filter 'M' out of permissions for non root storage
The sync engine rely on the 'M' in premission to ask for confirmation
(As requested in issue #5340)
But we only want to ask the premission for the 'root' of the mounting point and not
for every subfolders within it.
So we change the discovery phase in a way that it does not keep the 'M' for
children within the external storage.
2017-01-24 16:22:56 +01:00
Olivier Goffart 6dcd79ded6 Wizard: Add options to ask confirmation for external storage
Added two checkboxes in the Account Wizard in the advanced page to change the first options.
Also added a checkbox in the general settings to ask for confirmation for external storages.

Theme options allow to hide the checkboxes in the wizard.

As described in issue #5340
2017-01-24 16:21:18 +01:00
Olivier Goffart 0905bcdaea Discovery: Add branding option to disable default sync of 'M' directories
Issue #5331 and https://github.com/owncloud/enterprise/issues/1594
2017-01-24 16:20:55 +01:00
25 arquivos alterados com 380 adições e 99 exclusões
+1 -1
Ver Arquivo
@@ -89,7 +89,7 @@ struct csync_s {
/* hooks for checking the white list (uses the update_callback_userdata) */
int (*checkSelectiveSyncBlackListHook)(void*, const char*);
int (*checkSelectiveSyncNewFolderHook)(void*, const char*);
int (*checkSelectiveSyncNewFolderHook)(void*, const char* /* path */, const char* /* remotePerm */);
csync_vio_opendir_hook remote_opendir_hook;
+1 -1
Ver Arquivo
@@ -436,7 +436,7 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
st->instruction = CSYNC_INSTRUCTION_NEW;
if (fs->type == CSYNC_VIO_FILE_TYPE_DIRECTORY && ctx->current == REMOTE_REPLICA && ctx->callbacks.checkSelectiveSyncNewFolderHook) {
if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path)) {
if (ctx->callbacks.checkSelectiveSyncNewFolderHook(ctx->callbacks.update_callback_userdata, path, fs->remotePerm)) {
csync_file_stat_free(st);
return 1;
}
+7 -2
Ver Arquivo
@@ -675,8 +675,13 @@ void AccountSettings::refreshSelectiveSyncStatus()
ui->selectiveSyncButtons->setVisible(true);
ui->bigFolderUi->setVisible(false);
} else {
QString wholeMsg = tr("There are new folders that were not synchronized because they are too big: ") + msg;
ui->selectiveSyncNotification->setText(wholeMsg);
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: ");
ui->selectiveSyncNotification->setText(info + msg);
ui->selectiveSyncButtons->setVisible(false);
ui->bigFolderUi->setVisible(true);
shouldBeVisible = true;
+12 -7
Ver Arquivo
@@ -104,7 +104,8 @@ Folder::Folder(const FolderDefinition& definition,
connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo)));
connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)),
this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &)));
connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString)));
connect(_engine.data(), SIGNAL(newBigFolder(QString,bool)),
this, SLOT(slotNewBigFolderDiscovered(QString,bool)));
connect(_engine.data(), SIGNAL(seenLockedFile(QString)), FolderMan::instance(), SLOT(slotSyncOnceFileUnlocks(QString)));
connect(_engine.data(), SIGNAL(aboutToPropagate(SyncFileItemVector&)),
SLOT(slotLogPropagationStart()));
@@ -748,10 +749,12 @@ void Folder::startSync(const QStringList &pathList)
setDirtyNetworkLimits();
SyncOptions opt;
ConfigFile cfgFile;
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
quint64 limit = newFolderLimit.first ? newFolderLimit.second * 1000 * 1000 : -1; // convert from MB to B
_engine->setNewBigFolderSizeLimit(limit);
opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
_engine->setSyncOptions(opt);
_engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles);
@@ -928,7 +931,7 @@ void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& jo
emit ProgressDispatcher::instance()->itemCompleted(alias(), item, job);
}
void Folder::slotNewBigFolderDiscovered(const QString &newF)
void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
{
auto newFolder = newF;
if (!newFolder.endsWith(QLatin1Char('/'))) {
@@ -953,9 +956,11 @@ void Folder::slotNewBigFolderDiscovered(const QString &newF)
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
emit newBigFolderDiscovered(newFolder);
}
QString message = tr("A new folder larger than %1 MB has been added: %2.\n"
"Please go in the settings to select it if you wish to download it.")
.arg(ConfigFile().newBigFolderSizeLimit().second).arg(newF);
QString message = !isExternal ?
(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"));
message += tr("Please go in the settings to select it if you wish to download it.");
auto logger = Logger::instance();
logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message);
+1 -1
Ver Arquivo
@@ -290,7 +290,7 @@ private slots:
void slotEmitFinishedDelayed();
void slotNewBigFolderDiscovered(const QString &);
void slotNewBigFolderDiscovered(const QString &, bool isExternal);
void slotLogPropagationStart();
+33 -4
Ver Arquivo
@@ -29,6 +29,14 @@ Q_DECLARE_METATYPE(QPersistentModelIndex)
namespace OCC {
static const char propertyParentIndexC[] = "oc_parentIndex";
static const char propertyPermissionMap[] = "oc_permissionMap";
static QString removeTrailingSlash(const QString &s) {
if (s.endsWith('/')) {
return s.left(s.size() - 1);
}
return s;
}
FolderStatusModel::FolderStatusModel(QObject *parent)
:QAbstractItemModel(parent), _accountState(0), _dirty(false)
@@ -162,7 +170,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
case Qt::CheckStateRole:
return x._checked;
case Qt::DecorationRole:
return QFileIconProvider().icon(QFileIconProvider::Folder);
return QFileIconProvider().icon(x._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder);
case Qt::ForegroundRole:
if (x._isUndecided) {
return QColor(Qt::red);
@@ -368,6 +376,9 @@ FolderStatusModel::SubFolderInfo* FolderStatusModel::infoForIndex(const QModelIn
if (parentInfo->hasLabel()) {
return 0;
}
if (index.row() >= parentInfo->_subs.size()) {
return 0;
}
return &parentInfo->_subs[index.row()];
} else {
if (index.row() >= _folders.count()) {
@@ -537,12 +548,15 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
path += info->_path;
}
LsColJob *job = new LsColJob(_accountState->account(), path, this);
job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size");
job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size" << "http://owncloud.org/ns:permissions");
job->setTimeout(60 * 1000);
connect(job, SIGNAL(directoryListingSubfolders(QStringList)),
SLOT(slotUpdateDirectories(QStringList)));
connect(job, SIGNAL(finishedWithError(QNetworkReply*)),
this, SLOT(slotLscolFinishedWithError(QNetworkReply*)));
connect(job, SIGNAL(directoryListingIterated(const QString&, const QMap<QString,QString>&)),
this, SLOT(slotGatherPermissions(const QString&, const QMap<QString,QString>&)));
job->start();
QPersistentModelIndex persistentIndex(parent);
@@ -553,6 +567,20 @@ void FolderStatusModel::fetchMore(const QModelIndex& parent)
QTimer::singleShot(1000, this, SLOT(slotShowFetchProgress()));
}
void FolderStatusModel::slotGatherPermissions(const QString &href, const QMap<QString,QString> &map)
{
auto it = map.find("permissions");
if (it == map.end())
return;
auto job = sender();
auto permissionMap = job->property(propertyPermissionMap).toMap();
job->setProperty(propertyPermissionMap, QVariant()); // avoid a detach of the map while it is modified
Q_ASSERT(!href.endsWith(QLatin1Char('/'))); // LsColXMLParser::parse removes the trailing slash before calling us.
permissionMap[href] = *it;
job->setProperty(propertyPermissionMap, permissionMap);
}
void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
{
auto job = qobject_cast<LsColJob *>(sender());
@@ -598,6 +626,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
selectiveSyncUndecidedSet.insert(str);
}
}
const auto permissionMap = job->property(propertyPermissionMap).toMap();
QStringList sortedSubfolders = list;
// skip the parent item (first in the list)
@@ -618,8 +647,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list)
newInfo._folder = parentInfo->_folder;
newInfo._pathIdx = parentInfo->_pathIdx;
newInfo._pathIdx << newSubs.size();
auto size = job ? job->_sizes.value(path) : 0;
newInfo._size = size;
newInfo._size = job->_sizes.value(path);
newInfo._isExternal = permissionMap.value(removeTrailingSlash(path)).toString().contains("M");
newInfo._path = relativePath;
newInfo._name = relativePath.split('/', QString::SkipEmptyParts).last();
+3 -1
Ver Arquivo
@@ -51,7 +51,7 @@ public:
struct SubFolderInfo {
SubFolderInfo()
: _folder(0), _size(0), _fetched(false), _fetching(false),
: _folder(0), _size(0), _isExternal(false), _fetched(false), _fetching(false),
_hasError(false), _fetchingLabel(false), _isUndecided(false), _checked(Qt::Checked) {}
Folder *_folder;
QString _name;
@@ -59,6 +59,7 @@ public:
QVector<int> _pathIdx;
QVector<SubFolderInfo> _subs;
qint64 _size;
bool _isExternal;
bool _fetched; // If we did the LSCOL for this folder already
bool _fetching; // Whether a LSCOL job is currently running
@@ -113,6 +114,7 @@ public slots:
private slots:
void slotUpdateDirectories(const QStringList &);
void slotGatherPermissions(const QString &name, const QMap<QString,QString> &properties);
void slotLscolFinishedWithError(QNetworkReply *r);
void slotFolderSyncStateChange(Folder* f);
void slotFolderScheduleQueueChanged();
+11
Ver Arquivo
@@ -32,6 +32,7 @@
#include <QNetworkProxy>
#include <QDir>
#include <QScopedValueRollback>
namespace OCC {
@@ -66,6 +67,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
connect(_ui->crashreporterCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
connect(_ui->newFolderLimitCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
connect(_ui->newFolderLimitSpinBox, SIGNAL(valueChanged(int)), SLOT(saveMiscSettings()));
connect(_ui->newExternalStorage, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
#ifndef WITH_CRASHREPORTER
_ui->crashreporterCheckBox->setVisible(false);
@@ -85,6 +87,9 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
_ui->monoIconsCheckBox->setVisible(QDir(themeDir).exists());
connect(_ui->ignoredFilesButton, SIGNAL(clicked()), SLOT(slotIgnoreFilesEditor()));
// accountAdded means the wizard was finished and the wizard might change some options.
connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)), this, SLOT(loadMiscSettings()));
}
GeneralSettings::~GeneralSettings()
@@ -99,6 +104,7 @@ QSize GeneralSettings::sizeHint() const {
void GeneralSettings::loadMiscSettings()
{
QScopedValueRollback<bool> scope(_currentlyLoading, true);
ConfigFile cfgFile;
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
_ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
@@ -106,6 +112,8 @@ void GeneralSettings::loadMiscSettings()
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
_ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first);
_ui->newFolderLimitSpinBox->setValue(newFolderLimit.second);
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
}
void GeneralSettings::slotUpdateInfo()
@@ -130,6 +138,8 @@ void GeneralSettings::slotUpdateInfo()
void GeneralSettings::saveMiscSettings()
{
if (_currentlyLoading)
return;
ConfigFile cfgFile;
bool isChecked = _ui->monoIconsCheckBox->isChecked();
cfgFile.setMonoIcons(isChecked);
@@ -138,6 +148,7 @@ void GeneralSettings::saveMiscSettings()
cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(),
_ui->newFolderLimitSpinBox->value());
cfgFile.setConfirmExternalStorage(_ui->newExternalStorage->isChecked());
}
void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
+2 -1
Ver Arquivo
@@ -45,13 +45,14 @@ private slots:
void slotToggleOptionalDesktopNotifications(bool);
void slotUpdateInfo();
void slotIgnoreFilesEditor();
void loadMiscSettings();
private:
void loadMiscSettings();
Ui::GeneralSettings *_ui;
QPointer<IgnoreListEditor> _ignoreEditor;
QPointer<SyncLogDialog> _syncLogDialog;
bool _currentlyLoading = false;
};
+36 -42
Ver Arquivo
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>706</width>
<width>785</width>
<height>523</height>
</rect>
</property>
@@ -52,33 +52,37 @@
<property name="title">
<string>Advanced</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="ignoredFilesButton">
<property name="text">
<string>Edit &amp;Ignored Files</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="ignoredFilesButton">
<property name="text">
<string>Edit &amp;Ignored Files</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>555</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1" colspan="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>555</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="newFolderLimitCheckBox">
<property name="text">
<string>Ask &amp;confirmation before downloading folders larger than</string>
<string>Ask for confirmation before synchronizing folders larger than</string>
</property>
<property name="checked">
<bool>true</bool>
@@ -98,7 +102,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>MB</string>
<string extracomment="Trailing part of &quot;Ask confirmation before syncing folder larger than&quot; ">MB</string>
</property>
</widget>
</item>
@@ -117,7 +121,14 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item>
<widget class="QCheckBox" name="newExternalStorage">
<property name="text">
<string>Ask for confirmation before synchronizing external storages</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="crashreporterCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -130,23 +141,6 @@
</property>
</widget>
</item>
<item row="2" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
+4 -2
Ver Arquivo
@@ -533,9 +533,11 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
if (f) {
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
_ocWizard->selectiveSyncBlacklist());
// The user already accepted the selective sync dialog. everything is in the white list
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
if (!_ocWizard->isConfirmBigFolderChecked()) {
// The user already accepted the selective sync dialog. everything is in the white list
f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList,
QStringList() << QLatin1String("/"));
}
}
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
}
+27
Ver Arquivo
@@ -68,6 +68,15 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
_ui.lServerIcon->setPixmap(appIcon.pixmap(48));
_ui.lLocalIcon->setText(QString());
_ui.lLocalIcon->setPixmap(QPixmap(Theme::hidpiFileName(":/client/resources/folder-sync.png")));
if (theme->wizardHideExternalStorageConfirmationCheckbox()) {
_ui.confCheckBoxExternal->hide();
}
if (theme->wizardHideFolderSizeLimitCheckbox()) {
_ui.confCheckBoxSize->hide();
_ui.confSpinBox->hide();
_ui.confTraillingSizeLabel->hide();
}
}
void OwncloudAdvancedSetupPage::setupCustomization()
@@ -118,6 +127,12 @@ void OwncloudAdvancedSetupPage::initializePage()
_selectiveSyncBlacklist = QStringList("/");
QTimer::singleShot(0, this, SLOT(slotSelectiveSyncClicked()));
}
ConfigFile cfgFile;
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
_ui.confCheckBoxSize->setChecked(newFolderLimit.first);
_ui.confSpinBox->setValue(newFolderLimit.second);
_ui.confCheckBoxExternal->setChecked(cfgFile.confirmExternalStorage());
}
// Called if the user changes the user- or url field. Adjust the texts and
@@ -200,6 +215,11 @@ QStringList OwncloudAdvancedSetupPage::selectiveSyncBlacklist() const
return _selectiveSyncBlacklist;
}
bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const
{
return _ui.rSyncEverything->isChecked() && _ui.confCheckBoxSize->isChecked();
}
bool OwncloudAdvancedSetupPage::validatePage()
{
if(!_created) {
@@ -208,6 +228,13 @@ bool OwncloudAdvancedSetupPage::validatePage()
startSpinner();
emit completeChanged();
if (_ui.rSyncEverything->isChecked()) {
ConfigFile cfgFile;
cfgFile.setNewBigFolderSizeLimit(_ui.confCheckBoxSize->isChecked(),
_ui.confSpinBox->value());
cfgFile.setConfirmExternalStorage(_ui.confCheckBoxExternal->isChecked());
}
emit createLocalAndRemoteFolders(localFolder(), _remoteFolder);
return false;
} else {
+1
Ver Arquivo
@@ -41,6 +41,7 @@ public:
bool validatePage() Q_DECL_OVERRIDE;
QString localFolder() const;
QStringList selectiveSyncBlacklist() const;
bool isConfirmBigFolderChecked() const;
void setRemoteFolder( const QString& remoteFolder);
void setMultipleFoldersExist( bool exist );
void directoriesCreated();
+133 -7
Ver Arquivo
@@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>917</width>
<height>493</height>
<width>912</width>
<height>633</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -226,11 +226,14 @@
<item row="0" column="1" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="rSyncEverything">
<property name="text">
@@ -263,6 +266,64 @@
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<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>
<widget class="QCheckBox" name="confCheckBoxSize">
<property name="text">
<string>Ask for confirmation before synchroni&amp;zing folders larger than</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="confSpinBox">
<property name="maximum">
<number>999999</number>
</property>
<property name="value">
<number>99</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="confTraillingSizeLabel">
<property name="text">
<string extracomment="Trailing part of &quot;Ask confirmation before syncing folder larger than&quot; ">MB</string>
</property>
</widget>
</item>
</layout>
</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>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -345,5 +406,70 @@
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>rSyncEverything</sender>
<signal>toggled(bool)</signal>
<receiver>confCheckBoxSize</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>217</x>
<y>78</y>
</hint>
<hint type="destinationlabel">
<x>298</x>
<y>126</y>
</hint>
</hints>
</connection>
<connection>
<sender>rSyncEverything</sender>
<signal>toggled(bool)</signal>
<receiver>confSpinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>311</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>952</x>
<y>134</y>
</hint>
</hints>
</connection>
<connection>
<sender>rSyncEverything</sender>
<signal>toggled(bool)</signal>
<receiver>confTraillingSizeLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>277</x>
<y>76</y>
</hint>
<hint type="destinationlabel">
<x>1076</x>
<y>136</y>
</hint>
</hints>
</connection>
<connection>
<sender>rSyncEverything</sender>
<signal>toggled(bool)</signal>
<receiver>confCheckBoxExternal</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>181</x>
<y>78</y>
</hint>
<hint type="destinationlabel">
<x>382</x>
<y>174</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+7 -4
Ver Arquivo
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>602</width>
<height>193</height>
<width>506</width>
<height>515</height>
</rect>
</property>
<property name="sizePolicy">
@@ -80,7 +80,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Server &amp;Address</string>
<string>Ser&amp;ver Address</string>
</property>
<property name="buddy">
<cstring>leUrl</cstring>
@@ -166,10 +166,13 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>200</height>
</size>
</property>
</spacer>
+4 -1
Ver Arquivo
@@ -86,7 +86,6 @@ OwncloudWizard::OwncloudWizard(QWidget *parent)
setTitleFormat(Qt::RichText);
setSubTitleFormat(Qt::RichText);
setButtonText(QWizard::CustomButton1, tr("Skip folders configuration"));
}
void OwncloudWizard::setAccount(AccountPtr account)
@@ -109,6 +108,10 @@ QStringList OwncloudWizard::selectiveSyncBlacklist() const
return _advancedSetupPage->selectiveSyncBlacklist();
}
bool OwncloudWizard::isConfirmBigFolderChecked() const
{
return _advancedSetupPage->isConfirmBigFolderChecked();
}
QString OwncloudWizard::ocUrl() const
{
+1
Ver Arquivo
@@ -59,6 +59,7 @@ public:
QString ocUrl() const;
QString localFolder() const;
QStringList selectiveSyncBlacklist() const;
bool isConfirmBigFolderChecked() const;
void enableFinishOnResultWidget(bool enable);
+11
Ver Arquivo
@@ -67,6 +67,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 maxLogLinesC[] = "Logging/maxLogLines";
@@ -596,6 +597,16 @@ void ConfigFile::setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes)
setValue(useNewBigFolderSizeLimitC, isChecked);
}
bool ConfigFile::confirmExternalStorage() const
{
return getValue(confirmExternalStorageC, QString(), true).toBool();
}
void ConfigFile::setConfirmExternalStorage(bool isChecked)
{
setValue(confirmExternalStorageC, isChecked);
}
bool ConfigFile::promptDeleteFiles() const
{
QSettings settings(configFile(), QSettings::IniFormat);
+2
Ver Arquivo
@@ -105,6 +105,8 @@ public:
/** [checked, size in MB] **/
QPair<bool, quint64> newBigFolderSizeLimit() const;
void setNewBigFolderSizeLimit(bool isChecked, quint64 mbytes);
bool confirmExternalStorage() const;
void setConfirmExternalStorage(bool);
static bool setConfDir(const QString &value);
+37 -8
Ver Arquivo
@@ -20,6 +20,9 @@
#include <QUrl>
#include "account.h"
#include <QFileInfo>
#include "theme.h"
#include <cstring>
namespace OCC {
@@ -81,14 +84,32 @@ int DiscoveryJob::isInSelectiveSyncBlackListCallback(void *data, const char *pat
return static_cast<DiscoveryJob*>(data)->isInSelectiveSyncBlackList(path);
}
bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path)
bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path, const char *remotePerm)
{
// If this path or the parent is in the white list, then we do not block this file
if (_syncOptions._confirmExternalStorage && std::strchr(remotePerm, 'M')) {
// 'M' in the permission means external storage.
/* Note: DiscoverySingleDirectoryJob::directoryListingIteratedSlot make sure that only the
* root of a mounted storage has 'M', all sub entries have 'm' */
// Only allow it if the white list contains exactly this path (not parents)
// We want to ask confirmation for external storage even if the parents where selected
if (_selectiveSyncWhiteList.contains(path + QLatin1Char('/'))) {
return false;
}
emit newBigFolder(path, true);
return true;
}
// If this path or the parent is in the white list, then we do not block this file
if (findPathInList(_selectiveSyncWhiteList, path)) {
return false;
}
if (_newBigFolderSizeLimit < 0) {
auto limit = _syncOptions._newBigFolderSizeLimit;
if (limit < 0) {
// no limit, everything is allowed;
return false;
}
@@ -102,10 +123,9 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path)
_vioWaitCondition.wait(&_vioMutex);
}
auto limit = _newBigFolderSizeLimit;
if (result >= limit) {
// we tell the UI there is a new folder
emit newBigFolder(path);
emit newBigFolder(path, false);
return true;
} else {
// it is not too big, put it in the white list (so we will not do more query for the children)
@@ -119,9 +139,9 @@ bool DiscoveryJob::checkSelectiveSyncNewFolder(const QString& path)
}
}
int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path)
int DiscoveryJob::checkSelectiveSyncNewFolderCallback(void *data, const char *path, const char *remotePerm)
{
return static_cast<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path));
return static_cast<DiscoveryJob*>(data)->checkSelectiveSyncNewFolder(QString::fromUtf8(path), remotePerm);
}
@@ -321,7 +341,9 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con
// The first entry is for the folder itself, we should process it differently.
_ignoredFirst = true;
if (map.contains("permissions")) {
emit firstDirectoryPermissions(map.value("permissions"));
auto perm = map.value("permissions");
emit firstDirectoryPermissions(perm);
_isExternalStorage = perm.contains(QLatin1Char('M'));
}
if (map.contains("data-fingerprint")) {
_dataFingerprint = map.value("data-fingerprint").toUtf8();
@@ -344,6 +366,13 @@ void DiscoverySingleDirectoryJob::directoryListingIteratedSlot(QString file, con
if (!file_stat->etag || strlen(file_stat->etag) == 0) {
qDebug() << "WARNING: etag of" << file_stat->name << "is" << file_stat->etag << " This must not happen.";
}
if (_isExternalStorage) {
/* All the entries in a external storage have 'M' in their permission. However, for all
purposes in the desktop client, we only need to know about the mount points.
So replace the 'M' by a 'm' for every sub entries in an external storage */
std::replace(std::begin(file_stat->remotePerm), std::end(file_stat->remotePerm),
'M', 'm');
}
QStringRef fileRef(&file);
int slashPos = file.lastIndexOf(QLatin1Char('/'));
+16 -5
Ver Arquivo
@@ -34,6 +34,15 @@ class Account;
* if the files are new, or changed.
*/
struct SyncOptions {
/** Maximum size (in Bytes) a folder can have without asking for confirmation.
* -1 means infinite */
qint64 _newBigFolderSizeLimit = -1;
/** If a confirmation should be asked for external storages */
bool _confirmExternalStorage = false;
};
/**
* @brief The FileStatPointer class
* @ingroup libsync
@@ -107,6 +116,8 @@ private:
bool _ignoredFirst;
// Set to true if this is the root path and we need to check the data-fingerprint
bool _isRootPath;
// If this directory is an external storage (The first item has 'M' in its permission)
bool _isExternalStorage = false;
QPointer<LsColJob> _lsColJob;
public:
@@ -176,8 +187,8 @@ class DiscoveryJob : public QObject {
*/
bool isInSelectiveSyncBlackList(const char* path) const;
static int isInSelectiveSyncBlackListCallback(void *, const char *);
bool checkSelectiveSyncNewFolder(const QString &path);
static int checkSelectiveSyncNewFolderCallback(void*, const char*);
bool checkSelectiveSyncNewFolder(const QString &path, const char *remotePerm);
static int checkSelectiveSyncNewFolderCallback(void* data, const char* path, const char* remotePerm);
// Just for progress
static void update_job_update_callback (bool local,
@@ -197,7 +208,7 @@ class DiscoveryJob : public QObject {
public:
explicit DiscoveryJob(CSYNC *ctx, QObject* parent = 0)
: QObject(parent), _csync_ctx(ctx), _newBigFolderSizeLimit(-1) {
: QObject(parent), _csync_ctx(ctx) {
// We need to forward the log property as csync uses thread local
// and updates run in another thread
_log_callback = csync_get_log_callback();
@@ -207,7 +218,7 @@ public:
QStringList _selectiveSyncBlackList;
QStringList _selectiveSyncWhiteList;
qint64 _newBigFolderSizeLimit;
SyncOptions _syncOptions;
Q_INVOKABLE void start();
signals:
void finished(int result);
@@ -218,7 +229,7 @@ signals:
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);
void newBigFolder(const QString &folder, bool isExternal);
};
}
+3 -4
Ver Arquivo
@@ -71,7 +71,6 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
, _backInTimeFiles(0)
, _uploadLimit(0)
, _downloadLimit(0)
, _newBigFolderSizeLimit(-1)
, _checksum_hook(journal)
, _anotherSyncNeeded(NoFollowUpSync)
{
@@ -830,14 +829,14 @@ void SyncEngine::startSync()
return;
}
discoveryJob->_newBigFolderSizeLimit = _newBigFolderSizeLimit;
discoveryJob->_syncOptions = _syncOptions;
discoveryJob->moveToThread(&_thread);
connect(discoveryJob, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
connect(discoveryJob, SIGNAL(folderDiscovered(bool,QString)),
this, SIGNAL(folderDiscovered(bool,QString)));
connect(discoveryJob, SIGNAL(newBigFolder(QString)),
this, SIGNAL(newBigFolder(QString)));
connect(discoveryJob, SIGNAL(newBigFolder(QString,bool)),
this, SIGNAL(newBigFolder(QString,bool)));
// This is used for the DiscoveryJob to be able to request the main thread/
+3 -7
Ver Arquivo
@@ -78,10 +78,7 @@ public:
bool isSyncRunning() const { return _syncRunning; }
/* Set the maximum size a folder can have without asking for confirmation
* -1 means infinite
*/
void setNewBigFolderSizeLimit(qint64 limit) { _newBigFolderSizeLimit = limit; }
void setSyncOptions(const SyncOptions &options) { _syncOptions = options; }
bool ignoreHiddenFiles() const { return _csync_ctx->ignore_hidden_files; }
void setIgnoreHiddenFiles(bool ignore) { _csync_ctx->ignore_hidden_files = ignore; }
@@ -146,7 +143,7 @@ signals:
void aboutToRestoreBackup(bool *restore);
// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder);
void newBigFolder(const QString &folder, bool isExternal);
/** Emitted when propagation has problems with a locked file.
*
@@ -257,8 +254,7 @@ private:
int _uploadLimit;
int _downloadLimit;
/* maximum size a folder can have without asking for confirmation: -1 means infinite */
qint64 _newBigFolderSizeLimit;
SyncOptions _syncOptions;
// hash containing the permissions on the remote directory
QHash<QString, QByteArray> _remotePerms;
+12 -1
Ver Arquivo
@@ -275,6 +275,15 @@ qint64 Theme::newBigFolderSizeLimit() const
return 500;
}
bool Theme::wizardHideExternalStorageConfirmationCheckbox() const
{
return false;
}
bool Theme::wizardHideFolderSizeLimitCheckbox() const
{
return false;
}
QString Theme::gitSHA1() const
{
@@ -412,7 +421,7 @@ QPixmap Theme::wizardHeaderBanner() const
if (!c.isValid())
return QPixmap();
QPixmap pix(QSize(600, 78));
QPixmap pix(QSize(750, 78));
pix.fill(wizardHeaderBackgroundColor());
return pix;
}
@@ -478,4 +487,6 @@ QString Theme::quotaBaseFolder() const
{
return QLatin1String("/");
}
} // end namespace client
+12
Ver Arquivo
@@ -219,6 +219,17 @@ public:
**/
virtual qint64 newBigFolderSizeLimit() const;
/**
* Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB"
* in the account wizard
*/
virtual bool wizardHideFolderSizeLimitCheckbox() const;
/**
* Hide the checkbox that says "Ask for confirmation before synchronizing external storages"
* in the account wizard
*/
virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
/**
* Alternative path on the server that provides access to the webdav capabilities
*
@@ -302,6 +313,7 @@ public:
*/
virtual QString quotaBaseFolder() const;
protected:
#ifndef TOKEN_AUTH_ONLY
QIcon themeIcon(const QString& name, bool sysTray = false, bool sysTrayMenuVisible = false) const;