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

@ -19573,3 +19573,5 @@
* Added a 'delete_test' test harness. * Added a 'delete_test' test harness.
2020-02-20 Fred Gleason <fredg@paravelsystems.com> 2020-02-20 Fred Gleason <fredg@paravelsystems.com>
* Rebased 'RDUpload' to 'RDTransfer'. * Rebased 'RDUpload' to 'RDTransfer'.
2020-02-20 Fred Gleason <fredg@paravelsystems.com>
* Rebased 'RDDownload' to 'RDTransfer'.

View File

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

View File

@ -21,12 +21,12 @@
#ifndef RDDOWNLOAD_H #ifndef RDDOWNLOAD_H
#define RDDOWNLOAD_H #define RDDOWNLOAD_H
#include <qobject.h>
#include <qurl.h> #include <qurl.h>
#include <rdconfig.h> #include <rdconfig.h>
#include <rdtransfer.h>
class RDDownload : public QObject class RDDownload : public RDTransfer
{ {
Q_OBJECT; Q_OBJECT;
public: public:
@ -37,6 +37,7 @@ class RDDownload : public QObject
ErrorInvalidLogin=11,ErrorRemoteAccess=12, ErrorInvalidLogin=11,ErrorRemoteAccess=12,
ErrorRemoteConnection=13}; ErrorRemoteConnection=13};
RDDownload(RDConfig *config,QObject *parent=0); RDDownload(RDConfig *config,QObject *parent=0);
QStringList supportedSchemes() const;
void setSourceUrl(const QString &url); void setSourceUrl(const QString &url);
void setDestinationFile(const QString &filename); void setDestinationFile(const QString &filename);
int totalSteps() const; int totalSteps() const;
@ -60,7 +61,6 @@ class RDDownload : public QObject
QString conv_dst_filename; QString conv_dst_filename;
bool conv_aborting; bool conv_aborting;
uint conv_dst_size; uint conv_dst_size;
RDConfig *conv_config;
}; };