mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
FolderMan: refactor some function to take a Folder* instead of an alias
I want to remove this dependency of alias in the code because we might get rid of it entierly later
This commit is contained in:
parent
e4694a6db8
commit
e02f1a222e
9 changed files with 81 additions and 117 deletions
|
@ -236,7 +236,7 @@ void AccountSettings::slotRemoveCurrentFolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
folderMan->slotRemoveFolder( alias );
|
folderMan->slotRemoveFolder( folderMan->folder(alias) );
|
||||||
_model->removeRow(row);
|
_model->removeRow(row);
|
||||||
|
|
||||||
// single folder fix to show add-button and hide remove-button
|
// single folder fix to show add-button and hide remove-button
|
||||||
|
@ -349,7 +349,7 @@ void AccountSettings::slotEnableCurrentFolder()
|
||||||
f->slotTerminateSync();
|
f->slotTerminateSync();
|
||||||
}
|
}
|
||||||
f->setSyncPaused(!currentlyPaused); // toggle the pause setting
|
f->setSyncPaused(!currentlyPaused); // toggle the pause setting
|
||||||
folderMan->slotSetFolderPaused( alias, !currentlyPaused );
|
folderMan->slotSetFolderPaused( f, !currentlyPaused );
|
||||||
|
|
||||||
// keep state for the icon setting.
|
// keep state for the icon setting.
|
||||||
if( currentlyPaused ) _wasDisabledBefore = true;
|
if( currentlyPaused ) _wasDisabledBefore = true;
|
||||||
|
@ -366,7 +366,7 @@ void AccountSettings::slotSyncCurrentFolderNow()
|
||||||
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
|
||||||
folderMan->slotScheduleSync(alias);
|
folderMan->slotScheduleSync(folderMan->folder(alias));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotUpdateFolderState( Folder *folder )
|
void AccountSettings::slotUpdateFolderState( Folder *folder )
|
||||||
|
|
|
@ -292,7 +292,7 @@ void Folder::slotRunEtagJob()
|
||||||
<< _syncResult.statusString();
|
<< _syncResult.statusString();
|
||||||
}
|
}
|
||||||
_forceSyncOnPollTimeout = false;
|
_forceSyncOnPollTimeout = false;
|
||||||
emit scheduleToSync(alias());
|
emit scheduleToSync(this);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Do the ordinary etag check for the root folder and only schedule a real
|
// Do the ordinary etag check for the root folder and only schedule a real
|
||||||
|
@ -315,7 +315,7 @@ void Folder::etagRetreived(const QString& etag)
|
||||||
|
|
||||||
if (_lastEtag != etag) {
|
if (_lastEtag != etag) {
|
||||||
_lastEtag = etag;
|
_lastEtag = etag;
|
||||||
emit scheduleToSync(alias());
|
emit scheduleToSync(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ void Folder::slotWatchedPathChanged(const QString& path)
|
||||||
// When no sync is running or it's in the prepare phase, we can
|
// When no sync is running or it's in the prepare phase, we can
|
||||||
// always schedule a new sync.
|
// always schedule a new sync.
|
||||||
if (! _engine || _syncResult.status() == SyncResult::SyncPrepare) {
|
if (! _engine || _syncResult.status() == SyncResult::SyncPrepare) {
|
||||||
emit scheduleToSync(alias());
|
emit scheduleToSync(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ void Folder::slotWatchedPathChanged(const QString& path)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (! ownChange) {
|
if (! ownChange) {
|
||||||
emit scheduleToSync(alias());
|
emit scheduleToSync(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ signals:
|
||||||
void syncStateChange();
|
void syncStateChange();
|
||||||
void syncStarted();
|
void syncStarted();
|
||||||
void syncFinished(const SyncResult &result);
|
void syncFinished(const SyncResult &result);
|
||||||
void scheduleToSync( const QString& );
|
void scheduleToSync(Folder*);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
@ -96,21 +96,20 @@ OCC::Folder::Map FolderMan::map()
|
||||||
return _folderMap;
|
return _folderMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::unloadFolder( const QString& alias )
|
void FolderMan::unloadFolder( Folder *f )
|
||||||
{
|
{
|
||||||
Folder* f = folder(alias);
|
|
||||||
if( !f ) {
|
if( !f ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( _socketApi ) {
|
if( _socketApi ) {
|
||||||
_socketApi->slotUnregisterPath(alias);
|
_socketApi->slotUnregisterPath(f->alias());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( _folderWatchers.contains(alias)) {
|
if( _folderWatchers.contains(f->alias())) {
|
||||||
_folderWatchers.remove(alias);
|
_folderWatchers.remove(f->alias());
|
||||||
}
|
}
|
||||||
_folderMap.remove( alias );
|
_folderMap.remove( f->alias() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int FolderMan::unloadAndDeleteAllFolders()
|
int FolderMan::unloadAndDeleteAllFolders()
|
||||||
|
@ -122,12 +121,12 @@ int FolderMan::unloadAndDeleteAllFolders()
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
Folder* f = i.value();
|
Folder* f = i.value();
|
||||||
unloadFolder(i.key());
|
unloadFolder(f);
|
||||||
delete f;
|
delete f;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
_lastSyncFolder.clear();
|
_lastSyncFolder = 0;
|
||||||
_currentSyncFolder.clear();
|
_currentSyncFolder = 0;
|
||||||
_scheduleQueue.clear();
|
_scheduleQueue.clear();
|
||||||
|
|
||||||
Q_ASSERT(_folderMap.count() == 0);
|
Q_ASSERT(_folderMap.count() == 0);
|
||||||
|
@ -209,8 +208,8 @@ int FolderMan::setupFolders()
|
||||||
if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) {
|
if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) {
|
||||||
Folder* f = addFolderInternal(account.data(), folderDefinition);
|
Folder* f = addFolderInternal(account.data(), folderDefinition);
|
||||||
if (f) {
|
if (f) {
|
||||||
slotScheduleSync(f->alias());
|
slotScheduleSync(f);
|
||||||
emit folderSyncStateChange(f->alias());
|
emit folderSyncStateChange(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,8 +239,8 @@ int FolderMan::setupFoldersMigration()
|
||||||
foreach ( const QString& alias, list ) {
|
foreach ( const QString& alias, list ) {
|
||||||
Folder *f = setupFolderFromConfigFile( alias );
|
Folder *f = setupFolderFromConfigFile( alias );
|
||||||
if( f ) {
|
if( f ) {
|
||||||
slotScheduleSync(alias);
|
slotScheduleSync(f);
|
||||||
emit( folderSyncStateChange( f->alias() ) );
|
emit( folderSyncStateChange( f ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +401,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use a signal mapper to connect the signals to the alias */
|
/* Use a signal mapper to connect the signals to the alias */
|
||||||
connect(folder, SIGNAL(scheduleToSync(const QString&)), SLOT(slotScheduleSync(const QString&)));
|
connect(folder, SIGNAL(scheduleToSync(Folder*)), SLOT(slotScheduleSync(Folder*)));
|
||||||
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
||||||
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
||||||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||||
|
@ -413,15 +412,14 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::slotSetFolderPaused( const QString& alias, bool paused )
|
void FolderMan::slotSetFolderPaused( Folder *f, bool paused )
|
||||||
{
|
{
|
||||||
Folder *f = folder(alias);
|
|
||||||
if( !f ) {
|
if( !f ) {
|
||||||
qDebug() << "!! Can not enable alias " << alias << ", can not be found in folderMap.";
|
qWarning() << "!! slotSetFolderPaused called with empty folder";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
slotScheduleSync(alias);
|
slotScheduleSync(f);
|
||||||
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
_disabledFolders.remove(f);
|
_disabledFolders.remove(f);
|
||||||
|
@ -429,7 +427,7 @@ void FolderMan::slotSetFolderPaused( const QString& alias, bool paused )
|
||||||
_disabledFolders.insert(f);
|
_disabledFolders.insert(f);
|
||||||
}
|
}
|
||||||
f->setSyncPaused(paused);
|
f->setSyncPaused(paused);
|
||||||
emit folderSyncStateChange(alias);
|
emit folderSyncStateChange(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this really terminates the current sync process
|
// this really terminates the current sync process
|
||||||
|
@ -437,7 +435,7 @@ void FolderMan::slotSetFolderPaused( const QString& alias, bool paused )
|
||||||
// csync still remains in a stable state, regardless of that.
|
// csync still remains in a stable state, regardless of that.
|
||||||
void FolderMan::terminateSyncProcess()
|
void FolderMan::terminateSyncProcess()
|
||||||
{
|
{
|
||||||
Folder *f = folder(_currentSyncFolder);
|
Folder *f = _currentSyncFolder;
|
||||||
if( f ) {
|
if( f ) {
|
||||||
// This will, indirectly and eventually, call slotFolderSyncFinished
|
// This will, indirectly and eventually, call slotFolderSyncFinished
|
||||||
// and thereby clear _currentSyncFolder.
|
// and thereby clear _currentSyncFolder.
|
||||||
|
@ -455,17 +453,11 @@ Folder *FolderMan::folder( const QString& alias )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncResult FolderMan::syncResult( const QString& alias )
|
|
||||||
{
|
|
||||||
Folder *f = folder( alias );
|
|
||||||
return f ? f->syncResult() : SyncResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FolderMan::slotScheduleAllFolders()
|
void FolderMan::slotScheduleAllFolders()
|
||||||
{
|
{
|
||||||
foreach( Folder *f, _folderMap.values() ) {
|
foreach( Folder *f, _folderMap.values() ) {
|
||||||
if (f && ! f->syncPaused()) {
|
if (f && ! f->syncPaused()) {
|
||||||
slotScheduleSync( f->alias() );
|
slotScheduleSync( f );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,13 +466,13 @@ void FolderMan::slotScheduleAllFolders()
|
||||||
* if a folder wants to be synced, it calls this slot and is added
|
* if a folder wants to be synced, it calls this slot and is added
|
||||||
* to the queue. The slot to actually start a sync is called afterwards.
|
* to the queue. The slot to actually start a sync is called afterwards.
|
||||||
*/
|
*/
|
||||||
void FolderMan::slotScheduleSync( const QString& alias )
|
void FolderMan::slotScheduleSync( Folder *f )
|
||||||
{
|
{
|
||||||
Folder* f = folder(alias);
|
|
||||||
if( !f ) {
|
if( !f ) {
|
||||||
qDebug() << "Not scheduling sync for empty or unknown folder" << alias;
|
qWarning() << "slotScheduleSync called with null folder";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto alias = f->alias();
|
||||||
|
|
||||||
if( _socketApi ) {
|
if( _socketApi ) {
|
||||||
// We want the SocketAPI to already now update so that it can show the EVAL icon
|
// We want the SocketAPI to already now update so that it can show the EVAL icon
|
||||||
|
@ -491,7 +483,7 @@ void FolderMan::slotScheduleSync( const QString& alias )
|
||||||
|
|
||||||
qDebug() << "Schedule folder " << alias << " to sync!";
|
qDebug() << "Schedule folder " << alias << " to sync!";
|
||||||
|
|
||||||
if( ! _scheduleQueue.contains(alias) ) {
|
if( ! _scheduleQueue.contains(f) ) {
|
||||||
if( !f->syncPaused() ) {
|
if( !f->syncPaused() ) {
|
||||||
f->prepareToSync();
|
f->prepareToSync();
|
||||||
} else {
|
} else {
|
||||||
|
@ -501,7 +493,7 @@ void FolderMan::slotScheduleSync( const QString& alias )
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_scheduleQueue.enqueue(alias);
|
_scheduleQueue.enqueue(f);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!";
|
qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!";
|
||||||
}
|
}
|
||||||
|
@ -554,7 +546,7 @@ void FolderMan::setSyncEnabled( bool enabled )
|
||||||
}
|
}
|
||||||
_syncEnabled = enabled;
|
_syncEnabled = enabled;
|
||||||
// force a redraw in case the network connect status changed
|
// force a redraw in case the network connect status changed
|
||||||
emit( folderSyncStateChange(QString::null) );
|
emit( folderSyncStateChange(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
||||||
|
@ -565,7 +557,7 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
||||||
if (_scheduleQueue.empty()) {
|
if (_scheduleQueue.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (! _currentSyncFolder.isEmpty()) {
|
if (_currentSyncFolder) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +565,7 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
||||||
qint64 msSinceLastSync = 0;
|
qint64 msSinceLastSync = 0;
|
||||||
|
|
||||||
// Require a pause based on the duration of the last sync run.
|
// Require a pause based on the duration of the last sync run.
|
||||||
if (Folder* lastFolder = folder(_lastSyncFolder)) {
|
if (Folder* lastFolder = _lastSyncFolder) {
|
||||||
msSinceLastSync = lastFolder->msecSinceLastSync();
|
msSinceLastSync = lastFolder->msecSinceLastSync();
|
||||||
|
|
||||||
// 1s -> 1.5s pause
|
// 1s -> 1.5s pause
|
||||||
|
@ -585,7 +577,7 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Punish consecutive follow-up syncs with longer delays.
|
// Punish consecutive follow-up syncs with longer delays.
|
||||||
if (Folder* nextFolder = folder(_scheduleQueue.head())) {
|
if (Folder* nextFolder = _scheduleQueue.head()) {
|
||||||
int followUps = nextFolder->consecutiveFollowUpSyncs();
|
int followUps = nextFolder->consecutiveFollowUpSyncs();
|
||||||
if (followUps >= 2) {
|
if (followUps >= 2) {
|
||||||
// This is okay due to the 1min maximum delay limit below.
|
// This is okay due to the 1min maximum delay limit below.
|
||||||
|
@ -616,8 +608,8 @@ void FolderMan::startScheduledSyncSoon(qint64 msMinimumDelay)
|
||||||
*/
|
*/
|
||||||
void FolderMan::slotStartScheduledFolderSync()
|
void FolderMan::slotStartScheduledFolderSync()
|
||||||
{
|
{
|
||||||
if( !_currentSyncFolder.isEmpty() ) {
|
if( _currentSyncFolder ) {
|
||||||
qDebug() << "Currently folder " << _currentSyncFolder << " is running, wait for finish!";
|
qDebug() << "Currently folder " << _currentSyncFolder->alias() << " is running, wait for finish!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,16 +624,12 @@ void FolderMan::slotStartScheduledFolderSync()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to start the top scheduled sync.
|
// Try to start the top scheduled sync.
|
||||||
const QString alias = _scheduleQueue.dequeue();
|
Folder *f = _scheduleQueue.dequeue();
|
||||||
Folder *f = folder(alias);
|
Q_ASSERT(f);
|
||||||
if( !f ) {
|
|
||||||
qDebug() << "FolderMan: Not syncing queued folder" << alias << ": not in folder map anymore";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start syncing this folder!
|
// Start syncing this folder!
|
||||||
if( !f->syncPaused() ) {
|
if( !f->syncPaused() ) {
|
||||||
_currentSyncFolder = alias;
|
_currentSyncFolder = f;
|
||||||
|
|
||||||
f->startSync( QStringList() );
|
f->startSync( QStringList() );
|
||||||
|
|
||||||
|
@ -660,66 +648,46 @@ void FolderMan::slotEtagPollTimerTimeout()
|
||||||
ConfigFile cfg;
|
ConfigFile cfg;
|
||||||
int polltime = cfg.remotePollInterval();
|
int polltime = cfg.remotePollInterval();
|
||||||
|
|
||||||
QSet<QString> folderAliases = _folderMap.keys().toSet();
|
foreach (Folder *f, _folderMap) {
|
||||||
QMutableSetIterator<QString> i(folderAliases);
|
if (_currentSyncFolder == f) {
|
||||||
while (i.hasNext()) {
|
|
||||||
QString alias = i.next();
|
|
||||||
if (_currentSyncFolder == alias) {
|
|
||||||
i.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (_scheduleQueue.contains(alias)) {
|
if (_scheduleQueue.contains(f)) {
|
||||||
i.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Folder *f = _folderMap.value(alias);
|
|
||||||
if (f && _disabledFolders.contains(f)) {
|
if (f && _disabledFolders.contains(f)) {
|
||||||
i.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f && (f->etagJob() || f->isBusy() || f->syncPaused())) {
|
if (f && (f->etagJob() || f->isBusy() || f->syncPaused())) {
|
||||||
i.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f && f->msecSinceLastSync() < polltime) {
|
if (f && f->msecSinceLastSync() < polltime) {
|
||||||
i.remove();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
QMetaObject::invokeMethod(f, "slotRunEtagJob", Qt::QueuedConnection);
|
||||||
|
|
||||||
if (folderAliases.isEmpty()) {
|
|
||||||
qDebug() << Q_FUNC_INFO << "No folders need to check for the remote ETag";
|
|
||||||
} else {
|
|
||||||
qDebug() << Q_FUNC_INFO << "The following folders need to check for the remote ETag:" << folderAliases;
|
|
||||||
i = folderAliases; // reset
|
|
||||||
while (i.hasNext()) {
|
|
||||||
QString alias = i.next();
|
|
||||||
QMetaObject::invokeMethod(_folderMap.value(alias), "slotRunEtagJob", Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::slotRemoveFoldersForAccount(AccountState* accountState)
|
void FolderMan::slotRemoveFoldersForAccount(AccountState* accountState)
|
||||||
{
|
{
|
||||||
QStringList foldersToRemove;
|
QVarLengthArray<Folder *, 16> foldersToRemove;
|
||||||
Folder::MapIterator i(_folderMap);
|
Folder::MapIterator i(_folderMap);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
Folder* folder = i.value();
|
Folder* folder = i.value();
|
||||||
if (folder->accountState() == accountState) {
|
if (folder->accountState() == accountState) {
|
||||||
foldersToRemove.append(folder->alias());
|
foldersToRemove.append(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Account was removed, removing associated folders:" << foldersToRemove;
|
foreach (const auto &f, foldersToRemove) {
|
||||||
foreach (const QString& alias, foldersToRemove) {
|
slotRemoveFolder(f);
|
||||||
slotRemoveFolder(alias);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::slotFolderSyncStarted( )
|
void FolderMan::slotFolderSyncStarted( )
|
||||||
{
|
{
|
||||||
qDebug() << ">===================================== sync started for " << _currentSyncFolder;
|
qDebug() << ">===================================== sync started for " << _currentSyncFolder->alias();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -730,10 +698,10 @@ void FolderMan::slotFolderSyncStarted( )
|
||||||
*/
|
*/
|
||||||
void FolderMan::slotFolderSyncFinished( const SyncResult& )
|
void FolderMan::slotFolderSyncFinished( const SyncResult& )
|
||||||
{
|
{
|
||||||
qDebug() << "<===================================== sync finished for " << _currentSyncFolder;
|
qDebug() << "<===================================== sync finished for " << _currentSyncFolder->alias();
|
||||||
|
|
||||||
_lastSyncFolder = _currentSyncFolder;
|
_lastSyncFolder = _currentSyncFolder;
|
||||||
_currentSyncFolder.clear();
|
_currentSyncFolder = 0;
|
||||||
|
|
||||||
startScheduledSyncSoon();
|
startScheduledSyncSoon();
|
||||||
}
|
}
|
||||||
|
@ -761,7 +729,7 @@ Folder* FolderMan::addFolderInternal(AccountState* accountState, const FolderDef
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use a signal mapper to connect the signals to the alias */
|
/* Use a signal mapper to connect the signals to the alias */
|
||||||
connect(folder, SIGNAL(scheduleToSync(const QString&)), SLOT(slotScheduleSync(const QString&)));
|
connect(folder, SIGNAL(scheduleToSync(Folder*)), SLOT(slotScheduleSync(Folder*)));
|
||||||
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
connect(folder, SIGNAL(syncStateChange()), _folderChangeSignalMapper, SLOT(map()));
|
||||||
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
|
||||||
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
|
||||||
|
@ -788,17 +756,16 @@ Folder *FolderMan::folderForPath(const QString &path)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FolderMan::slotRemoveFolder( const QString& alias )
|
void FolderMan::slotRemoveFolder( Folder *f )
|
||||||
{
|
{
|
||||||
Folder *f = folder(alias);
|
|
||||||
if( !f ) {
|
if( !f ) {
|
||||||
qDebug() << "!! Can not remove " << alias << ", not in folderMap.";
|
qWarning() << "!! Can not remove null folder";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Removing " << alias;
|
qDebug() << "Removing " << f->alias();
|
||||||
|
|
||||||
const bool currentlyRunning = (_currentSyncFolder == alias);
|
const bool currentlyRunning = (_currentSyncFolder == f);
|
||||||
if( currentlyRunning ) {
|
if( currentlyRunning ) {
|
||||||
// let the folder delete itself when done and
|
// let the folder delete itself when done and
|
||||||
// abort the sync now
|
// abort the sync now
|
||||||
|
@ -806,7 +773,7 @@ void FolderMan::slotRemoveFolder( const QString& alias )
|
||||||
terminateSyncProcess();
|
terminateSyncProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
_scheduleQueue.removeAll(alias);
|
_scheduleQueue.removeAll(f);
|
||||||
|
|
||||||
f->wipe();
|
f->wipe();
|
||||||
f->setSyncPaused(true);
|
f->setSyncPaused(true);
|
||||||
|
@ -814,7 +781,7 @@ void FolderMan::slotRemoveFolder( const QString& alias )
|
||||||
// remove the folder configuration
|
// remove the folder configuration
|
||||||
f->removeFromSettings();
|
f->removeFromSettings();
|
||||||
|
|
||||||
unloadFolder( alias );
|
unloadFolder( f);
|
||||||
if( !currentlyRunning ) {
|
if( !currentlyRunning ) {
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,6 @@ public:
|
||||||
/** Returns the folder by alias or NULL if no folder with the alias exists. */
|
/** Returns the folder by alias or NULL if no folder with the alias exists. */
|
||||||
Folder *folder( const QString& );
|
Folder *folder( const QString& );
|
||||||
|
|
||||||
/** Returns the last sync result by alias */
|
|
||||||
SyncResult syncResult( const QString& );
|
|
||||||
|
|
||||||
/** Creates a folder for a specific configuration, identified by alias. */
|
/** Creates a folder for a specific configuration, identified by alias. */
|
||||||
Folder* setupFolderFromConfigFile(const QString & );
|
Folder* setupFolderFromConfigFile(const QString & );
|
||||||
|
|
||||||
|
@ -86,18 +83,17 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* signal to indicate a folder named by alias has changed its sync state.
|
* signal to indicate a folder has changed its sync state.
|
||||||
* Get the state via the Folder Map or the syncResult and syncState methods.
|
|
||||||
*
|
*
|
||||||
* Attention: The alias string may be zero. Do a general update of the state than.
|
* Attention: The folder may be zero. Do a general update of the state than.
|
||||||
*/
|
*/
|
||||||
void folderSyncStateChange( const QString & );
|
void folderSyncStateChange(Folder*);
|
||||||
|
|
||||||
void folderListLoaded(const Folder::Map &);
|
void folderListLoaded(const Folder::Map &);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotRemoveFolder( const QString& );
|
void slotRemoveFolder( Folder* );
|
||||||
void slotSetFolderPaused(const QString&, bool paused);
|
void slotSetFolderPaused(Folder *, bool paused);
|
||||||
|
|
||||||
void slotFolderSyncStarted();
|
void slotFolderSyncStarted();
|
||||||
void slotFolderSyncFinished( const SyncResult& );
|
void slotFolderSyncFinished( const SyncResult& );
|
||||||
|
@ -122,7 +118,7 @@ public slots:
|
||||||
void setDirtyNetworkLimits();
|
void setDirtyNetworkLimits();
|
||||||
|
|
||||||
// slot to add a folder to the syncing queue
|
// slot to add a folder to the syncing queue
|
||||||
void slotScheduleSync( const QString & );
|
void slotScheduleSync(Folder*);
|
||||||
// slot to scheule an ETag job
|
// slot to scheule an ETag job
|
||||||
void slotScheduleETagJob ( const QString &alias, RequestEtagJob *job);
|
void slotScheduleETagJob ( const QString &alias, RequestEtagJob *job);
|
||||||
void slotEtagJobDestroyed (QObject*);
|
void slotEtagJobDestroyed (QObject*);
|
||||||
|
@ -142,7 +138,7 @@ private:
|
||||||
Folder* addFolderInternal(AccountState* accountState, const FolderDefinition& folderDefinition);
|
Folder* addFolderInternal(AccountState* accountState, const FolderDefinition& folderDefinition);
|
||||||
|
|
||||||
/* unloads a folder object, does not delete it */
|
/* unloads a folder object, does not delete it */
|
||||||
void unloadFolder( const QString& alias );
|
void unloadFolder( Folder * );
|
||||||
|
|
||||||
/** Will start a sync after a bit of delay. */
|
/** Will start a sync after a bit of delay. */
|
||||||
void startScheduledSyncSoon(qint64 msMinimumDelay = 0);
|
void startScheduledSyncSoon(qint64 msMinimumDelay = 0);
|
||||||
|
@ -158,8 +154,8 @@ private:
|
||||||
Folder::Map _folderMap;
|
Folder::Map _folderMap;
|
||||||
QString _folderConfigPath;
|
QString _folderConfigPath;
|
||||||
QSignalMapper *_folderChangeSignalMapper;
|
QSignalMapper *_folderChangeSignalMapper;
|
||||||
QString _currentSyncFolder;
|
Folder *_currentSyncFolder = 0;
|
||||||
QString _lastSyncFolder;
|
QPointer<Folder> _lastSyncFolder;
|
||||||
bool _syncEnabled;
|
bool _syncEnabled;
|
||||||
QTimer _etagPollTimer;
|
QTimer _etagPollTimer;
|
||||||
QPointer<RequestEtagJob> _currentEtagJob; // alias of Folder running the current RequestEtagJob
|
QPointer<RequestEtagJob> _currentEtagJob; // alias of Folder running the current RequestEtagJob
|
||||||
|
@ -168,7 +164,7 @@ private:
|
||||||
QPointer<SocketApi> _socketApi;
|
QPointer<SocketApi> _socketApi;
|
||||||
|
|
||||||
/** The aliases of folders that shall be synced. */
|
/** The aliases of folders that shall be synced. */
|
||||||
QQueue<QString> _scheduleQueue;
|
QQueue<Folder*> _scheduleQueue;
|
||||||
|
|
||||||
/** When the timer expires one of the scheduled syncs will be started. */
|
/** When the timer expires one of the scheduled syncs will be started. */
|
||||||
QTimer _startScheduledSyncTimer;
|
QTimer _startScheduledSyncTimer;
|
||||||
|
|
|
@ -486,7 +486,7 @@ void FolderStatusModel::slotApplySelectiveSync()
|
||||||
foreach(const auto &it, changes) {
|
foreach(const auto &it, changes) {
|
||||||
folder->journalDb()->avoidReadFromDbOnNextSync(it);
|
folder->journalDb()->avoidReadFromDbOnNextSync(it);
|
||||||
}
|
}
|
||||||
folderMan->slotScheduleSync(folder->alias());
|
folderMan->slotScheduleSync(folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ ownCloudGui::ownCloudGui(Application *parent) :
|
||||||
SLOT(slotUpdateProgress(QString,ProgressInfo)) );
|
SLOT(slotUpdateProgress(QString,ProgressInfo)) );
|
||||||
|
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
|
connect( folderMan, SIGNAL(folderSyncStateChange(Folder*)),
|
||||||
this,SLOT(slotSyncStateChange(QString)));
|
this,SLOT(slotSyncStateChange(Folder*)));
|
||||||
|
|
||||||
connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
|
connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
|
||||||
SLOT(slotShowTrayMessage(QString,QString)));
|
SLOT(slotShowTrayMessage(QString,QString)));
|
||||||
|
@ -169,18 +169,17 @@ void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ownCloudGui::slotSyncStateChange( const QString& alias )
|
void ownCloudGui::slotSyncStateChange( Folder* folder )
|
||||||
{
|
{
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
|
||||||
const SyncResult& result = folderMan->syncResult( alias );
|
|
||||||
|
|
||||||
slotComputeOverallSyncStatus();
|
slotComputeOverallSyncStatus();
|
||||||
|
|
||||||
if( alias.isEmpty() ) {
|
if( !folder ) {
|
||||||
return; // Valid, just a general GUI redraw was needed.
|
return; // Valid, just a general GUI redraw was needed.
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Sync state changed for folder " << alias << ": " << result.statusString();
|
auto result = folder->syncResult();
|
||||||
|
|
||||||
|
qDebug() << "Sync state changed for folder " << folder->alias() << ": " << result.statusString();
|
||||||
|
|
||||||
if (result.status() == SyncResult::Success || result.status() == SyncResult::Error) {
|
if (result.status() == SyncResult::Success || result.status() == SyncResult::Error) {
|
||||||
Logger::instance()->enterNextLogFile();
|
Logger::instance()->enterNextLogFile();
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
|
class Folder;
|
||||||
|
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
class SettingsDialogMac;
|
class SettingsDialogMac;
|
||||||
class Application;
|
class Application;
|
||||||
|
@ -62,7 +64,7 @@ public slots:
|
||||||
void slotShowSettings();
|
void slotShowSettings();
|
||||||
void slotShowSyncProtocol();
|
void slotShowSyncProtocol();
|
||||||
void slotShutdown();
|
void slotShutdown();
|
||||||
void slotSyncStateChange( const QString& alias );
|
void slotSyncStateChange(Folder*);
|
||||||
void slotTrayClicked( QSystemTrayIcon::ActivationReason reason );
|
void slotTrayClicked( QSystemTrayIcon::ActivationReason reason );
|
||||||
void slotToggleLogBrowser();
|
void slotToggleLogBrowser();
|
||||||
void slotOpenOwnCloud();
|
void slotOpenOwnCloud();
|
||||||
|
|
|
@ -413,7 +413,7 @@ void SelectiveSyncDialog::accept()
|
||||||
_folder->journalDb()->avoidReadFromDbOnNextSync(it);
|
_folder->journalDb()->avoidReadFromDbOnNextSync(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
folderMan->slotScheduleSync(_folder->alias());
|
folderMan->slotScheduleSync(_folder);
|
||||||
}
|
}
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue