2023-04-25 Fred Gleason <fredg@paravelsystems.com>

* Added a 'RDFeed::generateReport()' method.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-04-25 15:25:39 -04:00
parent f84ad0cc54
commit 23b011cc93
4 changed files with 46 additions and 10 deletions

View File

@@ -38,7 +38,7 @@
#include "rdlog.h"
#include "rdpodcast.h"
#include "rdrenderer.h"
#include "rdtempdirectory.h"
#include "rdtextfile.h"
#include "rdupload.h"
#include "rdwavefile.h"
#include "rdwebresult.h"
@@ -1873,6 +1873,39 @@ QString RDFeed::itunesCategoryXml(const QString &category,
}
bool RDFeed::generateReport(const QString &feed_url,
const QString &stylesheet_pathname,
const QString &report_filename,
RDTempDirectory *tempdir,
QString *err_msg)
{
QString err_msg2;
int result;
bool ret=false;
ret=tempdir->create(&err_msg2);
if(ret) {
*err_msg=QObject::tr("Unable to create temporary directory.")+
"["+err_msg2+"]";
QString tmpfile=tempdir->path()+"/"+report_filename;
QString cmd="curl -f -s "+feed_url+" | xsltproc --encoding utf-8 "+
stylesheet_pathname+" - > "+tmpfile;
result=system(cmd.toUtf8());
if(result==-1) {
*err_msg=tr("unable to fork process")+" ["+strerror(errno)+"].";
return false;
}
if(WEXITSTATUS(result)!=0) {
*err_msg=tr("converter returned non-zero exit code.");
return false;
}
RDWebBrowser("file://"+tmpfile);
}
return ret;
}
void RDFeed::renderMessage(const QString &msg)
{
fprintf(stderr,"RENDERER: %s\n",msg.toUtf8().constData());