2020-01-10 Fred Gleason <fredg@paravelsystems.com>

* Removed all Qt3Support dependencies from the 'RDUpload' class.
	* Removed all Qt3Support dependencies from the 'RDDownload' class.
	* Added a 'test_download' test harness.
This commit is contained in:
Fred Gleason
2020-01-10 17:06:36 -05:00
parent aa7a2ab01d
commit d32aa115f7
9 changed files with 192 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
//
// Download a File
//
// (C) Copyright 2010-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -107,7 +107,7 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
long response_code=0;
RDDownload::ErrorCode ret=RDDownload::ErrorOk;
RDSystemUser *user=NULL;
char url[1024];
// char url[1024];
char userpwd[256];
//
@@ -128,14 +128,19 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
curl_easy_cleanup(curl);
return RDDownload::ErrorNoDestination;
}
//
// Write out URL as a C string before passing to curl_easy_setopt(),
// otherwise some versions of LibCurl will throw a 'bad/illegal format'
// error.
// Write out an encoded URL
//
strncpy(url,conv_src_url.
toString(conv_src_url.protocol().lower().left(4)=="http").utf8(),1024);
curl_easy_setopt(curl,CURLOPT_URL,url);
QByteArray url=conv_src_url.toEncoded(QUrl::RemoveUserInfo);
//
// An URL anchor element will never occur here, so treat any '#'
// characters as part of the path.
//
url.replace("#","%23");
curl_easy_setopt(curl,CURLOPT_URL,(const char *)url);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
strncpy(userpwd,(username+":"+password).utf8(),256);
curl_easy_setopt(curl,CURLOPT_USERPWD,userpwd);

View File

@@ -2,7 +2,7 @@
//
// Download a File
//
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -22,7 +22,7 @@
#define RDDOWNLOAD_H
#include <qobject.h>
#include <q3url.h>
#include <qurl.h>
#include <rdconfig.h>
@@ -56,7 +56,7 @@ class RDDownload : public QObject
void UpdateProgress(int step);
friend int DownloadProgressCallback(void *clientp,double dltotal,double dlnow,
double ultotal,double ulnow);
Q3Url conv_src_url;
QUrl conv_src_url;
QString conv_dst_filename;
bool conv_aborting;
uint conv_dst_size;

View File

@@ -2,7 +2,7 @@
//
// Upload a File
//
// (C) Copyright 2010-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -107,7 +107,6 @@ RDUpload::ErrorCode RDUpload::runUpload(const QString &username,
FILE *f;
RDUpload::ErrorCode ret=RDUpload::ErrorOk;
RDSystemUser *user=NULL;
char url[1024];
char userpwd[256];
//
@@ -130,13 +129,17 @@ RDUpload::ErrorCode RDUpload::runUpload(const QString &username,
}
//
// Write out URL as a C string before passing to curl_easy_setopt(),
// otherwise some versions of LibCurl will throw a 'bad/illegal format'
// error.
// Write out an encoded URL
//
strncpy(url,conv_dst_url.toString(conv_dst_url.protocol().lower()=="http").utf8(),
1024);
curl_easy_setopt(curl,CURLOPT_URL,url);
QByteArray url=conv_dst_url.toEncoded(QUrl::RemoveUserInfo);
//
// An URL anchor element will never occur here, so treat any '#'
// characters as part of the path.
//
url.replace("#","%23");
curl_easy_setopt(curl,CURLOPT_URL,(const char *)url);
curl_easy_setopt(curl,CURLOPT_UPLOAD,1);
curl_easy_setopt(curl,CURLOPT_READDATA,f);
curl_easy_setopt(curl,CURLOPT_INFILESIZE,(long)conv_src_size);

View File

@@ -2,7 +2,7 @@
//
// Upload a File
//
// (C) Copyright 2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -22,7 +22,7 @@
#define RDUPLOAD_H
#include <qobject.h>
#include <q3url.h>
#include <qurl.h>
class RDUpload : public QObject
{
@@ -55,7 +55,7 @@ class RDUpload : public QObject
friend int UploadProgressCallback(void *clientp,double dltotal,double dlnow,
double ultotal,double ulnow);
QString conv_src_filename;
Q3Url conv_dst_url;
QUrl conv_dst_url;
bool conv_aborting;
uint conv_src_size;
};