|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the QLop Software
|
|
|
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/*-- Author : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@member.fsf.org
|
|
|
----------------------------------------------------------------------------*/
|
|
|
|
|
|
#ifndef FILEDOWNLOADER_H
|
|
|
#define FILEDOWNLOADER_H
|
|
|
|
|
|
#include <QObject>
|
|
|
#include <QNetworkAccessManager>
|
|
|
#include <QNetworkReply>
|
|
|
#include <QNetworkProxy>
|
|
|
#include <QList>
|
|
|
#include <QHash>
|
|
|
#include <filedownloadertask.h>
|
|
|
#include <downloadhistory.h>
|
|
|
#include <qlopservice.h>
|
|
|
#include <QDockWidget>
|
|
|
#include <filedowloadersettingsgui.h>
|
|
|
#include <qlopsettings.h>
|
|
|
#include <QHostAddress>
|
|
|
#include <qlopnetworkproxyfactory.h>
|
|
|
|
|
|
class FileDownloader : public QLopService
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
private:
|
|
|
static FileDownloader* _self;
|
|
|
static QNetworkAccessManager* m_WebCtrl;
|
|
|
static QList<FileDownloaderTask*>* m_pendingTasks;
|
|
|
static DownLoadHistory* m_DownLoadHistory;
|
|
|
static QDockWidget* m_gui;
|
|
|
static QLopNetworkProxyFactory* m_ProxyFactory;
|
|
|
static FileDowloaderSettingsGUI* m_SettingsGui;
|
|
|
FileDownloader(bool noGUI=false,QObject *parent = 0);
|
|
|
~FileDownloader();
|
|
|
|
|
|
public:
|
|
|
static void init(bool noGUI=false,QObject *parent = 0);
|
|
|
static int downloadFile(QUrl fileUrl,const QString& name);
|
|
|
static int downloadFile(QString fileUrl,const QString& name);
|
|
|
static FileDownloaderTask *getDownloadTask(int ID);
|
|
|
static bool taskIsCompleted(int ID);
|
|
|
static FileDownloader *self();
|
|
|
void reloadConfig();
|
|
|
// QLopService methodes
|
|
|
QDockWidget* getGUI();
|
|
|
const QString& serviceName();
|
|
|
signals:
|
|
|
|
|
|
public slots:
|
|
|
int download_file(QUrl fileUrl,const QString& name);
|
|
|
int download_file(QString fileUrl,const QString& name);
|
|
|
private slots:
|
|
|
void gotHead(FileDownloaderTask *task, QNetworkReply *headerreply);
|
|
|
private:
|
|
|
void configureProxy();
|
|
|
int getTaskId();
|
|
|
};
|
|
|
|
|
|
#endif // FILEDOWNLOADER_H
|
|
|
|