libzypp  17.37.5
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/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 MediaUrl &url_r,
81  const std::vector<MediaUrl> &mirrors_r,
82  const Pathname & attach_point_hint_r );
83 
84  ~MediaCurl2() override { try { release(); } catch(...) {} }
85 
86  protected:
91  void checkProtocol(const Url &url) const override;
92 
93  private:
94  struct RequestData {
95  int _mirrorIdx = -1;
96  zyppng::NetworkRequestRef _req;
97  };
99 
100  bool tryZchunk( RequestData &reqData, const OnMediaLocation &srcFile , const Pathname & target, callback::SendReport<DownloadProgressReport> & report );
101 
102  private:
103  internal::MediaNetworkRequestExecutorRef _executor;
104 };
105 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
106 
108 
109  } // namespace media
110 } // namespace zypp
111 
112 #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:273
void getFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
Definition: MediaCurl2.cc:127
MediaCurl2(const MediaUrl &url_r, const std::vector< MediaUrl > &mirrors_r, const Pathname &attach_point_hint_r)
Definition: MediaCurl2.cc:68
void disconnectFrom() override
Definition: MediaCurl2.cc:112
bool tryZchunk(RequestData &reqData, const OnMediaLocation &srcFile, const Pathname &target, callback::SendReport< DownloadProgressReport > &report)
Definition: MediaCurl2.cc:331
~MediaCurl2() override
Definition: MediaCurl2.h:84
ZYPP_DECLARE_FLAGS(RequestOptions, RequestOption)
void executeRequest(RequestData &reqData, callback::SendReport< DownloadProgressReport > *report=nullptr)
Definition: MediaCurl2.cc:401
do not send a start ProgressReport
Definition: MediaCurl2.h:51
zyppng::NetworkRequestRef _req
Definition: MediaCurl2.h:96
Url url() const
Primary Url used.
Definition: MediaHandler.h:509
ZYPP_FWD_DECL_TYPE_WITH_REFS(EventDispatcher)
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions)
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
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:103