#pragma once #include "SiaCommon.h" #include "SiaCurl.h" NS_BEGIN(Sia) NS_BEGIN(Api) class AFX_EXT_CLASS CSiaApi { public: enum class _SiaApiError { Success, NotImplemented, RequestError, WalletExists, WalletLocked, WalletUnlocked, WalletNotCreated }; enum class _SiaSeedLanguage { English, German, Japanese }; class _CSiaFileTree; class AFX_EXT_CLASS _CSiaFile { friend CSiaApi; friend _CSiaFileTree; private: _CSiaFile(CSiaCurl& siaCurl, const json& fileJson); public: ~_CSiaFile(); private: CSiaCurl& _siaCurl; // Properties Property(String, SiaPath, public, private) Property(std::uint64_t, FileSize, public, private) Property(bool, Available, public, private) Property(bool, Renewing, public, private) Property(std::uint32_t, Redundancy, public, private) Property(std::uint32_t, UploadProgress, public, private) Property(std::uint32_t, Expiration, public, private) }; class AFX_EXT_CLASS _CSiaFileTree { friend CSiaApi; public: _CSiaFileTree(CSiaCurl& siaCurl); public: ~_CSiaFileTree(); private: CSiaCurl& _siaCurl; private: std::vector> _fileList; public: void BuildTree(const json& result); std::vector> GetFileList() const; std::vector> Query(String query) const; std::shared_ptr<_CSiaFile> GetFile(const String& siaPath) const; bool FileExists(const String& siaPath) const; }; class AFX_EXT_CLASS _CSiaWallet { friend CSiaApi; private: _CSiaWallet(CSiaCurl& siaCurl); public: ~_CSiaWallet(); private: CSiaCurl& _siaCurl; // Properties Property(bool, Created, public, private) Property(bool, Locked, public, private) public: _SiaApiError Create(const _SiaSeedLanguage& seedLanguage, String& seed); bool Refresh(); _SiaApiError Restore(const String& seed); _SiaApiError Lock(); _SiaApiError Unlock(const String& password); _SiaApiError GetConfirmedBalance(SiaCurrency& balance) const; _SiaApiError GetUnonfirmedBalance(SiaCurrency& balance) const; _SiaApiError GetAddress(String& address) const; }; class AFX_EXT_CLASS _CSiaRenter { friend CSiaApi; private: _CSiaRenter(CSiaCurl& siaCurl); public: ~_CSiaRenter(); private: CSiaCurl& _siaCurl; public: _SiaApiError FileExists(const String& siaPath, bool& exists) const; _SiaApiError DeleteFile(const String& siaPath); _SiaApiError DownloadFile(const String& siaPath, const String& location) const; _SiaApiError QueueUploadFile(const String& siaPath, const String& filePath); _SiaApiError GetFileTree(std::shared_ptr<_CSiaFileTree>& siaFileTree) const; }; public: CSiaApi(const SiaHostConfig& hostConfig); public: ~CSiaApi(); private: CSiaCurl _siaCurl; std::shared_ptr<_CSiaWallet> _wallet; std::shared_ptr<_CSiaRenter> _renter; public: static String FormatToSiaPath(String path); public: std::shared_ptr<_CSiaWallet> GetWallet() const; std::shared_ptr<_CSiaRenter> GetRenter() const; String GetServerVersion() const; }; typedef CSiaApi::_SiaApiError SiaApiError; typedef CSiaApi::_SiaSeedLanguage SiaSeedLanguage; typedef CSiaApi::_CSiaWallet CSiaWallet; typedef CSiaApi::_CSiaRenter CSiaRenter; typedef std::shared_ptr CSiaWalletPtr; typedef std::shared_ptr CSiaRenterPtr; typedef CSiaApi::_CSiaFile CSiaFile; typedef std::shared_ptr CSiaFilePtr; typedef std::vector CSiaFileCollection; typedef CSiaApi::_CSiaFileTree CSiaFileTree; typedef std::shared_ptr CSiaFileTreePtr; NS_END(2)