libosmscout  0.1
osmscout::FileDownloader Class Reference

Downloads a file specified by URL. More...

#include <FileDownloader.h>

+ Inheritance diagram for osmscout::FileDownloader:

Public Slots

void startDownload ()
 

Signals

void downloadedBytes (uint64_t sz)
 
void error (QString error_text, bool recoverable)
 
void finished (QString path)
 
void writtenBytes (uint64_t sz)
 

Public Member Functions

 FileDownloader (QNetworkAccessManager *manager, QString url, QString path, QObject *parent=nullptr)
 
uint64_t getBytesDownloaded () const
 
QString getFileName () const
 
QString getFilePath () const
 
 operator bool () const
 
 ~FileDownloader () override
 

Protected Slots

void onDownloaded ()
 
void onNetworkError (QNetworkReply::NetworkError code)
 
void onNetworkReadyRead ()
 
void onTimeout ()
 

Protected Member Functions

void onError (const QString &err)
 
void onFinished ()
 
bool restartDownload ()
 Restart download if download retries are not used up. More...
 

Detailed Description

Downloads a file specified by URL.

Downloads a file as specified by URL and stores in a given path. If the required directories do not exist, creates all parent directories as needed.

Constructor & Destructor Documentation

◆ FileDownloader()

osmscout::FileDownloader::FileDownloader ( QNetworkAccessManager *  manager,
QString  url,
QString  path,
QObject *  parent = nullptr 
)
explicit

◆ ~FileDownloader()

osmscout::FileDownloader::~FileDownloader ( )
override

Member Function Documentation

◆ downloadedBytes

void osmscout::FileDownloader::downloadedBytes ( uint64_t  sz)
signal

Referenced by onNetworkReadyRead().

◆ error

void osmscout::FileDownloader::error ( QString  error_text,
bool  recoverable 
)
signal

◆ finished

void osmscout::FileDownloader::finished ( QString  path)
signal

◆ getBytesDownloaded()

uint64_t osmscout::FileDownloader::getBytesDownloaded ( ) const

◆ getFileName()

QString osmscout::FileDownloader::getFileName ( ) const
inline

◆ getFilePath()

QString osmscout::FileDownloader::getFilePath ( ) const
inline

◆ onDownloaded

void osmscout::FileDownloader::onDownloaded ( )
protectedslot

References onFinished(), and onNetworkReadyRead().

Referenced by startDownload().

◆ onError()

void osmscout::FileDownloader::onError ( const QString &  err)
protected

References error().

Referenced by onNetworkError(), onNetworkReadyRead(), and onTimeout().

◆ onFinished()

void osmscout::FileDownloader::onFinished ( )
protected

References finished().

Referenced by onDownloaded().

◆ onNetworkError

void osmscout::FileDownloader::onNetworkError ( QNetworkReply::NetworkError  code)
protectedslot

References error(), onError(), and restartDownload().

Referenced by startDownload().

◆ onNetworkReadyRead

void osmscout::FileDownloader::onNetworkReadyRead ( )
protectedslot

◆ onTimeout

void osmscout::FileDownloader::onTimeout ( )
protectedslot

References error(), onError(), and restartDownload().

Referenced by FileDownloader().

◆ operator bool()

osmscout::FileDownloader::operator bool ( ) const
inlineexplicit

◆ restartDownload()

bool osmscout::FileDownloader::restartDownload ( )
protected

Restart download if download retries are not used up.

Referenced by onNetworkError(), and onTimeout().

◆ startDownload

void osmscout::FileDownloader::startDownload ( )
slot

Default value for "Accept-Encoding" in Qt is "gzip, deflate" and Qt code do the decompressing for us (when server reply with "Content-Encoding: gzip"). But with explicit byte range (content not from the beginning) decompressing is not possible (gzip header is not valid) and Qt fails with NetworkError::ProtocolFailure

For that reason we have to specify that only accepted encoding is identity.

References osmscout::FileDownloaderConfig::BufferNetwork, error(), osmscout::OSMScoutQt::GetInstance(), onDownloaded(), onNetworkError(), and onNetworkReadyRead().

Referenced by FileDownloader().

◆ writtenBytes

void osmscout::FileDownloader::writtenBytes ( uint64_t  sz)
signal

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