/* * Copyright (C) by Kevin Ottens * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ #pragma once #include #include "owncloudlib.h" #include "common/pinstate.h" #include "common/result.h" struct CF_PLACEHOLDER_BASIC_INFO; namespace OCC { class VfsCfApi; namespace CfApiWrapper { class OWNCLOUDSYNC_EXPORT ConnectionKey { public: ConnectionKey(); inline void *get() const { return _data.get(); } private: std::unique_ptr _data; }; class OWNCLOUDSYNC_EXPORT FileHandle { public: using Deleter = void (*)(void *); FileHandle(); FileHandle(void *data, Deleter deleter); inline void *get() const { return _data.get(); } inline explicit operator bool() const noexcept { return static_cast(_data); } private: std::unique_ptr _data; }; class OWNCLOUDSYNC_EXPORT PlaceHolderInfo { public: using Deleter = void (*)(CF_PLACEHOLDER_BASIC_INFO *); PlaceHolderInfo(); PlaceHolderInfo(CF_PLACEHOLDER_BASIC_INFO *data, Deleter deleter); inline CF_PLACEHOLDER_BASIC_INFO *get() const noexcept { return _data.get(); } inline CF_PLACEHOLDER_BASIC_INFO *operator->() const noexcept { return _data.get(); } inline explicit operator bool() const noexcept { return static_cast(_data); } Optional pinState() const; private: std::unique_ptr _data; }; OWNCLOUDSYNC_EXPORT Result registerSyncRoot(const QString &path, const QString &providerName, const QString &providerVersion, const QString &folderAlias, const QString &displayName, const QString &accountDisplayName); OWNCLOUDSYNC_EXPORT Result unregisterSyncRoot(const QString &path, const QString &providerName, const QString &accountDisplayName); OWNCLOUDSYNC_EXPORT Result connectSyncRoot(const QString &path, VfsCfApi *context); OWNCLOUDSYNC_EXPORT Result disconnectSyncRoot(ConnectionKey &&key); OWNCLOUDSYNC_EXPORT bool isSparseFile(const QString &path); OWNCLOUDSYNC_EXPORT FileHandle handleForPath(const QString &path); OWNCLOUDSYNC_EXPORT PlaceHolderInfo findPlaceholderInfo(const FileHandle &handle); enum SetPinRecurseMode { NoRecurse = 0, Recurse, ChildrenOnly }; OWNCLOUDSYNC_EXPORT Result setPinState(const FileHandle &handle, PinState state, SetPinRecurseMode mode); OWNCLOUDSYNC_EXPORT Result createPlaceholderInfo(const QString &path, time_t modtime, qint64 size, const QByteArray &fileId); OWNCLOUDSYNC_EXPORT Result updatePlaceholderInfo(const FileHandle &handle, time_t modtime, qint64 size, const QByteArray &fileId, const QString &replacesPath = QString()); OWNCLOUDSYNC_EXPORT Result convertToPlaceholder(const FileHandle &handle, time_t modtime, qint64 size, const QByteArray &fileId, const QString &replacesPath); } } // namespace OCC