2023-01-24 Fred Gleason <fredg@paravelsystems.com>

* Added more detail to data transfer errors generated by the
	podcasting subsystem.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2023-01-24 15:41:25 -05:00
parent f70e871508
commit 100e5dc025
6 changed files with 34 additions and 16 deletions

View File

@ -23945,3 +23945,6 @@
of similarly-named windows when enforcing single instances. of similarly-named windows when enforcing single instances.
2023-01-20 Fred Gleason <fredg@paravelsystems.com> 2023-01-20 Fred Gleason <fredg@paravelsystems.com>
* Added a splash screen to rdairplay(1). * Added a splash screen to rdairplay(1).
2023-01-24 Fred Gleason <fredg@paravelsystems.com>
* Added more detail to data transfer errors generated by the
podcasting subsystem.

View File

@ -955,11 +955,12 @@ QString RDFeed::imageUrl(int img_id) const
} }
bool RDFeed::postXml() bool RDFeed::postXml(QString *err_msg)
{ {
long response_code; long response_code;
CURL *curl=NULL; CURL *curl=NULL;
CURLcode curl_err; CURLcode curl_err;
char curl_errorbuffer[CURL_ERROR_SIZE];
struct curl_httppost *first=NULL; struct curl_httppost *first=NULL;
struct curl_httppost *last=NULL; struct curl_httppost *last=NULL;
@ -992,6 +993,7 @@ bool RDFeed::postXml()
QStringList *err_msgs=SetupCurlLogging(curl); QStringList *err_msgs=SetupCurlLogging(curl);
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout); curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first); curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,curl_errorbuffer);
curl_easy_setopt(curl,CURLOPT_USERAGENT, curl_easy_setopt(curl,CURLOPT_USERAGENT,
rda->config()->userAgent().toUtf8().constData()); rda->config()->userAgent().toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT); curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
@ -1005,6 +1007,7 @@ bool RDFeed::postXml()
// Send it // Send it
// //
if((curl_err=curl_easy_perform(curl))!=CURLE_OK) { if((curl_err=curl_easy_perform(curl))!=CURLE_OK) {
*err_msg=QString::fromUtf8(curl_errorbuffer);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_formfree(first); curl_formfree(first);
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs); ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
@ -1022,6 +1025,8 @@ bool RDFeed::postXml()
// Process the results // Process the results
// //
if((response_code<200)||(response_code>299)) { if((response_code<200)||(response_code>299)) {
*err_msg=tr("remote server returned unexpected response code")+
QString::asprintf(" %ld",response_code);
ProcessCurlLogging("RDFeed::postPodcast()",err_msgs); ProcessCurlLogging("RDFeed::postPodcast()",err_msgs);
return false; return false;
} }
@ -1033,9 +1038,11 @@ bool RDFeed::postXml()
bool RDFeed::postXmlConditional(const QString &caption,QWidget *widget) bool RDFeed::postXmlConditional(const QString &caption,QWidget *widget)
{ {
if(!postXml()) { QString err_msg;
if(!postXml(&err_msg)) {
QMessageBox::warning(widget,caption+" - "+tr("Error"), QMessageBox::warning(widget,caption+" - "+tr("Error"),
tr("XML data upload failed!")); tr("XML data upload failed!")+"\n["+err_msg+"]");
return false; return false;
} }
return true; return true;
@ -1393,7 +1400,7 @@ unsigned RDFeed::postCut(const QString &cutname,QString *err_msg)
// //
// Update posted XML // Update posted XML
// //
postXml(); postXml(err_msg);
emit postProgressChanged(5); emit postProgressChanged(5);
*err_msg=tr("OK"); *err_msg=tr("OK");
@ -1509,9 +1516,8 @@ unsigned RDFeed::postFile(const QString &srcfile,QString *err_msg)
// //
// Update posted XML // Update posted XML
// //
postXml(); postXml(err_msg);
emit postProgressChanged(6); emit postProgressChanged(6);
// *err=RDFeed::ErrorOk;
return cast_id; return cast_id;
} }
@ -1611,7 +1617,7 @@ unsigned RDFeed::postLog(const QString &logname,const QTime &start_time,
cast->setAudioTime(log_model->length(start_line,1+end_line)); cast->setAudioTime(log_model->length(start_line,1+end_line));
delete log; delete log;
postXml(); postXml(err_msg);
emit postProgressChanged(4+(end_line-start_line)); emit postProgressChanged(4+(end_line-start_line));
delete cast; delete cast;

View File

@ -135,7 +135,7 @@ class RDFeed : public QObject
bool postPodcast(unsigned cast_id,QString *err_msg); bool postPodcast(unsigned cast_id,QString *err_msg);
QString audioUrl(unsigned cast_id); QString audioUrl(unsigned cast_id);
QString imageUrl(int img_id) const; QString imageUrl(int img_id) const;
bool postXml(); bool postXml(QString *err_msg);
bool postXmlConditional(const QString &caption,QWidget *widget); bool postXmlConditional(const QString &caption,QWidget *widget);
bool removeRss(); bool removeRss();
bool postImage(int img_id) const; bool postImage(int img_id) const;

View File

@ -343,7 +343,7 @@ void ListFeeds::repostData()
while(q->next()) { while(q->next()) {
if(!feed->postPodcast(q->value(0).toUInt(),&err_msg)) { if(!feed->postPodcast(q->value(0).toUInt(),&err_msg)) {
QMessageBox::warning(this,"RDAdmin - "+tr("Error"), QMessageBox::warning(this,"RDAdmin - "+tr("Error"),
tr("Error posting to feed")+" \""+ tr("Error posting audio to feed")+" \""+
q->value(1).toString()+"\"\n"+ q->value(1).toString()+"\"\n"+
"["+err_msg+"]."); "["+err_msg+"].");
} }
@ -357,7 +357,12 @@ void ListFeeds::repostData()
pd->setLabelText(tr("Posting RSS XML data...")); pd->setLabelText(tr("Posting RSS XML data..."));
pd->setRange(0,1); pd->setRange(0,1);
pd->setValue(0); pd->setValue(0);
feed->postXml(); if(!feed->postXml(&err_msg)) {
QMessageBox::warning(this,"RDAdmin - "+tr("Error"),
tr("Error posting updated XML to feed")+" \""+
q->value(1).toString()+"\"\n"+
"["+err_msg+"].");
}
pd->setValue(1); pd->setValue(1);
delete pd; delete pd;

View File

@ -314,6 +314,7 @@ void ListCasts::deleteData()
{ {
QString sql; QString sql;
QString err_text; QString err_text;
QString err_msg;
QModelIndexList rows=list_casts_view->selectionModel()->selectedRows(); QModelIndexList rows=list_casts_view->selectionModel()->selectedRows();
if(rows.size()!=1) { if(rows.size()!=1) {
@ -361,9 +362,10 @@ void ListCasts::deleteData()
QString::asprintf("`ID`=%u",list_feed_id); QString::asprintf("`ID`=%u",list_feed_id);
RDSqlQuery::apply(sql); RDSqlQuery::apply(sql);
if(!list_feed->postXml()) { if(!list_feed->postXml(&err_msg)) {
QMessageBox::warning(this,"RDCastManager - "+tr("Remote Error"), QMessageBox::warning(this,"RDCastManager - "+tr("Remote Error"),
tr("Unable to update remote XML data!")); tr("Unable to update remote XML data!")+"\n"+
"["+err_msg+"]");
} }
pd->reset(); pd->reset();

View File

@ -172,7 +172,7 @@ void MainObject::ProcessFeed(const QString &key_name)
q->value(0).toUInt()); q->value(0).toUInt());
deleted=true; deleted=true;
} }
if(feed->postXml()) { if(feed->postXml(&err_msg)) {
rda->syslog(LOG_DEBUG, rda->syslog(LOG_DEBUG,
"repost of XML for feed \"%s\" triggered by cast id %u", "repost of XML for feed \"%s\" triggered by cast id %u",
key_name.toUtf8().constData(),q->value(0).toUInt()); key_name.toUtf8().constData(),q->value(0).toUInt());
@ -186,9 +186,11 @@ void MainObject::ProcessFeed(const QString &key_name)
} }
} }
else { else {
rda->syslog(LOG_WARNING, rda->
"repost of XML for feed \"%s\" triggered by cast id %u failed", syslog(LOG_WARNING,
key_name.toUtf8().constData(),q->value(0).toUInt()); "repost of XML for feed \"%s\" triggered by cast id %u failed [%s]",
key_name.toUtf8().constData(),q->value(0).toUInt(),
err_msg.toUtf8().constData());
} }
} }
delete q; delete q;