mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-12 14:47:44 +02:00
2017-12-27 Fred Gleason <fredg@paravelsystems.com>
* Added log locking logic to rdairplay(1).
This commit is contained in:
parent
afa98a737f
commit
f624114e60
@ -16541,3 +16541,5 @@
|
||||
* Added a lock check for before deleting logs in rdlogedit(1).
|
||||
2017-12-22 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a lock check for before deleting logs in rdclilogedit(1).
|
||||
2017-12-27 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added log locking logic to rdairplay(1).
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// The full log list for RDAirPlay
|
||||
//
|
||||
// (C) Copyright 2002-2006,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-2006,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
|
||||
@ -856,21 +856,22 @@ void ListLog::loadButtonData()
|
||||
QString svcname=list_log->serviceName();
|
||||
QString err_msg;
|
||||
RDLog *edit_log;
|
||||
RDLogLock *log_lock=NULL;
|
||||
|
||||
switch(list_logs_dialog->exec(&name,&svcname)) {
|
||||
case 0:
|
||||
switch((ListLogs::Operation)list_logs_dialog->exec(&name,&svcname,&log_lock)) {
|
||||
case ListLogs::Load:
|
||||
list_log->setLogName(RDLog::tableName(name));
|
||||
list_log->load();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case ListLogs::Save:
|
||||
list_log->save();
|
||||
edit_log=
|
||||
new RDLog(list_log->logName().left(list_log->logName().length()-4));
|
||||
delete edit_log;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case ListLogs::SaveAs:
|
||||
if(!RDLog::create(name,svcname,rdripc->user(),&err_msg,air_config)) {
|
||||
QMessageBox::warning(this,"RDAirPlay - "+tr("Error"),err_msg);
|
||||
return;
|
||||
@ -880,9 +881,15 @@ void ListLog::loadButtonData()
|
||||
list_log->save();
|
||||
break;
|
||||
|
||||
case -1:
|
||||
case ListLogs::Unload:
|
||||
list_log->clear();
|
||||
break;
|
||||
|
||||
case ListLogs::Cancel:
|
||||
break;
|
||||
}
|
||||
if(log_lock!=NULL) {
|
||||
delete log_lock;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <qmessagebox.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <rdadd_log.h>
|
||||
@ -121,10 +122,11 @@ QSizePolicy ListLogs::sizePolicy() const
|
||||
}
|
||||
|
||||
|
||||
int ListLogs::exec(QString *logname,QString *svcname)
|
||||
int ListLogs::exec(QString *logname,QString *svcname,RDLogLock **log_lock)
|
||||
{
|
||||
list_logname=logname;
|
||||
list_svcname=svcname;
|
||||
list_log_lock=log_lock;
|
||||
list_saveas_button->setEnabled(rduser->createLog());
|
||||
QStringList services_list;
|
||||
QString sql=QString("select SERVICE_NAME from SERVICE_PERMS where ")+
|
||||
@ -149,7 +151,7 @@ void ListLogs::filterChangedData(const QString &where_sql)
|
||||
|
||||
void ListLogs::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
done(1);
|
||||
done(ListLogs::Cancel);
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +168,8 @@ void ListLogs::loadButtonData()
|
||||
return;
|
||||
}
|
||||
*list_logname=item->text(0);
|
||||
done(0);
|
||||
*list_log_lock=NULL;
|
||||
done(ListLogs::Load);
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +179,20 @@ void ListLogs::saveButtonData()
|
||||
saveAsButtonData();
|
||||
}
|
||||
else {
|
||||
done(2);
|
||||
*list_log_lock=new RDLogLock(*list_logname,rduser,rdstation_conf,this);
|
||||
if(!TryLock(*list_log_lock)) {
|
||||
delete *list_log_lock;
|
||||
*list_log_lock=NULL;
|
||||
return;
|
||||
}
|
||||
if(list_log->isRefreshable()) {
|
||||
QMessageBox::warning(this,"RDAirPlay - "+tr("Error"),
|
||||
tr("You must refresh the log before it can be saved."));
|
||||
delete *list_log_lock;
|
||||
*list_log_lock=NULL;
|
||||
return;
|
||||
}
|
||||
done(ListLogs::Save);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +204,6 @@ void ListLogs::saveAsButtonData()
|
||||
RDAddLog *log;
|
||||
log=new RDAddLog(&logname,&svcname,RDLogFilter::StationFilter,rduser,
|
||||
rdstation_conf,tr("Rename Log"),this);
|
||||
|
||||
if(log->exec()<0) {
|
||||
delete log;
|
||||
return;
|
||||
@ -196,19 +211,21 @@ void ListLogs::saveAsButtonData()
|
||||
delete log;
|
||||
*list_logname=logname;
|
||||
*list_svcname=svcname;
|
||||
done(3);
|
||||
done(ListLogs::SaveAs);
|
||||
}
|
||||
|
||||
|
||||
void ListLogs::unloadButtonData()
|
||||
{
|
||||
done(-1);
|
||||
*list_log_lock=NULL;
|
||||
done(ListLogs::Unload);
|
||||
}
|
||||
|
||||
|
||||
void ListLogs::cancelButtonData()
|
||||
{
|
||||
done(1);
|
||||
*list_log_lock=NULL;
|
||||
done(ListLogs::Cancel);
|
||||
}
|
||||
|
||||
|
||||
@ -252,3 +269,22 @@ void ListLogs::RefreshList()
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
|
||||
|
||||
bool ListLogs::TryLock(RDLogLock *lock)
|
||||
{
|
||||
QString username;
|
||||
QString stationname;
|
||||
QHostAddress addr;
|
||||
|
||||
if(!lock->tryLock(&username,&stationname,&addr)) {
|
||||
QString msg=tr("Log already being edited by")+" "+username+"@"+stationname;
|
||||
if(stationname!=addr.toString()) {
|
||||
msg+=" ["+addr.toString()+"]";
|
||||
}
|
||||
msg+=".";
|
||||
QMessageBox::warning(this,"RDAirPlay - "+tr("Log Locked"),msg);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include <rdlogfilter.h>
|
||||
#include <rdloglock.h>
|
||||
|
||||
#include <log_play.h>
|
||||
|
||||
@ -35,12 +36,13 @@ class ListLogs : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Operation {Load=0,Cancel=1,Save=2,SaveAs=3,Unload=4};
|
||||
ListLogs(LogPlay *log,QWidget *parent=0);
|
||||
QSize sizeHint() const;
|
||||
QSizePolicy sizePolicy() const;
|
||||
|
||||
public slots:
|
||||
int exec(QString *logname,QString *svcname);
|
||||
int exec(QString *logname,QString *svcname,RDLogLock **loglock);
|
||||
|
||||
private slots:
|
||||
void filterChangedData(const QString &where_sql);
|
||||
@ -57,6 +59,7 @@ class ListLogs : public QDialog
|
||||
|
||||
private:
|
||||
void RefreshList();
|
||||
bool TryLock(RDLogLock *lock);
|
||||
RDLogFilter *list_filter_widget;
|
||||
QListView *list_log_list;
|
||||
QString *list_logname;
|
||||
@ -67,6 +70,7 @@ class ListLogs : public QDialog
|
||||
QPushButton *list_saveas_button;
|
||||
QPushButton *list_cancel_button;
|
||||
LogPlay *list_log;
|
||||
RDLogLock **list_log_lock;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1361,6 +1361,14 @@ void LogPlay::resync()
|
||||
}
|
||||
|
||||
|
||||
bool LogPlay::isRefreshable() const
|
||||
{
|
||||
return (play_log->exists())&&
|
||||
(play_log->linkDatetime()==play_link_datetime)&&
|
||||
(play_log->modifiedDatetime()>play_modified_datetime);
|
||||
}
|
||||
|
||||
|
||||
void LogPlay::transTimerData()
|
||||
{
|
||||
int lines[TRANSPORT_QUANTITY];
|
||||
|
@ -115,6 +115,7 @@ class LogPlay : public QObject,public RDLogEvent
|
||||
QTime nextStop() const;
|
||||
bool running(bool include_paused=true);
|
||||
void resync();
|
||||
bool isRefreshable() const;
|
||||
|
||||
private slots:
|
||||
void transTimerData();
|
||||
|
@ -456,6 +456,22 @@ poslechu</translation>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -456,6 +456,22 @@ vorhören</translation>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -456,6 +456,22 @@ Final</translation>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -456,6 +456,22 @@ la Fin</translation>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -462,6 +462,22 @@ Tail</source>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -462,6 +462,22 @@ Tail</source>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
@ -457,6 +457,22 @@ Log</source>
|
||||
<source>Save As</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log already being edited by</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log Locked</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>You must refresh the log before it can be saved.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LogLineBox</name>
|
||||
|
Loading…
x
Reference in New Issue
Block a user