File indexing completed on 2024-03-24 05:44:24
0001 /* This file is part of inqludeclient 0002 * Copyright 2014 David Faure <faure@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License or ( at 0007 * your option ) version 3 or, at the discretion of KDE e.V. ( which shall 0008 * act as a proxy as in section 14 of the GPLv3 ), any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef DownloadHandler_H 0022 #define DownloadHandler_H 0023 0024 #include "abstracthandler.h" 0025 #include <QUrl> 0026 0027 class QTextStream; 0028 class QJsonDocument; 0029 class QNetworkReply; 0030 class QNetworkAccessManager; 0031 class QFile; 0032 0033 class DownloadHandler : public AbstractHandler 0034 { 0035 Q_OBJECT 0036 public: 0037 DownloadHandler(QTextStream &errorStream, const QString &library); 0038 ~DownloadHandler(); 0039 0040 0041 public Q_SLOTS: 0042 void download(const QJsonDocument &doc); 0043 0044 protected: 0045 virtual void startDownload(const QUrl &sourceUrl); // reimplemented by the unittest 0046 0047 private Q_SLOTS: 0048 void slotReadyRead(); 0049 void slotFinished(QNetworkReply *reply); 0050 0051 private: 0052 QTextStream& m_errorStream; 0053 QString m_library; 0054 QNetworkReply *m_reply; 0055 QFile *m_destFile; 0056 QUrl m_urlRedirect; 0057 QNetworkAccessManager *m_qnam; 0058 }; 0059 0060 #endif