libzypp 17.37.10

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
15#include <zypp-core/zyppng/base/zyppglobal.h>
16#include <zypp/base/Flags.h>
17#include <zypp/ZYppCallbacks.h>
18#include <zypp/media/MediaNetworkCommonHandler.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
43 class MediaCurl2 : public MediaNetworkCommonHandler
44{
45 public:
46 enum RequestOption
47 {
49 OPTION_NONE = 0x0,
51 OPTION_NO_REPORT_START = 0x1
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
MediaNetworkCommonHandler.h
ZYppCallbacks.h
zypp::MirroredOrigin
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Definition MirroredOrigin.h:170
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition onmedialocation.h:37
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::internal::MediaNetworkRequestExecutor
Definition MediaNetworkRequestExecutor.h:36
zypp::media::MediaCurl2::releaseFrom
void releaseFrom(const std::string &ejectDev) override
Call concrete handler to release the media.
Definition MediaCurl2.cc:120
zypp::media::MediaCurl2::disconnectFrom
void disconnectFrom() override
Definition MediaCurl2.cc:112
zypp::media::MediaCurl2::getFileCopy
void getFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
Definition MediaCurl2.cc:127
zypp::media::MediaCurl2::MediaCurl2
MediaCurl2(const MirroredOrigin origin_r, const Pathname &attach_point_hint_r)
Definition MediaCurl2.cc:68
zypp::media::MediaCurl2::getDoesFileExist
bool getDoesFileExist(const Pathname &filename) const override
Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly,...
Definition MediaCurl2.cc:274
zypp::media::MediaCurl2::~MediaCurl2
~MediaCurl2() override
Definition MediaCurl2.h:83
zypp::media::MediaCurl2::RequestOption
RequestOption
Definition MediaCurl2.h:47
zypp::media::MediaCurl2::OPTION_NONE
@ OPTION_NONE
Defaults.
Definition MediaCurl2.h:49
zypp::media::MediaCurl2::OPTION_NO_REPORT_START
@ OPTION_NO_REPORT_START
do not send a start ProgressReport
Definition MediaCurl2.h:51
zypp::media::MediaCurl2::executeRequest
void executeRequest(RequestData &reqData, callback::SendReport< DownloadProgressReport > *report=nullptr)
Definition MediaCurl2.cc:409
zypp::media::MediaCurl2::_executor
internal::MediaNetworkRequestExecutorRef _executor
Definition MediaCurl2.h:102
zypp::media::MediaCurl2::tryZchunk
bool tryZchunk(RequestData &reqData, const OnMediaLocation &srcFile, const Pathname &target, callback::SendReport< DownloadProgressReport > &report)
Definition MediaCurl2.cc:339
zypp::media::MediaCurl2::checkProtocol
void checkProtocol(const Url &url) const override
check the url is supported by the curl library
Definition MediaCurl2.cc:101
zypp::media::MediaCurl2::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(RequestOptions, RequestOption)
zypp::media::MediaHandler::release
void release(const std::string &ejectDev="")
Use concrete handler to release the media.
Definition MediaHandler.cc:704
zypp::media::MediaNetworkCommonHandler::MediaNetworkCommonHandler
MediaNetworkCommonHandler(const MirroredOrigin &origin_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
Definition MediaNetworkCommonHandler.cc:36
zyppng::EventDispatcher
Definition eventdispatcher.h:42
zyppng::NetworkRequest
Definition request.h:43
zypp::internal
Definition DownloadProgressTracker.cc:13
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::target
Definition KeyRing.h:325
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zyppng
Definition MediaNetworkRequestExecutor.h:16
zypp::callback::SendReport
Definition Callback.h:237
zypp::media::MediaCurl2::RequestData
Definition MediaCurl2.h:93
zypp::media::MediaCurl2::RequestData::_req
zyppng::NetworkRequestRef _req
Definition MediaCurl2.h:95
zypp::media::MediaCurl2::RequestData::_mirrorIdx
int _mirrorIdx
Definition MediaCurl2.h:94
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
Flags.h
zyppglobal.h
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126