libzypp  17.22.0
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 
5 #include <zypp/zyppng/base/Base>
7 #include <zypp/zyppng/core/Url>
9 #include <zypp/zyppng/media/network/AuthData>
10 
11 #include <zypp/ByteCount.h>
12 
13 namespace zypp {
14  namespace media {
15  class TransferSettings;
16  }
17 }
18 
19 namespace zyppng {
20 
21  class NetworkRequestDispatcher;
22  class DownloaderPrivate;
23  class Download;
24 
26 
35  {
37  public:
38 
39  using Ptr = std::shared_ptr<Downloader>;
40  using WeakPtr = std::shared_ptr<Downloader>;
41 
42  Downloader( );
43 
50  std::shared_ptr<Download> downloadFile ( Url file, zypp::filesystem::Pathname targetPath, zypp::ByteCount expectedFileSize = zypp::ByteCount() );
51 
56  std::shared_ptr<NetworkRequestDispatcher> requestDispatcher () const;
57 
62 
68 
73  };
74 
75  class DownloadPrivate;
76 
124  {
126 
127  public:
128 
129  using Ptr = std::shared_ptr<Download>;
130  using WeakPtr = std::shared_ptr<Download>;
131 
136  enum State {
137  InitialState, //< This is the initial state, its only set before a download starts
138  Initializing = 10, //< This state is kept during the first 265Bytes or until the data looks like a Metalink download
139  Running = 20, //< This state is set once there have been more than 256 bytes downloaded and it does not look like a metalink download
140  RunningMulti = 30, //< Signals that the file is downloaded in chunks from different mirrors
141  Success = 200, //< Shows that the Download was successful
142  Failed //< Shows that the Download failed
143  };
144 
145 
149  Download ( DownloadPrivate &&prv );
150 
154  Url url () const;
155 
159  zypp::Pathname targetPath () const;
160 
165  State state () const;
166 
173  NetworkRequestError lastRequestError () const;
174 
179  std::string errorString () const;
180 
186  TransferSettings &settings ();
187 
192  void start ();
193 
199  void setMultiPartHandlingEnabled ( bool enable = true );
200 
204  void setCheckExistsOnly ( bool set = true );
205 
210  void setDeltaFile ( const zypp::Pathname &file );
211 
215  NetworkRequestDispatcher &dispatcher () const;
216 
221 
226 
231 
236 
240  SignalProxy<void ( Download &req )> sigFinished ( );
241 
247  };
248 }
249 
250 #endif
The Downloader class.
Definition: downloader.h:34
std::weak_ptr< Base > WeakPtr
Definition: base.h:39
Store and operate with byte count.
Definition: ByteCount.h:30
Holds transfer setting.
Url url
Definition: MediaCurl.cc:65
The NetworkRequestError class Represents a error that occured in.
#define ZYPP_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:21
#define LIBZYPP_NG_EXPORT
Definition: zyppglobal.h:7
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Url manipulation class.
Definition: Url.h:87
std::shared_ptr< Base > Ptr
Definition: base.h:38
zypp::media::TransferSettings TransferSettings
Definition: downloader.h:25