From 75883359b91feaeabdf7ad4f03a8de05407dab21 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 2 Oct 2017 08:31:09 -0400 Subject: [PATCH] 2017-10-02 Fred Gleason * Added an '%s' datetime wildcard for Service Name. --- ChangeLog | 2 ++ conf/rd.conf-sample | 3 ++- docs/datetime_wildcards.txt | 2 +- lib/rddatedecode.cpp | 17 +++++++++++++++-- lib/rddatedecode.h | 5 +++-- rdlogmanager/commandline_ops.cpp | 8 +++++--- rdlogmanager/generate_log.cpp | 20 +++++++++++++------- rdlogmanager/pick_report_dates.cpp | 4 ++-- 8 files changed, 43 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26f4f8a0..27a6778d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16035,3 +16035,5 @@ * Added static 'RDSvc::create()' and 'RDSvc::remove()' methods. * Implemented 'CreateService=' and 'NewServiceTemplate=' parameters in the [Provisioning] section of rd.conf(5). +2017-10-02 Fred Gleason + * Added an '%s' datetime wildcard for Service Name. diff --git a/conf/rd.conf-sample b/conf/rd.conf-sample index db431989..9d007fd3 100644 --- a/conf/rd.conf-sample +++ b/conf/rd.conf-sample @@ -42,7 +42,8 @@ NewHostTemplate=some_host_entry ; If CreateService=Yes, a Service entry will be automatically created in the DB ; when the 'rivendell' system service is started, using the Service definition -; specified in NewServiceTemplate= as the template. +; specified in NewServiceTemplate= as the template. The new service entry will +; have the same name as the hostname. CreateService=No NewServiceTemplate=some_service_entry diff --git a/docs/datetime_wildcards.txt b/docs/datetime_wildcards.txt index 4a2b8a0a..055d5899 100644 --- a/docs/datetime_wildcards.txt +++ b/docs/datetime_wildcards.txt @@ -87,7 +87,7 @@ where: R -- [unassigned] - s -- [unassigned] + s -- Service Name S -- Seconds, zero padded (00 - 60) diff --git a/lib/rddatedecode.cpp b/lib/rddatedecode.cpp index 6fce5ccf..e200f76e 100644 --- a/lib/rddatedecode.cpp +++ b/lib/rddatedecode.cpp @@ -22,7 +22,7 @@ #include -QString RDDateDecode(QString str,QDate date) +QString RDDateDecode(QString str,const QDate &date,const QString &svcname) { QString string; int yearnum; @@ -117,6 +117,12 @@ QString RDDateDecode(QString str,QDate date) field=QString().sprintf("%02d",date.month()); break; + case 's': // Service name + if(!svcname.isEmpty()) { + field=svcname; + } + break; + case 'u': // Day of week (numeric, 1..7, 1=Monday) field=QString().sprintf("%d",date.dayOfWeek()); break; @@ -164,7 +170,8 @@ QString RDDateDecode(QString str,QDate date) } -QString RDDateTimeDecode(QString str,QDateTime datetime) +QString RDDateTimeDecode(QString str,const QDateTime &datetime, + const QString &svcname) { QString string; int yearnum; @@ -291,6 +298,12 @@ QString RDDateTimeDecode(QString str,QDateTime datetime) field=QString().sprintf("%02d",datetime.time().second()); break; + case 's': // Service name + if(!svcname.isEmpty()) { + field=svcname; + } + break; + case 'u': // Day of week (numeric, 1..7, 1=Monday) field=QString().sprintf("%d",datetime.date().dayOfWeek()); break; diff --git a/lib/rddatedecode.h b/lib/rddatedecode.h index 48fb9fe8..d0ae5f74 100644 --- a/lib/rddatedecode.h +++ b/lib/rddatedecode.h @@ -23,8 +23,9 @@ #include -QString RDDateDecode(QString str,QDate date); -QString RDDateTimeDecode(QString str,QDateTime datetime); +QString RDDateDecode(QString str,const QDate &date,const QString &svcname=""); +QString RDDateTimeDecode(QString str,const QDateTime &datetime, + const QString &svcname=""); #endif // RDDATEDECODE diff --git a/rdlogmanager/commandline_ops.cpp b/rdlogmanager/commandline_ops.cpp index 9d162919..b1d4547b 100644 --- a/rdlogmanager/commandline_ops.cpp +++ b/rdlogmanager/commandline_ops.cpp @@ -83,7 +83,7 @@ int RunLogOperation(int argc,char *argv[],const QString &svcname, return 256; } QDate start_date=QDate::currentDate().addDays(1+start_offset); - QString logname=RDDateDecode(svc->nameTemplate(),start_date); + QString logname=RDDateDecode(svc->nameTemplate(),start_date,svc->name()); RDLog *log=new RDLog(logname); // @@ -106,8 +106,10 @@ int RunLogOperation(int argc,char *argv[],const QString &svcname, } delete q; if(!svc->generateLog(start_date, - RDDateDecode(svc->nameTemplate(),start_date), - RDDateDecode(svc->nameTemplate(),start_date.addDays(1)), + RDDateDecode(svc->nameTemplate(),start_date, + svc->name()), + RDDateDecode(svc->nameTemplate(),start_date.addDays(1), + svc->name()), &unused_report)) { fprintf(stderr,"rdlogmanager: unable to generate log\n"); return 256; diff --git a/rdlogmanager/generate_log.cpp b/rdlogmanager/generate_log.cpp index 5b4c6681..776867eb 100644 --- a/rdlogmanager/generate_log.cpp +++ b/rdlogmanager/generate_log.cpp @@ -307,7 +307,8 @@ void GenerateLog::createData() // Generate Log // RDSvc *svc=new RDSvc(gen_service_box->currentText(),this); - QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date()); + QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()); RDLog *log=new RDLog(logname); if(log->exists()) { str1=QString(tr("The log for")); @@ -361,9 +362,10 @@ void GenerateLog::createData() connect(svc,SIGNAL(generationProgress(int)), gen_progress_dialog,SLOT(setProgress(int))); svc->generateLog(gen_date_edit->date(), - RDDateDecode(svc->nameTemplate(),gen_date_edit->date()), + RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()), RDDateDecode(svc->nameTemplate(),gen_date_edit->date(). - addDays(1)),&unused_report); + addDays(1),svc->name()),&unused_report); log->updateTracks(); delete log; delete svc; @@ -392,7 +394,8 @@ void GenerateLog::musicData() unsigned tracks=0; RDSvc *svc=new RDSvc(gen_service_box->currentText(),this); - QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date()); + QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()); RDLog *log=new RDLog(logname); if(((log->linkState(RDLog::SourceMusic)==RDLog::LinkDone)|| (log->linkState(RDLog::SourceTraffic)==RDLog::LinkDone))) { @@ -443,7 +446,8 @@ void GenerateLog::musicData() void GenerateLog::trafficData() { RDSvc *svc=new RDSvc(gen_service_box->currentText(),this); - QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date()); + QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()); RDLog *log=new RDLog(logname); if((log->linkState(RDLog::SourceTraffic)==RDLog::LinkDone)) { QString str1=QString(tr("The log for")); @@ -477,7 +481,8 @@ void GenerateLog::trafficData() void GenerateLog::fileScanData() { RDSvc *svc=new RDSvc(gen_service_box->currentText(),this); - QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date()); + QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()); RDLog *log=new RDLog(logname); if(gen_music_enabled) { if(QFile::exists(svc-> @@ -545,7 +550,8 @@ void GenerateLog::resizeEvent(QResizeEvent *e) void GenerateLog::UpdateControls() { RDSvc *svc=new RDSvc(gen_service_box->currentText(),this); - QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date()); + QString logname=RDDateDecode(svc->nameTemplate(),gen_date_edit->date(), + svc->name()); RDLog *log=new RDLog(logname); if(log->exists()) { if(log->linkQuantity(RDLog::SourceMusic)>0) { diff --git a/rdlogmanager/pick_report_dates.cpp b/rdlogmanager/pick_report_dates.cpp index 7094fa82..ebf9bf6f 100644 --- a/rdlogmanager/pick_report_dates.cpp +++ b/rdlogmanager/pick_report_dates.cpp @@ -195,10 +195,10 @@ void PickReportDates::generateData() } #ifdef WIN32 QString filename=RDDateDecode(report->exportPath(RDReport::Windows), - edit_startdate_edit->date()); + edit_startdate_edit->date(),edit_svcname); #else QString filename=RDDateDecode(report->exportPath(RDReport::Linux), - edit_startdate_edit->date()); + edit_startdate_edit->date(),edit_svcname); #endif QFile file(filename); if(file.exists()) {