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

@@ -24044,3 +24044,5 @@
2023-04-24 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in the 'List Feeds' dialog in rdadmin(1) that
threw a segfault when reposting a feed.
2023-04-25 Fred Gleason <fredg@paravelsystems.com>
* Added a 'RDFeed::generateReport()' method.

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());

View File

@@ -30,6 +30,7 @@
#include <rdrssschemas.h>
#include <rdsettings.h>
#include <rdstation.h>
#include <rdtempdirectory.h>
#include <rduser.h>
#include <rdweb.h>
@@ -153,6 +154,10 @@ class RDFeed : public QObject
static QString publicUrl(const QString &base_url,const QString &keyname);
static QString itunesCategoryXml(const QString &category,
const QString &sub_category,int padding=0);
static bool generateReport(const QString &feed_url,
const QString &stylesheet_pathname,
const QString &report_filename,
RDTempDirectory *tempdir,QString *err_msg);
signals:
void postProgressChanged(int step);

View File

@@ -247,17 +247,13 @@ void MainWidget::reportData()
QString url=cast_feed_model->
data(cast_feed_model->index(rows.at(0).row(),6)).toString();
cast_temp_directories.push_back(new RDTempDirectory("rdcastmanager-report"));
if(!cast_temp_directories.last()->create(&err_msg)) {
QMessageBox::warning(this,"RDCastManager - "+tr("Error"),
tr("Unable to create temporary directory.")+"\n"+
"["+err_msg+"]");
if(!RDFeed::generateReport(url,
"/usr/share/rivendell/rdcastmanager-report.xsl",
"report.html",cast_temp_directories.back(),
&err_msg)) {
QMessageBox::warning(this,"RDCastManager - "+tr("Error"),err_msg);
return;
}
QString tmpfile=cast_temp_directories.last()->path()+"/report.html";
QString cmd="curl -f -s "+url+" | xsltproc --encoding utf-8 /usr/share/rivendell/rdcastmanager-report.xsl - > "+tmpfile;
printf("CMD: %s\n",cmd.toUtf8().constData());
system(cmd.toUtf8());
RDWebBrowser("file://"+tmpfile);
}