libzypp 17.31.23
downloader.h
Go to the documentation of this file.
1#ifndef ZYPP_NG_MEDIA_CURL_DOWNLOADER_H_INCLUDED
2#define ZYPP_NG_MEDIA_CURL_DOWNLOADER_H_INCLUDED
3
4#include <zypp-core/zyppng/base/zyppglobal.h>
5#include <zypp-core/zyppng/base/Base>
6#include <zypp-core/zyppng/base/signals.h>
7#include <zypp-core/zyppng/core/Url>
9#include <zypp-curl/ng/network/AuthData>
10
11#include <zypp-core/ByteCount.h>
12
13namespace zypp::media {
14 class TransferSettings;
15}
16
17namespace zyppng {
18
19 class NetworkRequestDispatcher;
20 class DownloaderPrivate;
21 class Download;
22 class DownloadSpec;
23 class MirrorControl;
24
26
29
30
38 class LIBZYPP_NG_EXPORT Downloader : public Base
39 {
40 ZYPP_DECLARE_PRIVATE( Downloader )
41 public:
42
43 using Ptr = DownloaderRef;
44 using WeakPtr = DownloaderWeakRef;
45
46 Downloader();
47 Downloader( std::shared_ptr<MirrorControl> mc );
48 virtual ~Downloader();
49
53 std::shared_ptr<Download> downloadFile ( const DownloadSpec &spec );
54
59 std::shared_ptr<NetworkRequestDispatcher> requestDispatcher () const;
60
64 SignalProxy<void ( Downloader &parent, Download& download )> sigStarted ( );
65
70 SignalProxy<void ( Downloader &parent, Download& download )> sigFinished ( );
71
75 SignalProxy<void ( Downloader &parent )> queueEmpty ( );
76 };
77
78 class DownloadPrivate;
79
126 class LIBZYPP_NG_EXPORT Download : public Base
127 {
128 ZYPP_DECLARE_PRIVATE( Download )
129
130 public:
131
132 using Ptr = DownloadRef;
133 using WeakPtr = DownloadWeakRef;
134
139 enum State {
140 InitialState, //< This is the initial state. It is only set before a download starts.
141 DetectMetaLink, //< Metalink downloads are enabled, trying to detect if we get a metalink or not
142 DlMetaLinkInfo, //< Downloading the metalink description file
143 PrepareMulti, //< This state is set for async preparations of the multi download, like mirror rating
144 DlMetalink, //< Metalink download is running
145 DlZChunkHead, //< Zchunk header download is running
146 DlZChunk, //< Zchunk download is running
147 DlSimple, //< Simple download running, no optimizations
148 Finished, //< Download has finished
149 };
150
151 virtual ~Download();
152
157 State state () const;
158
165 NetworkRequestError lastRequestError () const;
166
170 bool hasError () const;
171
176 std::string errorString () const;
177
182 void start ();
183
191 void prioritize();
192
196 void cancel ();
197
202 void setStopOnMetalink ( const bool set = true );
203
208 bool stoppedOnMetalink () const;
209
215 DownloadSpec &spec ();
216 const DownloadSpec &spec () const;
217
222 uint64_t lastAuthTimestamp () const;
223
227 NetworkRequestDispatcher &dispatcher () const;
228
232 SignalProxy<void ( Download &req )> sigStarted ();
233
237 SignalProxy<void ( Download &req, State state )> sigStateChanged ();
238
242 SignalProxy<void ( Download &req, off_t dlnow )> sigAlive ();
243
247 SignalProxy<void ( Download &req, off_t dltotal, off_t dlnow )> sigProgress ();
248
252 SignalProxy<void ( Download &req )> sigFinished ( );
253
262 SignalProxy<void ( Download &req, NetworkAuthData &auth, const std::string &availAuth )> sigAuthRequired ( );
263
264 private:
265 friend class zyppng::Downloader;
269 Download ( Downloader &parent, std::shared_ptr<NetworkRequestDispatcher> requestDispatcher, std::shared_ptr<MirrorControl> mirrors, DownloadSpec &&spec );
270 };
271}
272
273#endif
Curl HTTP authentication data.
Definition: curlauthdata.h:22
Holds transfer setting.
DownloadWeakRef WeakPtr
Definition: downloader.h:133
DownloadRef Ptr
Definition: downloader.h:132
The Downloader class.
Definition: downloader.h:39
DownloaderWeakRef WeakPtr
Definition: downloader.h:44
DownloaderRef Ptr
Definition: downloader.h:43
The NetworkRequestError class Represents a error that occured in.
zypp::media::TransferSettings TransferSettings
Definition: downloader.h:25
ZYPP_FWD_DECL_TYPE_WITH_REFS(SuseMediaDataVerifier)