Marble

HttpDownloadManager.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5// SPDX-FileCopyrightText: 2009 Jens-Michael Hoffmann <jensmh@gmx.de>
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
20class QUrl;
21
22namespace Marble
23{
24
25class DownloadPolicy;
26class 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
38class MARBLE_EXPORT HttpDownloadManager : public QObject
39{
40 Q_OBJECT
41
42public:
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
65public 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, const DownloadUsage usage);
71
72Q_SIGNALS:
73 void downloadComplete(const QString &, const QString &);
74
75 /**
76 * This signal is emitted if a file is downloaded and the data argument
77 * contains the files content. The HttpDownloadManager takes care to save
78 * it using the given storage policy.
79 */
80 void downloadComplete(const QByteArray &data, const QString &initiatorId);
81
82 /**
83 * Signal is emitted when a new job is added to the queue.
84 */
85 void jobAdded();
86
87 /**
88 * Signal is emitted when a job is removed from the queue.
89 * The job might be completed or blacklisted.
90 */
91 void jobRemoved();
92
93 /**
94 * A job was queued, activated or removed (finished, failed)
95 */
96 void progressChanged(int active, int queued);
97
98private:
99 Q_DISABLE_COPY(HttpDownloadManager)
100
101 class Private;
102 Private *const d;
103
104 Q_PRIVATE_SLOT(d, void finishJob(const QByteArray &, const QString &, const QString &id))
105 Q_PRIVATE_SLOT(d, void requeue())
106 Q_PRIVATE_SLOT(d, void startRetryTimer())
107};
108
109}
110
111#endif // MARBLE_HTTPDOWNLOADMANAGER_H
This class manages scheduled downloads.
void jobRemoved()
Signal is emitted when a job is removed from the queue.
void jobAdded()
Signal is emitted when a new job is added to the queue.
void downloadComplete(const QByteArray &data, const QString &initiatorId)
This signal is emitted if a file is downloaded and the data argument contains the files content.
void progressChanged(int active, int queued)
A job was queued, activated or removed (finished, failed)
Binds a QML item to a specific geodetic location in screen coordinates.
DownloadUsage
This enum is used to describe the type of download.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.