Marble

HttpDownloadManager.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2007 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2009 Jens-Michael Hoffmann <[email protected]>
6 //
7 
8 //
9 // The HttpDownloadManager manages http downloads.
10 //
11 
12 #ifndef MARBLE_HTTPDOWNLOADMANAGER_H
13 #define MARBLE_HTTPDOWNLOADMANAGER_H
14 
15 #include <QObject>
16 
17 #include "MarbleGlobal.h"
18 #include "marble_export.h"
19 
20 class QUrl;
21 
22 namespace Marble
23 {
24 
25 class DownloadPolicy;
26 class StoragePolicy;
27 
28 /**
29  * @short This class manages scheduled downloads.
30  *
31  * The downloadmanager offers a maximum number of active jobs and a
32  * limit for pending jobs. it also takes care that the job queue
33  * won't be polluted by jobs that timed out already.
34  *
35  * @author Torsten Rahn
36  */
37 
38 class MARBLE_EXPORT HttpDownloadManager : public QObject
39 {
40  Q_OBJECT
41 
42  public:
43  /**
44  * Creates a new http download manager.
45  *
46  * @note HttpDownloadManager doesn't take ownership of @p policy.
47  *
48  * @param policy The storage policy for this manager.
49  */
50  explicit HttpDownloadManager( StoragePolicy *policy );
51 
52  /**
53  * Destroys the http download manager.
54  */
55  ~HttpDownloadManager() override;
56 
57  /**
58  * Switches loading on/off, useful for offline mode.
59  */
60  void setDownloadEnabled( const bool enable );
61  void addDownloadPolicy( const DownloadPolicy& );
62 
63  static QByteArray userAgent(const QString &platform, const QString &plugin);
64 
65  public Q_SLOTS:
66 
67  /**
68  * Adds a new job with a sourceUrl, destination file name and given id.
69  */
70  void addJob( const QUrl& sourceUrl, const QString& destFilename, const QString &id,
71  const DownloadUsage usage );
72 
73 
74  Q_SIGNALS:
75  void downloadComplete( const QString&, const QString& );
76 
77  /**
78  * This signal is emitted if a file is downloaded and the data argument
79  * contains the files content. The HttpDownloadManager takes care to save
80  * it using the given storage policy.
81  */
82  void downloadComplete( const QByteArray &data, const QString& initiatorId );
83 
84  /**
85  * Signal is emitted when a new job is added to the queue.
86  */
87  void jobAdded();
88 
89  /**
90  * Signal is emitted when a job is removed from the queue.
91  * The job might be completed or blacklisted.
92  */
93  void jobRemoved();
94 
95  /**
96  * A job was queued, activated or removed (finished, failed)
97  */
98  void progressChanged( int active, int queued );
99 
100  private:
101  Q_DISABLE_COPY( HttpDownloadManager )
102 
103  class Private;
104  Private * const d;
105 
106  Q_PRIVATE_SLOT( d, void finishJob( const QByteArray&, const QString&, const QString& id ) )
107  Q_PRIVATE_SLOT( d, void requeue() )
108  Q_PRIVATE_SLOT( d, void startRetryTimer() )
109 };
110 
111 }
112 
113 #endif // MARBLE_HTTPDOWNLOADMANAGER_H
This class manages scheduled downloads.
DownloadUsage
This enum is used to describe the type of download.
Definition: MarbleGlobal.h:153
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.