mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-23 16:08:15 +02:00
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
* Converted rdcheckcuts(1) to use RDApplication.
This commit is contained in:
parent
3d380c4de8
commit
4de82a23eb
@ -16619,3 +16619,5 @@
|
|||||||
* Converted rdrepld(8) to use RDApplication.
|
* Converted rdrepld(8) to use RDApplication.
|
||||||
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
|
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Moved command-switch processing into RDApplication.
|
* Moved command-switch processing into RDApplication.
|
||||||
|
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Converted rdcheckcuts(1) to use RDApplication.
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
|
||||||
#include <rddb.h>
|
#include <rdapplication.h>
|
||||||
#include <rdcmd_switch.h>
|
|
||||||
#include <rdstation.h>
|
|
||||||
#include <rdaudioinfo.h>
|
#include <rdaudioinfo.h>
|
||||||
#include <rdcart.h>
|
#include <rdcart.h>
|
||||||
#include <rdcut.h>
|
#include <rdcut.h>
|
||||||
|
#include <rddb.h>
|
||||||
|
|
||||||
#include <rdcheckcuts.h>
|
#include <rdcheckcuts.h>
|
||||||
|
|
||||||
@ -38,36 +37,30 @@ MainObject::MainObject(QObject *parent)
|
|||||||
std::vector<QString> bad_cuts;
|
std::vector<QString> bad_cuts;
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
|
QString err_msg;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the Database
|
||||||
|
//
|
||||||
|
rda=new RDApplication("rdcheckcuts","rdcheckcuts",RDCHECKCUTS_USAGE,this);
|
||||||
|
if(!rda->open(&err_msg)) {
|
||||||
|
fprintf(stderr,"rdcheckcuts: %s\n",(const char *)err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
//
|
//
|
||||||
RDCmdSwitch *cmd=
|
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcheckcuts",RDCHECKCUTS_USAGE);
|
if(rda->cmdSwitch()->key(i)=="--group") {
|
||||||
for(unsigned i=0;i<cmd->keys();i++) {
|
group_names.push_back(rda->cmdSwitch()->value(i));
|
||||||
if(cmd->key(i)=="--group") {
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
group_names.push_back(cmd->value(i));
|
}
|
||||||
cmd->setProcessed(i,true);
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
|
fprintf(stderr,"rdcheckcuts: unknown command option \"%s\"\n",
|
||||||
|
(const char *)rda->cmdSwitch()->key(i));
|
||||||
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!cmd->allProcessed()) {
|
|
||||||
fprintf(stderr,"rdcheckcuts: unknown option\n");
|
|
||||||
exit(256);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open Configuration
|
|
||||||
//
|
|
||||||
cut_config=new RDConfig();
|
|
||||||
cut_config->load();
|
|
||||||
cut_config->setModuleName("rdcheckcuts");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open Database
|
|
||||||
//
|
|
||||||
if(!OpenDb()) {
|
|
||||||
fprintf(stderr,"rdcheckcuts: unable to open database\n");
|
|
||||||
exit(256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -121,8 +114,8 @@ bool MainObject::ValidateGroup(const QString &groupname,
|
|||||||
bool ret=true;
|
bool ret=true;
|
||||||
QString sql;
|
QString sql;
|
||||||
RDSqlQuery *q;
|
RDSqlQuery *q;
|
||||||
RDStation *station=new RDStation(cut_config->stationName());
|
// RDStation *station=new RDStation(rda->config()->stationName());
|
||||||
RDAudioInfo *info=new RDAudioInfo(station,cut_config);
|
RDAudioInfo *info=new RDAudioInfo(rda->station(),rda->config());
|
||||||
RDAudioInfo::ErrorCode err_code;
|
RDAudioInfo::ErrorCode err_code;
|
||||||
|
|
||||||
sql=QString("select CUTS.CUT_NAME,CUTS.CART_NUMBER,CUTS.LENGTH ")+
|
sql=QString("select CUTS.CUT_NAME,CUTS.CART_NUMBER,CUTS.LENGTH ")+
|
||||||
@ -153,32 +146,11 @@ bool MainObject::ValidateGroup(const QString &groupname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete info;
|
delete info;
|
||||||
delete station;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MainObject::OpenDb()
|
|
||||||
{
|
|
||||||
unsigned schema=0;
|
|
||||||
|
|
||||||
QString err(tr("rdcheckcuts: "));
|
|
||||||
QSqlDatabase *db=RDInitDb(&schema,&err);
|
|
||||||
if(!db) {
|
|
||||||
fprintf(stderr,err.ascii());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainObject::CloseDb()
|
|
||||||
{
|
|
||||||
QSqlDatabase::removeDatabase(cut_config->mysqlDbname());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc,argv,false);
|
QApplication a(argc,argv,false);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Check Rivendell Cuts for Valid Audio
|
// Check Rivendell Cuts for Valid Audio
|
||||||
//
|
//
|
||||||
// (C) Copyright 2012,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2012,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
|
||||||
#include <rdconfig.h>
|
|
||||||
|
|
||||||
#define RDCHECKCUTS_USAGE "[options]\n\nCheck Rivendell cuts for valid audio\n\n--group=<group-name>\n Name of group to scan. This option may be given multiple times.\n If no group is specified, then ALL groups will be scanned.\n"
|
#define RDCHECKCUTS_USAGE "[options]\n\nCheck Rivendell cuts for valid audio\n\n--group=<group-name>\n Name of group to scan. This option may be given multiple times.\n If no group is specified, then ALL groups will be scanned.\n"
|
||||||
|
|
||||||
class MainObject : public QObject
|
class MainObject : public QObject
|
||||||
@ -37,9 +35,6 @@ class MainObject : public QObject
|
|||||||
private:
|
private:
|
||||||
void RenderCut(const QString &cutname);
|
void RenderCut(const QString &cutname);
|
||||||
bool ValidateGroup(const QString &groupname,std::vector<QString> *cutnames);
|
bool ValidateGroup(const QString &groupname,std::vector<QString> *cutnames);
|
||||||
bool OpenDb();
|
|
||||||
void CloseDb();
|
|
||||||
RDConfig *cut_config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user