2017-12-01 Fred Gleason <fredg@paravelsystems.com>

* Added an 'Engine=' directive to the [MySQL] section of
	rd.conf(5).
	* Refactored the schema update code to use standard form
	in rdadmin(1).
This commit is contained in:
Fred Gleason 2017-12-01 17:37:37 -05:00
parent cbba0eb10a
commit a8ae9f9bfa
54 changed files with 4210 additions and 4680 deletions

View File

@ -16394,3 +16394,8 @@
* Changed the wording of the 'Purge Logs' and 'Purge ELR Data'
control in the Edit Service dialog in rdadmin(1).
* Added 'RDLog::create()' and 'RDLog::remove()' static methods.
2017-12-01 Fred Gleason <fredg@paravelsystems.com>
* Added an 'Engine=' directive to the [MySQL] section of
rd.conf(5).
* Refactored the schema update code to use standard form
in rdadmin(1).

View File

@ -624,7 +624,7 @@ void MainObject::InitProvisioning() const
q=new RDSqlQuery(sql);
if(!q->first()) {
if(RDSvc::create(svcname,&err_msg,
rd_config->provisioningServiceTemplate())) {
rd_config->provisioningServiceTemplate(),rd_config)) {
syslog(LOG_INFO,"created new service entry \"%s\"",
(const char *)svcname);
}

View File

@ -26,6 +26,16 @@ Password=letmein
Database=Rivendell
Driver=QMYSQL3
; Specify the type of DB storage engine to use when creating new tables.
; To get a list of supported engine types, use the 'SHOW ENGINES;' command
; in mysql(1).
;
; It is also possible to specify 'default', in which case Rivendell will
; use whatever default engine type is configured in MySQL.
;
; The default value is 'default'.
Engine=MyISAM
[AudioStore]
MountSource=
MountType=

View File

@ -329,8 +329,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdtrimaudio.cpp\
moc_rdupload.cpp\
moc_rdwavedata_dialog.cpp\
moc_schedcartlist.cpp\
moc_schedruleslist.cpp
moc_schedcartlist.cpp
librd_la_LDFLAGS = -release $(VERSION)

View File

@ -64,6 +64,7 @@
#define DEFAULT_MYSQL_PASSWORD "letmein"
#define DEFAULT_MYSQL_DRIVER "QMYSQL3"
#define DEFAULT_MYSQL_HEARTBEAT_INTERVAL 360
#define DEFAULT_MYSQL_ENGINE "default"
#define MYSQL_BUILTIN_DATABASE "mysql"
#define POSTGRESQL_BUILTIN_DATABASE "template1"

View File

@ -2,7 +2,7 @@
//
// A container class for a Rivendell Base Configuration
//
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2004,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
@ -181,6 +181,18 @@ int RDConfig::mysqlHeartbeatInterval() const
}
QString RDConfig::mysqlEngine() const
{
return conf_mysql_engine;
}
QString RDConfig::createTablePostfix() const
{
return conf_create_table_postfix;
}
RDConfig::LogFacility RDConfig::logFacility() const
{
return conf_log_facility;
@ -557,6 +569,14 @@ void RDConfig::load()
conf_mysql_heartbeat_interval=
profile->intValue("mySQL","HeartbeatInterval",
DEFAULT_MYSQL_HEARTBEAT_INTERVAL);
conf_mysql_engine=
profile->stringValue("mySQL","Engine",DEFAULT_MYSQL_ENGINE);
if(conf_mysql_engine.lower()=="default") {
conf_create_table_postfix="";
}
else {
conf_create_table_postfix=QString(" engine ")+conf_mysql_engine;
}
facility=profile->stringValue("Logs","Facility",DEFAULT_LOG_FACILITY).lower();
if(facility=="syslog") {
@ -662,6 +682,8 @@ void RDConfig::clear()
conf_mysql_password="";
conf_mysql_driver="";
conf_mysql_heartbeat_interval=DEFAULT_MYSQL_HEARTBEAT_INTERVAL;
conf_mysql_engine=DEFAULT_MYSQL_ENGINE;
conf_create_table_postfix="";
conf_log_facility=RDConfig::LogSyslog;
conf_log_directory="";
conf_log_core_dump_directory=DEFAULT_LOG_CORE_DUMP_DIRECTORY;

View File

@ -60,6 +60,8 @@ class RDConfig
QString mysqlPassword() const;
QString mysqlDriver() const;
int mysqlHeartbeatInterval() const;
QString mysqlEngine() const;
QString createTablePostfix() const;
RDConfig::LogFacility logFacility() const;
QString logDirectory() const;
QString logCoreDumpDirectory() const;
@ -124,6 +126,8 @@ class RDConfig
QString conf_mysql_dbname;
QString conf_mysql_password;
QString conf_mysql_driver;
QString conf_mysql_engine;
QString conf_create_table_postfix;
int conf_mysql_heartbeat_interval;
RDConfig::LogFacility conf_log_facility;
QString conf_log_directory;

View File

@ -26,15 +26,15 @@
#include <rd.h>
void RDCreateLogTable(const QString &name)
void RDCreateLogTable(const QString &name,RDConfig *config)
{
QString sql=RDCreateLogTableSql(name);
QString sql=RDCreateLogTableSql(name,config);
RDSqlQuery *q=new RDSqlQuery(sql);
delete q;
}
QString RDCreateLogTableSql(QString name)
QString RDCreateLogTableSql(QString name,RDConfig *config)
{
return QString("create table if not exists `")+name+"`"+
"(ID INT NOT NULL PRIMARY KEY,"+
@ -78,22 +78,24 @@ QString RDCreateLogTableSql(QString name)
"EXT_ANNC_TYPE char(8),"+
"index COUNT_IDX (COUNT),"+
"index CART_NUMBER_IDX (CART_NUMBER),"+
"index LABEL_IDX (LABEL))";
"index LABEL_IDX (LABEL))"+
config->createTablePostfix();
}
QString RDCreateClockTableSql(QString name)
QString RDCreateClockTableSql(QString name,RDConfig *config)
{
return QString("create table `")+name+"` ("+
"ID int unsigned auto_increment not null primary key,"+
"EVENT_NAME char(64) not null,"+
"START_TIME int not null,"+
"LENGTH int not null,"+
"INDEX EVENT_NAME_IDX (EVENT_NAME))";
"INDEX EVENT_NAME_IDX (EVENT_NAME))"+
config->createTablePostfix();
}
QString RDCreateReconciliationTableSql(QString name)
QString RDCreateReconciliationTableSql(QString name,RDConfig *config)
{
QString sql=QString("create table `")+name+"` ("+
"ID int unsigned auto_increment primary key,"+
@ -130,13 +132,14 @@ QString RDCreateReconciliationTableSql(QString name)
"EXT_DATA char(32),"+
"EXT_EVENT_ID char(8),"+
"EXT_ANNC_TYPE char(8),"+
"index EVENT_DATETIME_IDX(EVENT_DATETIME))";
"index EVENT_DATETIME_IDX(EVENT_DATETIME))"+
config->createTablePostfix();
return sql;
}
QString RDCreateStackTableSql(QString name)
QString RDCreateStackTableSql(QString name,RDConfig *config)
{
QString sql;
sql=QString().sprintf("create table if not exists `%s_STACK` (\
@ -145,6 +148,7 @@ QString RDCreateStackTableSql(QString name)
ARTIST varchar(255),\
SCHED_CODES varchar(255),\
SCHEDULED_AT datetime default '1000-01-01 00:00:00')",
(const char *)name.replace(" ","_"));
(const char *)name.replace(" ","_"))+
config->createTablePostfix();
return sql;
}

View File

@ -18,15 +18,15 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qsqldatabase.h>
#include "rdconfig.h"
#ifndef RDCREATE_LOG_H
#define RDCREATE_LOG_H
void RDCreateLogTable(const QString &name);
QString RDCreateLogTableSql(QString name);
QString RDCreateClockTableSql(QString name);
QString RDCreateReconciliationTableSql(QString name);
QString RDCreateStackTableSql(QString name);
void RDCreateLogTable(const QString &name,RDConfig *config);
QString RDCreateLogTableSql(QString name,RDConfig *config);
QString RDCreateClockTableSql(QString name,RDConfig *config);
QString RDCreateReconciliationTableSql(QString name,RDConfig *config);
QString RDCreateStackTableSql(QString name,RDConfig *config);
#endif

View File

@ -2,7 +2,7 @@
//
// Create a new, empty Rivendell log table.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2003,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
@ -20,12 +20,13 @@
#include <rddb.h>
void RDCreateAuxFieldsTable(QString keyname)
void RDCreateAuxFieldsTable(QString keyname,RDConfig *config)
{
keyname.replace(" ","_");
QString sql=QString().sprintf("create table if not exists %s_FIELDS (\
CAST_ID int unsigned not null primary key)",
(const char *)keyname);
QString sql=QString("create table if not exists `")+
keyname+"_FIELDS` (CAST_ID int unsigned not null primary key) "+
config->createTablePostfix();
RDSqlQuery *q=new RDSqlQuery(sql);
delete q;
}

View File

@ -2,7 +2,7 @@
//
// Create a new, empty Rivendell log table.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2003,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
@ -18,12 +18,14 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qstring.h>
#ifndef RDRDCREATEAUXFIELDSTABLE_H
#define RDRDCREATEAUXFIELDSTABLE_H
void RDCreateAuxFieldsTable(QString keyname);
#include <qstring.h>
#include <rdconfig.h>
void RDCreateAuxFieldsTable(QString keyname,RDConfig *config);
#endif // RDRDCREATEAUXFIELDSTABLE_H

View File

@ -79,8 +79,9 @@ QSqlDatabase *RDInitDb (unsigned *schema,QString *error)
return db;
}
RDSqlQuery::RDSqlQuery (const QString &query, QSqlDatabase *dbase):
QSqlQuery (query,dbase)
//RDSqlQuery::RDSqlQuery (const QString &query, QSqlDatabase *dbase):
RDSqlQuery::RDSqlQuery(const QString &query,bool reconnect):
QSqlQuery (query)
{
//printf("lastQuery: %s\n",(const char *)lastQuery());
@ -94,23 +95,27 @@ RDSqlQuery::RDSqlQuery (const QString &query, QSqlDatabase *dbase):
#ifndef WIN32
syslog(LOG_ERR,(const char *)err);
#endif // WIN32
QSqlDatabase *ldb = QSqlDatabase::database();
// Something went wrong with the DB, trying a reconnect
ldb->removeDatabase(RDConfiguration()->mysqlDbname());
ldb->close();
db = NULL;
RDInitDb (&schema);
QSqlQuery::prepare (query);
QSqlQuery::exec ();
if (RDDbStatus()){
if (isActive()){
if(reconnect) {
QSqlDatabase *ldb = QSqlDatabase::database();
// Something went wrong with the DB, trying a reconnect
ldb->removeDatabase(RDConfiguration()->mysqlDbname());
ldb->close();
db = NULL;
RDInitDb (&schema);
QSqlQuery::prepare (query);
QSqlQuery::exec ();
if (RDDbStatus()){
if (isActive()){
RDDbStatus()->sendRecon();
}
else {
RDDbStatus()->sendDiscon(query);
}
}
else {
RDDbStatus()->sendRecon();
} else {
RDDbStatus()->sendDiscon(query);
}
}
} else {
RDDbStatus()->sendRecon();
}
}
void RDSqlDatabaseStatus::sendRecon()

View File

@ -48,7 +48,8 @@ class RDSqlDatabaseStatus : public QObject
class RDSqlQuery : public QSqlQuery
{
public:
RDSqlQuery ( const QString & query = QString::null, QSqlDatabase * db = 0 );
// RDSqlQuery(const QString &query=QString::null, QSqlDatabase * db = 0 );
RDSqlQuery(const QString &query=QString::null,bool reconnect=true);
};
// Setup the default database, returns true on success.

View File

@ -378,7 +378,7 @@ bool RDEventLine::load()
}
bool RDEventLine::save()
bool RDEventLine::save(RDConfig *config)
{
QString sql=QString().sprintf("select NAME from EVENTS where NAME=\"%s\"",
(const char *)event_name);
@ -444,8 +444,8 @@ bool RDEventLine::save()
return false;
}
delete q;
event_preimport_log->save();
event_postimport_log->save();
event_preimport_log->save(config);
event_postimport_log->save(config);
return true;
}

View File

@ -79,7 +79,7 @@ class RDEventLine
void setLength(int msecs);
void clear();
bool load();
bool save();
bool save(RDConfig *config);
bool generateLog(QString logname,const QString &svcname,
QString *errors, unsigned artistsep,QString clockname);
bool linkLog(RDLogEvent *e,int next_id,const QString &svcname,

View File

@ -487,7 +487,7 @@ QString RDLog::xml() const
bool RDLog::create(const QString &name,const QString &svc_name,
const QString &user_name,QString *err_msg)
const QString &user_name,QString *err_msg,RDConfig *config)
{
QString sql;
RDSqlQuery *q;
@ -529,7 +529,7 @@ bool RDLog::create(const QString &name,const QString &svc_name,
return false;
}
delete q;
RDCreateLogTable(RDLog::tableName(name));
RDCreateLogTable(RDLog::tableName(name),config);
*err_msg=QObject::tr("OK");
return true;
}

View File

@ -18,6 +18,9 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDLOG_H
#define RDLOG_H
#include <qsqldatabase.h>
#include <rdconfig.h>
@ -25,9 +28,6 @@
#include <rduser.h>
#include <rdstation.h>
#ifndef RDLOG_H
#define RDLOG_H
class RDLog
{
public:
@ -79,7 +79,8 @@ class RDLog
RDLogEvent *createLogEvent() const;
QString xml() const;
static bool create(const QString &name,const QString &svc_name,
const QString &user_name,QString *err_msg);
const QString &user_name,QString *err_msg,
RDConfig *config);
static bool exists(const QString &name);
static bool remove(const QString &name,RDStation *station,RDUser *user,
RDConfig *config);
@ -100,4 +101,4 @@ class RDLog
};
#endif
#endif // RDLOG_H

View File

@ -131,16 +131,16 @@ int RDLogEvent::load(bool track_ptrs)
return log_line.size();
}
void RDLogEvent::saveModified(bool update_tracks)
void RDLogEvent::saveModified(RDConfig *config,bool update_tracks)
{
for(unsigned i=0;i<log_line.size();i++) {
if(log_line[i]->hasBeenModified()) {
save(update_tracks, i);
save(config,update_tracks, i);
}
}
}
void RDLogEvent::save(bool update_tracks,int line)
void RDLogEvent::save(RDConfig *config,bool update_tracks,int line)
{
QString sql;
RDSqlQuery *q;
@ -154,7 +154,7 @@ void RDLogEvent::save(bool update_tracks,int line)
q=new RDSqlQuery(sql);
delete q;
}
RDCreateLogTable(log_name);
RDCreateLogTable(log_name,config);
if (log_line.size() > 0) {
QString values = "";
for(unsigned i=0;i<log_line.size();i++) {

View File

@ -23,6 +23,7 @@
#include <qdatetime.h>
#include <qsqldatabase.h>
#include <rdconfig.h>
#include <rdlog_line.h>
#ifndef RDLOG_EVENT_H
@ -42,8 +43,8 @@ class RDLogEvent
void setLogName(QString logname);
QString serviceName() const;
int load(bool track_ptrs=false);
void saveModified(bool update_tracks=true);
void save(bool update_tracks=true,int line=-1);
void saveModified(RDConfig *config,bool update_tracks=true);
void save(RDConfig *config,bool update_tracks=true,int line=-1);
int append(const QString &logname,bool track_ptrs=false);
int validate(QString *report,const QDate &date);
void clear();

View File

@ -441,7 +441,7 @@ bool RDReport::generateReport(const QDate &startdate,const QDate &enddate,
QSqlQuery *p;
p=new QSqlQuery(sql);
delete p;
sql=RDCreateReconciliationTableSql(mixname+"_SRT");
sql=RDCreateReconciliationTableSql(mixname+"_SRT",report_config);
q=new RDSqlQuery(sql);
delete q;

View File

@ -525,7 +525,8 @@ bool RDSvc::import(ImportSource src,const QDate &date,const QString &break_str,
"LINK_START_TIME time default NULL,"+
"LINK_LENGTH int default NULL,"+
"EVENT_USED enum('N','Y') default 'N',"+
"INDEX START_TIME_IDX (START_HOUR,START_SECS))";
"INDEX START_TIME_IDX (START_HOUR,START_SECS)) "+
svc_config->createTablePostfix();
q=new RDSqlQuery(sql);
delete q;
@ -728,7 +729,7 @@ bool RDSvc::generateLog(const QDate &date,const QString &logname,
if(RDLog::exists(logname)) {
RDLog::remove(logname,svc_station,user,svc_config);
}
RDLog::create(logname,svc_name,"RDLogManager",&err_msg);
RDLog::create(logname,svc_name,"RDLogManager",&err_msg,svc_config);
log=new RDLog(logname);
log->setDescription(RDDateDecode(descriptionTemplate(),date,svc_station,
svc_config,svc_name));
@ -867,7 +868,7 @@ bool RDSvc::linkLog(RDSvc::ImportSource src,const QDate &date,
dest_event->logLine(dest_event->size()-1)->setId(dest_event->nextId());
}
}
dest_event->save();
dest_event->save(svc_config);
//
// Update the Log Link Status
@ -999,19 +1000,12 @@ void RDSvc::clearLogLinks(RDSvc::ImportSource src,const QDate &date,
dest_event->logLine(dest_event->size()-1)->setId(dest_event->nextId());
}
}
dest_event->save();
dest_event->save(svc_config);
delete src_event;
delete dest_event;
}
void RDSvc::create(const QString exemplar) const
{
QString err_msg;
RDSvc::create(svc_name,&err_msg,exemplar);
}
void RDSvc::remove() const
{
RDSvc::remove(svc_name);
@ -1053,7 +1047,7 @@ QString RDSvc::xml() const
bool RDSvc::create(const QString &name,QString *err_msg,
const QString &exemplar)
const QString &exemplar,RDConfig *config)
{
QString sql;
RDSqlQuery *q;
@ -1335,7 +1329,7 @@ bool RDSvc::create(const QString &name,QString *err_msg,
//
// Create Service Reconciliation Table
//
sql=RDCreateReconciliationTableSql(RDSvc::svcTableName(name));
sql=RDCreateReconciliationTableSql(RDSvc::svcTableName(name),config);
q=new RDSqlQuery(sql);
delete q;

View File

@ -91,11 +91,10 @@ class RDSvc : public QObject
const QString &logname,QString *report);
void clearLogLinks(RDSvc::ImportSource src,const QDate &date,
const QString &logname);
void create(const QString exemplar) const;
void remove() const;
QString xml() const;
static bool create(const QString &name,QString *err_msg,
const QString &exemplar);
const QString &exemplar,RDConfig *config);
static void remove(const QString &name);
static bool exists(const QString &name);
static QString timeString(int hour,int secs);

View File

@ -18,23 +18,26 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdclock.h>
#include <rddb.h>
#include <schedruleslist.h>
#include <qmessagebox.h>
SchedRulesList::SchedRulesList(QString clockname)
SchedRulesList::SchedRulesList(QString clockname,RDConfig *config)
{
QString sql;
RDSqlQuery *q;
RDSqlQuery *q1;
sql=QString().sprintf("create table if not exists `%s_RULES` (\
CODE varchar(10) not null primary key,\
MAX_ROW int unsigned,\
MIN_WAIT int unsigned,\
NOT_AFTER varchar(10),\
OR_AFTER varchar(10),\
OR_AFTER_II varchar(10))",(const char*)clockname.replace(" ","_"));
sql=QString("create table if not exists `")+
RDClock::tableName(clockname)+"_RULES` ("+
"CODE varchar(10) not null primary key,"+
"MAX_ROW int unsigned,"+
"MIN_WAIT int unsigned,"+
"NOT_AFTER varchar(10),"+
"OR_AFTER varchar(10),"+
"OR_AFTER_II varchar(10)) "+
config->createTablePostfix();
q=new RDSqlQuery(sql);
delete q;

View File

@ -21,12 +21,12 @@
#ifndef SCHEDRULESLIST_H
#define SCHEDRULESLIST_H
#include <qsqldatabase.h>
#include <rdconfig.h>
class SchedRulesList
{
public:
SchedRulesList(QString clockname);
SchedRulesList(QString clockname,RDConfig *config);
~SchedRulesList();
void insertItem(int pos,int maxrow,int minwait,QString notafter,QString orafter,QString orafterii);
QString getItemSchedCode(int pos);

View File

@ -31,8 +31,9 @@
#include <rdcreateauxfieldstable.h>
#include <rdfeedlog.h>
#include <edit_feed.h>
#include <add_feed.h>
#include "add_feed.h"
#include "edit_feed.h"
#include "globals.h"
AddFeed::AddFeed(unsigned *id,QString *keyname,QWidget *parent)
: QDialog(parent,"",true)
@ -178,7 +179,7 @@ void AddFeed::okData()
q=new RDSqlQuery(sql);
delete q;
RDCreateFeedLog(feed_keyname_edit->text());
RDCreateAuxFieldsTable(feed_keyname_edit->text());
RDCreateAuxFieldsTable(feed_keyname_edit->text(),admin_config);
sql=QString().sprintf("select ID from FEEDS where KEY_NAME=\"%s\"",
(const char *)feed_keyname_edit->text());
q=new RDSqlQuery(sql);

View File

@ -141,12 +141,23 @@ QSizePolicy AddSvc::sizePolicy() const
void AddSvc::okData()
{
QString err_msg;
QString exemplar="";
if(svc_name_edit->text().isEmpty()) {
QMessageBox::warning(this,tr("Invalid Name"),
tr("You must give the service a name!"));
return;
}
if(svc_exemplar_box->currentItem()>0) {
exemplar=svc_exemplar_box->currentText();
}
if(!RDSvc::create(svc_name_edit->text(),&err_msg,exemplar,admin_config)) {
QMessageBox::warning(this,"RDAdmin - "+tr("Error"),err_msg);
return;
}
/*
RDSvc *svc=new RDSvc(svc_name_edit->text(),admin_station,admin_config,this);
if(svc->exists()) {
QMessageBox::warning(this,tr("Service Exists"),
@ -155,12 +166,13 @@ void AddSvc::okData()
return;
}
if(svc_exemplar_box->currentItem()==0) { // Create Empty Service
svc->create("");
svc->create("",admin_config);
}
else {
svc->create(svc_exemplar_box->currentText());
svc->create(svc_exemplar_box->currentText(),admin_config);
}
delete svc;
*/
*svc_name=svc_name_edit->text();
EditSvc *edit_svc=new EditSvc(svc_name_edit->text(),this);

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
//
// Create a Rivendell Database
//
// (C) Copyright 2002-2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-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
@ -23,6 +23,8 @@
#include <qstring.h>
#include <rdconfig.h>
//
// UpdateDB return codes
//
@ -30,10 +32,10 @@
#define UPDATEDB_BACKUP_FAILED -1
#define UPDATEDB_QUERY_FAILED -2
bool CreateDb(QString name,QString pwd);
bool InitDb(QString name,QString pwd,QString stationname);
int UpdateDb(int ver);
bool CreateDb(QString name,QString pwd,RDConfig *config);
bool InitDb(QString name,QString pwd,QString stationname,RDConfig *config);
int UpdateDb(int ver,RDConfig *config);
#endif
#endif // CREATEDB_H

View File

@ -148,7 +148,7 @@ QString format_remote_host(const char *hostname) {
bool OpenDb(QString dbname,QString login,QString pwd,
QString host,QString stationname,bool interactive)
QString host,QString stationname,bool interactive,RDConfig *config)
{
//
// Yeesh, this whole method really needs a rewrite!
@ -263,7 +263,7 @@ and we will try to get this straightened out.");
db->removeDatabase(dbname);
return false;
}
if(!CreateDb(login,pwd)) { // Can't create tables.
if(!CreateDb(login,pwd,config)) { // Can't create tables.
PrintError(QObject::tr("Unable to create Rivendell Database!"),
interactive);
db->removeDatabase(dbname);
@ -279,7 +279,7 @@ and we will try to get this straightened out.");
db->removeDatabase(dbname);
return false;
}
if(!InitDb(login,pwd,stationname)) { // Can't initialize tables.
if(!InitDb(login,pwd,stationname,config)) { // Can't initialize tables.
PrintError(QObject::tr("Unable to initialize Rivendell Database!"),
interactive);
db->removeDatabase(dbname);
@ -360,7 +360,7 @@ with administrative privledges, otherwise hit cancel.");
db->removeDatabase(dbname);
return false;
}
if(!CreateDb(login,pwd)) { // Can't create tables.
if(!CreateDb(login,pwd,config)) { // Can't create tables.
PrintError(QObject::tr("Unable to create Rivendell Database!"),
interactive);
db->removeDatabase(dbname);
@ -376,7 +376,7 @@ with administrative privledges, otherwise hit cancel.");
db->removeDatabase(dbname);
return false;
}
if(!InitDb(login,pwd,stationname)) { // Can't initialize tables.
if(!InitDb(login,pwd,stationname,config)) { // Can't initialize tables.
PrintError(QObject::tr("Unable to initialize Rivendell Database!"),
interactive);
db->removeDatabase(dbname);
@ -397,7 +397,7 @@ on this machine for a few seconds. Continue?"),
}
}
RDKillDaemons();
if((err=UpdateDb(db_ver))!=UPDATEDB_SUCCESS) {
if((err=UpdateDb(db_ver,config))!=UPDATEDB_SUCCESS) {
err_str=QObject::tr("Unable to update Rivendell Database:");
switch(err) {
case UPDATEDB_BACKUP_FAILED:

View File

@ -23,8 +23,10 @@
#include <qstring.h>
#include <rdconfig.h>
bool OpenDb(QString dbname,QString username,QString password,QString hostname,
QString stationname,bool interactive);
QString stationname,bool interactive,RDConfig *config);
#endif // OPENDB_H

View File

@ -158,7 +158,7 @@ MainWidget::MainWidget(QWidget *parent)
//
if(!OpenDb(admin_config->mysqlDbname(),admin_config->mysqlUsername(),
admin_config->mysqlPassword(),admin_config->mysqlHostname(),
admin_config->stationName(),true)) {
admin_config->stationName(),true,admin_config)) {
exit(1);
}
new RDDbHeartbeat(admin_config->mysqlHeartbeatInterval());
@ -483,7 +483,7 @@ void MainWidget::restoreData()
}
delete q;
admin_skip_backup=true;
UpdateDb(ver);
UpdateDb(ver,admin_config);
QMessageBox::information(this,tr("Restore Complete"),
tr("Restore completed successfully."));
RDStartDaemons();
@ -604,7 +604,7 @@ int cmdline_main(int argc,char *argv[])
}
if(!OpenDb(admin_config->mysqlDbname(),admin_config->mysqlUsername(),
admin_config->mysqlPassword(),admin_config->mysqlHostname(),
station_name,false)) {
station_name,false,admin_config)) {
return 1;
}

View File

@ -583,11 +583,15 @@ a záloha původní databáze uložena v </translation>
</message>
<message>
<source>Service Exists</source>
<translation>Služba existuje</translation>
<translation type="obsolete">Služba existuje</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>Služba již existuje!</translation>
<translation type="obsolete">Služba již existuje!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -549,11 +549,15 @@ worden. Aktuelle Version</translation>
</message>
<message>
<source>Service Exists</source>
<translation>Service existiert</translation>
<translation type="obsolete">Service existiert</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>Service existiert bereits!</translation>
<translation type="obsolete">Service existiert bereits!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -583,11 +583,15 @@ y un respaldo de la base de datos se guardó en </translation>
</message>
<message>
<source>Service Exists</source>
<translation>El servicio ya existe</translation>
<translation type="obsolete">El servicio ya existe</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>¡El servicio ya existe!</translation>
<translation type="obsolete">¡El servicio ya existe!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -357,11 +357,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Service Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Service Already Exists!</source>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -531,11 +531,15 @@ oppdatert til versjon </translation>
</message>
<message>
<source>Service Exists</source>
<translation>Tenesta eksisterer</translation>
<translation type="obsolete">Tenesta eksisterer</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>Tenesta finst frå før!</translation>
<translation type="obsolete">Tenesta finst frå før!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -531,11 +531,15 @@ oppdatert til versjon </translation>
</message>
<message>
<source>Service Exists</source>
<translation>Tenesta eksisterer</translation>
<translation type="obsolete">Tenesta eksisterer</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>Tenesta finst frå før!</translation>
<translation type="obsolete">Tenesta finst frå før!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -532,11 +532,15 @@ atualizada para a Versão</translation>
</message>
<message>
<source>Service Exists</source>
<translation>Serviço existente</translation>
<translation type="obsolete">Serviço existente</translation>
</message>
<message>
<source>Service Already Exists!</source>
<translation>Serviço Existe!</translation>
<translation type="obsolete">Serviço Existe!</translation>
</message>
<message>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>

View File

@ -871,7 +871,7 @@ void ListLog::loadButtonData()
break;
case 3:
if(!RDLog::create(name,svcname,rdripc->user(),&err_msg)) {
if(!RDLog::create(name,svcname,rdripc->user(),&err_msg,air_config)) {
QMessageBox::warning(this,"RDAirPlay - "+tr("Error"),err_msg);
return;
}

View File

@ -755,7 +755,7 @@ bool LogPlay::refresh()
void LogPlay::save(int line)
{
RDLogEvent::save(line);
RDLogEvent::save(air_config,line);
if(play_log!=NULL) {
delete play_log;
}

View File

@ -41,13 +41,13 @@
#include <rdconf.h>
#include <rddatedialog.h>
#include <globals.h>
#include <add_meta.h>
#include <edit_log.h>
#include <edit_logline.h>
#include <edit_marker.h>
#include <edit_track.h>
#include <edit_chain.h>
#include "globals.h"
#include "add_meta.h"
#include "edit_chain.h"
#include "edit_log.h"
#include "edit_logline.h"
#include "edit_marker.h"
#include "edit_track.h"
//
// Icons
@ -1098,14 +1098,14 @@ void EditLog::saveasData()
if(log->exec()<0) {
return;
}
if(!RDLog::create(logname,svcname,rdripc->user(),&err_msg)) {
if(!RDLog::create(logname,svcname,rdripc->user(),&err_msg,log_config)) {
QMessageBox::warning(this,"RDLogEdit - "+tr("Error"),err_msg);
return;
}
delete edit_log;
edit_newlogs->push_back(logname);
edit_log=new RDLog(logname);
RDCreateLogTable(RDLog::tableName(logname));
RDCreateLogTable(RDLog::tableName(logname),log_config);
edit_log_event->setLogName(RDLog::tableName(logname));
for(int i=0;i<edit_service_box->count();i++) {
if(edit_service_box->text(i)==svcname) {
@ -1372,7 +1372,7 @@ void EditLog::SaveLog()
edit_log->setEndDate(QDate());
}
edit_log->setAutoRefresh(edit_autorefresh_box->currentItem()==0);
edit_log_event->save();
edit_log_event->save(log_config);
edit_log->
setModifiedDatetime(QDateTime(QDate::currentDate(),QTime::currentTime()));
}

View File

@ -424,7 +424,7 @@ void MainWidget::addData()
QString username(rdripc->user());
#endif // WIN32
QString err_msg;
if(!RDLog::create(logname,svcname,username,&err_msg)) {
if(!RDLog::create(logname,svcname,username,&err_msg,log_config)) {
QMessageBox::warning(this,"RDLogEdit - "+tr("Error"),err_msg);
return;
}

View File

@ -1951,7 +1951,7 @@ void VoiceTracker::closeData()
stopData();
CheckChanges();
if(track_size_altered) {
track_log_event->save();
track_log_event->save(log_config);
}
done(0);
}
@ -2318,10 +2318,10 @@ void VoiceTracker::SaveTrack(int line)
}
if(track_size_altered) {
track_log_event->save();
track_log_event->save(log_config);
}
else {
track_log_event->saveModified();
track_log_event->saveModified(log_config);
}
track_log->

View File

@ -99,7 +99,7 @@ int RunLogOperation(int argc,char *argv[],const QString &svcname,
}
log->removeTracks(rdstation_conf,rduser,config);
srand(QTime::currentTime().msec());
sql=RDCreateStackTableSql(svcname_table);
sql=RDCreateStackTableSql(svcname_table,config);
q=new RDSqlQuery(sql);
if(!q->isActive()) {
fprintf(stderr,"SQL: %s\n",(const char *)sql);

View File

@ -38,13 +38,14 @@
#include <rdcreate_log.h>
#include <rdescape_string.h>
#include <edit_clock.h>
#include <add_clock.h>
#include <edit_eventline.h>
#include <edit_perms.h>
#include <edit_event.h>
#include <list_clocks.h>
#include <edit_schedrules.h>
#include "edit_clock.h"
#include "add_clock.h"
#include "edit_eventline.h"
#include "edit_perms.h"
#include "edit_event.h"
#include "globals.h"
#include "list_clocks.h"
#include "edit_schedrules.h"
EditClock::EditClock(QString clockname,bool new_clock,
@ -240,7 +241,7 @@ EditClock::EditClock(QString clockname,bool new_clock,
//
// Populate Data
//
sched_rules_list = new SchedRulesList(clockname);
sched_rules_list = new SchedRulesList(clockname,log_config);
edit_clock=new RDClock();
edit_clock->setName(clockname);
edit_clock->load();
@ -498,7 +499,7 @@ void EditClock::saveAsData()
}
delete q;
edit_clock->setName(clockname);
sql=RDCreateClockTableSql(RDClock::tableName(clockname));
sql=RDCreateClockTableSql(RDClock::tableName(clockname),log_config);
q=new RDSqlQuery(sql);
delete q;

View File

@ -786,9 +786,9 @@ EditEvent::EditEvent(QString eventname,bool new_event,
event_color_button->setPalette(QPalette(color,backgroundColor()));
}
str=event_event->nestedEvent();
sql=QString().sprintf("select NAME from EVENTS where NAME!=\"%s\"\
order by NAME",
(const char *)eventname);
sql=QString("select NAME from EVENTS where ")+
"NAME!=\""+RDEscapeString(eventname)+"\""+
"order by NAME";
q=new RDSqlQuery(sql);
while(q->next()) {
event_nestevent_box->insertItem(q->value(0).toString());
@ -1507,10 +1507,10 @@ void EditEvent::Save()
listname.replace(" ","_");
event_preimport_list->logEvent()->
setLogName(QString().sprintf("%s_PRE",(const char *)listname));
event_preimport_list->logEvent()->save(false);
event_preimport_list->logEvent()->save(log_config,false);
event_postimport_list->logEvent()->
setLogName(QString().sprintf("%s_POST",(const char *)listname));
event_postimport_list->logEvent()->save(false);
event_postimport_list->logEvent()->save(log_config,false);
event_saved=true;
}

View File

@ -31,11 +31,11 @@
#include <rddb.h>
#include <rdlistviewitem.h>
#include <edit_schedrules.h>
#include <edit_schedcoderules.h>
#include <schedruleslist.h>
#include <list_clocks.h>
#include "edit_schedrules.h"
#include "edit_schedcoderules.h"
#include "globals.h"
#include "list_clocks.h"
#include "schedruleslist.h"
EditSchedRules::EditSchedRules(QString clock,unsigned *artistsep,SchedRulesList *schedruleslist,bool *rules_modified,QWidget *parent)
: QDialog(parent,"",true)
@ -221,7 +221,7 @@ void EditSchedRules::importData()
return;
}
delete listclocks;
SchedRulesList *import_list=new SchedRulesList(clockname);
SchedRulesList *import_list=new SchedRulesList(clockname,log_config);
list_schedCodes_view->clear();
for (int i=0; i<import_list->getNumberOfItems(); i++)

View File

@ -37,9 +37,9 @@
#include <rdtextfile.h>
#include <rdcreate_log.h>
#include <generate_log.h>
#include <edit_grid.h>
#include <globals.h>
#include "edit_grid.h"
#include "generate_log.h"
#include "globals.h"
//
// Icons
@ -345,7 +345,8 @@ void GenerateLog::createData()
RDSqlQuery *q;
srand(QTime::currentTime().msec());
sql=RDCreateStackTableSql(gen_service_box->currentText().replace(" ","_"));
sql=RDCreateStackTableSql(gen_service_box->currentText().replace(" ","_"),
log_config);
q=new RDSqlQuery(sql);
if(!q->isActive()) {

View File

@ -155,6 +155,7 @@ void ImportListView::refreshList(int line)
item->setText(3,RDGetTimeLength(logline->forcedLength(),false,false));
total_len+=logline->forcedLength();
switch(logline->transType()) {
printf("line: %d transtype: %d\n",line,logline->transType());
case RDLogLine::Play:
item->setText(5,tr("PLAY"));
break;

View File

@ -32,11 +32,11 @@
#include <rdevent.h>
#include <rdcreate_log.h>
#include <list_clocks.h>
#include <add_clock.h>
#include <edit_clock.h>
#include <globals.h>
#include <rename_item.h>
#include "add_clock.h"
#include "edit_clock.h"
#include "globals.h"
#include "list_clocks.h"
#include "rename_item.h"
ListClocks::ListClocks(QString *clockname,QWidget *parent)
: QDialog(parent,"",true)
@ -241,7 +241,7 @@ void ListClocks::addData()
(const char *)clockname);
q=new RDSqlQuery(sql);
delete q;
sql=RDCreateClockTableSql(RDClock::tableName(clockname));
sql=RDCreateClockTableSql(RDClock::tableName(clockname),log_config);
q=new RDSqlQuery(sql);
delete q;
EditClock *clock_dialog=new EditClock(clockname,true,&new_clocks,this);

View File

@ -368,7 +368,7 @@ void MainObject::Save()
Saveas(edit_log->name());
}
else {
edit_log_event->save();
edit_log_event->save(edit_config);
edit_log->setDescription(edit_description);
edit_log->setStartDate(edit_start_date);
edit_log->setEndDate(edit_end_date);
@ -404,9 +404,9 @@ void MainObject::Saveas(const QString &logname)
"SERVICE=\""+RDEscapeString(edit_service)+"\"";
q=new RDSqlQuery(sql);
delete q;
RDCreateLogTable(RDLog::tableName(logname));
RDCreateLogTable(RDLog::tableName(logname),edit_config);
edit_log_event->setLogName(RDLog::tableName(logname));
edit_log_event->save();
edit_log_event->save(edit_config);
delete edit_log;
edit_log=log;
edit_modified=false;

View File

@ -2,7 +2,7 @@
//
// A Database Check/Repair Tool for Rivendell.
//
// (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
@ -357,7 +357,8 @@ void MainObject::CheckClocks()
(const char *)q->value(0).toString());
fflush(NULL);
if(UserResponse()) {
sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()));
sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()),
rdconfig);
q2=new QSqlQuery(sql);
delete q2;
}
@ -392,7 +393,7 @@ void MainObject::CheckEvents()
(const char *)q->value(0).toString());
fflush(NULL);
if(UserResponse()) {
sql=RDCreateLogTableSql(eventname+"_PRE");
sql=RDCreateLogTableSql(eventname+"_PRE",rdconfig);
q2=new QSqlQuery(sql);
delete q2;
}
@ -409,7 +410,7 @@ void MainObject::CheckEvents()
(const char *)q->value(0).toString());
fflush(NULL);
if(UserResponse()) {
sql=RDCreateLogTableSql(eventname+"_POST");
sql=RDCreateLogTableSql(eventname+"_POST",rdconfig);
q2=new QSqlQuery(sql);
delete q2;
}

View File

@ -342,7 +342,8 @@ void MainObject::Revert251() const
sql=QString("select NAME from CLOCKS");
q=new QSqlQuery(sql);
while(q->next()) {
sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()));
sql=RDCreateClockTableSql(RDClock::tableName(q->value(0).toString()),
rev_config);
q1=new QSqlQuery(sql);
delete q1;
sql=QString("select EVENT_NAME,START_TIME,LENGTH from CLOCK_METADATA ")+
@ -377,7 +378,8 @@ void MainObject::Revert252() const
sql=QString("select NAME from EVENTS");
q=new QSqlQuery(sql);
while(q->next()) {
RDCreateLogTable(RDEvent::preimportTableName(q->value(0).toString()));
RDCreateLogTable(RDEvent::preimportTableName(q->value(0).toString()),
rev_config);
sql=QString("select COUNT,TYPE,TRANS_TYPE,CART_NUMBER,TEXT ")+
"from EVENT_METADATA where "+
"(EVENT_NAME=\""+RDEscapeString(q->value(0).toString())+"\")&&"+
@ -396,7 +398,8 @@ void MainObject::Revert252() const
}
delete q1;
RDCreateLogTable(RDEvent::postimportTableName(q->value(0).toString()));
RDCreateLogTable(RDEvent::postimportTableName(q->value(0).toString()),
rev_config);
sql=QString("select COUNT,TYPE,TRANS_TYPE,CART_NUMBER,TEXT ")+
"from EVENT_METADATA where "+
"(EVENT_NAME=\""+RDEscapeString(q->value(0).toString())+"\")&&"+

View File

@ -61,7 +61,8 @@ void Xport::AddLog()
}
QString err_msg;
if(!RDLog::create(log_name,service_name,xport_user->name(),&err_msg)) {
if(!RDLog::create(log_name,service_name,xport_user->name(),&err_msg,
xport_config)) {
XmlExit(err_msg,500,"logs.cpp",LINE_NUMBER);
}
XmlExit("OK",200,"logs.cpp",LINE_NUMBER);
@ -500,7 +501,7 @@ void Xport::SaveLog()
log->setEndDate(end_date);
log->setModifiedDatetime(QDateTime::currentDateTime());
logevt->save();
logevt->save(xport_config);
XmlExit(QString().sprintf("OK Saved %d events",logevt->size()),
200,"logs.cpp",LINE_NUMBER);