libzypp 17.36.7

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 namespace media {
30
31 class CredentialManager;
32
34//
35// CLASS NAME : MediaCurl2
40 class MediaCurl2 : public MediaNetworkCommonHandler
41{
42 public:
43 enum RequestOption
44 {
46 OPTION_NONE = 0x0,
48 OPTION_RANGE = 0x1,
50 OPTION_HEAD = 0x02,
52 OPTION_NO_IFMODSINCE = 0x04,
54 OPTION_NO_REPORT_START = 0x08,
55 };
56 ZYPP_DECLARE_FLAGS(RequestOptions,RequestOption);
57
58 protected:
59
60 Url clearQueryString(const Url &url) const;
61
62 void attachTo (bool next = false) override;
63 void releaseFrom( const std::string & ejectDev ) override;
64 void getFile( const OnMediaLocation & file ) const override;
65 void getDir( const Pathname & dirname, bool recurse_r ) const override;
66 void getDirInfo( std::list<std::string> & retlist,
67 const Pathname & dirname, bool dots = true ) const override;
68 void getDirInfo( filesystem::DirContent & retlist,
69 const Pathname & dirname, bool dots = true ) const override;
75 bool getDoesFileExist( const Pathname & filename ) const override;
76
82 void disconnectFrom() override;
88 void getFileCopy( const OnMediaLocation& srcFile, const Pathname & targetFilename ) const override;
89
95 virtual void doGetFileCopy( const OnMediaLocation &srcFile, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, RequestOptions options = OPTION_NONE ) const;
96
97
98 bool checkAttachPoint(const Pathname &apoint) const override;
99
100 public:
101
102 MediaCurl2( const Url & url_r,
103 const Pathname & attach_point_hint_r );
104
105 ~MediaCurl2() override { try { release(); } catch(...) {} }
106
107 // standard auth procedure, shared with CommitPackagePreloader
108 static bool authenticate( const Url &url, CredentialManager &cm, TransferSettings &settings, const std::string & availAuthTypes, bool firstTry);
109
110 protected:
115 void checkProtocol(const Url &url) const;
116
121 void setupEasy();
122
123 private:
124 void executeRequest( zyppng::NetworkRequestRef req, callback::SendReport<DownloadProgressReport> *report = nullptr );
125
126 bool authenticate(const std::string & availAuthTypes, bool firstTry);
127
128 bool tryZchunk( zyppng::NetworkRequestRef req, const OnMediaLocation &srcFile , const Pathname & target, callback::SendReport<DownloadProgressReport> & report );
129
130 private:
131 zyppng::EventDispatcherRef _evDispatcher; //< keep the ev dispatcher alive as long as MediaCurl2 is
132 zyppng::NetworkRequestDispatcherRef _nwDispatcher; //< keep the dispatcher alive as well
133 TransferSettings _effectiveSettings; // use another level of indirection, _settings contains the user modified settings
134};
135 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
136
138
139 } // namespace media
140} // namespace zypp
141
142#endif // ZYPP_MEDIA_MEDIACURL2_H
MediaNetworkCommonHandler.h
ZYppCallbacks.h
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::media::CredentialManager
Definition credentialmanager.h:64
zypp::media::MediaCurl2::releaseFrom
void releaseFrom(const std::string &ejectDev) override
Call concrete handler to release the media.
Definition MediaCurl2.cc:208
zypp::media::MediaCurl2::disconnectFrom
void disconnectFrom() override
Definition MediaCurl2.cc:200
zypp::media::MediaCurl2::tryZchunk
bool tryZchunk(zyppng::NetworkRequestRef req, const OnMediaLocation &srcFile, const Pathname &target, callback::SendReport< DownloadProgressReport > &report)
Definition MediaCurl2.cc:414
zypp::media::MediaCurl2::getFile
void getFile(const OnMediaLocation &file) const override
Call concrete handler to provide file below attach point.
Definition MediaCurl2.cc:215
zypp::media::MediaCurl2::getFileCopy
void getFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
Definition MediaCurl2.cc:224
zypp::media::MediaCurl2::getDir
void getDir(const Pathname &dirname, bool recurse_r) const override
Call concrete handler to provide directory content (not recursive!) below attach point.
Definition MediaCurl2.cc:488
zypp::media::MediaCurl2::attachTo
void attachTo(bool next=false) override
Call concrete handler to attach the media.
Definition MediaCurl2.cc:170
zypp::media::MediaCurl2::getDirInfo
void getDirInfo(std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const override
Call concrete handler to provide a content list of directory on media via retlist.
Definition MediaCurl2.cc:521
zypp::media::MediaCurl2::_evDispatcher
zyppng::EventDispatcherRef _evDispatcher
Definition MediaCurl2.h:131
zypp::media::MediaCurl2::getDoesFileExist
bool getDoesFileExist(const Pathname &filename) const override
Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly,...
Definition MediaCurl2.cc:258
zypp::media::MediaCurl2::~MediaCurl2
~MediaCurl2() override
Definition MediaCurl2.h:105
zypp::media::MediaCurl2::RequestOption
RequestOption
Definition MediaCurl2.h:44
zypp::media::MediaCurl2::OPTION_HEAD
@ OPTION_HEAD
only issue a HEAD (or equivalent) request
Definition MediaCurl2.h:50
zypp::media::MediaCurl2::OPTION_NONE
@ OPTION_NONE
Defaults.
Definition MediaCurl2.h:46
zypp::media::MediaCurl2::OPTION_NO_IFMODSINCE
@ OPTION_NO_IFMODSINCE
to not add a IFMODSINCE header if target exists
Definition MediaCurl2.h:52
zypp::media::MediaCurl2::OPTION_RANGE
@ OPTION_RANGE
retrieve only a range of the file
Definition MediaCurl2.h:48
zypp::media::MediaCurl2::OPTION_NO_REPORT_START
@ OPTION_NO_REPORT_START
do not send a start ProgressReport
Definition MediaCurl2.h:54
zypp::media::MediaCurl2::clearQueryString
Url clearQueryString(const Url &url) const
Definition MediaCurl2.cc:111
zypp::media::MediaCurl2::executeRequest
void executeRequest(zyppng::NetworkRequestRef req, callback::SendReport< DownloadProgressReport > *report=nullptr)
Definition MediaCurl2.cc:535
zypp::media::MediaCurl2::doGetFileCopy
virtual void doGetFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const
Definition MediaCurl2.cc:302
zypp::media::MediaCurl2::checkProtocol
void checkProtocol(const Url &url) const
check the url is supported by the curl library
Definition MediaCurl2.cc:118
zypp::media::MediaCurl2::checkAttachPoint
bool checkAttachPoint(const Pathname &apoint) const override
Verify if the specified directory as attach point (root) as requires by the particular media handler ...
Definition MediaCurl2.cc:195
zypp::media::MediaCurl2::setupEasy
void setupEasy()
initializes the curl easy handle with the data from the url
Definition MediaCurl2.cc:129
zypp::media::MediaCurl2::_nwDispatcher
zyppng::NetworkRequestDispatcherRef _nwDispatcher
Definition MediaCurl2.h:132
zypp::media::MediaCurl2::_effectiveSettings
TransferSettings _effectiveSettings
Definition MediaCurl2.h:133
zypp::media::MediaCurl2::MediaCurl2
MediaCurl2(const Url &url_r, const Pathname &attach_point_hint_r)
Definition MediaCurl2.cc:75
zypp::media::MediaCurl2::authenticate
static bool authenticate(const Url &url, CredentialManager &cm, TransferSettings &settings, const std::string &availAuthTypes, bool firstTry)
Definition MediaCurl2.cc:682
zypp::media::MediaCurl2::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(RequestOptions, RequestOption)
zypp::media::MediaHandler::url
Url url() const
Url used.
Definition MediaHandler.h:503
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 Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
Definition MediaNetworkCommonHandler.h:33
zypp::media::MediaNetworkCommonHandler::settings
TransferSettings & settings()
Definition MediaNetworkCommonHandler.h:43
zypp::media::TransferSettings
Holds transfer setting.
Definition transfersettings.h:34
zyppng::EventDispatcher
Definition eventdispatcher.h:42
zyppng::NetworkRequest
Definition request.h:43
zypp::filesystem::DirContent
std::list< DirEntry > DirContent
Returned by readdir.
Definition PathInfo.h:526
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 MediaCurl2.h:22
zypp::callback::SendReport
Definition Callback.h:237
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