![]() |
Just Intonation
Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
|
Class managing the download of large files from a repository in the background. More...
#include <downloader.h>
Signals | |
void | signalNoInternetConnection (QVariant forced) |
void | signalDownloading (QVariant downloading) |
void | signalProgress (QVariant filesRemaining, QVariant percent) |
void | signalNewFileDownloaded (QString localpath) |
void | signalAllFilesDownloaded () |
Public Member Functions | |
Downloader (QString url, QObject *parent=0) | |
Constructor, resetting the member variables. More... | |
virtual | ~Downloader () |
void | start (bool forced) |
Start the downloading process in the background. More... | |
void | stop () |
Stop downloading. More... | |
bool | isDownloading () |
QStringList | getPathsOfDownloadedFiles () |
Get a list of paths of all downloaded files. More... | |
void | setVerbosity (int verbosity) |
Set the verbosity level of the class-specific messages. More... | |
int | getVerbosity () |
Get the actual verbosity level. More... | |
Private Slots | |
void | downloadIndexFile () |
Download index file. More... | |
void | indexFileDownloadFinished (QNetworkReply *pReply) |
Private slot: Index file downloaded. More... | |
void | initiateDownloadOfNextFile () |
Private slot: Initiate download of next file. More... | |
void | checkWhetherFileExistsAndDownload () |
Private slot: Start downloading if necessary. More... | |
void | downloadProgress (qint64 bytesReceived, qint64 bytesTotal) |
Private slot: Download a data chunk and report progress. More... | |
void | downloadComplete (QNetworkReply *pReply) |
Private slot: Download completed. More... | |
void | finalize () |
Finalize download. More... | |
Private Member Functions | |
QString | fullPath (const QString &path, const QString &file) const |
Helper function: Construct a full path out of a path and a file name. More... | |
bool | isConnectedToInternet () |
Check internet connection. More... | |
Private Attributes | |
QString | mLocalPath |
Local path of the file to be downloaded. More... | |
QString | mRemotePath |
Remote path of the file to be downloaded. More... | |
QString | mIndexFileName |
Name of the remote index file. More... | |
QNetworkAccessManager | mNetworkManager |
Instance of the Qt network access manager. More... | |
QStringList | mIndexOfFiles |
The content of the index file as a QStringList. More... | |
QNetworkReply * | pNetworkReply |
Pointer to the network reply structure. More... | |
QFile | mFile |
File to be written. More... | |
bool | mIsWaitingForConnection |
Flag indicating waiting status. More... | |
bool | mForcedDownload |
Flag for forced download. More... | |
bool | mIsDownloading |
Flag indicating active download. More... | |
Class managing the download of large files from a repository in the background.
This module download files from a remote location (http server) to the local applicaition directory. The files that are downloaded are listed in an index file (index.txt) on the server. The downloading process is singal-slot-driven and is carried out silently in the background.
Definition at line 48 of file downloader.h.
|
explicit |
Constructor, resetting the member variables.
url | : String containing the http address (URL) from where the files are downloaded. |
parent | : Optional parent object |
Definition at line 48 of file downloader.cpp.
|
inlinevirtual |
|
privateslot |
Private slot: Start downloading if necessary.
This function first reads the header of the remote file without downloading it, extracting the remote file size and the remote date of last modification. If this size differs from the size of the local file of if the remote file was modified more recently than the local file was created, a new download is initiated.
Definition at line 381 of file downloader.cpp.
|
privateslot |
Private slot: Download completed.
: This slot is triggered by the network manager after complete download of the file. The slot disconnects itself and copies the last chunk of data to the temporary file and closes it. The temporary file is then renamed to the true filename. Finally the slot finalize() is called
pReply | : Network reply emitted by the network manager |
Definition at line 501 of file downloader.cpp.
|
privateslot |
Download index file.
The function first checks whether the local app data storage and an internet connection are available. If so, it sends a request to the NetworkManager to download the index file. Otherwise it will check again in a minute.
Definition at line 179 of file downloader.cpp.
|
privateslot |
Private slot: Download a data chunk and report progress.
This slot is called periodically from the mNetworkManager to report how many bytes have been downloaded. We use this slot for periodically reading the buffer and appending its content to the open local file. This allows one to download large files in the background without the need of excessive memory space
bytesReceived | : Number of bytes that have already been received |
bytesTotal | : Total length of the file in bytes |
Definition at line 477 of file downloader.cpp.
|
privateslot |
Finalize download.
This function finalizes the download of a single file, deletes its entry from the mIndexOfFiles, and proceeds with the next file. If not files are left a corresponding signal is emitted and the process terminates.
Definition at line 550 of file downloader.cpp.
|
private |
Helper function: Construct a full path out of a path and a file name.
path | : The path as a QString with or without a slash in the end |
file | : The bare filename without path and slashes |
Definition at line 574 of file downloader.cpp.
QStringList Downloader::getPathsOfDownloadedFiles | ( | ) |
Get a list of paths of all downloaded files.
Definition at line 319 of file downloader.cpp.
|
inherited |
|
privateslot |
Private slot: Index file downloaded.
The downloaded index file is converted to a QStringList named mIndexOfFiles and the index file is written to the local storage. Finally the slot initiateDownloadOfNextFile() is called.
pReply | : Pointer to the network reply (derived from QIODevice) |
Definition at line 262 of file downloader.cpp.
|
privateslot |
Private slot: Initiate download of next file.
This slot starts the download chain for the first entry in the mIndexOfFiles. The first step is to check the file sizes and to see whether the file to be downloaded already exists on the local drive. For this reason the first step is to download only the head (metadata) of the remote file. After downloading the head, the private slot checkWhetherFileExistsAndDownload() is called.
Definition at line 356 of file downloader.cpp.
|
private |
Check internet connection.
Definition at line 73 of file downloader.cpp.
|
inline |
|
inherited |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
void Downloader::start | ( | bool | forced | ) |
Start the downloading process in the background.
By calling this function the Downloader starts the chain of signal-slot interactions to carry out the downloading process.
If the parameter 'forced' is true, the function tries to reload the files
forced | : Reload all files (including the existing ones) |
Definition at line 121 of file downloader.cpp.
void Downloader::stop | ( | ) |
Stop downloading.
Terminate the network connection, close all files and exit.
Definition at line 237 of file downloader.cpp.
|
private |
File to be written.
Definition at line 89 of file downloader.h.
|
private |
Flag for forced download.
Definition at line 91 of file downloader.h.
|
private |
Name of the remote index file.
Definition at line 85 of file downloader.h.
|
private |
The content of the index file as a QStringList.
Definition at line 87 of file downloader.h.
|
private |
Flag indicating active download.
Definition at line 92 of file downloader.h.
|
private |
Flag indicating waiting status.
Definition at line 90 of file downloader.h.
|
private |
Local path of the file to be downloaded.
Definition at line 83 of file downloader.h.
|
private |
Instance of the Qt network access manager.
Definition at line 86 of file downloader.h.
|
private |
Remote path of the file to be downloaded.
Definition at line 84 of file downloader.h.
|
private |
Pointer to the network reply structure.
Definition at line 88 of file downloader.h.