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

* Implemented the 'Repost' button on the 'Rivendell Feed List'
	dialog in rdadmin(1).
	* Added an 'Unpost' button to the 'Rivendell Feed List' dialog
	in rdadmin(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2020-09-23 16:41:13 -04:00
parent 26bcbcb86b
commit c1fce3006e
24 changed files with 735 additions and 178 deletions

View File

@@ -796,6 +796,75 @@ bool RDFeed::deleteImage(int img_id,QString *err_msg)
}
bool RDFeed::postPodcast(unsigned cast_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_PODCAST),
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",cast_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;
}
QString RDFeed::audioUrl(unsigned cast_id)
{
RDPodcast *cast=new RDPodcast(feed_config,cast_id);
@@ -829,7 +898,7 @@ QString RDFeed::imageUrl(int img_id) const
}
bool RDFeed::postXml(QString *err_msg)
bool RDFeed::postXml()
{
long response_code;
CURL *curl=NULL;
@@ -900,19 +969,16 @@ bool RDFeed::postXml(QString *err_msg)
bool RDFeed::postXmlConditional(const QString &caption,QWidget *widget)
{
QString err_msg;
if(!postXml(&err_msg)) {
if(!postXml()) {
QMessageBox::warning(widget,caption+" - "+tr("Error"),
tr("XML data upload failed!")+"\n"+
"["+err_msg+"]");
tr("XML data upload failed!"));
return false;
}
return true;
}
bool RDFeed::removeRss(QString *err_msg)
bool RDFeed::removeRss()
{
long response_code;
CURL *curl=NULL;
@@ -1217,7 +1283,7 @@ unsigned RDFeed::postCut(const QString &cutname,Error *err)
//
// Upload to remote archive
//
PostPodcast(cast_id);
postPodcast(cast_id);
postProgressChanged(3);
//
@@ -1234,7 +1300,7 @@ unsigned RDFeed::postCut(const QString &cutname,Error *err)
//
// Update posted XML
//
postXml(&err_msg);
postXml();
emit postProgressChanged(5);
return cast_id;
@@ -1325,7 +1391,7 @@ unsigned RDFeed::postFile(const QString &srcfile,Error *err)
//
// Upload to remote archive
//
PostPodcast(cast_id);
postPodcast(cast_id);
postProgressChanged(4);
//
@@ -1346,7 +1412,7 @@ unsigned RDFeed::postFile(const QString &srcfile,Error *err)
//
// Update posted XML
//
postXml(&err_msg);
postXml();
emit postProgressChanged(6);
*err=RDFeed::ErrorOk;
@@ -1425,7 +1491,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
//
// Save to remote archive
//
PostPodcast(cast_id);
postPodcast(cast_id);
emit postProgressChanged(3+(end_line-start_line));
//
@@ -1442,7 +1508,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
cast->setAudioTime(log_event->length(start_line,1+end_line));
delete log;
postXml(&err_msg);
postXml();
*err=RDFeed::ErrorOk;
emit postProgressChanged(4+(end_line-start_line));
@@ -1824,75 +1890,6 @@ bool RDFeed::SavePodcast(unsigned cast_id,const QString &src_filename) const
}
bool RDFeed::PostPodcast(unsigned cast_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_PODCAST),
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",cast_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;
}
unsigned RDFeed::CreateCast(QString *filename,int bytes,int msecs) const
{
QString sql;

View File

@@ -133,11 +133,12 @@ class RDFeed : public QObject
int importImageFile(const QString &pathname,QString *err_msg,
QString desc="") const;
bool deleteImage(int img_id,QString *err_msg);
bool postPodcast(unsigned cast_id) const;
QString audioUrl(unsigned cast_id);
QString imageUrl(int img_id) const;
bool postXml(QString *err_msg);
bool postXml();
bool postXmlConditional(const QString &caption,QWidget *widget);
bool removeRss(QString *err_msg);
bool removeRss();
bool postImage(int img_id) const;
bool removeImage(int img_id) const;
void removeAllImages();
@@ -164,7 +165,6 @@ class RDFeed : public QObject
private:
bool SavePodcast(unsigned cast_id,const QString &src_filename) const;
bool PostPodcast(unsigned cast_id) const;
unsigned CreateCast(QString *filename,int bytes,int msecs) const;
QString ResolveChannelWildcards(const QString &tmplt,RDSqlQuery *chan_q,
const QDateTime &build_datetime);

View File

@@ -364,28 +364,14 @@ void RDPodcast::setStatus(RDPodcast::Status status)
bool RDPodcast::dropAudio(RDFeed *feed,QString *err_text,bool log_debug) const
{
if(!RemovePodcast(podcast_id)) {
if(!removePodcast()) {
return false;
}
return DeletePodcast(podcast_id);
}
QString RDPodcast::guid(const QString &url,const QString &filename,
unsigned feed_id,unsigned cast_id)
{
return url+"/"+filename+QString().sprintf("_%06u_%06u",feed_id,cast_id);
}
QString RDPodcast::guid(const QString &full_url,unsigned feed_id,
unsigned cast_id)
{
return full_url+QString().sprintf("_%06u_%06u",feed_id,cast_id);
}
bool RDPodcast::DeletePodcast(unsigned cast_id) const
bool RDPodcast::removePodcast() const
{
long response_code;
CURL *curl=NULL;
@@ -398,7 +384,7 @@ bool RDPodcast::DeletePodcast(unsigned cast_id) const
//
curl_formadd(&first,&last,CURLFORM_PTRNAME,"COMMAND",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_DELETE_PODCAST),
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_REMOVE_PODCAST),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"LOGIN_NAME",
CURLFORM_COPYCONTENTS,rda->user()->name().toUtf8().constData(),
@@ -408,7 +394,7 @@ bool RDPodcast::DeletePodcast(unsigned cast_id) const
rda->user()->password().toUtf8().constData(),CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"ID",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",cast_id),
(const char *)QString().sprintf("%u",podcast_id),
CURLFORM_END);
//
@@ -454,7 +440,21 @@ bool RDPodcast::DeletePodcast(unsigned cast_id) const
}
bool RDPodcast::RemovePodcast(unsigned cast_id) const
QString RDPodcast::guid(const QString &url,const QString &filename,
unsigned feed_id,unsigned cast_id)
{
return url+"/"+filename+QString().sprintf("_%06u_%06u",feed_id,cast_id);
}
QString RDPodcast::guid(const QString &full_url,unsigned feed_id,
unsigned cast_id)
{
return full_url+QString().sprintf("_%06u_%06u",feed_id,cast_id);
}
bool RDPodcast::DeletePodcast(unsigned cast_id) const
{
long response_code;
CURL *curl=NULL;
@@ -467,7 +467,7 @@ bool RDPodcast::RemovePodcast(unsigned cast_id) const
//
curl_formadd(&first,&last,CURLFORM_PTRNAME,"COMMAND",
CURLFORM_COPYCONTENTS,
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_REMOVE_PODCAST),
(const char *)QString().sprintf("%u",RDXPORT_COMMAND_DELETE_PODCAST),
CURLFORM_END);
curl_formadd(&first,&last,CURLFORM_PTRNAME,"LOGIN_NAME",
CURLFORM_COPYCONTENTS,rda->user()->name().toUtf8().constData(),

View File

@@ -75,6 +75,7 @@ class RDPodcast
RDPodcast::Status status() const;
void setStatus(RDPodcast::Status status);
bool dropAudio(RDFeed *feed,QString *err_text,bool log_debug) const;
bool removePodcast() const;
static QString guid(const QString &url,const QString &filename,
unsigned feed_id,unsigned cast_id);
static QString guid(const QString &full_url,
@@ -82,7 +83,6 @@ class RDPodcast
private:
bool DeletePodcast(unsigned cast_id) const;
bool RemovePodcast(unsigned cast_id) const;
void SetRow(const QString &param,int value) const;
void SetRow(const QString &param,const QString &value) const;
void SetRow(const QString &param,const QDateTime &datetime,const QString &value) const;