mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-13 15:17:44 +02:00
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDUpload class to use RDApplication.
This commit is contained in:
parent
ed4fe367a8
commit
2df78cb26d
@ -16693,3 +16693,5 @@
|
|||||||
* Refactored the RDPeaksExport class to use RDApplication.
|
* Refactored the RDPeaksExport class to use RDApplication.
|
||||||
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
|
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Refactored the RDSoundPanel class to use RDApplication.
|
* Refactored the RDSoundPanel class to use RDApplication.
|
||||||
|
2018-02-06 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored the RDUpload class to use RDApplication.
|
||||||
|
@ -605,7 +605,7 @@ unsigned RDFeed::postCut(RDUser *user,RDStation *station,
|
|||||||
unsigned cast_id=CreateCast(&destfile,length,cut->length());
|
unsigned cast_id=CreateCast(&destfile,length,cut->length());
|
||||||
delete cut;
|
delete cut;
|
||||||
cast=new RDPodcast(feed_config,cast_id);
|
cast=new RDPodcast(feed_config,cast_id);
|
||||||
upload=new RDUpload(feed_config,this);
|
upload=new RDUpload(this);
|
||||||
upload->setSourceFile(tmpfile);
|
upload->setSourceFile(tmpfile);
|
||||||
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
|
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
|
||||||
switch((upload_err=upload->runUpload(purgeUsername(),purgePassword(),
|
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);
|
unsigned cast_id=CreateCast(&destfile,length,time_length);
|
||||||
RDPodcast *cast=new RDPodcast(feed_config,cast_id);
|
RDPodcast *cast=new RDPodcast(feed_config,cast_id);
|
||||||
upload=new RDUpload(feed_config,this);
|
upload=new RDUpload(this);
|
||||||
upload->setSourceFile(tmpfile);
|
upload->setSourceFile(tmpfile);
|
||||||
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
|
upload->setDestinationUrl(purgeUrl()+"/"+cast->audioFilename());
|
||||||
switch((upload_err=upload->runUpload(purgeUsername(),purgePassword(),
|
switch((upload_err=upload->runUpload(purgeUsername(),purgePassword(),
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Upload a File
|
// 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
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -32,9 +32,10 @@
|
|||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
|
|
||||||
#include <rd.h>
|
#include "rd.h"
|
||||||
#include <rdsystemuser.h>
|
#include "rdapplication.h"
|
||||||
#include <rdupload.h>
|
#include "rdsystemuser.h"
|
||||||
|
#include "rdupload.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CURL Progress Callback
|
// 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)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
conv_config=config;
|
|
||||||
conv_aborting=false;
|
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_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());
|
(const char *)rda->config()->userAgent());
|
||||||
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,UploadErrorCallback);
|
curl_easy_setopt(curl,CURLOPT_DEBUGFUNCTION,UploadErrorCallback);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Upload a File
|
// 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
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -24,8 +24,6 @@
|
|||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qurl.h>
|
#include <qurl.h>
|
||||||
|
|
||||||
#include <rdconfig.h>
|
|
||||||
|
|
||||||
class RDUpload : public QObject
|
class RDUpload : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
@ -36,7 +34,7 @@ class RDUpload : public QObject
|
|||||||
ErrorUnspecified=8,ErrorInvalidUser=9,ErrorAborted=10,
|
ErrorUnspecified=8,ErrorInvalidUser=9,ErrorAborted=10,
|
||||||
ErrorInvalidLogin=11,ErrorRemoteAccess=12,
|
ErrorInvalidLogin=11,ErrorRemoteAccess=12,
|
||||||
ErrorRemoteConnection=13};
|
ErrorRemoteConnection=13};
|
||||||
RDUpload(RDConfig *config,QObject *parent=0);
|
RDUpload(QObject *parent=0);
|
||||||
void setSourceFile(const QString &filename);
|
void setSourceFile(const QString &filename);
|
||||||
void setDestinationUrl(const QString &url);
|
void setDestinationUrl(const QString &url);
|
||||||
int totalSteps() const;
|
int totalSteps() const;
|
||||||
@ -60,7 +58,6 @@ class RDUpload : public QObject
|
|||||||
QUrl conv_dst_url;
|
QUrl conv_dst_url;
|
||||||
bool conv_aborting;
|
bool conv_aborting;
|
||||||
uint conv_src_size;
|
uint conv_src_size;
|
||||||
RDConfig *conv_config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ void MainObject::RunUpload(CatchEvent *evt)
|
|||||||
(const char *)evt->
|
(const char *)evt->
|
||||||
resolvedUrl(),
|
resolvedUrl(),
|
||||||
evt->id()));
|
evt->id()));
|
||||||
RDUpload *conv=new RDUpload(rda->config(),this);
|
RDUpload *conv=new RDUpload(this);
|
||||||
conv->setSourceFile(evt->tempName());
|
conv->setSourceFile(evt->tempName());
|
||||||
conv->setDestinationUrl(evt->resolvedUrl());
|
conv->setDestinationUrl(evt->resolvedUrl());
|
||||||
QString url_username=evt->urlUsername();
|
QString url_username=evt->urlUsername();
|
||||||
|
@ -381,7 +381,7 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
|
|||||||
//
|
//
|
||||||
// Upload File
|
// Upload File
|
||||||
//
|
//
|
||||||
RDUpload *upload=new RDUpload(rda->config());
|
RDUpload *upload=new RDUpload();
|
||||||
upload->setSourceFile(tempfile);
|
upload->setSourceFile(tempfile);
|
||||||
upload->setDestinationUrl(config()->url()+"/"+filename);
|
upload->setDestinationUrl(config()->url()+"/"+filename);
|
||||||
switch(upload_err=upload->runUpload(config()->urlUsername(),
|
switch(upload_err=upload->runUpload(config()->urlUsername(),
|
||||||
|
@ -18,22 +18,64 @@
|
|||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
|
||||||
|
#include <rdapplication.h>
|
||||||
#include <rddb.h>
|
#include <rddb.h>
|
||||||
#include <rdcmd_switch.h>
|
//#include <rdcmd_switch.h>
|
||||||
#include <rdupload.h>
|
#include <rdupload.h>
|
||||||
|
|
||||||
#include <upload_test.h>
|
#include "upload_test.h"
|
||||||
|
|
||||||
MainObject::MainObject(QObject *parent)
|
MainObject::MainObject(QObject *parent)
|
||||||
:QObject(parent)
|
:QObject(parent)
|
||||||
{
|
{
|
||||||
|
QString err_msg;
|
||||||
|
|
||||||
username="";
|
username="";
|
||||||
password="";
|
password="";
|
||||||
RDUpload::ErrorCode conv_err;
|
RDUpload::ErrorCode conv_err;
|
||||||
unsigned schema=0;
|
unsigned schema=0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the Database
|
||||||
|
//
|
||||||
|
rda=new RDApplication("upload_test","upload_test",UPLOAD_TEST_USAGE,this);
|
||||||
|
if(!rda->open(&err_msg)) {
|
||||||
|
fprintf(stderr,"upload_test: %s\n",(const char *)err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read Command Options
|
||||||
|
//
|
||||||
|
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||||
|
if(rda->cmdSwitch()->key(i)=="--username") {
|
||||||
|
username=rda->cmdSwitch()->value(i);
|
||||||
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(rda->cmdSwitch()->key(i)=="--password") {
|
||||||
|
password=rda->cmdSwitch()->value(i);
|
||||||
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(rda->cmdSwitch()->key(i)=="--source-file") {
|
||||||
|
source_filename=rda->cmdSwitch()->value(i);
|
||||||
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(rda->cmdSwitch()->key(i)=="--destination-url") {
|
||||||
|
destination_url=rda->cmdSwitch()->value(i);
|
||||||
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
|
}
|
||||||
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
|
fprintf(stderr,"rdrepld: unknown command option \"%s\"\n",
|
||||||
|
(const char *)rda->cmdSwitch()->key(i));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
//
|
//
|
||||||
@ -58,6 +100,11 @@ MainObject::MainObject(QObject *parent)
|
|||||||
cmd->setProcessed(i,true);
|
cmd->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Sanity Checks
|
||||||
|
//
|
||||||
if(source_filename.isEmpty()) {
|
if(source_filename.isEmpty()) {
|
||||||
fprintf(stderr,"upload_test: missing source-file\n");
|
fprintf(stderr,"upload_test: missing source-file\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
@ -66,7 +113,7 @@ MainObject::MainObject(QObject *parent)
|
|||||||
fprintf(stderr,"upload_test: missing destination-url\n");
|
fprintf(stderr,"upload_test: missing destination-url\n");
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//
|
//
|
||||||
// Read Configuration
|
// Read Configuration
|
||||||
//
|
//
|
||||||
@ -84,12 +131,16 @@ MainObject::MainObject(QObject *parent)
|
|||||||
delete cmd;
|
delete cmd;
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
RDUpload *conv=new RDUpload(rdconfig,this);
|
//
|
||||||
|
// Run the Test
|
||||||
|
//
|
||||||
|
RDUpload *conv=new RDUpload(this);
|
||||||
conv->setSourceFile(source_filename);
|
conv->setSourceFile(source_filename);
|
||||||
conv->setDestinationUrl(destination_url);
|
conv->setDestinationUrl(destination_url);
|
||||||
printf("Uploading...\n");
|
printf("Uploading...\n");
|
||||||
conv_err=conv->runUpload(username,password,rdconfig->logXloadDebugData());
|
conv_err=conv->
|
||||||
|
runUpload(username,password,rda->config()->logXloadDebugData());
|
||||||
printf("Result: %s\n",(const char *)RDUpload::errorText(conv_err));
|
printf("Result: %s\n",(const char *)RDUpload::errorText(conv_err));
|
||||||
delete conv;
|
delete conv;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Test Rivendell file uploading
|
// Test Rivendell file uploading
|
||||||
//
|
//
|
||||||
// (C) Copyright 2010,2016 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
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -24,19 +24,9 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qsqldatabase.h>
|
|
||||||
|
|
||||||
#include <rdconfig.h>
|
|
||||||
#include <rdcmd_switch.cpp>
|
|
||||||
|
|
||||||
#define UPLOAD_TEST_USAGE "[options]\n\nTest the Rivendell upload routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--source-file=<filename>\n\n--destination-url=<url>\n\n"
|
#define UPLOAD_TEST_USAGE "[options]\n\nTest the Rivendell upload routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--source-file=<filename>\n\n--destination-url=<url>\n\n"
|
||||||
|
|
||||||
//
|
|
||||||
// Global Variables
|
|
||||||
//
|
|
||||||
RDConfig *rdconfig;
|
|
||||||
|
|
||||||
|
|
||||||
class MainObject : public QObject
|
class MainObject : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user