arcsdownloader.h
1 /*
2  name: tools/pkg/arcsdownloader.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSDOWNLOADER_H__
30 #define __ARCSDOWNLOADER_H__
31 
32 #include <QObject>
33 
34 #include <QNetworkProxy>
35 #include <QSslError>
36 #include <QStringList>
37 
38 class QNetworkReply;
39 class QAuthenticator;
40 class QNetworkAccessManager;
41 class QEventLoop;
42 
43 
44 class ARCSDownloader : public QObject
45 {
46  Q_OBJECT
47 public:
48  explicit ARCSDownloader(QObject *parent = 0);
49 
50 signals:
51  void finished();
52 
53 public slots:
54  void download(QString s);
55 
56 private slots:
57  void replyFinished(QNetworkReply* reply);
58  void authenticateToSite(QNetworkReply* reply, QAuthenticator*auth);
59  void authenticateToProxy(const QNetworkProxy & proxy, QAuthenticator * auth );
60  void sslErrors ( QNetworkReply * reply, const QList<QSslError> & errors );
61 
62  void setProgress(qint64 received, qint64 total);
63 
64 private:
65  void authenticate(QAuthenticator* auth);
66  QNetworkAccessManager* manager;
67  QEventLoop* eventLoop;
68  QString filename;
69  QList<QSslError> cachedSslErrors;
70 };
71 
72 #endif // __ARCSDOWNLOADER_H__