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
16#include <zypp/base/Flags.h>
17#include <zypp/ZYppCallbacks.h>
19
20#include <curl/curl.h>
21
27
28namespace zypp {
29 namespace media {
30
31 class CredentialManager;
32
34//
35// CLASS NAME : MediaCurl2
41{
42 public:
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};
135ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
136
138
139 } // namespace media
140} // namespace zypp
141
142#endif // ZYPP_MEDIA_MEDIACURL2_H
Describes a resource file located on a medium.
Url manipulation class.
Definition Url.h:93
void releaseFrom(const std::string &ejectDev) override
Call concrete handler to release the media.
void disconnectFrom() override
bool tryZchunk(zyppng::NetworkRequestRef req, const OnMediaLocation &srcFile, const Pathname &target, callback::SendReport< DownloadProgressReport > &report)
void getFile(const OnMediaLocation &file) const override
Call concrete handler to provide file below attach point.
void getFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
void getDir(const Pathname &dirname, bool recurse_r) const override
Call concrete handler to provide directory content (not recursive!) below attach point.
void attachTo(bool next=false) override
Call concrete handler to attach the media.
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.
zyppng::EventDispatcherRef _evDispatcher
Definition MediaCurl2.h:131
bool getDoesFileExist(const Pathname &filename) const override
Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly,...
@ OPTION_HEAD
only issue a HEAD (or equivalent) request
Definition MediaCurl2.h:50
@ OPTION_NO_IFMODSINCE
to not add a IFMODSINCE header if target exists
Definition MediaCurl2.h:52
@ OPTION_RANGE
retrieve only a range of the file
Definition MediaCurl2.h:48
@ OPTION_NO_REPORT_START
do not send a start ProgressReport
Definition MediaCurl2.h:54
Url clearQueryString(const Url &url) const
void executeRequest(zyppng::NetworkRequestRef req, callback::SendReport< DownloadProgressReport > *report=nullptr)
virtual void doGetFileCopy(const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const
void checkProtocol(const Url &url) const
check the url is supported by the curl library
bool checkAttachPoint(const Pathname &apoint) const override
Verify if the specified directory as attach point (root) as requires by the particular media handler ...
void setupEasy()
initializes the curl easy handle with the data from the url
zyppng::NetworkRequestDispatcherRef _nwDispatcher
Definition MediaCurl2.h:132
TransferSettings _effectiveSettings
Definition MediaCurl2.h:133
MediaCurl2(const Url &url_r, const Pathname &attach_point_hint_r)
Definition MediaCurl2.cc:75
static bool authenticate(const Url &url, CredentialManager &cm, TransferSettings &settings, const std::string &availAuthTypes, bool firstTry)
ZYPP_DECLARE_FLAGS(RequestOptions, RequestOption)
Url url() const
Url used.
void release(const std::string &ejectDev="")
Use concrete handler to release the media.
MediaNetworkCommonHandler(const Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
Holds transfer setting.
std::list< DirEntry > DirContent
Returned by readdir.
Definition PathInfo.h:526
Url details namespace.
Definition UrlBase.cc:58
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126