libzypp  17.37.18
MediaCurl2.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_MEDIA_MEDIACURL2_H
13 #define ZYPP_MEDIA_MEDIACURL2_H
14 
16 #include <zypp-core/base/Flags.h>
17 #include <zypp/ZYppCallbacks.h>
19 
20 #include <curl/curl.h>
21 
22 namespace zyppng {
23  ZYPP_FWD_DECL_TYPE_WITH_REFS (EventDispatcher);
24  ZYPP_FWD_DECL_TYPE_WITH_REFS (NetworkRequestDispatcher);
25  ZYPP_FWD_DECL_TYPE_WITH_REFS (NetworkRequest);
26 }
27 
28 namespace zypp {
29 
30  namespace internal {
31  ZYPP_FWD_DECL_TYPE_WITH_REFS (MediaNetworkRequestExecutor);
32  }
33 
34  namespace media {
35 
37 //
38 // CLASS NAME : MediaCurl2
44 {
45  public:
47  {
49  OPTION_NONE = 0x0,
52  };
53  ZYPP_DECLARE_FLAGS(RequestOptions,RequestOption);
54 
55  protected:
56 
57  void releaseFrom( const std::string & ejectDev ) override;
58 
64  bool getDoesFileExist( const Pathname & filename ) const override;
65 
71  void disconnectFrom() override;
77  void getFileCopy( const OnMediaLocation& srcFile, const Pathname & targetFilename ) const override;
78  public:
79 
80  MediaCurl2(const MirroredOrigin origin_r,
81  const Pathname & attach_point_hint_r );
82 
83  ~MediaCurl2() override { try { release(); } catch(...) {} }
84 
85  protected:
90  void checkProtocol(const Url &url) const override;
91 
92  private:
93  struct RequestData {
94  int _mirrorIdx = -1;
95  zyppng::NetworkRequestRef _req;
96  };
97  void executeRequest(RequestData &reqData, callback::SendReport<DownloadProgressReport> *report = nullptr );
98 
99  bool tryZchunk( RequestData &reqData, const OnMediaLocation &srcFile , const Pathname & target, callback::SendReport<DownloadProgressReport> & report );
100 
101  private:
102  internal::MediaNetworkRequestExecutorRef _executor;
103 };
104 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
105 
107 
108  } // namespace media
109 } // namespace zypp
110 
111 #endif // ZYPP_MEDIA_MEDIACURL2_H
void checkProtocol(const Url &url) const override
check the url is supported by the curl library
Definition: MediaCurl2.cc:101
Implementation class for FTP, HTTP and HTTPS MediaHandler.
Definition: MediaCurl2.h:43
Describes a resource file located on a medium.
bool getDoesFileExist(const Pathname &filename) const override
Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly, or user cancels the operation.
Definition: MediaCurl2.cc:274
void getFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
Definition: MediaCurl2.cc:127
void disconnectFrom() override
Definition: MediaCurl2.cc:112
bool tryZchunk(RequestData &reqData, const OnMediaLocation &srcFile, const Pathname &target, callback::SendReport< DownloadProgressReport > &report)
Definition: MediaCurl2.cc:339
~MediaCurl2() override
Definition: MediaCurl2.h:83
ZYPP_DECLARE_FLAGS(RequestOptions, RequestOption)
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
MediaCurl2(const MirroredOrigin origin_r, const Pathname &attach_point_hint_r)
Definition: MediaCurl2.cc:68
void executeRequest(RequestData &reqData, callback::SendReport< DownloadProgressReport > *report=nullptr)
Definition: MediaCurl2.cc:404
do not send a start ProgressReport
Definition: MediaCurl2.h:51
zyppng::NetworkRequestRef _req
Definition: MediaCurl2.h:95
Url url() const
Primary Url used.
Definition: MediaHandler.h:502
ZYPP_FWD_DECL_TYPE_WITH_REFS(EventDispatcher)
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions)
void release(const std::string &ejectDev="")
Use concrete handler to release the media.
ZYPP_FWD_DECL_TYPE_WITH_REFS(MediaNetworkRequestExecutor)
Url manipulation class.
Definition: Url.h:92
void releaseFrom(const std::string &ejectDev) override
Call concrete handler to release the media.
Definition: MediaCurl2.cc:120
internal::MediaNetworkRequestExecutorRef _executor
Definition: MediaCurl2.h:102