libzypp: zypp/media/MediaCurl2.h Source File

libzypp 17.38.15

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/ng/base/zyppglobal.h>
16#include <zypp-core/base/Flags.h>
17#include <zypp/ZYppCallbacks.h>
18#include <zypp/media/MediaNetworkCommonHandler.h>
19
20#include <curl/curl.h>
21
22namespace 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
28namespace 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};
104ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
105
107
108 } // namespace media
109} // namespace zypp
110
111#endif // ZYPP_MEDIA_MEDIACURL2_H
Flags.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:48
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:277
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:410
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:345
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:37
zyppng::EventDispatcher
Definition eventdispatcher.h:43
zyppng::NetworkRequest
Definition request.h:43
zypp::internal
Definition DownloadProgressTracker.cc:13
zypp::internal::ZYPP_FWD_DECL_TYPE_WITH_REFS
ZYPP_FWD_DECL_TYPE_WITH_REFS(MediaNetworkRequestExecutor)
zypp::media
Definition MediaNetworkRequestExecutor.h:22
zypp::media::ZYPP_DECLARE_OPERATORS_FOR_FLAGS
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions)
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 CodePitfalls.doc:2
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppng::ZYPP_FWD_DECL_TYPE_WITH_REFS
ZYPP_FWD_DECL_TYPE_WITH_REFS(EventDispatcher)
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
zyppglobal.h