File indexing completed on 2024-05-19 04:29:18

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
0003  *  SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  *
0007  */
0008 #ifndef KISREMOTEFILEFETCHER_H
0009 #define KISREMOTEFILEFETCHER_H
0010 
0011 #include <QIODevice>
0012 #include <QNetworkReply>
0013 #include <QNetworkRequest>
0014 #include <QObject>
0015 #include <QUrl>
0016 
0017 /**
0018  * @brief The KisRemoteFileFetcher class can fetch a remote file and blocks until the file is downloaded
0019  */
0020 class KisRemoteFileFetcher : public QObject
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit KisRemoteFileFetcher(QObject *parent = 0);
0025     ~KisRemoteFileFetcher() override;
0026 
0027     /// fetch the image. Shows a progress dialog
0028     bool fetchFile(const QUrl &remote, QIODevice *io);
0029 
0030     static QByteArray fetchFile(const QUrl &remote);
0031 
0032 
0033 private Q_SLOTS:
0034     void error(QNetworkReply::NetworkError error);
0035 
0036 private:
0037     QNetworkRequest *m_request;
0038     QNetworkReply *m_reply;
0039 };
0040 
0041 #endif // KISREMOTEFILEFETCHER_H