mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-16 06:02:36 +02:00
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
* Converted rdclilogedit(1) to use RDApplication.
This commit is contained in:
parent
4de82a23eb
commit
941f846060
@ -16621,3 +16621,5 @@
|
||||
* Moved command-switch processing into RDApplication.
|
||||
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Converted rdcheckcuts(1) to use RDApplication.
|
||||
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Converted rdclilogedit(1) to use RDApplication.
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// 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
|
||||
@ -18,6 +18,7 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <rdapplication.h>
|
||||
#include <rdconf.h>
|
||||
#include <rdcreate_log.h>
|
||||
#include <rdescape_string.h>
|
||||
@ -32,7 +33,7 @@ void MainObject::Addcart(int line,unsigned cartnum)
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
setTransType(rda->airplayConf()->defaultTransType());
|
||||
edit_log_event->logLine(line)->setFadeupGain(-3000);
|
||||
edit_log_event->logLine(line)->setFadedownGain(-3000);
|
||||
edit_log_event->logLine(line)->setCartNumber(cartnum);
|
||||
@ -49,7 +50,7 @@ void MainObject::Addchain(int line,const QString &logname)
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Chain);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
setTransType(rda->airplayConf()->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerLabel(logname);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
@ -64,7 +65,7 @@ void MainObject::Addmarker(int line)
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Marker);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
setTransType(rda->airplayConf()->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerLabel(tr("Label"));
|
||||
edit_log_event->logLine(line)->setMarkerComment(tr("Marker Comment"));
|
||||
edit_log_event->refresh(line);
|
||||
@ -80,7 +81,7 @@ void MainObject::Addtrack(int line)
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Track);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
setTransType(rda->airplayConf()->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerComment(tr("Voice Track"));
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
@ -107,12 +108,12 @@ void MainObject::Deletelog(QString logname)
|
||||
delete q;
|
||||
|
||||
if((edit_log==NULL)||(edit_log->name()!=logname)) {
|
||||
RDLogLock *log_lock=new RDLogLock(logname,edit_user,edit_station,this);
|
||||
RDLogLock *log_lock=new RDLogLock(logname,rda->user(),rda->station(),this);
|
||||
QString err_msg;
|
||||
RDLog *log=new RDLog(logname);
|
||||
if(log->exists()) {
|
||||
if(TryLock(log_lock,logname)) {
|
||||
if(!log->remove(edit_station,edit_user,edit_config)) {
|
||||
if(!log->remove(rda->station(),rda->user(),rda->config())) {
|
||||
fprintf(stderr,
|
||||
"deletelog: audio deletion error, log not deleted\n");
|
||||
}
|
||||
@ -238,7 +239,7 @@ void MainObject::Load(QString logname)
|
||||
QString username;
|
||||
QString stationname;
|
||||
QHostAddress addr;
|
||||
edit_log_lock=new RDLogLock(logname,edit_user,edit_station,this);
|
||||
edit_log_lock=new RDLogLock(logname,rda->user(),rda->station(),this);
|
||||
if(!TryLock(edit_log_lock,logname)) {
|
||||
delete edit_log_lock;
|
||||
edit_log_lock=NULL;
|
||||
@ -374,7 +375,7 @@ void MainObject::New(const QString &logname)
|
||||
// edit_new_log=true;
|
||||
edit_modified=false;
|
||||
Saveas(edit_log->name());
|
||||
edit_log_lock=new RDLogLock(edit_log->name(),edit_user,edit_station,this);
|
||||
edit_log_lock=new RDLogLock(edit_log->name(),rda->user(),rda->station(),this);
|
||||
if(!TryLock(edit_log_lock,edit_log->name())) {
|
||||
fprintf(stderr,"FATAL ERROR: unable to lock new log!\n");
|
||||
exit(256);
|
||||
@ -395,7 +396,7 @@ void MainObject::Remove(int line)
|
||||
|
||||
void MainObject::Save()
|
||||
{
|
||||
edit_log_event->save(edit_config);
|
||||
edit_log_event->save(rda->config());
|
||||
edit_log->setDescription(edit_description);
|
||||
edit_log->setStartDate(edit_start_date);
|
||||
edit_log->setEndDate(edit_end_date);
|
||||
@ -419,7 +420,7 @@ void MainObject::Saveas(const QString &logname)
|
||||
"NAME=\""+RDEscapeString(logname)+"\","+
|
||||
"TYPE=0,"+
|
||||
"DESCRIPTION=\""+RDEscapeString(edit_description)+"\","+
|
||||
"ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+
|
||||
"ORIGIN_USER=\""+RDEscapeString(rda->user()->name())+"\","+
|
||||
"ORIGIN_DATETIME=now(),"+
|
||||
"LINK_DATETIME=now(),"+
|
||||
"MODIFIED_DATETIME=now(),"+
|
||||
@ -430,9 +431,9 @@ void MainObject::Saveas(const QString &logname)
|
||||
"SERVICE=\""+RDEscapeString(edit_service)+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDCreateLogTable(RDLog::tableName(logname),edit_config);
|
||||
RDCreateLogTable(RDLog::tableName(logname),rda->config());
|
||||
edit_log_event->setLogName(RDLog::tableName(logname));
|
||||
edit_log_event->save(edit_config);
|
||||
edit_log_event->save(rda->config());
|
||||
delete edit_log;
|
||||
edit_log=log;
|
||||
edit_modified=false;
|
||||
@ -534,7 +535,7 @@ void MainObject::Setpurgedate(const QDate &date)
|
||||
|
||||
void MainObject::Setservice(const QString &str)
|
||||
{
|
||||
RDSvc *svc=new RDSvc(str,edit_station,edit_config);
|
||||
RDSvc *svc=new RDSvc(str,rda->station(),rda->config());
|
||||
if(svc->exists()) {
|
||||
edit_service=str;
|
||||
edit_modified=true;
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// 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
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rdapplication.h>
|
||||
#include <rdweb.h>
|
||||
|
||||
#include "rdclilogedit.h"
|
||||
@ -46,7 +47,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
// No loaded log needed for these
|
||||
//
|
||||
if(verb=="deletelog") {
|
||||
if(edit_user->deleteLog()) {
|
||||
if(rda->user()->deleteLog()) {
|
||||
if(cmds.size()==2) {
|
||||
Deletelog(cmds[1]);
|
||||
}
|
||||
@ -123,7 +124,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
//
|
||||
if((processed)||(edit_log_event!=NULL)) {
|
||||
if(verb=="addcart") {
|
||||
if(edit_user->addtoLog()) {
|
||||
if(rda->user()->addtoLog()) {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
@ -150,7 +151,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="addchain") {
|
||||
if(edit_user->addtoLog()) {
|
||||
if(rda->user()->addtoLog()) {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
@ -171,7 +172,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="addmarker") {
|
||||
if(edit_user->addtoLog()) {
|
||||
if(rda->user()->addtoLog()) {
|
||||
if(cmds.size()==2) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
@ -192,7 +193,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="addtrack") {
|
||||
if(edit_user->addtoLog()) {
|
||||
if(rda->user()->addtoLog()) {
|
||||
if(cmds.size()==2) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
@ -223,7 +224,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="remove") {
|
||||
if(edit_user->removefromLog()) {
|
||||
if(rda->user()->removefromLog()) {
|
||||
if(cmds.size()==2) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
@ -244,7 +245,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="save") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
Save();
|
||||
}
|
||||
else {
|
||||
@ -254,7 +255,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="saveas") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==2) {
|
||||
if(cmds[1].length()>64) {
|
||||
fprintf(stderr,"saveas: log name too long\n");
|
||||
@ -273,7 +274,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setautorefresh") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==2) {
|
||||
QString arg=cmds[1].lower();
|
||||
if((arg=="yes")||(arg=="true")||(arg=="y")) {
|
||||
@ -300,7 +301,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setcart") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
@ -328,7 +329,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setcomment") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()>=3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
@ -352,7 +353,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setdesc") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()>=2) {
|
||||
cmds.erase(cmds.begin());
|
||||
Setdesc(cmds.join(" "));
|
||||
@ -369,7 +370,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setenddate") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==1) {
|
||||
Setenddate(QDate());
|
||||
}
|
||||
@ -396,7 +397,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setlabel") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
@ -418,7 +419,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setpurgedate") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==1) {
|
||||
Setpurgedate(QDate());
|
||||
}
|
||||
@ -445,7 +446,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setservice") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==2) {
|
||||
Setservice(cmds[1]);
|
||||
}
|
||||
@ -461,7 +462,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="setstartdate") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==1) {
|
||||
Setstartdate(QDate());
|
||||
}
|
||||
@ -488,7 +489,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="settime") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()>=3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
@ -540,7 +541,7 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
|
||||
if(verb=="settrans") {
|
||||
if(edit_user->arrangeLog()) {
|
||||
if(rda->user()->arrangeLog()) {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)&&(line<edit_log_event->size())) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// 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
|
||||
@ -28,7 +28,7 @@
|
||||
#include <qfile.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdapplication.h>
|
||||
#include <rdconf.h>
|
||||
#include <rddbheartbeat.h>
|
||||
#include <rdweb.h>
|
||||
@ -38,6 +38,8 @@
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
QString err_msg;
|
||||
|
||||
edit_quiet_option=false;
|
||||
|
||||
edit_log=NULL;
|
||||
@ -45,57 +47,37 @@ MainObject::MainObject(QObject *parent)
|
||||
edit_modified=false;
|
||||
edit_log_lock=NULL;
|
||||
|
||||
//
|
||||
// Open the Database
|
||||
//
|
||||
rda=new RDApplication("rdclilogedit","rdclilogedit",RDCLILOGEDIT_USAGE,this);
|
||||
if(!rda->open(&err_msg)) {
|
||||
fprintf(stderr,"rdclilogedit: %s\n",(const char *)err_msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdclilogedit",
|
||||
RDCLILOGEDIT_USAGE);
|
||||
for(int i=0;i<(int)cmd->keys();i++) {
|
||||
if((cmd->key(i)=="-n")||(cmd->key(i)=="--quiet")||
|
||||
(cmd->key(i)=="--silent")) {
|
||||
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||
if((rda->cmdSwitch()->key(i)=="-n")||(rda->cmdSwitch()->key(i)=="--quiet")||
|
||||
(rda->cmdSwitch()->key(i)=="--silent")) {
|
||||
edit_quiet_option=true;
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(!rda->cmdSwitch()->processed(i)) {
|
||||
fprintf(stderr,"rdclilogedit: unknown command option \"%s\"\n",
|
||||
(const char *)rda->cmdSwitch()->key(i));
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Read Configuration
|
||||
//
|
||||
edit_config=new RDConfig();
|
||||
edit_config->load();
|
||||
edit_config->setModuleName("rdclilogedit");
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
QSqlDatabase *db=QSqlDatabase::addDatabase(edit_config->mysqlDriver());
|
||||
if(!db) {
|
||||
fprintf(stderr,"rdclilogedit: unable to initialize connection to database\n");
|
||||
exit(256);
|
||||
}
|
||||
db->setDatabaseName(edit_config->mysqlDbname());
|
||||
db->setUserName(edit_config->mysqlUsername());
|
||||
db->setPassword(edit_config->mysqlPassword());
|
||||
db->setHostName(edit_config->mysqlHostname());
|
||||
if(!db->open()) {
|
||||
fprintf(stderr,"rdclilogedit: unable to connect to database\n");
|
||||
db->removeDatabase(edit_config->mysqlDbname());
|
||||
exit(256);
|
||||
}
|
||||
new RDDbHeartbeat(edit_config->mysqlHeartbeatInterval(),this);
|
||||
|
||||
//
|
||||
// Configuration Objects
|
||||
//
|
||||
edit_station=new RDStation(edit_config->stationName());
|
||||
edit_airplay_conf=new RDAirPlayConf(edit_config->stationName(),"RDAIRPLAY");
|
||||
|
||||
//
|
||||
// RIPC Connection
|
||||
//
|
||||
edit_user=NULL;
|
||||
edit_ripc=new RDRipc(edit_station,edit_config,this);
|
||||
connect(edit_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
edit_ripc->connectHost("localhost",RIPCD_TCP_PORT,edit_config->password());
|
||||
connect(rda->ripc(),SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
rda->ripc()->
|
||||
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
||||
}
|
||||
|
||||
|
||||
@ -107,11 +89,8 @@ void MainObject::userData()
|
||||
//
|
||||
// Get User Context
|
||||
//
|
||||
disconnect(edit_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
if(edit_user!=NULL) {
|
||||
delete edit_user;
|
||||
}
|
||||
edit_user=new RDUser(edit_ripc->user());
|
||||
disconnect(rda->ripc(),SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
rda->user()->setName(rda->ripc()->user());
|
||||
|
||||
//
|
||||
// Start up command processor
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A Command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016-2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// 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
|
||||
@ -23,15 +23,11 @@
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdairplay_conf.h>
|
||||
#include <rdconfig.h>
|
||||
#include <rdcut.h>
|
||||
#include <rddb.h>
|
||||
#include <rdlog.h>
|
||||
#include <rdlog_event.h>
|
||||
#include <rdloglock.h>
|
||||
#include <rdripc.h>
|
||||
#include <rduser.h>
|
||||
|
||||
#define RDCLILOGEDIT_USAGE "[options]\n"
|
||||
|
||||
@ -80,7 +76,6 @@ class MainObject : public QObject
|
||||
bool edit_quiet_option;
|
||||
QString edit_accum;
|
||||
bool edit_modified;
|
||||
// bool edit_new_log;
|
||||
RDLog *edit_log;
|
||||
RDLogEvent *edit_log_event;
|
||||
QString edit_description;
|
||||
@ -89,11 +84,6 @@ class MainObject : public QObject
|
||||
QDate edit_end_date;
|
||||
QDate edit_purge_date;
|
||||
bool edit_auto_refresh;
|
||||
RDUser *edit_user;
|
||||
RDStation *edit_station;
|
||||
RDRipc *edit_ripc;
|
||||
RDAirPlayConf *edit_airplay_conf;
|
||||
RDConfig *edit_config;
|
||||
RDLogLock *edit_log_lock;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user