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 
61  SignalProxy<void ( Downloader &parent, Download& download )> sigStarted ( );
62 
67  SignalProxy<void ( Downloader &parent, Download& download )> sigFinished ( );
68 
72  SignalProxy<void ( Downloader &parent )> queueEmpty ( );
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 
220  SignalProxy<void ( Download &req )> sigStarted ();
221 
225  SignalProxy<void ( Download &req, State state )> sigStateChanged ();
226 
230  SignalProxy<void ( Download &req, off_t dlnow )> sigAlive ();
231 
235  SignalProxy<void ( Download &req, off_t dltotal, off_t dlnow )> sigProgress ();
236 
240  SignalProxy<void ( Download &req )> sigFinished ( );
241 
246  SignalProxy<void ( Download &req, NetworkAuthData &auth, const std::string &availAuth )> sigAuthRequired ( );
247  };
248 }
249 
250 #endif
zyppng::DownloadPrivate
Definition: downloader_p.h:18
LIBZYPP_NG_EXPORT
#define LIBZYPP_NG_EXPORT
Definition: zyppglobal.h:7
zyppng::Download
Definition: downloader.h:123
zyppng::Download::InitialState
Definition: downloader.h:137
zypp::media::TransferSettings
Holds transfer setting.
Definition: TransferSettings.h:20
zyppng::Base
Definition: base.h:32
zypp::ByteCount
Store and operate with byte count.
Definition: ByteCount.h:30
zypp::media::state
state
Definition: MetaLinkParser.cc:34
zyppng::SignalProxy
Definition: signals.h:28
networkrequesterror.h
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
signals.h
zyppng::Downloader
The Downloader class.
Definition: downloader.h:34
zyppng::NetworkRequestError
The NetworkRequestError class Represents a error that occured in.
Definition: networkrequesterror.h:20
zypp::media::CurlAuthData
Curl HTTP authentication data.
Definition: MediaUserAuth.h:74
zyppglobal.h
zyppng::Base::Ptr
std::shared_ptr< Base > Ptr
Definition: base.h:38
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:21
ByteCount.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zyppng::Base::WeakPtr
std::weak_ptr< Base > WeakPtr
Definition: base.h:39
zyppng
Definition: abstracteventsource.cc:8
zyppng::Download::State
State
Definition: downloader.h:136
zyppng::TransferSettings
zypp::media::TransferSettings TransferSettings
Definition: downloader.h:25
url
Url url
Definition: MediaCurl.cc:65
zypp::Url
Url manipulation class.
Definition: Url.h:87