summaryrefslogblamecommitdiffstats
path: root/src/downloadManager.h
blob: 461d31a51811a6b2e4b4c86b8adca206463c346e (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                         
                  
                  
               
                    
 

                    

                            
 
 
                                      
 
                
 
       
                          

        
                                               
                                           
                                    
                         
                                
                                       
                      
                         
                                     
                 
                            
                              
 

                        
                                                    
                                  
 
             
                                         
                                            
 
              
                                 


                                                                 


                           
#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H

#include "fbgui.h"
#include <QObject>
#include <QDir>
#include <QtNetwork>

extern bool debug;
extern QUrl baseURL;
extern QString binPath;
extern QString downloadPath;


class downloadManager : public QObject
{
	Q_OBJECT

public:
	downloadManager();

private:
	void processDownloadRequest(QUrl& url);
	// Object required for downloading.
	QNetworkAccessManager* qnam;
	QQueue<QUrl> dlQ;
	QNetworkRequest request;
	QNetworkReply* currentDownload;
	QFile outfile;
	QDir downloadDir;
	// Download-in-progress flag.
	bool dip;
	int currentProgress;
	static int downloaded;

signals:
	void finished();
	void updateProgress(QString current, int i);
	void downloadQueueEmpty();

public slots:
	void downloadFile(QUrl& fileUrl);
	void downloadFile(QString& fileUrl);

private slots:
	void startNextDownload();
	void downloadReady();
	void downloadProgress(qint64 bytesIn, qint64 bytesTotal);
	void downloadFinished();
};

#endif // DOWNLOADMANAGER_H