// // Created by WolverinDEV on 20/04/2021. // #pragma once #include namespace ts::server::file { namespace filesystem { class RustFileSystem : public filesystem::AbstractProvider { using FileModifyError = filesystem::FileModifyError; using DirectoryModifyError = filesystem::DirectoryModifyError; public: virtual ~RustFileSystem(); std::shared_ptr> initialize_server(const std::shared_ptr & /* server */) override; std::shared_ptr> query_channel_info(const std::shared_ptr & /* server */, const std::vector>& /* names */) override; std::shared_ptr query_channel_directory(const std::shared_ptr & id, ChannelId channelId, const std::string &string) override; std::shared_ptr> create_channel_directory(const std::shared_ptr & id, ChannelId channelId, const std::string &string) override; std::shared_ptr> delete_channel_files(const std::shared_ptr & id, ChannelId channelId, const std::vector &string) override; std::shared_ptr> rename_channel_file(const std::shared_ptr & id, ChannelId channelId, const std::string &, ChannelId, const std::string &) override; std::shared_ptr> query_icon_info(const std::shared_ptr & /* server */, const std::vector& /* names */) override; std::shared_ptr query_icon_directory(const std::shared_ptr & id) override; std::shared_ptr> delete_icons(const std::shared_ptr & id, const std::vector &string) override; std::shared_ptr> query_avatar_info(const std::shared_ptr & /* server */, const std::vector& /* names */) override; std::shared_ptr query_avatar_directory(const std::shared_ptr & id) override; std::shared_ptr> delete_avatars(const std::shared_ptr & id, const std::vector &string) override; private: template std::shared_ptr> create_execute_response() { return std::make_shared>(this->result_notify_mutex, this->result_notify_cv); } std::shared_ptr> execute_info(const char* /* server unique id */, void* /* query */, size_t /* query count */); std::shared_ptr execute_query(const char* /* server unique id */, void* /* directory */); std::shared_ptr> execute_delete(const char* /* server unique id */, void* /* files */, size_t /* file count */); std::mutex result_notify_mutex{}; std::condition_variable result_notify_cv{}; }; } namespace transfer { class RustFileTransfer : public AbstractProvider { public: std::shared_ptr>> initialize_channel_transfer(Transfer::Direction direction, const std::shared_ptr &ptr, ChannelId id, const TransferInfo &info) override; std::shared_ptr>> initialize_icon_transfer(Transfer::Direction direction, const std::shared_ptr &ptr, const TransferInfo &info) override; std::shared_ptr>> initialize_avatar_transfer(Transfer::Direction direction, const std::shared_ptr &ptr, const TransferInfo &info) override; std::shared_ptr>> list_transfer() override; std::shared_ptr> stop_transfer(const std::shared_ptr &ptr, transfer_id id, bool b) override; private: template std::shared_ptr> create_execute_response() { return std::make_shared>(this->result_notify_mutex, this->result_notify_cv); } std::mutex result_notify_mutex{}; std::condition_variable result_notify_cv{}; }; } class RustVirtualFileServer : public VirtualFileServer { public: explicit RustVirtualFileServer(ServerId server_id, std::string unique_id) : VirtualFileServer{server_id, std::move(unique_id)} {} void max_networking_upload_bandwidth(int64_t value) override; void max_networking_download_bandwidth(int64_t value) override; }; class RustFileProvider : public AbstractFileServer { public: RustFileProvider(); virtual ~RustFileProvider(); [[nodiscard]] std::string file_base_path() const override; filesystem::AbstractProvider &file_system() override; transfer::AbstractProvider &file_transfer() override; std::shared_ptr register_server(ServerId /* server id */) override; void unregister_server(ServerId /* server id */, bool /* delete files */) override; private: filesystem::RustFileSystem* file_system_; transfer::RustFileTransfer* file_transfer_; }; }