libzypp 17.36.3
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
32//
33// CLASS NAME : MediaCurl2
39{
40 public:
55
56 protected:
57
58 Url clearQueryString(const Url &url) const;
59
60 void attachTo (bool next = false) override;
61 void releaseFrom( const std::string & ejectDev ) override;
62 void getFile( const OnMediaLocation & file ) const override;
63 void getDir( const Pathname & dirname, bool recurse_r ) const override;
64 void getDirInfo( std::list<std::string> & retlist,
65 const Pathname & dirname, bool dots = true ) const override;
66 void getDirInfo( filesystem::DirContent & retlist,
67 const Pathname & dirname, bool dots = true ) const override;
73 bool getDoesFileExist( const Pathname & filename ) const override;
74
80 void disconnectFrom() override;
86 void getFileCopy( const OnMediaLocation& srcFile, const Pathname & targetFilename ) const override;
87
93 virtual void doGetFileCopy( const OnMediaLocation &srcFile, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report, RequestOptions options = OPTION_NONE ) const;
94
95
96 bool checkAttachPoint(const Pathname &apoint) const override;
97
98 public:
99
100 MediaCurl2( const Url & url_r,
101 const Pathname & attach_point_hint_r );
102
103 ~MediaCurl2() override { try { release(); } catch(...) {} }
104
105 static void setCookieFile( const Pathname & );
106
107 protected:
112 void checkProtocol(const Url &url) const;
113
118 void setupEasy();
119
120 private:
121 void executeRequest( zyppng::NetworkRequestRef req, callback::SendReport<DownloadProgressReport> *report = nullptr );
122
123 bool authenticate(const std::string & availAuthTypes, bool firstTry);
124
125 bool tryZchunk( zyppng::NetworkRequestRef req, const OnMediaLocation &srcFile , const Pathname & target, callback::SendReport<DownloadProgressReport> & report );
126
127 private:
128 zyppng::EventDispatcherRef _evDispatcher; //< keep the ev dispatcher alive as long as MediaCurl2 is
129 zyppng::NetworkRequestDispatcherRef _nwDispatcher; //< keep the dispatcher alive as well
130 TransferSettings _effectiveSettings; // use another level of indirection, _settings contains the user modified settings
131};
132ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaCurl2::RequestOptions);
133
135
136 } // namespace media
137} // namespace zypp
138
139#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
static void setCookieFile(const Pathname &)
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:128
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:48
@ OPTION_NO_IFMODSINCE
to not add a IFMODSINCE header if target exists
Definition MediaCurl2.h:50
@ OPTION_RANGE
retrieve only a range of the file
Definition MediaCurl2.h:46
@ OPTION_NO_REPORT_START
do not send a start ProgressReport
Definition MediaCurl2.h:52
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:129
TransferSettings _effectiveSettings
Definition MediaCurl2.h:130
MediaCurl2(const Url &url_r, const Pathname &attach_point_hint_r)
bool authenticate(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
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