[Pkg-owncloud-commits] [owncloud-client] 220/470: Connect the SocketApi directly to the SyncFileStatusTracker
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:25:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit ea5e6d367bdceab86e0f786ef5d3d98a43f856ed
Author: Jocelyn Turcotte <jturcotte at woboq.com>
Date: Mon Mar 21 12:35:57 2016 +0100
Connect the SocketApi directly to the SyncFileStatusTracker
Don't go through the Folder->ProgressDispatcher->SocketApi route and
keep the path logic in SyncFileStatusTracker.
---
src/gui/folder.cpp | 6 -----
src/gui/folder.h | 1 -
src/gui/folderman.cpp | 4 ++++
src/gui/socketapi.cpp | 45 ++---------------------------------
src/gui/socketapi.h | 5 +---
src/libsync/progressdispatcher.h | 2 --
src/libsync/syncfilestatustracker.cpp | 32 +++++++++++++++++++++++--
src/libsync/syncfilestatustracker.h | 5 ++++
8 files changed, 42 insertions(+), 58 deletions(-)
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 9cc7aef..bfa857f 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 a76b9e2..0603e7a 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 661d0f3..006555f 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 b3c7161..338fdfb 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());
-}
-
-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);
+ broadcastMessage(QLatin1String("STATUS"), systemFileName, fileStatus.toSocketAPIString());
}
-
-
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 5e29def..f010142 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 a89e0fd..ec555c3 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 e88459b..674c608 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 ac8a823..4ed067f 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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list