diff options
| author | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
|---|---|---|
| committer | tony mancill <tmancill@debian.org> | 2026-04-12 08:46:47 -0700 |
| commit | cd2dad3bc7ae0ee0a18b7b20a945009362ec3851 (patch) | |
| tree | 5a622ec4193e9bc899f6499f936848a661be29cb /SampleDownloader/RemoteFile.hpp | |
| parent | 558c0b9d6ecf70c5222e2069ece1fea3656c75d7 (diff) | |
| parent | 291b3817bf0c7a742e9e17d42c94fc8c9530e40d (diff) | |
Merge branch 'debian/latest' into debian/trixie-backports
Diffstat (limited to 'SampleDownloader/RemoteFile.hpp')
| -rw-r--r--[-rwxr-xr-x] | SampleDownloader/RemoteFile.hpp | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/SampleDownloader/RemoteFile.hpp b/SampleDownloader/RemoteFile.hpp index 4001052a..3e6cb851 100755..100644 --- a/SampleDownloader/RemoteFile.hpp +++ b/SampleDownloader/RemoteFile.hpp @@ -1,84 +1,84 @@ -#ifndef REMOTE_FILE_HPP__
-#define REMOTE_FILE_HPP__
-
-#include <QObject>
-#include <QString>
-#include <QUrl>
-#include <QFileInfo>
-#include <QSaveFile>
-#include <QPointer>
-
-class QNetworkAccessManager;
-class QNetworkReply;
-
-//
-// Synchronize an individual file specified by a URL to the local file
-// system
-//
-class RemoteFile final
- : public QObject
-{
- Q_OBJECT
-
-public:
- //
- // Clients of RemoteFile must provide an instance of this
- // interface. It may be used to receive information and requests
- // from the RemoteFile instance as it does its work.
- //
- class ListenerInterface
- {
- protected:
- ListenerInterface () {}
-
- public:
- virtual void error (QString const& title, QString const& message) = 0;
- virtual bool redirect_request (QUrl const&) {return false;} // disallow
- virtual void download_progress (qint64 /* bytes_received */, qint64 /* total_bytes */) {}
- virtual void download_finished (bool /* success */) {}
- };
-
- explicit RemoteFile (ListenerInterface * listener, QNetworkAccessManager * network_manager
- , QString const& local_file_path, bool http_only = false
- , QObject * parent = nullptr);
-
- // true if local file exists or will do very soon
- bool local () const;
-
- // download/remove the local file
- bool sync (QUrl const& url, bool local = true, bool force = false);
-
- // abort an active download
- void abort ();
-
- // change the local location, this will rename if the file exists locally
- void local_file_path (QString const&);
-
- QString local_file_path () const {return local_file_.absoluteFilePath ();}
- QUrl url () const {return url_;}
-
- // always use an http scheme for remote URLs
- void http_only (bool flag = true) {http_only_ = flag;}
-
-private:
- void download (QUrl url);
- void reply_finished ();
-
- Q_SLOT void store ();
-
- Q_SIGNAL void redirect (QUrl const&, unsigned redirect_count);
- Q_SIGNAL void downloadProgress (qint64 bytes_received, qint64 total_bytes);
- Q_SIGNAL void finished ();
-
- ListenerInterface * listener_;
- QNetworkAccessManager * network_manager_;
- QFileInfo local_file_;
- bool http_only_;
- QUrl url_;
- QPointer<QNetworkReply> reply_;
- bool is_valid_;
- unsigned redirect_count_;
- QSaveFile file_;
-};
-
-#endif
+#ifndef REMOTE_FILE_HPP__ +#define REMOTE_FILE_HPP__ + +#include <QObject> +#include <QString> +#include <QUrl> +#include <QFileInfo> +#include <QSaveFile> +#include <QPointer> + +class QNetworkAccessManager; +class QNetworkReply; + +// +// Synchronize an individual file specified by a URL to the local file +// system +// +class RemoteFile final + : public QObject +{ + Q_OBJECT + +public: + // + // Clients of RemoteFile must provide an instance of this + // interface. It may be used to receive information and requests + // from the RemoteFile instance as it does its work. + // + class ListenerInterface + { + protected: + ListenerInterface () {} + + public: + virtual void error (QString const& title, QString const& message) = 0; + virtual bool redirect_request (QUrl const&) {return false;} // disallow + virtual void download_progress (qint64 /* bytes_received */, qint64 /* total_bytes */) {} + virtual void download_finished (bool /* success */) {} + }; + + explicit RemoteFile (ListenerInterface * listener, QNetworkAccessManager * network_manager + , QString const& local_file_path, bool http_only = false + , QObject * parent = nullptr); + + // true if local file exists or will do very soon + bool local () const; + + // download/remove the local file + bool sync (QUrl const& url, bool local = true, bool force = false); + + // abort an active download + void abort (); + + // change the local location, this will rename if the file exists locally + void local_file_path (QString const&); + + QString local_file_path () const {return local_file_.absoluteFilePath ();} + QUrl url () const {return url_;} + + // always use an http scheme for remote URLs + void http_only (bool flag = true) {http_only_ = flag;} + +private: + void download (QUrl url); + void reply_finished (); + + Q_SLOT void store (); + + Q_SIGNAL void redirect (QUrl const&, unsigned redirect_count); + Q_SIGNAL void downloadProgress (qint64 bytes_received, qint64 total_bytes); + Q_SIGNAL void finished (); + + ListenerInterface * listener_; + QNetworkAccessManager * network_manager_; + QFileInfo local_file_; + bool http_only_; + QUrl url_; + QPointer<QNetworkReply> reply_; + bool is_valid_; + unsigned redirect_count_; + QSaveFile file_; +}; + +#endif |
