File indexing completed on 2025-01-05 03:59:36
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2008, 2009 Jens-Michael Hoffmann <jensmh@gmx.de> 0006 // SPDX-FileCopyrightText: 2008 Pino Toscano <pino@kde.org> 0007 // 0008 0009 #ifndef MARBLE_HTTPJOB_H 0010 #define MARBLE_HTTPJOB_H 0011 0012 #include <QObject> 0013 #include <QNetworkReply> 0014 0015 #include "MarbleGlobal.h" 0016 0017 #include "digikam_export.h" 0018 0019 class QNetworkAccessManager; 0020 class QString; 0021 class QByteArray; 0022 class QUrl; 0023 0024 namespace Marble 0025 { 0026 class HttpJobPrivate; 0027 0028 class DIGIKAM_EXPORT HttpJob: public QObject 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 HttpJob( const QUrl & sourceUrl, const QString & destFileName, const QString &id, QNetworkAccessManager *networkAccessManager ); 0034 ~HttpJob() override; 0035 0036 QUrl sourceUrl() const; 0037 void setSourceUrl( const QUrl & ); 0038 0039 QString initiatorId() const; 0040 void setInitiatorId( const QString & ); 0041 0042 QString destinationFileName() const; 0043 void setDestinationFileName( const QString & ); 0044 0045 bool tryAgain(); 0046 0047 DownloadUsage downloadUsage() const; 0048 void setDownloadUsage( const DownloadUsage ); 0049 0050 void setUserAgentPluginId( const QString & pluginId ) const; 0051 0052 QByteArray userAgent() const; 0053 0054 Q_SIGNALS: 0055 /** 0056 * errorCode contains 0, if there was no error and 1 otherwise 0057 */ 0058 void jobDone( HttpJob *, int errorCode ); 0059 void redirected( HttpJob * job, const QUrl& redirectionTarget ); 0060 0061 /** 0062 * This signal is Q_EMITted if the data was successfully received and 0063 * the argument data contains completely the downloaded content. 0064 */ 0065 void dataReceived( HttpJob * job, const QByteArray& data ); 0066 0067 public Q_SLOTS: 0068 void execute(); 0069 0070 private Q_SLOTS: 0071 void downloadProgress( qint64 bytesReceived, qint64 bytesTotal ); 0072 void error( QNetworkReply::NetworkError code ); 0073 void finished(); 0074 0075 private: 0076 Q_DISABLE_COPY( HttpJob ) 0077 HttpJobPrivate *const d; 0078 friend class HttpJobPrivate; 0079 }; 0080 0081 } 0082 0083 #endif