File indexing completed on 2024-05-12 16:01:54

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     bool fetchFile(const QUrl &remote, QIODevice *io);
0027 
0028 private Q_SLOTS:
0029     void error(QNetworkReply::NetworkError error);
0030 
0031 private:
0032     QNetworkRequest *m_request;
0033     QNetworkReply *m_reply;
0034 };
0035 
0036 #endif // KISREMOTEFILEFETCHER_H