mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-20 16:09:51 +02:00
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Added a 'settime' command to rdclilogedit(1). * Added a 'setmarker' command to rdclilogedit(1). * Added a 'settrack' command to rdclilogedit(1).
This commit is contained in:
parent
c388bda77b
commit
2af6845d6e
@ -15342,3 +15342,7 @@
|
||||
large output listings to be truncated.
|
||||
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Implemented '!' override character in rdclilogedit(1).
|
||||
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'settime' command to rdclilogedit(1).
|
||||
* Added a 'setmarker' command to rdclilogedit(1).
|
||||
* Added a 'settrack' command to rdclilogedit(1).
|
||||
|
@ -30,6 +30,7 @@ moc_%.cpp: %.h
|
||||
bin_PROGRAMS = rdclilogedit
|
||||
|
||||
dist_rdclilogedit_SOURCES = help.cpp\
|
||||
operations.cpp\
|
||||
rdclilogedit.cpp rdclilogedit.h
|
||||
|
||||
nodist_rdclilogedit_SOURCES = moc_rdclilogedit.cpp
|
||||
|
@ -27,8 +27,8 @@ void MainObject::Help(const QStringList &cmds) const
|
||||
if(cmds.size()==1) {
|
||||
printf("\n");
|
||||
printf("The following commands are available:\n");
|
||||
printf("?, addcart, bye, exit, help, list, listlogs, load, quit, remove,\n");
|
||||
printf("save, saveas, setcart, settime, settrans, unload\n");
|
||||
printf("?, addcart, addchain, addmarker, addtrack, bye, exit, help, list, listlogs,\n");
|
||||
printf("load, quit, remove, save, saveas, setcart, settime, settrans, unload\n");
|
||||
printf("\n");
|
||||
printf("Enter \"? <cmd-name>\" for specific help.\n");
|
||||
printf("\n");
|
||||
@ -44,6 +44,30 @@ void MainObject::Help(const QStringList &cmds) const
|
||||
printf("\n");
|
||||
processed=true;
|
||||
}
|
||||
if(verb=="addmarker") {
|
||||
printf("\n");
|
||||
printf(" addmarker <line>\n");
|
||||
printf("\n");
|
||||
printf("Add a new marker event before line <line>.\n");
|
||||
printf("\n");
|
||||
processed=true;
|
||||
}
|
||||
if(verb=="addchain") {
|
||||
printf("\n");
|
||||
printf(" addchain <line> <log-name>\n");
|
||||
printf("\n");
|
||||
printf("Add a new chain-to event before line <line> pointing to <log-name>.\n");
|
||||
printf("\n");
|
||||
processed=true;
|
||||
}
|
||||
if(verb=="addtrack") {
|
||||
printf("\n");
|
||||
printf(" addtrack <line>\n");
|
||||
printf("\n");
|
||||
printf("Add a new track event before line <line>.\n");
|
||||
printf("\n");
|
||||
processed=true;
|
||||
}
|
||||
if((verb=="bye")||(verb=="exit")||(verb=="quit")) {
|
||||
printf("\n");
|
||||
printf(" %s\n",(const char *)cmds[1]);
|
||||
|
266
utils/rdclilogedit/operations.cpp
Normal file
266
utils/rdclilogedit/operations.cpp
Normal file
@ -0,0 +1,266 @@
|
||||
// rdclilogedit.cpp
|
||||
//
|
||||
// A command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 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
|
||||
// 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 <rdcreate_log.h>
|
||||
#include <rdescape_string.h>
|
||||
|
||||
#include "rdclilogedit.h"
|
||||
|
||||
void MainObject::Addcart(int line,unsigned cartnum)
|
||||
{
|
||||
if(edit_user->addtoLog()) {
|
||||
if(line>edit_log_event->size()) {
|
||||
line=edit_log_event->size();
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
edit_log_event->logLine(line)->setFadeupGain(-3000);
|
||||
edit_log_event->logLine(line)->setFadedownGain(-3000);
|
||||
edit_log_event->logLine(line)->setCartNumber(cartnum);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addcart: insufficient privileges [Add Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Addchain(int line,const QString &logname)
|
||||
{
|
||||
if(edit_user->addtoLog()) {
|
||||
if(line>edit_log_event->size()) {
|
||||
line=edit_log_event->size();
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Chain);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerLabel(logname);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addchain: insufficient privileges [Add Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Addmarker(int line)
|
||||
{
|
||||
if(edit_user->addtoLog()) {
|
||||
if(line>edit_log_event->size()) {
|
||||
line=edit_log_event->size();
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Marker);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerLabel(tr("Label"));
|
||||
edit_log_event->logLine(line)->setMarkerComment(tr("Marker Comment"));
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addmarker: insufficient privileges [Add Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Addtrack(int line)
|
||||
{
|
||||
if(edit_user->addtoLog()) {
|
||||
if(line>edit_log_event->size()) {
|
||||
line=edit_log_event->size();
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->setType(RDLogLine::Track);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
edit_log_event->logLine(line)->setMarkerComment(tr("Voice Track"));
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addtrack: insufficient privileges [Add Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ListLogs() const
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
sql=QString("select NAME from LOGS order by NAME");
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
Print(QString().sprintf("%s\n",(const char *)q->value(0).toString()));
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Load(const QString &logname)
|
||||
{
|
||||
if(edit_log!=NULL) {
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
if(edit_log_event!=NULL) {
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
edit_log=new RDLog(logname);
|
||||
if(edit_log->exists()) {
|
||||
edit_log_event=new RDLogEvent(RDLog::tableName(logname));
|
||||
edit_log_event->load();
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"log \"%s\" does not exist\n",(const char *)logname);
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::List()
|
||||
{
|
||||
for(int i=0;i<edit_log_event->size();i++) {
|
||||
Print(QString().sprintf("%4d %s\n",i,
|
||||
(const char *)ListLine(edit_log_event,i)));
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Remove(int line)
|
||||
{
|
||||
edit_log_event->remove(line,1);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Save()
|
||||
{
|
||||
if(edit_user->arrangeLog()) {
|
||||
edit_log_event->save();
|
||||
edit_log->
|
||||
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"save: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Saveas(const QString &logname)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
if(edit_user->arrangeLog()) {
|
||||
RDLog *log=new RDLog(logname);
|
||||
if(!log->exists()) {
|
||||
sql=QString("insert into LOGS set ")+
|
||||
"NAME=\""+RDEscapeString(logname)+"\","+
|
||||
"TYPE=0,"+
|
||||
"DESCRIPTION=\""+"Copy of "+RDEscapeString(edit_log->name())+"\","+
|
||||
"ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+
|
||||
"ORIGIN_DATETIME=now(),"+
|
||||
"LINK_DATETIME=now(),"+
|
||||
"MODIFIED_DATETIME=now(),"+
|
||||
"SERVICE=\""+edit_log->service()+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDCreateLogTable(RDLog::tableName(logname));
|
||||
edit_log_event->setLogName(RDLog::tableName(logname));
|
||||
edit_log_event->save();
|
||||
delete edit_log;
|
||||
edit_log=log;
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"saveas: log already exists\n");
|
||||
delete log;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"saveas: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Setcart(int line,unsigned cartnum)
|
||||
{
|
||||
if(edit_user->arrangeLog()) {
|
||||
RDLogLine *logline=edit_log_event->logLine(line);
|
||||
if(logline!=NULL) {
|
||||
if((logline->type()==RDLogLine::Cart)||
|
||||
(logline->type()==RDLogLine::Macro)) {
|
||||
logline->setCartNumber(cartnum);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: incompatible event type\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: no such line\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time)
|
||||
{
|
||||
edit_log_event->logLine(line)->setTimeType(type);
|
||||
edit_log_event->logLine(line)->setStartTime(RDLogLine::Logged,time);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Settrans(int line,RDLogLine::TransType type)
|
||||
{
|
||||
edit_log_event->logLine(line)->setTransType(type);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Unload()
|
||||
{
|
||||
if(edit_log!=NULL) {
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
if(edit_log_event!=NULL) {
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
edit_modified=false;
|
||||
}
|
@ -25,14 +25,11 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qcstring.h>
|
||||
#include <qfile.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdconf.h>
|
||||
#include <rdcreate_log.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdweb.h>
|
||||
|
||||
#include "rdclilogedit.h"
|
||||
@ -143,188 +140,6 @@ void MainObject::inputActivatedData(int sock)
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Addcart(int line,unsigned cartnum)
|
||||
{
|
||||
if(edit_user->addtoLog()) {
|
||||
if(line>edit_log_event->size()) {
|
||||
line=edit_log_event->size();
|
||||
}
|
||||
edit_log_event->insert(line,1);
|
||||
edit_log_event->logLine(line)->
|
||||
setTransType(edit_airplay_conf->defaultTransType());
|
||||
edit_log_event->logLine(line)->setFadeupGain(-3000);
|
||||
edit_log_event->logLine(line)->setFadedownGain(-3000);
|
||||
edit_log_event->logLine(line)->setCartNumber(cartnum);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addcart: insufficient privileges [Add Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::ListLogs() const
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
sql=QString("select NAME from LOGS order by NAME");
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
Print(QString().sprintf("%s\n",(const char *)q->value(0).toString()));
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Load(const QString &logname)
|
||||
{
|
||||
if(edit_log!=NULL) {
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
if(edit_log_event!=NULL) {
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
edit_log=new RDLog(logname);
|
||||
if(edit_log->exists()) {
|
||||
edit_log_event=new RDLogEvent(RDLog::tableName(logname));
|
||||
edit_log_event->load();
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"log \"%s\" does not exist\n",(const char *)logname);
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::List()
|
||||
{
|
||||
for(int i=0;i<edit_log_event->size();i++) {
|
||||
Print(QString().sprintf("%4d %s\n",i,
|
||||
(const char *)ListLine(edit_log_event,i)));
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Remove(int line)
|
||||
{
|
||||
edit_log_event->remove(line,1);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Save()
|
||||
{
|
||||
if(edit_user->arrangeLog()) {
|
||||
edit_log_event->save();
|
||||
edit_log->
|
||||
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"save: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Saveas(const QString &logname)
|
||||
{
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
if(edit_user->arrangeLog()) {
|
||||
RDLog *log=new RDLog(logname);
|
||||
if(!log->exists()) {
|
||||
sql=QString("insert into LOGS set ")+
|
||||
"NAME=\""+RDEscapeString(logname)+"\","+
|
||||
"TYPE=0,"+
|
||||
"DESCRIPTION=\""+"Copy of "+RDEscapeString(edit_log->name())+"\","+
|
||||
"ORIGIN_USER=\""+RDEscapeString(edit_user->name())+"\","+
|
||||
"ORIGIN_DATETIME=now(),"+
|
||||
"LINK_DATETIME=now(),"+
|
||||
"MODIFIED_DATETIME=now(),"+
|
||||
"SERVICE=\""+edit_log->service()+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
RDCreateLogTable(RDLog::tableName(logname));
|
||||
edit_log_event->setLogName(RDLog::tableName(logname));
|
||||
edit_log_event->save();
|
||||
delete edit_log;
|
||||
edit_log=log;
|
||||
edit_modified=false;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"saveas: log already exists\n");
|
||||
delete log;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"saveas: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Setcart(int line,unsigned cartnum)
|
||||
{
|
||||
if(edit_user->arrangeLog()) {
|
||||
RDLogLine *logline=edit_log_event->logLine(line);
|
||||
if(logline!=NULL) {
|
||||
if((logline->type()==RDLogLine::Cart)||
|
||||
(logline->type()==RDLogLine::Macro)) {
|
||||
logline->setCartNumber(cartnum);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: incompatible event type\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: no such line\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"setcart: insufficient privileges [Rearrange Log Items]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Settime(int line,RDLogLine::TimeType type,const QTime &time)
|
||||
{
|
||||
edit_log_event->logLine(line)->setTimeType(type);
|
||||
edit_log_event->logLine(line)->setStartTime(RDLogLine::Logged,time);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Settrans(int line,RDLogLine::TransType type)
|
||||
{
|
||||
edit_log_event->logLine(line)->setTransType(type);
|
||||
edit_log_event->refresh(line);
|
||||
edit_modified=true;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Unload()
|
||||
{
|
||||
if(edit_log!=NULL) {
|
||||
delete edit_log;
|
||||
edit_log=NULL;
|
||||
}
|
||||
if(edit_log_event!=NULL) {
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
edit_modified=false;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::OverwriteError(const QString &cmd) const
|
||||
{
|
||||
fprintf(stderr,"%s: buffer not saved (append \"!\" to override)\n",
|
||||
@ -414,6 +229,54 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
||||
if(verb=="addchain") {
|
||||
if(cmds.size()==3) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
Addchain(line,cmds[2]);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addchain: invalid line number\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addchain: invalid command arguments\n");
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
||||
if(verb=="addmarker") {
|
||||
if(cmds.size()==2) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
Addmarker(line);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addmarker: invalid line number\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addmarker: invalid command arguments\n");
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
||||
if(verb=="addtrack") {
|
||||
if(cmds.size()==2) {
|
||||
line=cmds[1].toInt(&ok);
|
||||
if(ok&&(line>=0)) {
|
||||
Addtrack(line);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addtrack: invalid line number\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"addtrack: invalid command arguments\n");
|
||||
}
|
||||
processed=true;
|
||||
}
|
||||
|
||||
if(verb=="list") {
|
||||
List();
|
||||
|
@ -47,6 +47,9 @@ class MainObject : public QObject
|
||||
|
||||
private:
|
||||
void Addcart(int line,unsigned cartnum);
|
||||
void Addchain(int line,const QString &logname);
|
||||
void Addmarker(int line);
|
||||
void Addtrack(int line);
|
||||
void Help(const QStringList &cmds) const;
|
||||
void ListLogs() const;
|
||||
void Load(const QString &logname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user