2020-09-22 Fred Gleason <fredg@paravelsystems.com>

* Added a 'PostImage' method to the Web API.
	* Added a 'RemoveImage' method to the Web API.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2020-09-23 13:11:11 -04:00
parent d534aacfd1
commit 9ae7f909cb
20 changed files with 539 additions and 211 deletions

View File

@ -20303,3 +20303,6 @@
* Modified the type of the 'FEED_IMAGES.DATA' database field
to 'longblob'.
* Incremented the database version to 336.
2020-09-22 Fred Gleason <fredg@paravelsystems.com>
* Added a 'PostImage' method to the Web API.
* Added a 'RemoveImage' method to the Web API.

View File

@ -2852,6 +2852,63 @@
</table>
</sect1>
<sect1>
<title>PostImage</title>
<subtitle>Upload a podcast image to the remote archive</subtitle>
<para>
Command Code: <code>RDXPORT_COMMAND_POST_IMAGE</code>
</para>
<para>
Required User Permissions: <code>Administer System</code>
</para>
<table xml:id="ex.post_image
" frame="all">
<title>PostRss Call Fields</title>
<tgroup cols="3" align="left" colsep="1" rowsep="1">
<colspec colname="FIELD NAME" />
<colspec colname="MEANING" />
<colspec colname="REMARKS" />
<thead>
<row>
<entry>
FIELD NAME
</entry>
<entry>
MEANING
</entry>
<entry>
REMARKS
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
COMMAND
</entry>
<entry>
44
</entry>
<entry>
Mandatory
</entry>
</row>
<row>
<entry>
ID
</entry>
<entry>
ID of image (integer)
</entry>
<entry>
Mandatory
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1>
<title>PostPodcast</title>
<subtitle>Upload podcast audio from the audio store to the remote archive</subtitle>
@ -3168,6 +3225,63 @@
</table>
</sect1>
<sect1>
<title>RemoveImage</title>
<subtitle>Remove a podcast image from the remote archive</subtitle>
<para>
Command Code: <code>RDXPORT_COMMAND_REMOVE_IMAGE</code>
</para>
<para>
Required User Permissions: <code>Administer System</code>
</para>
<table xml:id="ex.remove_image
" frame="all">
<title>PostRss Call Fields</title>
<tgroup cols="3" align="left" colsep="1" rowsep="1">
<colspec colname="FIELD NAME" />
<colspec colname="MEANING" />
<colspec colname="REMARKS" />
<thead>
<row>
<entry>
FIELD NAME
</entry>
<entry>
MEANING
</entry>
<entry>
REMARKS
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
COMMAND
</entry>
<entry>
45
</entry>
<entry>
Mandatory
</entry>
</row>
<row>
<entry>
ID
</entry>
<entry>
ID of image (integer)
</entry>
<entry>
Mandatory
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1>
<title>RemovePodcast</title>
<subtitle>Delete podcast audio from the remote archive</subtitle>

View File

@ -689,6 +689,12 @@ void RDFeed::setNormalizeLevel(int lvl) const
}
QByteArray RDFeed::imageData(int img_id) const
{
return RDGetSqlValue("FEED_IMAGES","ID",img_id,"DATA").toByteArray();
}
int RDFeed::importImageFile(const QString &pathname,QString *err_msg,
QString desc) const
{
@ -775,9 +781,7 @@ bool RDFeed::deleteImage(int img_id,QString *err_msg)
*err_msg="OK";
//
// FIXME: Delete from remote file store here...
//
removeImage(img_id);
sql=QString("delete from FEED_IMAGES where ")+
QString().sprintf("ID=%d",img_id);
@ -974,25 +978,144 @@ bool RDFeed::removeRss(QString *err_msg)
}
return true;
}
/*
RDDelete::ErrorCode conv_err;
RDDelete *conv=new RDDelete(rda->config());
if(!conv->urlIsSupported(feedUrl())) {
*err_msg="unsupported url scheme";
delete conv;
bool RDFeed::postImage(int img_id) const
{
long response_code;
CURL *curl=NULL;
CURLcode curl_err;
struct curl_httppost *first=NULL;
struct curl_httppost *last=NULL;
//
// Generate POST Data
//
curl_formadd(&first,&last,CURLFORM_PTRNAME,"COMMAND",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_POST_IMAGE),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"LOGIN_NAME",
CURLFORM_COPYCONTENTS,rda->user()->name().toUtf8().constData(),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"PASSWORD",
CURLFORM_COPYCONTENTS,
rda->user()->password().toUtf8().constData(),CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"ID",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",img_id),
CURLFORM_END);
//
// Set up the transfer
//
if((curl=curl_easy_init())==NULL) {
curl_formfree(first);
return false;
}
conv->setTargetUrl(feedUrl());
conv_err=conv->runDelete(purgeUsername(),purgePassword(),
rda->station()->sshIdentityFile(),
purgeUseIdFile(),
rda->config()->logXloadDebugData());
*err_msg=RDDelete::errorText(conv_err);
delete conv;
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)rda->config()->userAgent());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
curl_easy_setopt(curl,CURLOPT_URL,
rda->station()->webServiceUrl(rda->config()).toUtf8().constData());
return conv_err==RDDelete::ErrorOk;
*/
//
// Send it
//
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
curl_easy_cleanup(curl);
curl_formfree(first);
return false;
}
//
// Clean up
//
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response_code);
curl_easy_cleanup(curl);
curl_formfree(first);
//
// Process the results
//
if((response_code<200)||(response_code>299)) {
return false;
}
return true;
}
bool RDFeed::removeImage(int img_id) const
{
long response_code;
CURL *curl=NULL;
CURLcode curl_err;
struct curl_httppost *first=NULL;
struct curl_httppost *last=NULL;
//
// Generate POST Data
//
curl_formadd(&first,&last,CURLFORM_PTRNAME,"COMMAND",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_REMOVE_IMAGE),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"LOGIN_NAME",
CURLFORM_COPYCONTENTS,rda->user()->name().toUtf8().constData(),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"PASSWORD",
CURLFORM_COPYCONTENTS,
rda->user()->password().toUtf8().constData(),CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"ID",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",img_id),
CURLFORM_END);
//
// Set up the transfer
//
if((curl=curl_easy_init())==NULL) {
curl_formfree(first);
return false;
}
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)rda->config()->userAgent());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
curl_easy_setopt(curl,CURLOPT_URL,
rda->station()->webServiceUrl(rda->config()).toUtf8().constData());
//
// Send it
//
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
curl_easy_cleanup(curl);
curl_formfree(first);
return false;
}
//
// Clean up
//
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response_code);
curl_easy_cleanup(curl);
curl_formfree(first);
//
// Process the results
//
if((response_code<200)||(response_code>299)) {
return false;
}
return true;
}

View File

@ -129,6 +129,7 @@ class RDFeed : public QObject
void setUploadMimetype(const QString &str);
int normalizeLevel() const;
void setNormalizeLevel(int lvl) const;
QByteArray imageData(int img_id) const;
int importImageFile(const QString &pathname,QString *err_msg,
QString desc="") const;
bool deleteImage(int img_id,QString *err_msg);
@ -136,8 +137,9 @@ class RDFeed : public QObject
QString imageUrl(int img_id) const;
bool postXml(QString *err_msg);
bool postXmlConditional(const QString &caption,QWidget *widget);
//bool deleteXml(QString *err_msg);
bool removeRss(QString *err_msg);
bool postImage(int img_id) const;
bool removeImage(int img_id) const;
bool deleteImages(QString *err_msg);
unsigned postCut(const QString &cutname,Error *err);
unsigned postFile(const QString &srcfile,Error *err);

View File

@ -64,6 +64,8 @@
#define RDXPORT_COMMAND_REMOVE_PODCAST 41
#define RDXPORT_COMMAND_POST_RSS 42
#define RDXPORT_COMMAND_REMOVE_RSS 43
#define RDXPORT_COMMAND_POST_IMAGE 44
#define RDXPORT_COMMAND_REMOVE_IMAGE 45
#endif // RDXPORT_INTERFACE_H

View File

@ -58,12 +58,10 @@ ListImages::ListImages(RDImagePickerModel *model,QWidget *parent)
list_view_button=new QPushButton(tr("View"),this);
list_view_button->setFont(buttonFont());
// list_view_button->setDisabled(true);
connect(list_view_button,SIGNAL(clicked()),this,SLOT(viewData()));
list_delete_button=new QPushButton(tr("Delete"),this);
list_delete_button->setFont(buttonFont());
// list_delete_button->setDisabled(true);
connect(list_delete_button,SIGNAL(clicked()),this,SLOT(deleteData()));
list_close_button=new QPushButton(tr("Close"),this);
@ -123,18 +121,12 @@ void ListImages::addData()
// Upload the image
//
f0=filename.split(".",QString::SkipEmptyParts);
if(!UploadRemoteImage(filename,list_feed->purgeUrl()+"/"+
RDFeed::imageFilename(list_feed->id(),
img_id,f0.last()),
list_feed->purgeUsername(),
list_feed->purgePassword(),
rda->station()->sshIdentityFile(),
list_feed->purgeUseIdFile(),
&err_msg)){
if(!list_feed->postImage(img_id)) {
QMessageBox::warning(this,"RDAdmin - "+tr("Upload Error"),
tr("Image upload failed!")+"\n"+
"["+err_msg+"].");
list_feed->deleteImage(img_id,&err_msg);
return;
}
//
@ -188,26 +180,6 @@ void ListImages::deleteData()
QMessageBox::Yes) {
return;
}
if(!DeleteRemoteImage(list_feed->purgeUrl()+"/"+
RDFeed::imageFilename(list_feed->id(),
list_model->imageId(row),
q->value(0).toString()),
list_feed->purgeUsername(),
list_feed->purgePassword(),
rda->station()->sshIdentityFile(),
list_feed->purgeUseIdFile(),&err_msg)) {
if(QMessageBox::information(this,"RDAdmin - "+tr("Delete Error"),
tr("Unable to delete remote file!")+"\n"+
"["+err_msg+"].\n"+
"\n"+
tr("Delete local data?"),
QMessageBox::Yes,QMessageBox::No)!=
QMessageBox::Yes) {
return;
}
}
if(list_feed->deleteImage(list_model->imageId(row),&err_msg)) {
list_model->refresh();
}
@ -276,42 +248,3 @@ int ListImages::SelectedRow() const
return -1;
}
bool ListImages::UploadRemoteImage(const QString &filename,const QString &url,
const QString &username,
const QString &password,
const QString &id_filename,bool use_id_file,
QString *err_msg)
{
RDUpload::ErrorCode err_code;
RDUpload *upload=new RDUpload(rda->config(),this);
upload->setSourceFile(filename);
upload->setDestinationUrl(url);
QProgressDialog *pd=new QProgressDialog(tr("Uploading image..."),"",
0,upload->totalSteps(),this);
pd->setWindowTitle("RDAdmin");
connect(upload,SIGNAL(progressChanged(int)),pd,SLOT(setValue(int)));
err_code=upload->runUpload(username,password,id_filename,use_id_file,false);
delete pd;
delete upload;
return err_code==RDUpload::ErrorOk;
}
bool ListImages::DeleteRemoteImage(const QString &url,const QString &username,
const QString &password,
const QString &id_filename,bool use_id_file,
QString *err_msg)
{
RDDelete::ErrorCode err_code;
RDDelete *del=new RDDelete(rda->config(),this);
del->setTargetUrl(url);
err_code=del->runDelete(username,password,id_filename,use_id_file,false);
*err_msg=RDDelete::errorText(err_code);
delete del;
return err_code==RDDelete::ErrorOk;
}

View File

@ -56,13 +56,6 @@ class ListImages : public RDDialog
private:
int SelectedRow() const;
bool UploadRemoteImage(const QString &filename,const QString &url,
const QString &username,const QString &password,
const QString &id_filename,bool use_id_file,
QString *err_msg);
bool DeleteRemoteImage(const QString &url,const QString &username,
const QString &password,const QString &id_filename,
bool use_id_file,QString *err_msg);
EditImage *list_edit_image_dialog;
QListView *list_view;
RDImagePickerModel *list_model;

View File

@ -5466,22 +5466,6 @@ Stále ještě jej chcete smazat?</translation>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -5232,22 +5232,6 @@ Generieren</translation>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -5429,22 +5429,6 @@ Do you still want to delete it?</source>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -4377,22 +4377,6 @@ Permissions</source>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -5101,22 +5101,6 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -5101,22 +5101,6 @@ Klikk på &quot;Lisens&quot;-knappen for fleire opplysningar.</translation>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -5216,22 +5216,6 @@ Você ainda quer Deletar?</translation>
<source>Image upload failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to delete remote file!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Delete local data?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Uploading image...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ListLiveWireGpios</name>

View File

@ -392,7 +392,7 @@ void Xport::PostRss()
xport_curl_data_ptr=0;
//
// Authentication
// Authentication Parameters
//
if((QUrl(feed->feedUrl()).scheme().toLower()=="sftp")&&
(!rda->station()->sshIdentityFile().isEmpty())&&feed->purgeUseIdFile()) {
@ -410,6 +410,9 @@ void Xport::PostRss()
feed->purgePassword().toUtf8().constData());
}
//
// Transfer Parameters
//
curl_easy_setopt(curl,CURLOPT_URL,feed->feedUrl().toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_UPLOAD,1);
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_Readfunction_Callback);
@ -421,9 +424,9 @@ void Xport::PostRss()
(const char *)rda->config()->userAgent().utf8());
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errstr);
//curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
//curl_easy_setopt(curl,CURLOPT_DEBUGFUNCTION,UploadErrorCallback);
//
// Execute it
//
switch((curl_err=curl_easy_perform(curl))) {
case CURLE_OK:
case CURLE_PARTIAL_FILE:
@ -519,3 +522,188 @@ void Xport::RemoveRss()
Exit(0);
}
void Xport::PostImage()
{
int img_id=0;
QString keyname;
QString desturl;
QString err_msg;
unsigned feed_id=0;
RDFeed *feed=NULL;
QString file_ext;
bool ret=false;
QString sql;
RDSqlQuery *q=NULL;
CURL *curl=NULL;
CURLcode curl_err;
char errstr[CURL_ERROR_SIZE];
QDateTime now=QDateTime::currentDateTime();
if(!xport_post->getValue("ID",&img_id)) {
XmlExit("Missing ID",400,"podcasts.cpp",LINE_NUMBER);
}
sql=QString("select ")+
"FEED_ID,"+ // 00
"DATA,"+ // 01
"FILE_EXTENSION "+ // 02
"from FEED_IMAGES where "+
QString().sprintf("ID=%d",img_id);
q=new RDSqlQuery(sql);
if(q->first()) {
feed_id=q->value(0).toUInt();
xport_curl_data=q->value(1).toByteArray();
xport_curl_data_ptr=0;
file_ext=q->value(2).toString();
}
delete q;
if(feed_id==0) {
XmlExit("invalid image ID",400,"podcasts.cpp",LINE_NUMBER);
}
feed=new RDFeed(feed_id,rda->config(),this);
if(!feed->exists()) {
XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER);
}
keyname=feed->keyName();
if(!rda->user()->adminConfig()) {
delete feed;
XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER);
}
desturl=feed->purgeUrl()+"/"+RDFeed::imageFilename(feed_id,img_id,file_ext);
if((curl=curl_easy_init())==NULL) {
XmlExit("unable to get CURL handle",500,"podcasts.cpp",LINE_NUMBER);
}
//
// Authentication Parameters
//
if((QUrl(feed->feedUrl()).scheme().toLower()=="sftp")&&
(!rda->station()->sshIdentityFile().isEmpty())&&feed->purgeUseIdFile()) {
curl_easy_setopt(curl,CURLOPT_USERNAME,
feed->purgeUsername().toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_SSH_PRIVATE_KEYFILE,
rda->station()->sshIdentityFile().toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_KEYPASSWD,
feed->purgePassword().toUtf8().constData());
}
else {
curl_easy_setopt(curl,CURLOPT_USERNAME,
feed->purgeUsername().toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_PASSWORD,
feed->purgePassword().toUtf8().constData());
}
//
// Transfer Parameters
//
curl_easy_setopt(curl,CURLOPT_URL,desturl.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_UPLOAD,1);
curl_easy_setopt(curl,CURLOPT_READFUNCTION, __PostRss_Readfunction_Callback);
curl_easy_setopt(curl,CURLOPT_READDATA,this);
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_NOPROGRESS,1);
curl_easy_setopt(curl,CURLOPT_USERAGENT,
(const char *)rda->config()->userAgent().utf8());
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errstr);
//
// Execute it
//
switch((curl_err=curl_easy_perform(curl))) {
case CURLE_OK:
case CURLE_PARTIAL_FILE:
feed->setLastBuildDateTime(now);
ret=true;
break;
default:
err_msg=errstr;
ret=false;
break;
}
curl_easy_cleanup(curl);
if(!ret) {
XmlExit(err_msg,500,"podcasts.cpp",LINE_NUMBER);
}
printf("Content-type: text/html; charset: UTF-8\n");
printf("Status: 200\n\n");
printf("OK\n");
rda->syslog(LOG_DEBUG,
"posted image \"%s\"",desturl.toUtf8().constData());
Exit(0);
}
void Xport::RemoveImage()
{
int img_id=0;
QString keyname;
unsigned feed_id=0;
RDFeed *feed=NULL;
QString desturl;
QString file_ext;
QString sql;
RDSqlQuery *q=NULL;
QDateTime now=QDateTime::currentDateTime();
RDDelete::ErrorCode del_err;
if(!xport_post->getValue("ID",&img_id)) {
XmlExit("Missing ID",400,"podcasts.cpp",LINE_NUMBER);
}
sql=QString("select ")+
"FEED_ID,"+ // 00
"FILE_EXTENSION "+ // 01
"from FEED_IMAGES where "+
QString().sprintf("ID=%d",img_id);
q=new RDSqlQuery(sql);
if(q->first()) {
feed_id=q->value(0).toUInt();
file_ext=q->value(1).toString();
}
delete q;
if(feed_id==0) {
XmlExit("invalid image ID",400,"podcasts.cpp",LINE_NUMBER);
}
feed=new RDFeed(feed_id,rda->config(),this);
if(!feed->exists()) {
XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER);
}
keyname=feed->keyName();
if(!rda->user()->adminConfig()) {
delete feed;
XmlExit("No such podcast",404,"podcasts.cpp",LINE_NUMBER);
}
feed=new RDFeed(keyname,rda->config(),this);
desturl=feed->purgeUrl()+"/"+RDFeed::imageFilename(feed_id,img_id,file_ext);
RDDelete *del=new RDDelete(rda->config(),this);
del->setTargetUrl(desturl);
if((del_err=del->
runDelete(feed->purgeUsername(),feed->purgePassword(),
rda->station()->sshIdentityFile(),feed->purgeUseIdFile(),
rda->config()->logXloadDebugData()))!=RDDelete::ErrorOk) {
delete del;
delete feed;
XmlExit(QString("Deletion of image \"")+desturl+"\" failed ["+
RDDelete::errorText(del_err)+"]",500,"podcasts.cpp",LINE_NUMBER);
}
delete del;
printf("Content-type: text/html; charset: UTF-8\n");
printf("Status: 200\n\n");
printf("OK\n");
rda->syslog(LOG_DEBUG,
"deleted image \"%s\"",desturl.toUtf8().constData());
delete feed;
Exit(0);
}

View File

@ -324,6 +324,14 @@ void Xport::ripcConnectedData(bool state)
RemoveRss();
break;
case RDXPORT_COMMAND_POST_IMAGE:
PostImage();
break;
case RDXPORT_COMMAND_REMOVE_IMAGE:
RemoveImage();
break;
default:
printf("Content-type: text/html\n\n");
printf("rdxport: missing/invalid command\n");

View File

@ -89,6 +89,8 @@ class Xport : public QObject
void RemovePodcast();
void PostRss();
void RemoveRss();
void PostImage();
void RemoveImage();
void LockLog();
QString LogLockXml(bool result,const QString &log_name,const QString &guid,
const QString &username,const QString &stationname,

View File

@ -53,11 +53,13 @@ install-exec-am:
cp listservices.html $(DESTDIR)@libexecdir@
cp listsystemsettings.html $(DESTDIR)@libexecdir@
cp locklog.html $(DESTDIR)@libexecdir@
cp postimage.html $(DESTDIR)@libexecdir@
cp postpodcast.html $(DESTDIR)@libexecdir@
cp postrss.html $(DESTDIR)@libexecdir@
cp rehash.html $(DESTDIR)@libexecdir@
cp removecart.html $(DESTDIR)@libexecdir@
cp removecut.html $(DESTDIR)@libexecdir@
cp removeimage.html $(DESTDIR)@libexecdir@
cp removepodcast.html $(DESTDIR)@libexecdir@
cp removerss.html $(DESTDIR)@libexecdir@
cp savefile.html $(DESTDIR)@libexecdir@
@ -101,11 +103,13 @@ uninstall-local:
rm -f $(DESTDIR)@libexecdir@/listservices.html
rm -f $(DESTDIR)@libexecdir@/listsystemsettings.html
rm -f $(DESTDIR)@libexecdir@/locklog.html
rm -f $(DESTDIR)@libexecdir@/postimage.html
rm -f $(DESTDIR)@libexecdir@/postpodcast.html
rm -f $(DESTDIR)@libexecdir@/postrss.html
rm -f $(DESTDIR)@libexecdir@/rehash.html
rm -f $(DESTDIR)@libexecdir@/removecart.html
rm -f $(DESTDIR)@libexecdir@/removecut.html
rm -f $(DESTDIR)@libexecdir@/removeimage.html
rm -f $(DESTDIR)@libexecdir@/removepodcast.html
rm -f $(DESTDIR)@libexecdir@/removepodrss.html
rm -f $(DESTDIR)@libexecdir@/savefile.html
@ -148,11 +152,13 @@ EXTRA_DIST = addcart.html\
listservices.html\
listsystemsettings.html\
locklog.html\
postimage.html\
postpodcast.html\
postrss.html\
rehash.html\
removecart.html\
removecut.html\
removeimage.html\
removepodcast.html\
removerss.html\
savefile.html\

33
web/tests/postimage.html Normal file
View File

@ -0,0 +1,33 @@
<html>
<head>
<title>Rivendell POSTIMAGE Service Test Harness</title>
<body>
<form action="/rd-bin/rdxport.cgi" method="post" enctype="multipart/form-data">
<input type="hidden" name="COMMAND" value="44">
<table cellpadding="0" cellspacing="2" border="0">
<tr>
<td align="right">LOGIN NAME:</td>
<td><input type="text" name="LOGIN_NAME" size="20" maxlength="255"></td>
</tr>
<tr>
<td align="right">PASSWORD:</td>
<td><input type="password" name="PASSWORD" size="20" maxlength="32"></td>
</tr>
<tr>
<td align="right">TICKET:</td>
<td><input type="text" name="TICKET" size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right">ID:</td>
<td><input type="text" name="ID" size="12" maxlength="12"></td>
</tr>
<tr>
<td colspan="2" align="right">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>

View File

@ -0,0 +1,33 @@
<html>
<head>
<title>Rivendell REMOVEIMAGE Service Test Harness</title>
<body>
<form action="/rd-bin/rdxport.cgi" method="post" enctype="multipart/form-data">
<input type="hidden" name="COMMAND" value="45">
<table cellpadding="0" cellspacing="2" border="0">
<tr>
<td align="right">LOGIN NAME:</td>
<td><input type="text" name="LOGIN_NAME" size="20" maxlength="255"></td>
</tr>
<tr>
<td align="right">PASSWORD:</td>
<td><input type="password" name="PASSWORD" size="20" maxlength="32"></td>
</tr>
<tr>
<td align="right">TICKET:</td>
<td><input type="text" name="TICKET" size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right">ID:</td>
<td><input type="text" name="ID" size="12" maxlength="12"></td>
</tr>
<tr>
<td colspan="2" align="right">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="OK"></td>
</tr>
</table>
</form>
</body>
</html>