return {};
}
-VfsDefaults::VfsDefaults(QObject *parent)
- : Vfs(parent)
-{
-}
-
-void VfsDefaults::start(const VfsSetupParams ¶ms)
+void Vfs::start(const VfsSetupParams ¶ms)
{
_setupParams = params;
+ startImpl(params);
}
-bool VfsDefaults::setPinState(const QString &folderPath, PinState state)
+bool Vfs::setPinStateInDb(const QString &folderPath, PinState state)
{
auto path = folderPath.toUtf8();
_setupParams.journal->internalPinStates().wipeForPathAndBelow(path);
return true;
}
-Optional<PinState> VfsDefaults::pinState(const QString &folderPath)
+Optional<PinState> Vfs::pinStateInDb(const QString &folderPath)
{
return _setupParams.journal->internalPinStates().effectiveForPath(folderPath.toUtf8());
}
VfsOff::VfsOff(QObject *parent)
- : VfsDefaults(parent)
+ : Vfs(parent)
{
}
/// For WithSuffix modes: the suffix (including the dot)
virtual QString fileSuffix() const = 0;
+ /// Access to the parameters the instance was start()ed with.
+ const VfsSetupParams ¶ms() const { return _setupParams; }
+
/** Initializes interaction with the VFS provider.
*
- * For example, the VFS provider might monitor files to be able to start a file
- * hydration (download of a file's remote contents) when the user wants to open
- * it.
- *
- * Usually some registration needs to be done with the backend. This function
- * should take care of it if necessary.
+ * The plugin-specific work is done in startImpl().
*/
- virtual void start(const VfsSetupParams ¶ms) = 0;
+ void start(const VfsSetupParams ¶ms);
/// Stop interaction with VFS provider. Like when the client application quits.
virtual void stop() = 0;
void beginHydrating();
/// Emitted when the hydration ends
void doneHydrating();
-};
-class OCSYNC_EXPORT VfsDefaults : public Vfs
-{
-public:
- explicit VfsDefaults(QObject* parent = nullptr);
-
- // stores the params
- void start(const VfsSetupParams ¶ms) override;
-
- // use the journal to back the pinstates
- bool setPinState(const QString &folderPath, PinState state) override;
- Optional<PinState> pinState(const QString &folderPath) override;
+protected:
+ /** Setup the plugin for the folder.
+ *
+ * For example, the VFS provider might monitor files to be able to start a file
+ * hydration (download of a file's remote contents) when the user wants to open
+ * it.
+ *
+ * Usually some registration needs to be done with the backend. This function
+ * should take care of it if necessary.
+ */
+ virtual void startImpl(const VfsSetupParams ¶ms) = 0;
- // access initial setup data
- const VfsSetupParams ¶ms() const { return _setupParams; }
+ // Db-backed pin state handling. Derived classes may use it to implement pin states.
+ bool setPinStateInDb(const QString &folderPath, PinState state);
+ Optional<PinState> pinStateInDb(const QString &folderPath);
-protected:
+ // the parameters passed to start()
VfsSetupParams _setupParams;
};
/// Implementation of Vfs for Vfs::Off mode - does nothing
-class OCSYNC_EXPORT VfsOff : public VfsDefaults
+class OCSYNC_EXPORT VfsOff : public Vfs
{
Q_OBJECT
bool isDehydratedPlaceholder(const QString &) override { return false; }
bool statTypeVirtualFile(csync_file_stat_t *, void *) override { return false; }
+ bool setPinState(const QString &folderPath, PinState state) override
+ { return setPinStateInDb(folderPath, state); }
+ Optional<PinState> pinState(const QString &folderPath) override
+ { return pinStateInDb(folderPath); }
+
public slots:
void fileStatusChanged(const QString &, SyncFileStatus) override {}
+
+protected:
+ void startImpl(const VfsSetupParams &) override {}
};
/// Check whether the plugin for the mode is available.
namespace OCC {
-class VfsSuffix : public VfsDefaults
+class VfsSuffix : public Vfs
{
Q_OBJECT
bool isDehydratedPlaceholder(const QString &filePath) override;
bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override;
+ bool setPinState(const QString &folderPath, PinState state) override
+ { return setPinStateInDb(folderPath, state); }
+ Optional<PinState> pinState(const QString &folderPath) override
+ { return pinStateInDb(folderPath); }
+
public slots:
void fileStatusChanged(const QString &, SyncFileStatus) override {}
+
+protected:
+ void startImpl(const VfsSetupParams &) override {}
};
class SuffixVfsPluginFactory : public QObject, public DefaultPluginFactory<VfsSuffix>