Vfs: Send SyncFileStatusTracker data to vfs plugins

This commit is contained in:
Christian Kamm 2019-01-21 11:24:16 +01:00 committed by Kevin Ottens
parent 31394f14b5
commit e2eea24a03
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
3 changed files with 24 additions and 2 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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<VfsSuffix>