vfs_suffix.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) by Christian Kamm <mail@ckamm.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #pragma once
  15. #include <QObject>
  16. #include <QScopedPointer>
  17. #include "common/vfs.h"
  18. #include "common/plugin.h"
  19. namespace OCC {
  20. class VfsSuffix : public Vfs
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit VfsSuffix(QObject *parent = nullptr);
  25. ~VfsSuffix() override;
  26. [[nodiscard]] Mode mode() const override;
  27. [[nodiscard]] QString fileSuffix() const override;
  28. void stop() override;
  29. void unregisterFolder() override;
  30. [[nodiscard]] bool socketApiPinStateActionsShown() const override { return true; }
  31. [[nodiscard]] bool isHydrating() const override;
  32. Result<void, QString> updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) override;
  33. Result<void, QString> createPlaceholder(const SyncFileItem &item) override;
  34. Result<void, QString> dehydratePlaceholder(const SyncFileItem &item) override;
  35. Result<Vfs::ConvertToPlaceholderResult, QString> convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override;
  36. bool needsMetadataUpdate(const SyncFileItem &) override { return false; }
  37. bool isDehydratedPlaceholder(const QString &filePath) override;
  38. bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override;
  39. bool setPinState(const QString &folderPath, PinState state) override
  40. { return setPinStateInDb(folderPath, state); }
  41. Optional<PinState> pinState(const QString &folderPath) override
  42. { return pinStateInDb(folderPath); }
  43. AvailabilityResult availability(const QString &folderPath) override;
  44. public slots:
  45. void fileStatusChanged(const QString &, OCC::SyncFileStatus) override {}
  46. protected:
  47. void startImpl(const VfsSetupParams &params) override;
  48. };
  49. class SuffixVfsPluginFactory : public QObject, public DefaultPluginFactory<VfsSuffix>
  50. {
  51. Q_OBJECT
  52. Q_PLUGIN_METADATA(IID "org.owncloud.PluginFactory" FILE "vfspluginmetadata.json")
  53. Q_INTERFACES(OCC::PluginFactory)
  54. };
  55. } // namespace OCC