diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 16:57:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:57:47 +0100 |
commit | 3e16c3a78fff61c20e63ba730d15e94e3bb877b4 (patch) | |
tree | c070350db219f2c4241d22bc31949685c7b42fe9 /src/client/clientmedia.h | |
parent | 5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (diff) | |
parent | 6ccb5835ff55d85156be91473c598eca9d6cb9a6 (diff) | |
download | dragonfireclient-3e16c3a78fff61c20e63ba730d15e94e3bb877b4.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/client/clientmedia.h')
-rw-r--r-- | src/client/clientmedia.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/client/clientmedia.h b/src/client/clientmedia.h index 6a52c551d..5a918535b 100644 --- a/src/client/clientmedia.h +++ b/src/client/clientmedia.h @@ -35,7 +35,8 @@ struct HTTPFetchResult; // Store file into media cache (unless it exists already) // Validating the hash is responsibility of the caller -bool clientMediaUpdateCache(const std::string &raw_hash, const std::string &filedata); +bool clientMediaUpdateCache(const std::string &raw_hash, + const std::string &filedata); class ClientMediaDownloader { @@ -43,21 +44,22 @@ public: ClientMediaDownloader(); ~ClientMediaDownloader(); - float getProgress() const - { + float getProgress() const { if (m_uncached_count >= 1) - return 1.0f * m_uncached_received_count / m_uncached_count; + return 1.0f * m_uncached_received_count / + m_uncached_count; return 0.0f; } - bool isStarted() const { return m_initial_step_done; } + bool isStarted() const { + return m_initial_step_done; + } // If this returns true, the downloader is done and can be deleted - bool isDone() const - { + bool isDone() const { return m_initial_step_done && - m_uncached_received_count == m_uncached_count; + m_uncached_received_count == m_uncached_count; } // Add a file to the list of required file (but don't fetch it yet) @@ -80,42 +82,44 @@ public: // Must be called for each file received through TOCLIENT_MEDIA void conventionalTransferDone( - const std::string &name, const std::string &data, Client *client); + const std::string &name, + const std::string &data, + Client *client); private: - struct FileStatus - { + struct FileStatus { bool received; std::string sha1; s32 current_remote; std::vector<s32> available_remotes; }; - struct RemoteServerStatus - { + struct RemoteServerStatus { std::string baseurl; s32 active_count; }; void initialStep(Client *client); void remoteHashSetReceived(const HTTPFetchResult &fetch_result); - void remoteMediaReceived(const HTTPFetchResult &fetch_result, Client *client); + void remoteMediaReceived(const HTTPFetchResult &fetch_result, + Client *client); s32 selectRemoteServer(FileStatus *filestatus); void startRemoteMediaTransfers(); void startConventionalTransfers(Client *client); bool checkAndLoad(const std::string &name, const std::string &sha1, - const std::string &data, bool is_from_cache, Client *client); + const std::string &data, bool is_from_cache, + Client *client); std::string serializeRequiredHashSet(); - static void deSerializeHashSet( - const std::string &data, std::set<std::string> &result); + static void deSerializeHashSet(const std::string &data, + std::set<std::string> &result); // Maps filename to file status - std::map<std::string, FileStatus *> m_files; + std::map<std::string, FileStatus*> m_files; // Array of remote media servers - std::vector<RemoteServerStatus *> m_remotes; + std::vector<RemoteServerStatus*> m_remotes; // Filesystem-based media cache FileCache m_media_cache; @@ -144,4 +148,5 @@ private: // don't need to be looked at again // (use m_files.upper_bound(m_name_bound) to get an iterator) std::string m_name_bound = ""; + }; |