mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-26 01:15:13 +02:00
2017-12-20 Fred Gleason <fredg@paravelsystems.com>
* Added log locking logic to rdclilogedit(1).
This commit is contained in:
parent
28fbd59c4e
commit
941aece664
@ -16521,3 +16521,5 @@
|
||||
* Added log locking logic to rdlogedit(1).
|
||||
2017-12-19 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added log locking logic to the voice tracker in rdlogedit(1).
|
||||
2017-12-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added log locking logic to rdclilogedit(1).
|
||||
|
@ -208,6 +208,10 @@ void MainObject::Load(QString logname)
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
if(edit_log_lock!=NULL) {
|
||||
delete edit_log_lock;
|
||||
edit_log_lock=NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize log name case
|
||||
@ -223,6 +227,16 @@ void MainObject::Load(QString logname)
|
||||
}
|
||||
delete q;
|
||||
|
||||
QString username;
|
||||
QString stationname;
|
||||
QHostAddress addr;
|
||||
edit_log_lock=new RDLogLock(logname,edit_user,edit_station,this);
|
||||
if(!TryLock(edit_log_lock,logname)) {
|
||||
delete edit_log_lock;
|
||||
edit_log_lock=NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
edit_log=new RDLog(logname);
|
||||
if(edit_log->exists()) {
|
||||
edit_log_event=new RDLogEvent(RDLog::tableName(logname));
|
||||
@ -555,5 +569,9 @@ void MainObject::Unload()
|
||||
delete edit_log_event;
|
||||
edit_log_event=NULL;
|
||||
}
|
||||
if(edit_log_lock!=NULL) {
|
||||
delete edit_log_lock;
|
||||
edit_log_lock=NULL;
|
||||
}
|
||||
edit_modified=false;
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ void MainObject::DispatchCommand(QString cmd)
|
||||
|
||||
if((verb=="exit")||(verb=="quit")||(verb=="bye")) {
|
||||
if(overwrite) {
|
||||
if(edit_log_lock!=NULL) {
|
||||
delete edit_log_lock;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
|
@ -44,6 +44,7 @@ MainObject::MainObject(QObject *parent)
|
||||
edit_log_event=NULL;
|
||||
edit_modified=false;
|
||||
edit_new_log=false;
|
||||
edit_log_lock=NULL;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
@ -137,10 +138,32 @@ void MainObject::userData()
|
||||
if(!edit_quiet_option) {
|
||||
printf("\n");
|
||||
}
|
||||
if(edit_log_lock!=NULL) {
|
||||
delete edit_log_lock;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
bool MainObject::TryLock(RDLogLock *lock,const QString &logname)
|
||||
{
|
||||
QString username;
|
||||
QString stationname;
|
||||
QHostAddress addr;
|
||||
bool ret;
|
||||
|
||||
ret=lock->tryLock(&username,&stationname,&addr);
|
||||
if(!ret) {
|
||||
fprintf(stderr,"log \"%s\" in use by %s@%s [%s]\n",
|
||||
(const char *)logname,
|
||||
(const char *)username,
|
||||
(const char *)stationname,
|
||||
(const char *)addr.toString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void MainObject::OverwriteError(const QString &cmd) const
|
||||
{
|
||||
fprintf(stderr,"%s: buffer not saved (append \"!\" to override)\n",
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A Command-line log editor for Rivendell
|
||||
//
|
||||
// (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2016-2017 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
|
||||
@ -29,6 +29,7 @@
|
||||
#include <rddb.h>
|
||||
#include <rdlog.h>
|
||||
#include <rdlog_event.h>
|
||||
#include <rdloglock.h>
|
||||
#include <rdripc.h>
|
||||
#include <rduser.h>
|
||||
|
||||
@ -71,6 +72,7 @@ class MainObject : public QObject
|
||||
void Settime(int line,RDLogLine::TimeType type,const QTime &time=QTime());
|
||||
void Settrans(int line,RDLogLine::TransType type);
|
||||
void Unload();
|
||||
bool TryLock(RDLogLock *lock,const QString &logname);
|
||||
void OverwriteError(const QString &cmd) const;
|
||||
void DispatchCommand(QString cmd);
|
||||
QString ListLine(RDLogEvent *evt,int line) const;
|
||||
@ -92,6 +94,7 @@ class MainObject : public QObject
|
||||
RDRipc *edit_ripc;
|
||||
RDAirPlayConf *edit_airplay_conf;
|
||||
RDConfig *edit_config;
|
||||
RDLogLock *edit_log_lock;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user