mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-23 09:18:34 +02:00
2020-02-20 Fred Gleason <fredg@paravelsystems.com>
* Rebased 'RDDownload' to 'RDTransfer'.
This commit is contained in:
parent
a75850637f
commit
b4be9a8cf6
@ -19573,3 +19573,5 @@
|
||||
* Added a 'delete_test' test harness.
|
||||
2020-02-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Rebased 'RDUpload' to 'RDTransfer'.
|
||||
2020-02-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Rebased 'RDDownload' to 'RDTransfer'.
|
||||
|
@ -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);
|
||||
|
@ -21,12 +21,12 @@
|
||||
#ifndef RDDOWNLOAD_H
|
||||
#define RDDOWNLOAD_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qurl.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdtransfer.h>
|
||||
|
||||
class RDDownload : public QObject
|
||||
class RDDownload : public RDTransfer
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
@ -37,6 +37,7 @@ class RDDownload : public QObject
|
||||
ErrorInvalidLogin=11,ErrorRemoteAccess=12,
|
||||
ErrorRemoteConnection=13};
|
||||
RDDownload(RDConfig *config,QObject *parent=0);
|
||||
QStringList supportedSchemes() const;
|
||||
void setSourceUrl(const QString &url);
|
||||
void setDestinationFile(const QString &filename);
|
||||
int totalSteps() const;
|
||||
@ -60,7 +61,6 @@ class RDDownload : public QObject
|
||||
QString conv_dst_filename;
|
||||
bool conv_aborting;
|
||||
uint conv_dst_size;
|
||||
RDConfig *conv_config;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user