diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 9cc7aef0e6..bfa857ff12 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -114,7 +114,6 @@ 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(syncItemDiscovered(const SyncFileItem &)), this, SLOT(slotSyncItemDiscovered(const SyncFileItem &))); connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString))); } @@ -913,11 +912,6 @@ void Folder::slotItemCompleted(const SyncFileItem &item, const PropagatorJob& jo emit ProgressDispatcher::instance()->itemCompleted(alias(), item, job); } -void Folder::slotSyncItemDiscovered(const SyncFileItem & item) -{ - emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item); -} - void Folder::slotNewBigFolderDiscovered(const QString &newF) { auto newFolder = newF; diff --git a/src/gui/folder.h b/src/gui/folder.h index a76b9e2557..0603e7a64c 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -248,7 +248,6 @@ private slots: void slotFolderDiscovered(bool local, QString folderName); void slotTransmissionProgress(const ProgressInfo& pi); void slotItemCompleted(const SyncFileItem&, const PropagatorJob&); - void slotSyncItemDiscovered(const SyncFileItem & item); void slotRunEtagJob(); void etagRetreived(const QString &); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 661d0f3ce2..006555f3c8 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -105,6 +105,8 @@ void FolderMan::unloadFolder( Folder *f ) this, SLOT(slotForwardFolderSyncStateChange())); disconnect(f, SIGNAL(syncPausedChanged(Folder*,bool)), this, SLOT(slotFolderSyncPaused(Folder*,bool))); + disconnect(&f->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)), + _socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus))); } int FolderMan::unloadAndDeleteAllFolders() @@ -796,6 +798,8 @@ Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition, A connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult))); connect(folder, SIGNAL(syncStateChange()), SLOT(slotForwardFolderSyncStateChange())); connect(folder, SIGNAL(syncPausedChanged(Folder*,bool)), SLOT(slotFolderSyncPaused(Folder*,bool))); + connect(&folder->syncEngine().syncFileStatusTracker(), SIGNAL(fileStatusChanged(const QString &, SyncFileStatus)), + _socketApi.data(), SLOT(slotFileStatusChanged(const QString &, SyncFileStatus))); registerFolderMonitor(folder); return folder; diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index b3c7161f6c..338fdfbbff 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -114,10 +114,6 @@ SocketApi::SocketApi(QObject* parent) // folder watcher connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)), this, SLOT(slotUpdateFolderView(Folder*))); - connect(ProgressDispatcher::instance(), SIGNAL(itemCompleted(QString, const SyncFileItem &, const PropagatorJob &)), - SLOT(slotItemCompleted(QString, const SyncFileItem &))); - connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString, const SyncFileItem &)), - this, SLOT(slotSyncItemDiscovered(QString, const SyncFileItem &))); } SocketApi::~SocketApi() @@ -225,48 +221,11 @@ void SocketApi::slotUpdateFolderView(Folder *f) } } -void SocketApi::slotItemCompleted(const QString &folder, const SyncFileItem &item) +void SocketApi::slotFileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus) { - if (_listeners.isEmpty()) { - return; - } - - Folder *f = FolderMan::instance()->folder(folder); - if (!f) { - return; - } - - auto status = f->syncEngine().syncFileStatusTracker().fileStatus(item.destination()); - const QString path = f->path() + item.destination(); - broadcastMessage(QLatin1String("STATUS"), path, status.toSocketAPIString()); + broadcastMessage(QLatin1String("STATUS"), systemFileName, fileStatus.toSocketAPIString()); } -void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem &item) -{ - if (_listeners.isEmpty()) { - return; - } - - Folder *f = FolderMan::instance()->folder(folder); - if (!f) { - return; - } - - QString path = f->path() + item.destination(); - - // the trailing slash for directories must be appended as the filenames coming in - // from the plugins have that too. Otherwise the matching entry item is not found - // in the plugin. - if( item._type == SyncFileItem::Type::Directory ) { - path += QLatin1Char('/'); - } - - const QString command = QLatin1String("SYNC"); - broadcastMessage(QLatin1String("STATUS"), path, command); -} - - - void SocketApi::sendMessage(QIODevice *socket, const QString& message, bool doWait) { DEBUG << "Sending message: " << message; diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h index 5e29def36e..f01014225f 100644 --- a/src/gui/socketapi.h +++ b/src/gui/socketapi.h @@ -60,12 +60,9 @@ private slots: void slotNewConnection(); void onLostConnection(); void slotReadSocket(); - void slotItemCompleted(const QString &, const SyncFileItem &); - void slotSyncItemDiscovered(const QString &, const SyncFileItem &); + void slotFileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus); private: - SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName); - void sendMessage(QIODevice* socket, const QString& message, bool doWait = false); void broadcastMessage(const QString& verb, const QString &path, const QString &status = QString::null, bool doWait = false); diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h index a89e0fd3a2..ec555c3131 100644 --- a/src/libsync/progressdispatcher.h +++ b/src/libsync/progressdispatcher.h @@ -239,8 +239,6 @@ signals: const SyncFileItem & item, const PropagatorJob & job); - void syncItemDiscovered(const QString &folder, const SyncFileItem & item); - protected: void setProgressInfo(const QString& folder, const ProgressInfo& progress); diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp index e88459ba41..674c608e53 100644 --- a/src/libsync/syncfilestatustracker.cpp +++ b/src/libsync/syncfilestatustracker.cpp @@ -54,8 +54,10 @@ SyncFileStatusTracker::SyncFileStatusTracker(SyncEngine *syncEngine) connect(syncEngine, SIGNAL(aboutToPropagate(SyncFileItemVector&)), this, SLOT(slotAboutToPropagate(SyncFileItemVector&))); connect(syncEngine, SIGNAL(finished(bool)), SLOT(slotSyncFinished())); - connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)), - this, SLOT(slotItemCompleted(const SyncFileItem &))); + connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem&, const PropagatorJob&)), + this, SLOT(slotItemCompleted(const SyncFileItem&))); + connect(syncEngine, SIGNAL(syncItemDiscovered(const SyncFileItem&)), + this, SLOT(slotItemDiscovered(const SyncFileItem&))); } bool SyncFileStatusTracker::estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s) @@ -225,6 +227,32 @@ void SyncFileStatusTracker::slotItemCompleted(const SyncFileItem &item) if (showErrorInSocketApi(item)) { _stateLastSyncItemsWithErrorNew.insert(item._file); } + + QString systemFileName = _syncEngine->localPath() + item.destination(); + + // the trailing slash for directories must be appended as the filenames coming in + // from the plugins have that too. Otherwise the matching entry item is not found + // in the plugin. + if( item._type == SyncFileItem::Type::Directory ) { + systemFileName += QLatin1Char('/'); + } + + auto status = fileStatus(item.destination()); + emit fileStatusChanged(systemFileName, status); +} + +void SyncFileStatusTracker::slotItemDiscovered(const SyncFileItem &item) +{ + QString systemFileName = _syncEngine->localPath() + item.destination(); + + // the trailing slash for directories must be appended as the filenames coming in + // from the plugins have that too. Otherwise the matching entry item is not found + // in the plugin. + if( item._type == SyncFileItem::Type::Directory ) { + systemFileName += QLatin1Char('/'); + } + + emit fileStatusChanged(systemFileName, SyncFileStatus(SyncFileStatus::STATUS_EVAL)); } } diff --git a/src/libsync/syncfilestatustracker.h b/src/libsync/syncfilestatustracker.h index ac8a8233c6..4ed067ff18 100644 --- a/src/libsync/syncfilestatustracker.h +++ b/src/libsync/syncfilestatustracker.h @@ -26,15 +26,20 @@ class SyncEngine; class OWNCLOUDSYNC_EXPORT SyncFileStatusTracker : public QObject { + Q_OBJECT public: SyncFileStatusTracker(SyncEngine *syncEngine); SyncFileStatus fileStatus(const QString& systemFileName); +signals: + void fileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus); + private slots: void slotThreadTreeWalkResult(const SyncFileItemVector& items); void slotAboutToPropagate(SyncFileItemVector& items); void slotSyncFinished(); void slotItemCompleted(const SyncFileItem &item); + void slotItemDiscovered(const SyncFileItem &item); private: bool estimateState(QString fn, csync_ftw_type_e t, SyncFileStatus* s);