zypp::media::MediaCurl Class Reference

#include <MediaCurl.h>

Inheritance diagram for zypp::media::MediaCurl:
[legend]

List of all members.

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
 
See also:
MediaHandler::getDoesFileExist

virtual void disconnectFrom ()
 
Exceptions:
MediaException 

virtual void getFileCopy (const Pathname &srcFilename, const Pathname &targetFilename) const
 
Exceptions:
MediaException 

virtual void doGetFileCopy (const Pathname &srcFilename, const Pathname &targetFilename, callback::SendReport< DownloadProgressReport > &_report) const
 
Exceptions:
MediaException 

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


Detailed Description

Implementation class for FTP, HTTP and HTTPS MediaHandler
See also:
MediaHandler

Definition at line 30 of file MediaCurl.h.


Constructor & Destructor Documentation

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]

Definition at line 82 of file MediaCurl.h.

References zypp::media::MediaHandler::release().


Member Function Documentation

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.

Parameters:
next try next available device in turn until end of device list is reached (for media which are accessible through multiple devices like cdroms).
Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
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.

Exceptions:
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]

See also:
MediaHandler::getDoesFileExist

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]

Exceptions:
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]

Exceptions:
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]

Exceptions:
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.

Parameters:
apoint The directory to check.
Returns:
True, if the directory checks succeeded.

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]

Definition at line 202 of file MediaCurl.cc.

References _cookieFile.

int zypp::media::MediaCurl::progressCallback ( void *  clientp,
double  dltotal,
double  dlnow,
double  ultotal,
double  ulnow 
) [static, protected]

Definition at line 1391 of file MediaCurl.cc.

Referenced by attachTo().

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().


Member Data Documentation

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]

Definition at line 107 of file MediaCurl.h.

Referenced by attachTo(), and MediaCurl().

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]

Definition at line 110 of file MediaCurl.h.

Referenced by attachTo().

std::string zypp::media::MediaCurl::_proxyuserpwd [private]

Definition at line 111 of file MediaCurl.h.

Referenced by attachTo().

std::string zypp::media::MediaCurl::_currentCookieFile [private]

Definition at line 112 of file MediaCurl.h.

Referenced by attachTo().

std::string zypp::media::MediaCurl::_ca_path [private]

Definition at line 113 of file MediaCurl.h.

Referenced by attachTo().

long zypp::media::MediaCurl::_xfer_timeout [private]

Definition at line 114 of file MediaCurl.h.

Referenced by attachTo(), and doGetFileCopy().

Pathname zypp::media::MediaCurl::_cookieFile = "/var/lib/YaST2/cookies" [static, private]

Definition at line 116 of file MediaCurl.h.

Referenced by attachTo(), and setCookieFile().

std::string zypp::media::MediaCurl::_agent = "Novell ZYPP Installer" [static, private]

Definition at line 117 of file MediaCurl.h.

Referenced by attachTo().


The documentation for this class was generated from the following files:
Generated on Tue Sep 25 19:23:20 2007 for libzypp by  doxygen 1.5.3