2020-02-20 Fred Gleason <fredg@paravelsystems.com>

* Rebased 'RDDownload' to 'RDTransfer'.
This commit is contained in:
Fred Gleason
2020-02-20 18:44:28 -05:00
parent a75850637f
commit b4be9a8cf6
3 changed files with 29 additions and 12 deletions

View File

@@ -69,14 +69,27 @@ int DownloadErrorCallback(CURL *curl,curl_infotype type,char *msg,size_t size,
}
RDDownload::RDDownload(RDConfig *config,QObject *parent)
: QObject(parent)
RDDownload::RDDownload(RDConfig *c,QObject *parent)
: RDTransfer(c,parent)
{
conv_config=config;
conv_aborting=false;
}
QStringList RDDownload::supportedSchemes() const
{
QStringList schemes;
schemes.push_back("file");
schemes.push_back("ftp");
schemes.push_back("http");
schemes.push_back("https");
schemes.push_back("sftp");
return schemes;
}
void RDDownload::setSourceUrl(const QString &url)
{
conv_src_url=url;
@@ -107,8 +120,10 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
long response_code=0;
RDDownload::ErrorCode ret=RDDownload::ErrorOk;
RDSystemUser *user=NULL;
// char url[1024];
char userpwd[256];
if(!urlIsSupported(conv_src_url)) {
return RDDownload::ErrorUnsupportedProtocol;
}
//
// Validate User for file: transfers
@@ -140,17 +155,17 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
//
url.replace("#","%23");
curl_easy_setopt(curl,CURLOPT_URL,(const char *)url);
curl_easy_setopt(curl,CURLOPT_URL,url.constData());
curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
strncpy(userpwd,(username+":"+password).utf8(),256);
curl_easy_setopt(curl,CURLOPT_USERPWD,userpwd);
curl_easy_setopt(curl,CURLOPT_USERNAME,username.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_PASSWORD,password.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
curl_easy_setopt(curl,CURLOPT_PROGRESSFUNCTION,DownloadProgressCallback);
curl_easy_setopt(curl,CURLOPT_PROGRESSDATA,this);
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,0);
curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)conv_config->userAgent().utf8());
config()->userAgent().toUtf8().constData());
if(log_debug) {
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
curl_easy_setopt(curl,CURLOPT_DEBUGFUNCTION,DownloadErrorCallback);