#include <MediaCurl.h>
Public Member Functions | ||||
| MediaCurl (const Url &url_r, const Pathname &attach_point_hint_r) | ||||
| virtual | ~MediaCurl () | |||
Static Public Member Functions | ||||
| static void | setCookieFile (const Pathname &) | |||
Protected Member Functions | ||||
| virtual void | attachTo (bool next=false) | |||
| Call concrete handler to attach the media. | ||||
| virtual void | releaseFrom (bool eject) | |||
| Call concrete handler to release the media. | ||||
| virtual void | getFile (const Pathname &filename) const | |||
| Call concrete handler to provide file below attach point. | ||||
| virtual void | getDir (const Pathname &dirname, bool recurse_r) const | |||
| 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 | |||
| 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 | |||
| Basically the same as getDirInfo above. | ||||
| virtual bool | getDoesFileExist (const Pathname &filename) const | |||
| Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly, or user cancels the operation. | ||||
| virtual bool | doGetDoesFileExist (const Pathname &filename) const | |||
| ||||
| virtual void | disconnectFrom () | |||
| ||||
| virtual void | getFileCopy (const Pathname &srcFilename, const Pathname &targetFilename) const | |||
| ||||
| virtual void | doGetFileCopy (const Pathname &srcFilename, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report) const | |||
| ||||
| virtual bool | checkAttachPoint (const Pathname &apoint) const | |||
| Verify if the specified directory as attach point (root) as requires by the particular media handler implementation. | ||||
Static Protected Member Functions | ||||
| static int | progressCallback (void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) | |||
Private Member Functions | ||||
| std::string | getAuthHint () const | |||
| Return a comma separated list of available authentication methods supported by server. | ||||
Private Attributes | ||||
| CURL * | _curl | |||
| char | _curlError [CURL_ERROR_SIZE] | |||
| long | _curlDebug | |||
| std::string | _userpwd | |||
| std::string | _proxy | |||
| std::string | _proxyuserpwd | |||
| std::string | _currentCookieFile | |||
| std::string | _ca_path | |||
| long | _xfer_timeout | |||
Static Private Attributes | ||||
| static Pathname | _cookieFile = "/var/lib/YaST2/cookies" | |||
| static std::string | _agent = "Novell ZYPP Installer" | |||
Classes | ||||
| class | Callbacks | |||
Definition at line 30 of file MediaCurl.h.
| zypp::media::MediaCurl::MediaCurl | ( | const Url & | url_r, | |
| const Pathname & | attach_point_hint_r | |||
| ) |
Definition at line 167 of file MediaCurl.cc.
References _curlDebug, _curlError, zypp::media::MediaHandler::attachPoint(), zypp::Url::getScheme(), globalInitOnce(), MIL, zypp::filesystem::rmdir(), zypp::media::MediaHandler::setAttachPoint(), and WAR.
| virtual zypp::media::MediaCurl::~MediaCurl | ( | ) | [inline, virtual] |
| void zypp::media::MediaCurl::attachTo | ( | bool | next = false |
) | [protected, virtual] |
Call concrete handler to attach the media.
Asserted that not already attached, and attachPoint is a directory.
| next | try next available device in turn until end of device list is reached (for media which are accessible through multiple devices like cdroms). |
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 215 of file MediaCurl.cc.
References _agent, _ca_path, _cookieFile, _curl, _curlDebug, _curlError, _currentCookieFile, _proxy, _proxyuserpwd, zypp::media::MediaHandler::_url, _userpwd, _xfer_timeout, zypp::Url::asString(), zypp::ui::asString(), zypp::media::MediaHandler::attachPoint(), zypp::media::CurlAuthData::auth_type_str2long(), CONNECT_TIMEOUT, zypp::media::MediaHandler::createAttachPoint(), DBG, disconnectFrom(), zypp::media::ProxyInfo::enabled(), getAuthHint(), zypp::Url::getHost(), zypp::Url::getPassword(), zypp::Url::getQueryParam(), zypp::Url::getScheme(), zypp::Url::getUsername(), zypp::media::MediaHandler::isUseableAttachPoint(), zypp::Url::isValid(), log_curl(), zypp::Exception::msg(), zypp::media::ProxyInfo::noProxy(), zypp::media::ProxyInfo::noProxyBegin(), zypp::media::ProxyInfo::noProxyEnd(), progressCallback(), zypp::media::ProxyInfo::proxy(), zypp::base::sysconfig::read(), zypp::media::MediaHandler::setAttachPoint(), zypp::media::MediaHandler::setMediaSource(), zypp::url::split(), zypp::str::toLower(), TRANSFER_TIMEOUT, TRANSFER_TIMEOUT_MAX, zypp::media::unEscape(), zypp::media::MediaHandler::url(), WAR, and ZYPP_THROW.
| void zypp::media::MediaCurl::releaseFrom | ( | bool | eject | ) | [protected, virtual] |
Call concrete handler to release the media.
If eject is true, and the media is used in one handler instance only, physically eject the media (i.e. CD-ROM).
Asserted that media is attached.
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 671 of file MediaCurl.cc.
References zypp::media::MediaHandler::disconnect().
| void zypp::media::MediaCurl::getFile | ( | const Pathname & | filename | ) | const [protected, virtual] |
Call concrete handler to provide file below attach point.
Default implementation provided, that returns whether a file is located at 'localRoot + filename'.
Asserted that media is attached.
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 683 of file MediaCurl.cc.
References getFileCopy(), and zypp::media::MediaHandler::localPath().
Referenced by getDir().
| void zypp::media::MediaCurl::getDir | ( | const Pathname & | dirname, | |
| bool | recurse_r | |||
| ) | const [protected, virtual] |
Call concrete handler to provide directory content (not recursive!) below attach point.
Return E_not_supported_by_media if media does not support retrieval of directory content.
Default implementation provided, that returns whether a directory is located at 'localRoot + dirname'.
Asserted that media is attached.
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 1324 of file MediaCurl.cc.
References zypp::filesystem::assert_dir(), zypp::filesystem::FT_DIR, zypp::filesystem::FT_FILE, zypp::filesystem::FT_NOT_AVAIL, getDirInfo(), getFile(), zypp::media::MediaHandler::localPath(), and WAR.
| void zypp::media::MediaCurl::getDirInfo | ( | std::list< std::string > & | retlist, | |
| const Pathname & | dirname, | |||
| bool | dots = true | |||
| ) | const [protected, virtual] |
Call concrete handler to provide a content list of directory on media via retlist.
If dots is false entries starting with '.' are not reported.
Return E_not_supported_by_media if media does not support retrieval of directory content.
Default implementation provided, that returns the content of a directory at 'localRoot + dirnname' retrieved via 'readdir'.
Asserted that media is attached and retlist is empty.
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 1363 of file MediaCurl.cc.
References zypp::media::MediaHandler::getDirectoryYast().
Referenced by getDir().
| void zypp::media::MediaCurl::getDirInfo | ( | filesystem::DirContent & | retlist, | |
| const Pathname & | dirname, | |||
| bool | dots = true | |||
| ) | const [protected, virtual] |
Basically the same as getDirInfo above.
The content list is returned as filesystem::DirContent, which includes name and filetype of each directory entry. Retrieving the filetype usg. requires an additional stat call for each entry, thus it's more expensive than a simple readdir.
Asserted that media is attached and retlist is empty.
| MediaException |
Implements zypp::media::MediaHandler.
Definition at line 1377 of file MediaCurl.cc.
References zypp::media::MediaHandler::getDirectoryYast().
| bool zypp::media::MediaCurl::getDoesFileExist | ( | const Pathname & | filename | ) | const [protected, virtual] |
Repeatedly calls doGetDoesFileExist() until it successfully returns, fails unexpectedly, or user cancels the operation.
This is used to handle authentication or similar retry scenarios on media level.
Implements zypp::media::MediaHandler.
Definition at line 765 of file MediaCurl.cc.
References _, _curl, _curlError, zypp::media::MediaHandler::_url, _userpwd, zypp::Url::asString(), zypp::media::CurlAuthData::authType(), DBG, doGetDoesFileExist(), zypp::Url::getUsername(), zypp::media::CurlAuthData::getUserPwd(), zypp::media::MediaUnauthorizedException::hint(), zypp::media::CurlAuthData::setAuthType(), zypp::media::AuthData::setUserName(), zypp::solver::detail::str, zypp::media::CurlAuthData::valid(), ZYPP_RETHROW, and ZYPP_THROW.
| bool zypp::media::MediaCurl::doGetDoesFileExist | ( | const Pathname & | filename | ) | const [protected, virtual] |
Definition at line 830 of file MediaCurl.cc.
References _curl, _curlError, zypp::media::MediaHandler::_url, zypp::Url::asString(), DBG, ERR, getAuthHint(), zypp::Url::getHost(), zypp::Url::getPathName(), zypp::Url::isValid(), MIL, zypp::str::numstring(), zypp::Url::setFragment(), zypp::Url::setPassword(), zypp::Url::setPathName(), zypp::Url::setPathParams(), zypp::Url::setQueryString(), zypp::Url::setUsername(), zypp::media::MediaHandler::url(), ZYPP_RETHROW, and ZYPP_THROW.
Referenced by getDoesFileExist().
| void zypp::media::MediaCurl::disconnectFrom | ( | ) | [protected, virtual] |
| MediaException |
Reimplemented from zypp::media::MediaHandler.
Definition at line 654 of file MediaCurl.cc.
References _curl.
Referenced by attachTo().
| void zypp::media::MediaCurl::getFileCopy | ( | const Pathname & | srcFilename, | |
| const Pathname & | targetFilename | |||
| ) | const [protected, virtual] |
| MediaException |
Reimplemented from zypp::media::MediaHandler.
Definition at line 691 of file MediaCurl.cc.
References _, _curl, _curlError, zypp::media::MediaHandler::_url, _userpwd, zypp::media::DownloadProgressReport::ACCESS_DENIED, zypp::Url::asString(), zypp::Exception::asUserString(), zypp::media::CurlAuthData::authType(), DBG, doGetFileCopy(), zypp::media::DownloadProgressReport::ERROR, zypp::Url::getUsername(), zypp::media::CurlAuthData::getUserPwd(), zypp::media::MediaUnauthorizedException::hint(), zypp::media::DownloadProgressReport::NO_ERROR, report, zypp::media::CurlAuthData::setAuthType(), zypp::media::AuthData::setUserName(), zypp::solver::detail::str, zypp::media::MediaHandler::url(), zypp::media::CurlAuthData::valid(), ZYPP_RETHROW, and ZYPP_THROW.
Referenced by getFile().
| void zypp::media::MediaCurl::doGetFileCopy | ( | const Pathname & | srcFilename, | |
| const Pathname & | targetFilename, | |||
| callback::SendReport< DownloadProgressReport > & | _report | |||
| ) | const [protected, virtual] |
| MediaException |
Definition at line 1038 of file MediaCurl.cc.
References _curl, _curlError, zypp::media::MediaHandler::_url, _xfer_timeout, zypp::filesystem::applyUmaskTo(), zypp::filesystem::assert_dir(), zypp::Url::asString(), DBG, ERR, getAuthHint(), zypp::Url::getHost(), zypp::Url::getPathName(), zypp::Url::getScheme(), zypp::Url::isValid(), zypp::str::numstring(), zypp::filesystem::rename(), zypp::Url::setFragment(), zypp::Url::setPassword(), zypp::Url::setPathName(), zypp::Url::setPathParams(), zypp::Url::setQueryString(), zypp::Url::setUsername(), zypp::filesystem::unlink(), zypp::media::MediaHandler::url(), WAR, ZYPP_RETHROW, and ZYPP_THROW.
Referenced by getFileCopy().
| bool zypp::media::MediaCurl::checkAttachPoint | ( | const Pathname & | apoint | ) | const [protected, virtual] |
Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.
| apoint | The directory to check. |
Reimplemented from zypp::media::MediaHandler.
Definition at line 643 of file MediaCurl.cc.
References zypp::media::MediaHandler::checkAttachPoint().
| void zypp::media::MediaCurl::setCookieFile | ( | const Pathname & | fileName | ) | [static] |
| int zypp::media::MediaCurl::progressCallback | ( | void * | clientp, | |
| double | dltotal, | |||
| double | dlnow, | |||
| double | ultotal, | |||
| double | ulnow | |||
| ) | [static, protected] |
| string zypp::media::MediaCurl::getAuthHint | ( | ) | const [private] |
Return a comma separated list of available authentication methods supported by server.
Definition at line 1445 of file MediaCurl.cc.
References _curl, and zypp::media::CurlAuthData::auth_type_long2str().
Referenced by attachTo(), doGetDoesFileExist(), and doGetFileCopy().
CURL* zypp::media::MediaCurl::_curl [private] |
Definition at line 105 of file MediaCurl.h.
Referenced by attachTo(), disconnectFrom(), doGetDoesFileExist(), doGetFileCopy(), getAuthHint(), getDoesFileExist(), and getFileCopy().
char zypp::media::MediaCurl::_curlError[CURL_ERROR_SIZE] [private] |
Definition at line 106 of file MediaCurl.h.
Referenced by attachTo(), doGetDoesFileExist(), doGetFileCopy(), getDoesFileExist(), getFileCopy(), and MediaCurl().
long zypp::media::MediaCurl::_curlDebug [private] |
std::string zypp::media::MediaCurl::_userpwd [mutable, private] |
Definition at line 109 of file MediaCurl.h.
Referenced by attachTo(), getDoesFileExist(), and getFileCopy().
std::string zypp::media::MediaCurl::_proxy [private] |
std::string zypp::media::MediaCurl::_proxyuserpwd [private] |
std::string zypp::media::MediaCurl::_currentCookieFile [private] |
std::string zypp::media::MediaCurl::_ca_path [private] |
long zypp::media::MediaCurl::_xfer_timeout [private] |
Pathname zypp::media::MediaCurl::_cookieFile = "/var/lib/YaST2/cookies" [static, private] |
std::string zypp::media::MediaCurl::_agent = "Novell ZYPP Installer" [static, private] |
1.5.3