2018-02-06 Fred Gleason <fredg@paravelsystems.com>

* Refactored the RDUpload class to use RDApplication.
This commit is contained in:
Fred Gleason
2018-02-06 07:29:11 -05:00
parent ed4fe367a8
commit 2df78cb26d
8 changed files with 73 additions and 33 deletions

View File

@@ -605,7 +605,7 @@ unsigned RDFeed::postCut(RDUser *user,RDStation *station,
unsigned cast_id=CreateCast(&destfile,length,cut->length());
delete cut;
cast=new RDPodcast(feed_config,cast_id);
upload=new RDUpload(feed_config,this);
upload=new RDUpload(this);
upload->setSourceFile(tmpfile);
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
switch((upload_err=upload->runUpload(purgeUsername(),purgePassword(),
@@ -718,7 +718,7 @@ unsigned RDFeed::postFile(RDStation *station,const QString &srcfile,Error *err,
unsigned cast_id=CreateCast(&destfile,length,time_length);
RDPodcast *cast=new RDPodcast(feed_config,cast_id);
upload=new RDUpload(feed_config,this);
upload=new RDUpload(this);
upload->setSourceFile(tmpfile);
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
switch((upload_err=upload->runUpload(purgeUsername(),purgePassword(),

View File

@@ -2,7 +2,7 @@
//
// Upload a File
//
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010,2016-2018 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
@@ -32,9 +32,10 @@
#include <qapplication.h>
#include <qfileinfo.h>
#include <rd.h>
#include <rdsystemuser.h>
#include <rdupload.h>
#include "rd.h"
#include "rdapplication.h"
#include "rdsystemuser.h"
#include "rdupload.h"
//
// CURL Progress Callback
@@ -70,10 +71,9 @@ int UploadErrorCallback(CURL *curl,curl_infotype type,char *msg,size_t size,
}
RDUpload::RDUpload(RDConfig *config,QObject *parent)
RDUpload::RDUpload(QObject *parent)
: QObject(parent)
{
conv_config=config;
conv_aborting=false;
}
@@ -147,7 +147,7 @@ RDUpload::ErrorCode RDUpload::runUpload(const QString &username,
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());
(const char *)rda->config()->userAgent());
if(log_debug) {
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
curl_easy_setopt(curl,CURLOPT_DEBUGFUNCTION,UploadErrorCallback);

View File

@@ -2,7 +2,7 @@
//
// Upload a File
//
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010,2016-2018 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
@@ -24,8 +24,6 @@
#include <qobject.h>
#include <qurl.h>
#include <rdconfig.h>
class RDUpload : public QObject
{
Q_OBJECT;
@@ -36,7 +34,7 @@ class RDUpload : public QObject
ErrorUnspecified=8,ErrorInvalidUser=9,ErrorAborted=10,
ErrorInvalidLogin=11,ErrorRemoteAccess=12,
ErrorRemoteConnection=13};
RDUpload(RDConfig *config,QObject *parent=0);
RDUpload(QObject *parent=0);
void setSourceFile(const QString &filename);
void setDestinationUrl(const QString &url);
int totalSteps() const;
@@ -60,7 +58,6 @@ class RDUpload : public QObject
QUrl conv_dst_url;
bool conv_aborting;
uint conv_src_size;
RDConfig *conv_config;
};