Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
SingleMediaDownloader Class Reference

#include <clientmedia.h>

+ Inheritance diagram for SingleMediaDownloader:
+ Collaboration diagram for SingleMediaDownloader:

Public Member Functions

 SingleMediaDownloader (bool write_to_cache)
 
 ~SingleMediaDownloader ()
 
bool isStarted () const override
 
bool isDone () const override
 
void addFile (const std::string &name, const std::string &sha1) override
 
void addRemoteServer (const std::string &baseurl) override
 
void step (Client *client) override
 
bool conventionalTransferDone (const std::string &name, const std::string &data, Client *client) override
 

Protected Member Functions

bool loadMedia (Client *client, const std::string &data, const std::string &name) override
 
- Protected Member Functions inherited from IClientMediaDownloader
 IClientMediaDownloader ()
 
virtual ~IClientMediaDownloader ()=default
 
bool tryLoadFromCache (const std::string &name, const std::string &sha1, Client *client)
 
bool checkAndLoad (const std::string &name, const std::string &sha1, const std::string &data, bool is_from_cache, Client *client)
 

Private Types

enum  Stage { STAGE_INIT , STAGE_CACHE_CHECKED , STAGE_DONE }
 

Private Member Functions

void initialStep (Client *client)
 
void remoteMediaReceived (const HTTPFetchResult &fetch_result, Client *client)
 
void startRemoteMediaTransfer ()
 
void startConventionalTransfer (Client *client)
 

Private Attributes

std::string m_file_name
 
std::string m_file_sha1
 
s32 m_current_remote
 
std::vector< std::string > m_remotes
 
enum Stage m_stage = STAGE_INIT
 
unsigned long m_httpfetch_caller
 
unsigned long m_httpfetch_next_id = 0
 

Additional Inherited Members

- Protected Attributes inherited from IClientMediaDownloader
FileCache m_media_cache
 
bool m_write_to_cache
 

Member Enumeration Documentation

◆ Stage

Enumerator
STAGE_INIT 
STAGE_CACHE_CHECKED 
STAGE_DONE 

Constructor & Destructor Documentation

◆ SingleMediaDownloader()

SingleMediaDownloader::SingleMediaDownloader ( bool write_to_cache)

◆ ~SingleMediaDownloader()

SingleMediaDownloader::~SingleMediaDownloader ( )

References httpfetch_caller_free(), HTTPFETCH_DISCARD, and m_httpfetch_caller.

+ Here is the call graph for this function:

Member Function Documentation

◆ addFile()

void SingleMediaDownloader::addFile ( const std::string & name,
const std::string & sha1 )
overridevirtual

◆ addRemoteServer()

void SingleMediaDownloader::addRemoteServer ( const std::string & baseurl)
overridevirtual

Implements IClientMediaDownloader.

References g_settings, Settings::getBool(), m_remotes, m_stage, and STAGE_INIT.

+ Here is the call graph for this function:

◆ conventionalTransferDone()

bool SingleMediaDownloader::conventionalTransferDone ( const std::string & name,
const std::string & data,
Client * client )
overridevirtual

Implements IClientMediaDownloader.

References IClientMediaDownloader::checkAndLoad(), m_file_name, m_file_sha1, m_stage, and STAGE_DONE.

+ Here is the call graph for this function:

◆ initialStep()

void SingleMediaDownloader::initialStep ( Client * client)
private

References httpfetch_caller_alloc(), isDone(), m_current_remote, m_file_name, m_file_sha1, m_httpfetch_caller, m_remotes, m_stage, STAGE_DONE, startConventionalTransfer(), startRemoteMediaTransfer(), and IClientMediaDownloader::tryLoadFromCache().

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDone()

bool SingleMediaDownloader::isDone ( ) const
inlineoverridevirtual

Implements IClientMediaDownloader.

Referenced by initialStep(), and remoteMediaReceived().

+ Here is the caller graph for this function:

◆ isStarted()

bool SingleMediaDownloader::isStarted ( ) const
inlineoverridevirtual

◆ loadMedia()

bool SingleMediaDownloader::loadMedia ( Client * client,
const std::string & data,
const std::string & name )
overrideprotectedvirtual

◆ remoteMediaReceived()

void SingleMediaDownloader::remoteMediaReceived ( const HTTPFetchResult & fetch_result,
Client * client )
private

References IClientMediaDownloader::checkAndLoad(), HTTPFetchResult::data, infostream, isDone(), m_current_remote, m_file_name, m_file_sha1, m_remotes, m_stage, sanity_check, STAGE_DONE, startConventionalTransfer(), startRemoteMediaTransfer(), and HTTPFetchResult::succeeded.

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startConventionalTransfer()

void SingleMediaDownloader::startConventionalTransfer ( Client * client)
private

References m_file_name.

Referenced by initialStep(), and remoteMediaReceived().

+ Here is the caller graph for this function:

◆ startRemoteMediaTransfer()

void SingleMediaDownloader::startRemoteMediaTransfer ( )
private

References HTTPFetchRequest::caller, g_settings, Settings::getS32(), hex_encode(), httpfetch_async(), m_current_remote, m_file_name, m_file_sha1, m_httpfetch_caller, m_httpfetch_next_id, m_remotes, HTTPFetchRequest::request_id, HTTPFetchRequest::timeout, HTTPFetchRequest::url, and verbosestream.

Referenced by initialStep(), and remoteMediaReceived().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ step()

void SingleMediaDownloader::step ( Client * client)
overridevirtual

Implements IClientMediaDownloader.

References httpfetch_async_get(), HTTPFETCH_DISCARD, initialStep(), m_httpfetch_caller, m_stage, remoteMediaReceived(), STAGE_CACHE_CHECKED, and STAGE_INIT.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_current_remote

s32 SingleMediaDownloader::m_current_remote
private

◆ m_file_name

std::string SingleMediaDownloader::m_file_name
private

◆ m_file_sha1

std::string SingleMediaDownloader::m_file_sha1
private

◆ m_httpfetch_caller

unsigned long SingleMediaDownloader::m_httpfetch_caller
private

◆ m_httpfetch_next_id

unsigned long SingleMediaDownloader::m_httpfetch_next_id = 0
private

◆ m_remotes

std::vector<std::string> SingleMediaDownloader::m_remotes
private

◆ m_stage

enum Stage SingleMediaDownloader::m_stage = STAGE_INIT
private

The documentation for this class was generated from the following files: