diff --git a/.gitignore b/.gitignore index 32b2f469..ca8a67c7 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ tests/audio_export_test tests/audio_import_test tests/audio_peaks_test tests/datedecode_test +tests/log_unlink_test tests/rdxml_parse_test tests/reserve_carts_test tests/sas_switch_torture diff --git a/ChangeLog b/ChangeLog index 1398b041..3f0a4a0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16087,3 +16087,7 @@ 2017-10-11 Fred Gleason * Updated the 'NEWS' file. * Updated the package version to 2.17.0. +2017-12-04 Fred Gleason + * Added a 'log_unlink_test' harness. + * Fixed a bug that caused a log's link status flags to fail to be + updated when the log was unlinked. diff --git a/lib/rdsvc.cpp b/lib/rdsvc.cpp index 66bee7e9..846eaf14 100644 --- a/lib/rdsvc.cpp +++ b/lib/rdsvc.cpp @@ -27,6 +27,7 @@ #include #include #include + #include #include #include @@ -976,8 +977,7 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date, } -void RDSvc::clearLogLinks(RDSvc::ImportSource src,const QDate &date, - const QString &logname) +void RDSvc::clearLogLinks(RDSvc::ImportSource src,const QString &logname) { std::vector cleared_ids; RDLogLine::Type event_type=RDLogLine::UnknownType; @@ -1032,6 +1032,16 @@ void RDSvc::clearLogLinks(RDSvc::ImportSource src,const QDate &date, dest_event->save(); delete src_event; delete dest_event; + + RDLog *log=new RDLog(logname); + if(src==RDSvc::Traffic) { + log->setLinkState(RDLog::SourceTraffic,false); + } + if(src==RDSvc::Music) { + log->setLinkState(RDLog::SourceMusic,false); + } + delete log; + } diff --git a/lib/rdsvc.h b/lib/rdsvc.h index c3a757e2..f7bd1789 100644 --- a/lib/rdsvc.h +++ b/lib/rdsvc.h @@ -85,8 +85,7 @@ class RDSvc : public QObject const QString &nextname,QString *report); bool linkLog(RDSvc::ImportSource src,const QDate &date, const QString &logname,QString *report); - void clearLogLinks(RDSvc::ImportSource src,const QDate &date, - const QString &logname); + void clearLogLinks(RDSvc::ImportSource src,const QString &logname); void create(const QString exemplar) const; void remove() const; QString xml() const; diff --git a/rdlogedit/rdlogedit_cs.ts b/rdlogedit/rdlogedit_cs.ts index a85d4a49..4398f3ec 100644 --- a/rdlogedit/rdlogedit_cs.ts +++ b/rdlogedit/rdlogedit_cs.ts @@ -900,6 +900,101 @@ Vyhledejte svého správce systému kvůli aktualizaci! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + Vybrat + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + Z&rušit + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_de.ts b/rdlogedit/rdlogedit_de.ts index c71969f0..92dd1fbe 100644 --- a/rdlogedit/rdlogedit_de.ts +++ b/rdlogedit/rdlogedit_de.ts @@ -899,6 +899,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + Auswählen + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + Abbre&chen + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_es.ts b/rdlogedit/rdlogedit_es.ts index f9d1ec4b..d6a90294 100644 --- a/rdlogedit/rdlogedit_es.ts +++ b/rdlogedit/rdlogedit_es.ts @@ -900,6 +900,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + Seleccionar + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + &Cancelar + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_fr.ts b/rdlogedit/rdlogedit_fr.ts index f7bb86d5..370bc9f3 100644 --- a/rdlogedit/rdlogedit_fr.ts +++ b/rdlogedit/rdlogedit_fr.ts @@ -872,6 +872,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_nb.ts b/rdlogedit/rdlogedit_nb.ts index 42a89042..34f91dd2 100644 --- a/rdlogedit/rdlogedit_nb.ts +++ b/rdlogedit/rdlogedit_nb.ts @@ -921,6 +921,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + Vel + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + &Avbryt + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_nn.ts b/rdlogedit/rdlogedit_nn.ts index 42a89042..34f91dd2 100644 --- a/rdlogedit/rdlogedit_nn.ts +++ b/rdlogedit/rdlogedit_nn.ts @@ -921,6 +921,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + Vel + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + &Avbryt + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogedit/rdlogedit_pt_BR.ts b/rdlogedit/rdlogedit_pt_BR.ts index 0d065f07..c6d1c009 100644 --- a/rdlogedit/rdlogedit_pt_BR.ts +++ b/rdlogedit/rdlogedit_pt_BR.ts @@ -900,6 +900,101 @@ See your system administrator for an update! + + RenderDialog + + Render Log + + + + Rendering Log... + + + + Cancel + + + + Render Progress + + + + Cart/Cut + + + + File + + + + Render To + + + + Select + + + + Audio Parameters + + + + Set + + + + [now] + + + + As Specified + + + + Virtual Start Time + + + + All Events + + + + Only Selected Events + + + + Include + + + + Stop Rendering + + + + Treat as PLAY + + + + At STOP transition + + + + &Render + + + + &Cancel + &Cancelar + + + Filename + + + + Rendering Error + + + VoiceTracker diff --git a/rdlogmanager/commandline_ops.cpp b/rdlogmanager/commandline_ops.cpp index b1d4547b..3ff6ef40 100644 --- a/rdlogmanager/commandline_ops.cpp +++ b/rdlogmanager/commandline_ops.cpp @@ -145,8 +145,8 @@ int RunLogOperation(int argc,char *argv[],const QString &svcname, } report=""; log->removeTracks(rdstation_conf,rduser,config); - svc->clearLogLinks(RDSvc::Traffic,start_date,logname); - svc->clearLogLinks(RDSvc::Music,start_date,logname); + svc->clearLogLinks(RDSvc::Traffic,logname); + svc->clearLogLinks(RDSvc::Music,logname); if(svc->linkLog(RDSvc::Music,start_date,logname,&report)) { printf("%s\n",(const char*)report); } @@ -174,7 +174,7 @@ int RunLogOperation(int argc,char *argv[],const QString &svcname, return 256; } report=""; - svc->clearLogLinks(RDSvc::Traffic,start_date,logname); + svc->clearLogLinks(RDSvc::Traffic,logname); if(svc->linkLog(RDSvc::Traffic,start_date,logname,&report)) { printf("%s\n",(const char*)report); } diff --git a/rdlogmanager/generate_log.cpp b/rdlogmanager/generate_log.cpp index 776867eb..846ed179 100644 --- a/rdlogmanager/generate_log.cpp +++ b/rdlogmanager/generate_log.cpp @@ -427,8 +427,8 @@ void GenerateLog::musicData() } } log->removeTracks(rdstation_conf,rduser,log_config); - svc->clearLogLinks(RDSvc::Traffic,gen_date_edit->date(),logname); - svc->clearLogLinks(RDSvc::Music,gen_date_edit->date(),logname); + svc->clearLogLinks(RDSvc::Traffic,logname); + svc->clearLogLinks(RDSvc::Music,logname); } connect(svc,SIGNAL(generationProgress(int)), gen_progress_dialog,SLOT(setProgress(int))); @@ -462,7 +462,7 @@ void GenerateLog::trafficData() delete svc; return; } - svc->clearLogLinks(RDSvc::Traffic,gen_date_edit->date(),logname); + svc->clearLogLinks(RDSvc::Traffic,logname); } connect(svc,SIGNAL(generationProgress(int)), gen_progress_dialog,SLOT(setProgress(int))); diff --git a/tests/Makefile.am b/tests/Makefile.am index d8e7ffd4..4e4781af 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,6 +33,7 @@ noinst_PROGRAMS = audio_convert_test\ audio_import_test\ audio_peaks_test\ datedecode_test\ + log_unlink_test\ rdxml_parse_test\ reserve_carts_test\ sas_switch_torture\ @@ -59,6 +60,9 @@ audio_peaks_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ dist_datedecode_test_SOURCES = datedecode_test.cpp datedecode_test.h datedecode_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ +dist_log_unlink_test_SOURCES = log_unlink_test.cpp log_unlink_test.h +log_unlink_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ + dist_rdxml_parse_test_SOURCES = rdxml_parse_test.cpp rdxml_parse_test.h rdxml_parse_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ diff --git a/tests/log_unlink_test.cpp b/tests/log_unlink_test.cpp new file mode 100644 index 00000000..55be3492 --- /dev/null +++ b/tests/log_unlink_test.cpp @@ -0,0 +1,120 @@ +// log_unlink_test.cpp +// +// Test the Rivendell log unlinker methods. +// +// (C) Copyright 2017 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "log_unlink_test.h" + +MainObject::MainObject(QObject *parent) + :QObject(parent) +{ + QString log_name=""; + RDSvc::ImportSource import_source=RDSvc::Traffic; + RDConfig *config=NULL; + unsigned schema=0; + + // + // Read Command Options + // + RDCmdSwitch *cmd= + new RDCmdSwitch(qApp->argc(),qApp->argv(),"log_unlink_test", + LOG_UNLINK_TEST_USAGE); + for(unsigned i=0;ikeys();i++) { + if(cmd->key(i)=="--log") { + log_name=cmd->value(i); + cmd->setProcessed(i,true); + } + if(cmd->key(i)=="--source") { + if(cmd->value(i).lower()=="traffic") { + import_source=RDSvc::Traffic; + } + else { + if(cmd->value(i).lower()=="music") { + import_source=RDSvc::Music; + } + else { + fprintf(stderr, + "log_unlink_test: you must specify a source to unlink\n"); + exit(1); + } + } + cmd->setProcessed(i,true); + } + if(!cmd->processed(i)) { + fprintf(stderr,"log_unlink_test: unknown option \"%s\"\n", + (const char *)cmd->value(i)); + exit(256); + } + } + if(log_name.isEmpty()) { + fprintf(stderr,"log_unlink_test: you must specify a log name with \"--log=\"\n"); + exit(1); + } + + // + // Load Configuration + // + config=new RDConfig(); + config->load(); + config->setModuleName("reserve_carts_test"); + + // + // Open Database + // + QString err (tr("upload_test: ")); + QSqlDatabase *db=RDInitDb(&schema,&err); + if(!db) { + fprintf(stderr,err.ascii()); + delete cmd; + exit(256); + } + + // + // Run the Test + // + if(!RDLog::exists(log_name)) { + fprintf(stderr,"log_unlink_test: no such log\n"); + exit(1); + } + RDLog *log=new RDLog(log_name); + RDSvc *svc=new RDSvc(log->service()); + svc->clearLogLinks(import_source,log_name); + + exit(0); +} + + +int main(int argc,char *argv[]) +{ + QApplication a(argc,argv,false); + new MainObject(); + return a.exec(); +} diff --git a/tests/log_unlink_test.h b/tests/log_unlink_test.h new file mode 100644 index 00000000..6da8b2b3 --- /dev/null +++ b/tests/log_unlink_test.h @@ -0,0 +1,35 @@ +// log_unlink_test.h +// +// Test the Rivendell log unlinker methods +// +// (C) Copyright 2017 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef LOG_UNLINK_TEST_H +#define LOG_UNLINK_TEST_H + +#include + +#define LOG_UNLINK_TEST_USAGE "[options]\n\nTest the Rivendell log unlinker methods\n\nOptions are:\n--log=\n Name of log to unlink.\n\n--source=music|traffic\n Data source to unlink\n\n" + +class MainObject : public QObject +{ + public: + MainObject(QObject *parent=0); +}; + + +#endif // LOG_UNLINK_TEST_H