libzypp 17.31.23
zypp::media::MediaMultiCurl Class Reference

#include <media/MediaMultiCurl.h>

Inheritance diagram for zypp::media::MediaMultiCurl:

Public Member Functions

 MediaMultiCurl (const Url &url_r, const Pathname &attach_point_hint_r)
 
 ~MediaMultiCurl () override
 
virtual void doGetFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const override
 
void multifetch (const Pathname &filename, FILE *fp, std::vector< Url > *urllist, callback::SendReport< DownloadProgressReport > *report=0, MediaBlockList *blklist=0, off_t filesize=off_t(-1)) const
 
void multifetch (const Pathname &filename, FILE *fp, std::vector< Url > *urllist, callback::SendReport< DownloadProgressReport > *report, MediaBlockList *blklist, const ByteCount &filesize) const
 
- Public Member Functions inherited from zypp::media::MediaCurl
 ZYPP_DECLARE_FLAGS (RequestOptions, RequestOption)
 
 MediaCurl (const Url &url_r, const Pathname &attach_point_hint_r)
 
virtual ~MediaCurl () override
 
- Public Member Functions inherited from zypp::media::MediaNetworkCommonHandler
 MediaNetworkCommonHandler (const Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
 
TransferSettingssettings ()
 
- Public Member Functions inherited from zypp::media::MediaHandler
bool dependsOnParent (MediaAccessId parentId, bool exactIdMatch)
 Check if the current media handler depends on an another handler specified by media access id.
 
bool dependsOnParent ()
 
void resetParentId ()
 Called in case, where the media manager takes over the destruction of the parent id (e.g.
 
Pathname attachPoint () const
 Return the currently used attach point.
 
void setAttachPoint (const Pathname &path, bool temp)
 Set a new attach point.
 
void setAttachPoint (const AttachPointRef &ref)
 Set a (shared) attach point.
 
AttachPoint attachPointHint () const
 Get the actual attach point hint.
 
void attachPointHint (const Pathname &path, bool temp)
 Set the attach point hint as specified by the user.
 
Pathname createAttachPoint () const
 Try to create a default / temporary attach point.
 
Pathname createAttachPoint (const Pathname &attach_root) const
 Try to create a temporary attach point in specified root.
 
void removeAttachPoint ()
 Remove unused attach point.
 
virtual bool checkAttachPoint (const Pathname &apoint) const
 Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.
 
bool isUseableAttachPoint (const Pathname &path, bool mtab=true) const
 Ask media manager, if the specified path is already used as attach point or if there are another attach points bellow of it.
 
std::string mediaSourceName () const
 Get the media source name or an empty string.
 
void setMediaSource (const MediaSourceRef &ref)
 Set new media source reference.
 
AttachedMedia findAttachedMedia (const MediaSourceRef &media) const
 Ask the media manager if specified media source is already attached.
 
AttachedMedia attachedMedia () const
 Returns the attached media.
 
bool isSharedMedia () const
 Returns a hint if the media is shared or not.
 
bool checkAttached (bool matchMountFs) const
 Check actual mediaSource attachment against the current mount table of the system.
 
void forceRelaseAllMedia (bool matchMountFs)
 Call to this function will try to release all media matching the currenlty attached media source, that it is able to find in the mount table.
 
void forceRelaseAllMedia (const MediaSourceRef &ref, bool matchMountFs)
 
 MediaHandler (const Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
 If the concrete media handler provides a nonempty attach_point, it must be an existing directory.
 
virtual ~MediaHandler ()
 Contolling MediaAccess takes care, that attached media is released prior to deleting this.
 
bool downloads () const
 Hint if files are downloaded or not.
 
std::string protocol () const
 Protocol hint for MediaAccess.
 
Url url () const
 Url used.
 
void attach (bool next)
 Use concrete handler to attach the media.
 
virtual bool isAttached () const
 True if media is attached.
 
Pathname localRoot () const
 Return the local directory that corresponds to medias url, no matter if media isAttached or not.
 
Pathname localPath (const Pathname &pathname) const
 Files provided will be available at 'localPath(filename)'.
 
void disconnect ()
 Use concrete handler to isconnect media.
 
void release (const std::string &ejectDev="")
 Use concrete handler to release the media.
 
void provideFile (const OnMediaLocation &file) const
 Use concrete handler to provide file denoted by path below 'localRoot'.
 
void provideFileCopy (const OnMediaLocation &srcFile, Pathname targetFilename) const
 Call concrete handler to provide a copy of a file under a different place in the file system (usually not under attach point) as a copy.
 
void provideDir (Pathname dirname) const
 Use concrete handler to provide directory denoted by path below 'localRoot' (not recursive!).
 
void provideDirTree (Pathname dirname) const
 Use concrete handler to provide directory tree denoted by path below 'localRoot' (recursive!!).
 
void releaseFile (const Pathname &filename) const
 Remove filename below localRoot IFF handler downloads files to the local filesystem.
 
void releaseDir (const Pathname &dirname) const
 Remove directory tree below localRoot IFF handler downloads files to the local filesystem.
 
void releasePath (Pathname pathname) const
 Remove pathname below localRoot IFF handler downloads files to the local filesystem.
 
void dirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
 Return content of directory on media via retlist.
 
void dirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
 Basically the same as dirInfo above.
 
bool doesFileExist (const Pathname &filename) const
 check if a file exists
 
virtual bool hasMoreDevices ()
 Check if the media has one more device available for attach(true).
 
virtual void getDetectedDevices (std::vector< std::string > &devices, unsigned int &index) const
 Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.
 
virtual void precacheFiles (const std::vector< OnMediaLocation > &files)
 Tries to fetch the given files and precaches them.
 

Protected Member Functions

bool isDNSok (const std::string &host) const
 
void setDNSok (const std::string &host) const
 
CURL * fromEasyPool (const std::string &host) const
 
void toEasyPool (const std::string &host, CURL *easy) const
 
virtual void setupEasy () override
 initializes the curl easy handle with the data from the url
 
void checkFileDigest (Url &url, FILE *fp, MediaBlockList *blklist) const
 
- Protected Member Functions inherited from zypp::media::MediaCurl
Url clearQueryString (const Url &url) const
 
virtual void attachTo (bool next=false) override
 Call concrete handler to attach the media.
 
virtual void releaseFrom (const std::string &ejectDev) override
 Call concrete handler to release the media.
 
virtual void getFile (const OnMediaLocation &file) const override
 Call concrete handler to provide file below attach point.
 
virtual void getDir (const Pathname &dirname, bool recurse_r) const override
 Call concrete handler to provide directory content (not recursive!) below attach point.
 
virtual 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.
 
virtual void getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const override
 Basically the same as getDirInfo above.
 
virtual bool getDoesFileExist (const Pathname &filename) const override
 Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly, or user cancels the operation.
 
virtual bool doGetDoesFileExist (const Pathname &filename) const
 
virtual void disconnectFrom () override
 
virtual void getFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename) const override
 
virtual void doGetFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report, RequestOptions options=OPTION_NONE) const
 
virtual bool checkAttachPoint (const Pathname &apoint) const override
 Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.
 
void checkProtocol (const Url &url) const
 check the url is supported by the curl library
 
virtual void setupEasy ()
 initializes the curl easy handle with the data from the url
 
void evaluateCurlCode (const zypp::Pathname &filename, CURLcode code, bool timeout) const
 Evaluates a curl return code and throws the right MediaException filename Filename being downloaded code Code curl returnes timeout Whether we reached timeout, which we need to differentiate in case the codes aborted-by-callback or timeout are returned by curl Otherwise we can't differentiate abort from timeout.
 
void doGetFileCopyFile (const OnMediaLocation &srcFile, const Pathname &dest, FILE *file, callback::SendReport< DownloadProgressReport > &report, RequestOptions options=OPTION_NONE) const
 
- Protected Member Functions inherited from zypp::media::MediaNetworkCommonHandler
Url getFileUrl (const Pathname &filename) const
 concatenate the attach url and the filename to a complete download url
 
- Protected Member Functions inherited from zypp::media::MediaHandler
virtual void attachTo (bool next=false)=0
 Call concrete handler to attach the media.
 
virtual void disconnectFrom ()
 Call concrete handler to disconnect media.
 
virtual void releaseFrom (const std::string &ejectDev="")=0
 Call concrete handler to release the media.
 
virtual void forceEject (const std::string &device)
 Call concrete handler to physically eject the media (i.e.
 
virtual void getFile (const OnMediaLocation &file) const
 Call concrete handler to provide file below attach point.
 
virtual void getFileCopy (const OnMediaLocation &file, const Pathname &targetFilename) const
 Call concrete handler to provide a file under a different place in the file system (usually not under attach point) as a copy.
 
virtual void getDir (const Pathname &dirname, bool recurse_r) const =0
 Call concrete handler to provide directory content (not recursive!) below attach point.
 
virtual void getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const =0
 Call concrete handler to provide a content list of directory on media via retlist.
 
virtual void getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const =0
 Basically the same as getDirInfo above.
 
virtual bool getDoesFileExist (const Pathname &filename) const =0
 check if a file exists
 
void getDirectoryYast (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
 Retrieve and if available scan dirname/directory.yast.
 
void getDirectoryYast (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
 Retrieve and if available scan dirname/directory.yast.
 

Static Protected Member Functions

static int progressCallback (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
 
- Static Protected Member Functions inherited from zypp::media::MediaCurl
static int aliveCallback (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
 Callback sending just an alive trigger to the UI, without stats (e.g.
 
static int progressCallback (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
 Callback reporting download progress.
 
static CURL * progressCallback_getcurl (void *clientp)
 
static void resetExpectedFileSize (void *clientp, const ByteCount &expectedFileSize)
 MediaMultiCurl needs to reset the expected filesize in case a metalink file is downloaded otherwise this function should not be called.
 
- Static Protected Member Functions inherited from zypp::media::MediaNetworkCommonHandler
static zypp::Url findGeoIPRedirect (const zypp::Url &url)
 Rewrites the baseURL to the geoIP target if one is found in the metadata cache, otherwise simply returns the url again.
 

Private Attributes

curl_slist * _customHeadersMetalink
 
CURLM * _multi
 
std::set< std::string > _dnsok
 
std::map< std::string, CURL * > _easypool
 

Friends

class multifetchrequest
 
class multifetchworker
 

Additional Inherited Members

- Public Types inherited from zypp::media::MediaCurl
enum  RequestOption {
  OPTION_NONE = 0x0 , OPTION_RANGE = 0x1 , OPTION_HEAD = 0x02 , OPTION_NO_IFMODSINCE = 0x04 ,
  OPTION_NO_REPORT_START = 0x08
}
 
- Public Types inherited from zypp::media::MediaHandler
typedef shared_ptr< MediaHandlerPtr
 
typedef shared_ptr< const MediaHandlerconstPtr
 
- Static Public Member Functions inherited from zypp::media::MediaCurl
static void setCookieFile (const Pathname &)
 
- Static Public Member Functions inherited from zypp::media::MediaHandler
static bool setAttachPrefix (const Pathname &attach_prefix)
 
static std::string getRealPath (const std::string &path)
 
static Pathname getRealPath (const Pathname &path)
 
static bool checkAttachPoint (const Pathname &apoint, bool empty_dir, bool writeable)
 Verify if the specified directory as attach point (root) using requested checks.
 
- Protected Attributes inherited from zypp::media::MediaCurl
CURL * _curl
 
char _curlError [CURL_ERROR_SIZE]
 
curl_slist * _customHeaders
 
- Protected Attributes inherited from zypp::media::MediaNetworkCommonHandler
TransferSettings _settings
 
Url _redirTarget
 
- Protected Attributes inherited from zypp::media::MediaHandler
const Url _url
 Url to handle.
 
MediaAccessId _parentId
 Access Id of media handler we depend on.
 

Detailed Description

Definition at line 40 of file MediaMultiCurl.h.

Constructor & Destructor Documentation

◆ MediaMultiCurl()

zypp::media::MediaMultiCurl::MediaMultiCurl ( const Url url_r,
const Pathname attach_point_hint_r 
)

Definition at line 1179 of file MediaMultiCurl.cc.

◆ ~MediaMultiCurl()

zypp::media::MediaMultiCurl::~MediaMultiCurl ( )
override

Definition at line 1187 of file MediaMultiCurl.cc.

Member Function Documentation

◆ doGetFileCopy()

void zypp::media::MediaMultiCurl::doGetFileCopy ( const OnMediaLocation srcFile,
const Pathname targetFilename,
callback::SendReport< DownloadProgressReport > &  _report,
RequestOptions  options = OPTION_NONE 
) const
overridevirtual
Exceptions
MediaException

Reimplemented from zypp::media::MediaCurl.

Definition at line 1316 of file MediaMultiCurl.cc.

◆ multifetch() [1/2]

void zypp::media::MediaMultiCurl::multifetch ( const Pathname filename,
FILE *  fp,
std::vector< Url > *  urllist,
callback::SendReport< DownloadProgressReport > *  report = 0,
MediaBlockList blklist = 0,
off_t  filesize = off_t(-1) 
) const

Definition at line 1535 of file MediaMultiCurl.cc.

◆ multifetch() [2/2]

void zypp::media::MediaMultiCurl::multifetch ( const Pathname filename,
FILE *  fp,
std::vector< Url > *  urllist,
callback::SendReport< DownloadProgressReport > *  report,
MediaBlockList blklist,
const ByteCount filesize 
) const
inline

Definition at line 55 of file MediaMultiCurl.h.

◆ isDNSok()

bool zypp::media::MediaMultiCurl::isDNSok ( const std::string &  host) const
protected

Definition at line 1603 of file MediaMultiCurl.cc.

◆ setDNSok()

void zypp::media::MediaMultiCurl::setDNSok ( const std::string &  host) const
protected

Definition at line 1608 of file MediaMultiCurl.cc.

◆ fromEasyPool()

CURL * zypp::media::MediaMultiCurl::fromEasyPool ( const std::string &  host) const
protected

Definition at line 1613 of file MediaMultiCurl.cc.

◆ toEasyPool()

void zypp::media::MediaMultiCurl::toEasyPool ( const std::string &  host,
CURL *  easy 
) const
protected

Definition at line 1622 of file MediaMultiCurl.cc.

◆ setupEasy()

void zypp::media::MediaMultiCurl::setupEasy ( )
overrideprotectedvirtual

initializes the curl easy handle with the data from the url

Exceptions
MediaCurlSetOptExceptionif there is a problem

Force IPv4/v6

Connect timeout

Speed limits

Reimplemented from zypp::media::MediaCurl.

Definition at line 1211 of file MediaMultiCurl.cc.

◆ checkFileDigest()

void zypp::media::MediaMultiCurl::checkFileDigest ( Url url,
FILE *  fp,
MediaBlockList blklist 
) const
protected

Definition at line 1587 of file MediaMultiCurl.cc.

◆ progressCallback()

int zypp::media::MediaMultiCurl::progressCallback ( void *  clientp,
curl_off_t  dltotal,
curl_off_t  dlnow,
curl_off_t  ultotal,
curl_off_t  ulnow 
)
staticprotected

Definition at line 1265 of file MediaMultiCurl.cc.

Friends And Related Function Documentation

◆ multifetchrequest

friend class multifetchrequest
friend

Definition at line 42 of file MediaMultiCurl.h.

◆ multifetchworker

friend class multifetchworker
friend

Definition at line 43 of file MediaMultiCurl.h.

Member Data Documentation

◆ _customHeadersMetalink

curl_slist* zypp::media::MediaMultiCurl::_customHeadersMetalink
private

Definition at line 72 of file MediaMultiCurl.h.

◆ _multi

CURLM* zypp::media::MediaMultiCurl::_multi
mutableprivate

Definition at line 73 of file MediaMultiCurl.h.

◆ _dnsok

std::set<std::string> zypp::media::MediaMultiCurl::_dnsok
mutableprivate

Definition at line 74 of file MediaMultiCurl.h.

◆ _easypool

std::map<std::string, CURL *> zypp::media::MediaMultiCurl::_easypool
mutableprivate

Definition at line 75 of file MediaMultiCurl.h.


The documentation for this class was generated from the following files: