#include <iostream>
-#include <vector>
#include <sstream>
#include "zypp/base/String.h"
using namespace std;
-#define ARIA2C_BINARY "/usr/bin/aria2c"
#define CURL_BINARY "/usr/bin/curl"
namespace zypp
{
namespace media
{
-
+
class TransferSettings::Impl
{
public:
, _minDownloadSpeed(ZConfig::instance().download_min_download_speed())
, _maxDownloadSpeed(ZConfig::instance().download_max_download_speed())
, _maxSilentTries(ZConfig::instance().download_max_silent_tries())
+ , _verify_host(false)
+ , _verify_peer(false)
+ , _ca_path("/etc/ssl/certs")
+ , _head_requests_allowed(true)
{}
virtual ~Impl()
- {}
+ {}
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
string _proxy;
string _proxy_username;
string _proxy_password;
+ string _authtype;
long _timeout;
long _connect_timeout;
Url _url;
long _minDownloadSpeed;
long _maxDownloadSpeed;
long _maxSilentTries;
+
+ bool _verify_host;
+ bool _verify_peer;
+ Pathname _ca_path;
+ Pathname _client_cert_path;
+ Pathname _client_key_path;
+
+ // workarounds
+ bool _head_requests_allowed;
};
-
+
TransferSettings::TransferSettings()
: _impl(new TransferSettings::Impl())
{
}
+void TransferSettings::reset()
+{
+ _impl.reset(new TransferSettings::Impl());
+}
+
void TransferSettings::addHeader( const std::string &header )
{
_impl->_headers.push_back(header);
_impl->_password = password;
}
+void TransferSettings::setAnonymousAuth()
+{
+ setUsername("anonymous");
+ string id = "yast@";
+ setPassword(id + VERSION);
+}
+
std::string TransferSettings::password() const
{
return _impl->_password;
}
+std::string TransferSettings::userPassword() const
+{
+ string userpwd = username();
+ if ( password().size() ) {
+ userpwd += ":" + password();
+ }
+ return userpwd;
+}
+
void TransferSettings::setProxyEnabled( bool enabled )
{
_impl->_useproxy = enabled;
return _impl->_proxy_password;
}
+std::string TransferSettings::proxyUserPassword() const
+{
+ string userpwd = proxyUsername();
+ if ( proxyPassword().size() ) {
+ userpwd += ":" + proxyPassword();
+ }
+ return userpwd;
+}
+
void TransferSettings::setTimeout( long t )
{
_impl->_timeout = t;
_impl->_maxSilentTries = v;
}
+bool TransferSettings::verifyHostEnabled() const
+{
+ return _impl->_verify_host;
+}
+
+void TransferSettings::setVerifyHostEnabled( bool enabled )
+{
+ _impl->_verify_host = enabled;
+}
+
+bool TransferSettings::verifyPeerEnabled() const
+{
+ return _impl->_verify_peer;
+}
+
+Pathname TransferSettings::clientCertificatePath() const
+{
+ return _impl->_client_cert_path;
+}
+
+void TransferSettings::setClientCertificatePath( const zypp::Pathname &path )
+{
+ _impl->_client_cert_path = path;
+}
+
+Pathname TransferSettings::clientKeyPath() const
+{
+ return _impl->_client_key_path;
+}
+
+void TransferSettings::setClientKeyPath( const zypp::Pathname &path )
+{
+ _impl->_client_key_path = path;
+}
+
+
+void TransferSettings::setVerifyPeerEnabled( bool enabled )
+{
+ _impl->_verify_peer = enabled;
+}
+
+Pathname TransferSettings::certificateAuthoritiesPath() const
+{
+ return _impl->_ca_path;
+}
+
+void TransferSettings::setCertificateAuthoritiesPath( const zypp::Pathname &path )
+{
+ _impl->_ca_path = path;
+}
+
+void TransferSettings::setAuthType( const std::string &authtype)
+{
+ _impl->_authtype = authtype;
+}
+
+std::string TransferSettings::authType() const
+{
+ return _impl->_authtype;
+}
+
+void TransferSettings::setHeadRequestsAllowed(bool allowed)
+{
+ _impl->_head_requests_allowed = allowed;
+}
+
+bool TransferSettings::headRequestsAllowed() const
+{
+ return _impl->_head_requests_allowed;
+}
+
} // ns media
} // ns zypp