mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-25 16:58:04 +02:00
2018-01-31 Fred Gleason <fredg@paravelsystems.com>
* Converted rdrepld(8) to use RDApplication.
This commit is contained in:
parent
99814a9f00
commit
2103fa72c1
@ -16615,3 +16615,5 @@
|
||||
* Converted rdlogmanager(1) to use RDApplication.
|
||||
2018-01-31 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Converted rdpanel(1) to use RDApplication.
|
||||
2018-01-31 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Converted rdrepld(8) to use RDApplication.
|
||||
|
@ -29,8 +29,7 @@ moc_%.cpp: %.h
|
||||
$(MOC) $< -o $@
|
||||
|
||||
bin_PROGRAMS = rdrepld
|
||||
dist_rdrepld_SOURCES = globals.h\
|
||||
rdrepld.cpp rdrepld.h \
|
||||
dist_rdrepld_SOURCES = rdrepld.cpp rdrepld.h \
|
||||
replconfig.cpp replconfig.h\
|
||||
replfactory.cpp replfactory.h\
|
||||
citadelxds.cpp citadelxds.h
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Replicator implementation for the Citadel XDS Portal
|
||||
//
|
||||
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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
|
||||
@ -26,6 +26,7 @@
|
||||
#include <qfileinfo.h>
|
||||
#include <qdatetime.h>
|
||||
|
||||
#include <rdapplication.h>
|
||||
#include <rdaudioconvert.h>
|
||||
#include <rdcart.h>
|
||||
#include <rdcut.h>
|
||||
@ -37,7 +38,7 @@
|
||||
#include <rdtempdirectory.h>
|
||||
#include <rdupload.h>
|
||||
|
||||
#include <citadelxds.h>
|
||||
#include "citadelxds.h"
|
||||
|
||||
#define RD_MAX_CART_NUMBER 999999
|
||||
|
||||
@ -86,10 +87,10 @@ void CitadelXds::CheckIsciXreference()
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
|
||||
QFileInfo *fi=new QFileInfo(rdsystem->isciXreferencePath());
|
||||
QFileInfo *fi=new QFileInfo(rda->system()->isciXreferencePath());
|
||||
if(fi->exists()) {
|
||||
if(fi->lastModified()>xds_isci_datetime) {
|
||||
if(LoadIsciXreference(rdsystem->isciXreferencePath())) {
|
||||
if(LoadIsciXreference(rda->system()->isciXreferencePath())) {
|
||||
sql="update VERSION set LAST_ISCI_XREFERENCE=now()";
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
@ -99,9 +100,9 @@ void CitadelXds::CheckIsciXreference()
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogErr,
|
||||
rda->config()->log("rdrepld",RDConfig::LogErr,
|
||||
QString().sprintf("unable to load ISCI cross reference file \"%s\"",
|
||||
(const char *)rdsystem->isciXreferencePath()));
|
||||
(const char *)rda->system()->isciXreferencePath()));
|
||||
}
|
||||
delete fi;
|
||||
}
|
||||
@ -121,9 +122,9 @@ bool CitadelXds::LoadIsciXreference(const QString &filename)
|
||||
unsigned linenum=3;
|
||||
|
||||
if((f=fopen(filename,"r"))==NULL) {
|
||||
rdconfig->log("rdrepld",RDConfig::LogErr,
|
||||
rda->config()->log("rdrepld",RDConfig::LogErr,
|
||||
QString().sprintf("unable to load ISCI cross reference file \"%s\" [%s]",
|
||||
(const char *)rdsystem->isciXreferencePath(),
|
||||
(const char *)rda->system()->isciXreferencePath(),
|
||||
strerror(errno)));
|
||||
return false;
|
||||
}
|
||||
@ -172,31 +173,31 @@ bool CitadelXds::LoadIsciXreference(const QString &filename)
|
||||
delete q;
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
rda->config()->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
sprintf("invalid date in line %d of \"%s\"",
|
||||
linenum,(const char *)filename));
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
rda->config()->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
sprintf("invalid FILENAME field \"%s\" in line %d of \"%s\"",
|
||||
(const char *)fields[8],linenum,(const char *)filename));
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
rda->config()->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
sprintf("invalid date in line %d of \"%s\"",
|
||||
linenum,(const char *)filename));
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogDebug,QString().
|
||||
rda->config()->log("rdrepld",RDConfig::LogDebug,QString().
|
||||
sprintf("missing/invalid cart number in line %d of \"%s\"",
|
||||
linenum,(const char *)filename));
|
||||
}
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
rda->config()->log("rdrepld",RDConfig::LogWarning,QString().
|
||||
sprintf("line %d malformed in \"%s\"",
|
||||
linenum,(const char *)filename));
|
||||
}
|
||||
@ -206,9 +207,9 @@ bool CitadelXds::LoadIsciXreference(const QString &filename)
|
||||
//
|
||||
// Clean Up
|
||||
//
|
||||
rdconfig->log("rdrepld",RDConfig::LogInfo,
|
||||
rda->config()->log("rdrepld",RDConfig::LogInfo,
|
||||
QString().sprintf("loaded ISCI cross reference file \"%s\"",
|
||||
(const char *)rdsystem->isciXreferencePath()));
|
||||
(const char *)rda->system()->isciXreferencePath()));
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
@ -347,7 +348,7 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
|
||||
}
|
||||
RDSettings *settings=new RDSettings();
|
||||
QString tempfile=RDTempDirectory::basePath()+"/"+filename;
|
||||
RDAudioConvert *conv=new RDAudioConvert(rdconfig->stationName());
|
||||
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
|
||||
conv->setSourceFile(RDCut::pathName(cutname));
|
||||
conv->setDestinationFile(tempfile);
|
||||
conv->setRange(cut->startPoint(),cut->endPoint());
|
||||
@ -366,7 +367,7 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
|
||||
break;
|
||||
|
||||
default:
|
||||
rdconfig->log("rdrepld",RDConfig::LogErr,
|
||||
rda->config()->log("rdrepld",RDConfig::LogErr,
|
||||
QString().sprintf("CitadelXds: audio conversion failed: %s, cutname: %s",
|
||||
(const char *)RDAudioConvert::errorText(conv_err),
|
||||
(const char *)cutname));
|
||||
@ -380,17 +381,17 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
|
||||
//
|
||||
// Upload File
|
||||
//
|
||||
RDUpload *upload=new RDUpload(rdconfig);
|
||||
RDUpload *upload=new RDUpload(rda->config());
|
||||
upload->setSourceFile(tempfile);
|
||||
upload->setDestinationUrl(config()->url()+"/"+filename);
|
||||
switch(upload_err=upload->runUpload(config()->urlUsername(),
|
||||
config()->urlPassword(),
|
||||
rdconfig->logXloadDebugData())) {
|
||||
rda->config()->logXloadDebugData())) {
|
||||
case RDUpload::ErrorOk:
|
||||
break;
|
||||
|
||||
default:
|
||||
rdconfig->log("rdrepld",RDConfig::LogErr,
|
||||
rda->config()->log("rdrepld",RDConfig::LogErr,
|
||||
QString().sprintf("CitadelXds: audio upload failed: %s",
|
||||
(const char *)RDUpload::errorText(upload_err)));
|
||||
unlink(tempfile);
|
||||
@ -399,7 +400,7 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
|
||||
}
|
||||
unlink(tempfile);
|
||||
delete upload;
|
||||
rdconfig->log("rdrepld",RDConfig::LogInfo,
|
||||
rda->config()->log("rdrepld",RDConfig::LogInfo,
|
||||
QString().sprintf("CitadelXds: uploaded cut %s to %s/%s",
|
||||
(const char *)cutname,
|
||||
(const char *)config()->url(),
|
||||
@ -433,23 +434,23 @@ void CitadelXds::PurgeCuts()
|
||||
path+="/";
|
||||
}
|
||||
QUrl url(path+q->value(1).toString());
|
||||
conv=new RDDelete(rdconfig);
|
||||
conv=new RDDelete(rda->config());
|
||||
conv->setTargetUrl(url);
|
||||
if((conv_err=conv->runDelete(config()->urlUsername(),
|
||||
config()->urlPassword(),
|
||||
rdconfig->logXloadDebugData()))==
|
||||
rda->config()->logXloadDebugData()))==
|
||||
RDDelete::ErrorOk) {
|
||||
sql=QString().sprintf("delete from REPL_CART_STATE where ID=%d",
|
||||
q->value(0).toInt());
|
||||
q2=new RDSqlQuery(sql);
|
||||
delete q2;
|
||||
rdconfig->log("rdrepld",RDConfig::LogInfo,
|
||||
rda->config()->log("rdrepld",RDConfig::LogInfo,
|
||||
QString().sprintf("purged \"%s\" for replicator \"%s\"",
|
||||
(const char *)url.toString(),
|
||||
(const char *)config()->name()));
|
||||
}
|
||||
else {
|
||||
rdconfig->log("rdrepld",RDConfig::LogErr,
|
||||
rda->config()->log("rdrepld",RDConfig::LogErr,
|
||||
QString().sprintf("unable to delete \"%s\" for replicator \"%s\" [%s]",
|
||||
(const char *)url.toString(),
|
||||
(const char *)config()->name(),
|
||||
|
@ -21,7 +21,6 @@
|
||||
#ifndef CITADELXDS_H
|
||||
#define CITADELXDS_H
|
||||
|
||||
#include "globals.h"
|
||||
#include "replfactory.h"
|
||||
|
||||
class CitadelXds : public ReplFactory
|
||||
|
@ -1,31 +0,0 @@
|
||||
// globals.h
|
||||
//
|
||||
// The Rivendell Replicator Daemon Global Definitions
|
||||
//
|
||||
// (C) Copyright 2010,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.
|
||||
//
|
||||
|
||||
#ifndef GLOBALS_H
|
||||
#define GLOBALS_H
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdsystem.h>
|
||||
|
||||
extern RDConfig *rdconfig;
|
||||
extern RDSystem *rdsystem;
|
||||
|
||||
|
||||
#endif // GLOBALS_H
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// The Rivendell Replicator Daemon
|
||||
//
|
||||
// (C) Copyright 2010,2016-2017 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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
|
||||
@ -25,6 +25,7 @@
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <dbversion.h>
|
||||
#include <rdapplication.h>
|
||||
#include <rdcart.h>
|
||||
#include <rdconf.h>
|
||||
#include <rdcmd_switch.h>
|
||||
@ -32,12 +33,8 @@
|
||||
#include <rdescape_string.h>
|
||||
#include <rdtempdirectory.h>
|
||||
|
||||
#include <globals.h>
|
||||
#include <citadelxds.h>
|
||||
#include <rdrepld.h>
|
||||
|
||||
RDConfig *rdconfig;
|
||||
RDSystem *rdsystem;
|
||||
#include "citadelxds.h"
|
||||
#include "rdrepld.h"
|
||||
|
||||
void SigHandler(int signum)
|
||||
{
|
||||
@ -64,15 +61,7 @@ void SigHandler(int signum)
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
bool skip_db_check=false;
|
||||
unsigned schema=0;
|
||||
|
||||
//
|
||||
// Load the config
|
||||
//
|
||||
rdconfig=new RDConfig();
|
||||
rdconfig->load();
|
||||
rdconfig->setModuleName("rdrepld");
|
||||
QString err_msg;
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
@ -81,7 +70,6 @@ MainObject::MainObject(QObject *parent)
|
||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdrepld",RDREPLD_USAGE);
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)=="--skip-db-check") {
|
||||
skip_db_check=true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +81,12 @@ MainObject::MainObject(QObject *parent)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rda=new RDApplication("rdrepld",this);
|
||||
if(!rda->open(&err_msg)) {
|
||||
fprintf(stderr,"rdrepld: %s\n",(const char *)err_msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Data Structures
|
||||
//
|
||||
@ -103,39 +97,15 @@ MainObject::MainObject(QObject *parent)
|
||||
//
|
||||
repl_temp_dir=RDTempDirectory::basePath();
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
QString err (tr("ERROR rdrepld aborting - "));
|
||||
|
||||
repl_db=RDInitDb(&schema,&err);
|
||||
if(!repl_db) {
|
||||
printf(err.ascii());
|
||||
exit(1);
|
||||
}
|
||||
if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) {
|
||||
fprintf(stderr,"rdrepld: database version mismatch, should be %u, is %u\n",
|
||||
RD_VERSION_DATABASE,schema);
|
||||
exit(256);
|
||||
}
|
||||
connect (RDDbStatus(),SIGNAL(logText(RDConfig::LogPriority,const QString &)),
|
||||
connect(RDDbStatus(),
|
||||
SIGNAL(logText(RDConfig::LogPriority,const QString &)),
|
||||
this,SLOT(log(RDConfig::LogPriority,const QString &)));
|
||||
|
||||
//
|
||||
// System Configuration
|
||||
//
|
||||
rdsystem=new RDSystem();
|
||||
|
||||
//
|
||||
// Station Configuration
|
||||
//
|
||||
repl_station=new RDStation(rdconfig->stationName());
|
||||
|
||||
//
|
||||
// Detach
|
||||
//
|
||||
if(qApp->argc()==1) {
|
||||
RDDetach(rdconfig->logCoreDumpDirectory());
|
||||
RDDetach(rda->config()->logCoreDumpDirectory());
|
||||
}
|
||||
else {
|
||||
debug=true;
|
||||
@ -156,7 +126,7 @@ MainObject::MainObject(QObject *parent)
|
||||
connect(repl_loop_timer,SIGNAL(timeout()),this,SLOT(mainLoop()));
|
||||
repl_loop_timer->start(RD_RDREPL_SCAN_INTERVAL,true);
|
||||
|
||||
rdconfig->log("rdrepld",RDConfig::LogNotice,"started");
|
||||
rda->config()->log("rdrepld",RDConfig::LogNotice,"started");
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +141,7 @@ void MainObject::mainLoop()
|
||||
|
||||
void MainObject::log(RDConfig::LogPriority prio,const QString &msg)
|
||||
{
|
||||
rdconfig->log("rdrepld",prio,msg);
|
||||
rda->config()->log("rdrepld",prio,msg);
|
||||
}
|
||||
|
||||
|
||||
@ -254,7 +224,7 @@ void MainObject::LoadReplicators()
|
||||
BITRATE,QUALITY,URL,URL_USERNAME,URL_PASSWORD,\
|
||||
ENABLE_METADATA,NORMALIZATION_LEVEL from \
|
||||
REPLICATORS where STATION_NAME=\"%s\"",
|
||||
(const char *)RDEscapeString(rdconfig->stationName()));
|
||||
(const char *)RDEscapeString(rda->config()->stationName()));
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
config=new ReplConfig();
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// The Rivendell Replicator Daemon
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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
|
||||
@ -26,12 +26,10 @@
|
||||
#include <qobject.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <rdcheck_daemons.h>
|
||||
#include <rdsystem.h>
|
||||
#include <rdstation.h>
|
||||
#include <rdconfig.h>
|
||||
#include <rdcheck_daemons.h>
|
||||
|
||||
#include <replfactory.h>
|
||||
#include "replfactory.h"
|
||||
|
||||
#define RDREPLD_USAGE "[-d][--event-id=<id>]\n\nOptions:\n\n-d\n Set 'debug' mode, causing rdrepld(8) to stay in the foreground\n and print debugging info on standard output.\n\n"
|
||||
#define RD_RDREPLD_PID "rdrepl.pid"
|
||||
@ -53,8 +51,6 @@ class MainObject : public QObject
|
||||
void FreeReplicators();
|
||||
QTimer *repl_loop_timer;
|
||||
QString repl_temp_dir;
|
||||
RDStation *repl_station;
|
||||
QSqlDatabase *repl_db;
|
||||
std::vector<ReplFactory *> repl_replicators;
|
||||
bool debug;
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// A container class for a Rivendell replication configuration
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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,7 +20,7 @@
|
||||
|
||||
#include <rd.h>
|
||||
|
||||
#include <replconfig.h>
|
||||
#include "replconfig.h"
|
||||
|
||||
ReplConfig::ReplConfig()
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Virtual base class for replicator methods
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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,7 +18,7 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <replfactory.h>
|
||||
#include "replfactory.h"
|
||||
|
||||
ReplFactory::ReplFactory(ReplConfig *config)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Virtual base class for replicator methods
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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
|
||||
@ -21,8 +21,7 @@
|
||||
#ifndef REPLFACTORY_H
|
||||
#define REPLFACTORY_H
|
||||
|
||||
#include <globals.h>
|
||||
#include <replconfig.h>
|
||||
#include "replconfig.h"
|
||||
|
||||
class ReplFactory
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user