From e2eea24a03a922e9084f081304bbb30beee558e2 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 21 Jan 2019 11:24:16 +0100 Subject: [PATCH] Vfs: Send SyncFileStatusTracker data to vfs plugins --- src/common/vfs.h | 13 +++++++++++++ src/gui/folder.cpp | 10 ++++++++-- src/libsync/vfs/suffix/vfs_suffix.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/common/vfs.h b/src/common/vfs.h index a358619cb..f9f209e13 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -21,6 +21,7 @@ #include "ocsynclib.h" #include "result.h" +#include "syncfilestatus.h" typedef struct csync_file_stat_s csync_file_stat_t; @@ -153,6 +154,15 @@ public: */ virtual bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) = 0; +public slots: + /** Update in-sync state based on SyncFileStatusTracker signal. + * + * For some vfs plugins the icons aren't based on SocketAPI but rather on data shared + * via the vfs plugin. The connection to SyncFileStatusTracker allows both to be based + * on the same data. + */ + virtual void fileStatusChanged(const QString &systemFileName, SyncFileStatus fileStatus) = 0; + signals: /// Emitted when a user-initiated hydration starts void beginHydrating(); @@ -187,6 +197,9 @@ public: bool isDehydratedPlaceholder(const QString &) override { return false; } bool statTypeVirtualFile(csync_file_stat_t *, void *) override { return false; } + +public slots: + void fileStatusChanged(const QString &, SyncFileStatus) override {} }; /// Check whether the plugin for the mode is available. diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index db9c2c296..f4a8107a1 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -481,8 +481,11 @@ void Folder::startVfs() vfsParams.providerName = Theme::instance()->appNameGUI(); vfsParams.providerVersion = Theme::instance()->version(); - connect(_vfs.data(), &OCC::Vfs::beginHydrating, this, &Folder::slotHydrationStarts); - connect(_vfs.data(), &OCC::Vfs::doneHydrating, this, &Folder::slotHydrationDone); + connect(_vfs.data(), &Vfs::beginHydrating, this, &Folder::slotHydrationStarts); + connect(_vfs.data(), &Vfs::doneHydrating, this, &Folder::slotHydrationDone); + + connect(&_engine->syncFileStatusTracker(), &SyncFileStatusTracker::fileStatusChanged, + _vfs.data(), &Vfs::fileStatusChanged); _vfs->registerFolder(vfsParams); // Do this always? _vfs->start(vfsParams); @@ -637,6 +640,9 @@ void Folder::setSupportsVirtualFiles(bool enabled) _vfs->stop(); _vfs->unregisterFolder(); + disconnect(_vfs.data(), 0, this, 0); + disconnect(&_engine->syncFileStatusTracker(), 0, _vfs.data(), 0); + _vfs.reset(createVfsFromPlugin(newMode).release()); _definition.virtualFilesMode = newMode; diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h index 6c60c530a..2949533aa 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.h +++ b/src/libsync/vfs/suffix/vfs_suffix.h @@ -46,6 +46,9 @@ public: bool isDehydratedPlaceholder(const QString &filePath) override; bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override; + +public slots: + void fileStatusChanged(const QString &, SyncFileStatus) override {} }; class SuffixVfsPluginFactory : public QObject, public DefaultPluginFactory