Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
20 //=============================================================================
21 // Downloader
22 //=============================================================================
24 #ifndef DOWNLOADER_H
25 #define DOWNLOADER_H
27 #include <QObject>
28 #include <QByteArray>
29 #include <QNetworkAccessManager>
30 #include <QNetworkRequest>
31 #include <QNetworkReply>
32 #include <QVariant>
33 #include <QFile>
35 #include "system/shared.h"
36 #include "system/log.h"
48 class Downloader : public QObject , public Log
49 {
51 public:
53  explicit Downloader(QString url, QObject *parent = 0);
54  virtual ~Downloader() {}
56  void start(bool forced);
57  void stop();
58  bool isDownloading() { return mIsDownloading; }
60  QStringList getPathsOfDownloadedFiles();
62 signals:
63  void signalNoInternetConnection (QVariant forced);
64  void signalDownloading (QVariant downloading);
65  void signalProgress (QVariant filesRemaining, QVariant percent);
66  void signalNewFileDownloaded (QString localpath);
69 private slots:
70  void downloadIndexFile();
71  void indexFileDownloadFinished (QNetworkReply* pReply);
74  void downloadProgress (qint64 bytesReceived, qint64 bytesTotal);
75  void downloadComplete (QNetworkReply* pReply);
76  void finalize();
78 private:
79  QString fullPath (const QString &path, const QString &file) const;
80  bool isConnectedToInternet();
82 private:
83  QString mLocalPath;
84  QString mRemotePath;
85  QString mIndexFileName;
86  QNetworkAccessManager mNetworkManager;
87  QStringList mIndexOfFiles;
88  QNetworkReply *pNetworkReply;
89  QFile mFile;
93 };
95 #endif // DOWNLOADER_H
void signalNewFileDownloaded(QString localpath)
void checkWhetherFileExistsAndDownload()
Private slot: Start downloading if necessary.
Definition: downloader.cpp:381
QString mLocalPath
Local path of the file to be downloaded.
Definition: downloader.h:83
void downloadIndexFile()
Download index file.
Definition: downloader.cpp:179
void signalDownloading(QVariant downloading)
void stop()
Stop downloading.
Definition: downloader.cpp:237
void finalize()
Finalize download.
Definition: downloader.cpp:550
bool isConnectedToInternet()
Check internet connection.
Definition: downloader.cpp:73
bool mForcedDownload
Flag for forced download.
Definition: downloader.h:91
Downloader(QString url, QObject *parent=0)
Constructor, resetting the member variables.
Definition: downloader.cpp:48
void start(bool forced)
Start the downloading process in the background.
Definition: downloader.cpp:121
void signalNoInternetConnection(QVariant forced)
QNetworkAccessManager mNetworkManager
Instance of the Qt network access manager.
Definition: downloader.h:86
QString mRemotePath
Remote path of the file to be downloaded.
Definition: downloader.h:84
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Private slot: Download a data chunk and report progress.
Definition: downloader.cpp:477
bool isDownloading()
Definition: downloader.h:58
QNetworkReply * pNetworkReply
Pointer to the network reply structure.
Definition: downloader.h:88
void initiateDownloadOfNextFile()
Private slot: Initiate download of next file.
Definition: downloader.cpp:356
QString fullPath(const QString &path, const QString &file) const
Helper function: Construct a full path out of a path and a file name.
Definition: downloader.cpp:574
Class managing the download of large files from a repository in the background.
Definition: downloader.h:48
QString mIndexFileName
Name of the remote index file.
Definition: downloader.h:85
QFile mFile
File to be written.
Definition: downloader.h:89
bool mIsWaitingForConnection
Flag indicating waiting status.
Definition: downloader.h:90
void signalProgress(QVariant filesRemaining, QVariant percent)
void signalAllFilesDownloaded()
Base class for managing log messages.
Definition: log.h:83
virtual ~Downloader()
Definition: downloader.h:54
QStringList getPathsOfDownloadedFiles()
Get a list of paths of all downloaded files.
Definition: downloader.cpp:319
void indexFileDownloadFinished(QNetworkReply *pReply)
Private slot: Index file downloaded.
Definition: downloader.cpp:262
QStringList mIndexOfFiles
The content of the index file as a QStringList.
Definition: downloader.h:87
void downloadComplete(QNetworkReply *pReply)
Private slot: Download completed.
Definition: downloader.cpp:501
bool mIsDownloading
Flag indicating active download.
Definition: downloader.h:92