FileDownloader Class | Qt Installer Framework Manual

- Qt Installer Framework Manual
- FileDownloader

# FileDownloader Class

(KDUpdater::FileDownloader)

The FileDownloader class is the base class for file downloaders used in KDUpdater. More...

Header: | #include <FileDownloader>
Inherited By: | KDUpdater::HttpDownloader, KDUpdater::LocalFileDownloader, and KDUpdater::ResourceFileDownloader

- List of all members, including inherited members

## Properties

- autoRemoveDownloadedFile : bool
- scheme : QString
- url : QUrl

## Public Functions

| FileDownloader(const QString &scheme, QObject *parent = 0)
virtual | ~FileDownloader()
QByteArray | assumedSha1Sum() const
QAuthenticator | authenticator() const
virtual bool | canDownload() const = 0
bool | checkSha1Sum() const
virtual KDUpdater::FileDownloader * | clone(QObject *parent = 0) const = 0
void | download()
virtual QString | downloadedFileName() const = 0
QString | errorString() const
bool | followRedirects() const
qint64 | getBytesReceived() const
bool | ignoreSslErrors()
bool | isAutoRemoveDownloadedFile() const
virtual bool | isDownloaded() const = 0
KDUpdater::FileDownloaderProxyFactory * | proxyFactory() const
QString | scheme() const
void | setAssumedSha1Sum(const QByteArray &sha1)
void | setAuthenticator(const QAuthenticator &authenticator)
void | setAutoRemoveDownloadedFile(bool val)
void | setCheckSha1Sum(const bool checkSha1Sum)
virtual void | setDownloadedFileName(const QString &name) = 0
void | setFollowRedirects(bool val)
void | setIgnoreSslErrors(bool ignore)
void | setProxyFactory(KDUpdater::FileDownloaderProxyFactory *factory)
void | setScheme(const QString &scheme)
void | setUrl(const QUrl &url)
QByteArray | sha1Sum() const
QUrl | url() const

## Public Slots

virtual void | cancelDownload()

## Signals

void | authenticatorChanged(const QAuthenticator &authenticator)
void | downloadAborted(const QString &errorMessage)
void | downloadCanceled()
void | downloadCompleted()
void | downloadProgress(double progress)
void | downloadProgress(qint64 bytesReceived, qint64 bytesToReceive)
void | downloadSpeed(qint64 bytesPerSecond)
void | downloadStarted()
void | downloadStatus(const QString &status)
void | estimatedDownloadTime(int seconds)

## Static Public Members

const QMetaObject | staticMetaObject

## Protected Functions

void | addCheckSumData(const QByteArray &data)
void | addSample(qint64 sample)
qint64 | bytesDownloadedBeforeResume()
void | clearBytesDownloadedBeforeResume()
int | downloadDeadlineTimerId() const
int | downloadSpeedTimerId() const
void | emitDownloadProgress()
void | emitDownloadSpeed()
void | emitDownloadStatus()
void | emitEstimatedDownloadTime()
bool | isDownloadPaused()
bool | isDownloadResumed()
virtual void | onError() = 0
virtual void | onSuccess() = 0
void | resetCheckSumData()
void | runDownloadDeadlineTimer()
void | runDownloadSpeedTimer()
void | setDownloadAborted(const QString &error)
void | setDownloadCanceled()
void | setDownloadCompleted()
void | setDownloadPaused(bool paused)
void | setDownloadResumed(bool resumed)
void | setProgress(qint64 bytesReceived, qint64 bytesToReceive)
void | stopDownloadDeadlineTimer()
void | stopDownloadSpeedTimer()
qint64 | totalBytesDownloadedBeforeResume()
void | updateBytesDownloadedBeforeResume(qint64 bytes)
void | updateTotalBytesDownloadedBeforeResume()

## Detailed Description

The FileDownloader class is the base class for file downloaders used in KDUpdater.

File downloaders are used by the KDUpdater::Update class to download update files. Each subclass of FileDownloader can download files from a specific category of sources (such as `local`, `ftp`, `http`).

This is an internal class, not a part of the public API. Currently we have the following subclasses of FileDownloader:

- HttpDownloader to download files over FTP, HTTP, or HTTPS if Qt is built with SSL.
- LocalFileDownloader to copy files from the local file system.
- ResourceFileDownloader to download resource files.

## Property Documentation

### autoRemoveDownloadedFile : bool

This property holds whether the downloaded file should be automatically removed after it is downloaded and the class goes out of scope.

Access functions:

bool | isAutoRemoveDownloadedFile() const
void | setAutoRemoveDownloadedFile(bool val)

### scheme : QString

This property holds the scheme to use for downloading files.

Access functions:

QString | scheme() const
void | setScheme(const QString &scheme)

### url : QUrl

This property holds the URL to download files from.

Access functions:

QUrl | url() const
void | setUrl(const QUrl &url)

## Member Function Documentation

### FileDownloader::FileDownloader(const QString &scheme, QObject *parent = 0)

Default constructs an instance of FileDownloader.

### `[virtual]` FileDownloader::~FileDownloader()

Destroys the instance of FileDownloader. The destructor is virtual.

### `[protected]` void FileDownloader::addCheckSumData(const QByteArray &data)

### `[protected]` void FileDownloader::addSample(qint64 sample)

### QByteArray FileDownloader::assumedSha1Sum() const

See also setAssumedSha1Sum().

### QAuthenticator FileDownloader::authenticator() const

See also setAuthenticator().

### `[signal]` void FileDownloader::authenticatorChanged(const QAuthenticator &authenticator)

### `[protected]` qint64 FileDownloader::bytesDownloadedBeforeResume()

### `[pure virtual]` bool FileDownloader::canDownload() const

### `[virtual slot]` void FileDownloader::cancelDownload()

### bool FileDownloader::checkSha1Sum() const

See also setCheckSha1Sum().

### `[protected]` void FileDownloader::clearBytesDownloadedBeforeResume()

### `[pure virtual]` KDUpdater::FileDownloader *FileDownloader::clone(QObject *parent = 0) const

### void FileDownloader::download()

### `[signal]` void FileDownloader::downloadAborted(const QString &errorMessage)

See also setDownloadAborted().

### `[signal]` void FileDownloader::downloadCanceled()

See also setDownloadCanceled().

### `[signal]` void FileDownloader::downloadCompleted()

See also setDownloadCompleted().

### `[protected]` int FileDownloader::downloadDeadlineTimerId() const

### `[signal]` void FileDownloader::downloadProgress(double progress)

Note: Signal downloadProgress is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:

     connect(fileDownloader, QOverload<double>::of(&FileDownloader::downloadProgress),
         [=](double progress){ /* ... */ });

### `[signal]` void FileDownloader::downloadProgress(qint64 bytesReceived, qint64 bytesToReceive)

Note: Signal downloadProgress is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:

     connect(fileDownloader, QOverload<qint64, qint64>::of(&FileDownloader::downloadProgress),
         [=](qint64 bytesReceived, qint64 bytesToReceive){ /* ... */ });

### `[signal]` void FileDownloader::downloadSpeed(qint64 bytesPerSecond)

### `[protected]` int FileDownloader::downloadSpeedTimerId() const

### `[signal]` void FileDownloader::downloadStarted()

### `[signal]` void FileDownloader::downloadStatus(const QString &status)

### `[pure virtual]` QString FileDownloader::downloadedFileName() const

See also setDownloadedFileName().

### `[protected]` void FileDownloader::emitDownloadProgress()

### `[protected]` void FileDownloader::emitDownloadSpeed()

### `[protected]` void FileDownloader::emitDownloadStatus()

### `[protected]` void FileDownloader::emitEstimatedDownloadTime()

### QString FileDownloader::errorString() const

### `[signal]` void FileDownloader::estimatedDownloadTime(int seconds)

### bool FileDownloader::followRedirects() const

See also setFollowRedirects().

### qint64 FileDownloader::getBytesReceived() const

### bool FileDownloader::ignoreSslErrors()

See also setIgnoreSslErrors().

### `[protected]` bool FileDownloader::isDownloadPaused()

### `[protected]` bool FileDownloader::isDownloadResumed()

### `[pure virtual]` bool FileDownloader::isDownloaded() const

### `[pure virtual protected]` void FileDownloader::onError()

### `[pure virtual protected]` void FileDownloader::onSuccess()

### KDUpdater::FileDownloaderProxyFactory *FileDownloader::proxyFactory() const

See also setProxyFactory().

### `[protected]` void FileDownloader::resetCheckSumData()

### `[protected]` void FileDownloader::runDownloadDeadlineTimer()

### `[protected]` void FileDownloader::runDownloadSpeedTimer()

### void FileDownloader::setAssumedSha1Sum(const QByteArray &sha1)

See also assumedSha1Sum().

### void FileDownloader::setAuthenticator(const QAuthenticator &authenticator)

See also authenticator().

### void FileDownloader::setCheckSha1Sum(const bool checkSha1Sum)

See also checkSha1Sum().

### `[protected]` void FileDownloader::setDownloadAborted(const QString &error)

See also downloadAborted().

### `[protected]` void FileDownloader::setDownloadCanceled()

See also downloadCanceled().

### `[protected]` void FileDownloader::setDownloadCompleted()

See also downloadCompleted().

### `[protected]` void FileDownloader::setDownloadPaused(bool paused)

See also isDownloadPaused().

### `[protected]` void FileDownloader::setDownloadResumed(bool resumed)

See also isDownloadResumed().

### `[pure virtual]` void FileDownloader::setDownloadedFileName(const QString &name)

See also downloadedFileName().

### void FileDownloader::setFollowRedirects(bool val)

See also followRedirects().

### void FileDownloader::setIgnoreSslErrors(bool ignore)

See also ignoreSslErrors().

### `[protected]` void FileDownloader::setProgress(qint64 bytesReceived, qint64 bytesToReceive)

### void FileDownloader::setProxyFactory(KDUpdater::FileDownloaderProxyFactory *factory)

See also proxyFactory().

### QByteArray FileDownloader::sha1Sum() const

### `[protected]` void FileDownloader::stopDownloadDeadlineTimer()

### `[protected]` void FileDownloader::stopDownloadSpeedTimer()

### `[protected]` qint64 FileDownloader::totalBytesDownloadedBeforeResume()

### `[protected]` void FileDownloader::updateBytesDownloadedBeforeResume(qint64 bytes)

### `[protected]` void FileDownloader::updateTotalBytesDownloadedBeforeResume()