File indexing completed on 2024-04-28 15:27:11

0001 /*
0002     SPDX-FileCopyrightText: 2003 Malte Starostik <malte@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPAC_DOWNLOADER_H
0008 #define KPAC_DOWNLOADER_H
0009 
0010 #include <QObject>
0011 
0012 #include <QUrl>
0013 
0014 class KJob;
0015 namespace KIO
0016 {
0017 class Job;
0018 }
0019 
0020 namespace KPAC
0021 {
0022 class Downloader : public QObject
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit Downloader(QObject *);
0027 
0028     void download(const QUrl &);
0029     const QUrl &scriptUrl()
0030     {
0031         return m_scriptURL;
0032     }
0033     const QString &script()
0034     {
0035         return m_script;
0036     }
0037     const QString &error()
0038     {
0039         return m_error;
0040     }
0041 
0042 Q_SIGNALS:
0043     void result(bool);
0044 
0045 protected:
0046     virtual void failed();
0047     void setError(const QString &);
0048 
0049 private Q_SLOTS:
0050     void redirection(KIO::Job *, const QUrl &);
0051     void data(KIO::Job *, const QByteArray &);
0052     void result(KJob *);
0053 
0054 private:
0055     QByteArray m_data;
0056     QUrl m_scriptURL;
0057     QString m_script;
0058     QString m_error;
0059 };
0060 }
0061 
0062 #endif // KPAC_DOWNLOADER_H