2018-02-01 Fred Gleason <fredg@paravelsystems.com>

* Converted rddgimport(1) to use RDApplication.
This commit is contained in:
Fred Gleason
2018-01-31 17:35:04 -05:00
parent 0e47266a4d
commit 914d903dc6
9 changed files with 71 additions and 179 deletions

View File

@@ -16627,3 +16627,5 @@
* Converted rddelete(1) to use RDApplication. * Converted rddelete(1) to use RDApplication.
2018-02-01 Fred Gleason <fredg@paravelsystems.com> 2018-02-01 Fred Gleason <fredg@paravelsystems.com>
* Added an 'RDApplication::userChanged() signal. * Added an 'RDApplication::userChanged() signal.
2018-02-01 Fred Gleason <fredg@paravelsystems.com>
* Converted rddgimport(1) to use RDApplication.

View File

@@ -2,7 +2,7 @@
// //
// A Qt-based application for importing Dial Global CDN downloads // A Qt-based application for importing Dial Global CDN downloads
// //
// (C) Copyright 2012,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2012,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@@ -30,33 +30,48 @@
#include <qstringlist.h> #include <qstringlist.h>
#include <qfile.h> #include <qfile.h>
#include <rdescape_string.h> #include <rdapplication.h>
#include <rdcmd_switch.h>
#include <rdconf.h>
#include <rddatedialog.h>
#include <rdgroup.h>
#include <rdcart.h>
#include <rdcut.h>
#include <rdaudioimport.h> #include <rdaudioimport.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rdcut.h>
#include <rddatedecode.h> #include <rddatedecode.h>
#include <rddatedialog.h>
#include <rdescape_string.h>
#include <rdgroup.h>
#include <rddgimport.h> #include "rddgimport.h"
MainWidget::MainWidget(QWidget *parent) MainWidget::MainWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
dg_user=NULL; QString sql;
RDSqlQuery *q;
QString err_msg;
dg_group=NULL; dg_group=NULL;
dg_svc=NULL; dg_svc=NULL;
QString sql; //
RDSqlQuery *q; // Open the Database
//
rda=new RDApplication("RDDgImport","rddgimport",RDDGIMPORT_USAGE,this);
if(!rda->open(&err_msg)) {
QMessageBox::critical(this,"RDDgImport - "+tr("Error"),err_msg);
exit(1);
}
// //
// Read Command Options // Read Command Options
// //
RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rddgimport","\n"); for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
delete cmd; if(!rda->cmdSwitch()->processed(i)) {
QMessageBox::critical(this,"RDDgImport - "+tr("Error"),
tr("Unknown command option")+": "+
rda->cmdSwitch()->key(i));
exit(2);
}
}
// //
// Set Window Size // Set Window Size
@@ -66,33 +81,6 @@ MainWidget::MainWidget(QWidget *parent)
SetCaption(); SetCaption();
//
// Load Local Configs
//
dg_config=new RDConfig();
dg_config->load();
dg_config->setModuleName("RDDgiImport");
//
// Open Database
//
dg_db=QSqlDatabase::addDatabase(dg_config->mysqlDriver());
if(!dg_db) {
QMessageBox::warning(this,tr("Database Error"),
tr("Can't Connect","Unable to connect to mySQL Server!"));
exit(0);
}
dg_db->setDatabaseName(dg_config->mysqlDbname());
dg_db->setUserName(dg_config->mysqlUsername());
dg_db->setPassword(dg_config->mysqlPassword());
dg_db->setHostName(dg_config->mysqlHostname());
if(!dg_db->open()) {
QMessageBox::warning(this,tr("Can't Connect"),
tr("Unable to connect to mySQL Server!"));
dg_db->removeDatabase(dg_config->mysqlDbname());
exit(0);
}
// //
// Fonts // Fonts
// //
@@ -105,11 +93,8 @@ MainWidget::MainWidget(QWidget *parent)
// //
// Configuration Elements // Configuration Elements
// //
dg_station=new RDStation(dg_config->stationName(),this); connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
dg_library_conf=new RDLibraryConf(dg_config->stationName()); rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
dg_ripc=new RDRipc(dg_station,dg_config,this);
connect(dg_ripc,SIGNAL(userChanged()),this,SLOT(userChangedData()));
dg_ripc->connectHost("localhost",RIPCD_TCP_PORT,dg_config->password());
// //
// Service Selector // Service Selector
@@ -209,7 +194,7 @@ void MainWidget::serviceActivatedData(int index)
if(dg_svc!=NULL) { if(dg_svc!=NULL) {
delete dg_svc; delete dg_svc;
} }
dg_svc=new RDSvc(dg_service_box->currentText(),dg_station,dg_config); dg_svc=new RDSvc(dg_service_box->currentText(),rda->station(),rda->config());
if(dg_group!=NULL) { if(dg_group!=NULL) {
delete dg_group; delete dg_group;
} }
@@ -269,10 +254,6 @@ void MainWidget::processData()
void MainWidget::userChangedData() void MainWidget::userChangedData()
{ {
if(dg_user!=NULL) {
delete dg_user;
}
dg_user=new RDUser(dg_ripc->user());
SetCaption(); SetCaption();
} }
@@ -304,9 +285,7 @@ void MainWidget::resizeEvent(QResizeEvent *e)
void MainWidget::SetCaption() void MainWidget::SetCaption()
{ {
QString username=tr("[unknown]"); QString username=tr("[unknown]");
if(dg_user!=NULL) { username=rda->user()->name();
username=dg_user->name();
}
setCaption(tr("RDDgImport")+" v"+VERSION+" "+tr("User")+": "+username); setCaption(tr("RDDgImport")+" v"+VERSION+" "+tr("User")+": "+username);
} }
@@ -391,8 +370,8 @@ bool MainWidget::WriteTrafficFile()
// Open Output File // Open Output File
// //
outname=RDDateDecode(dg_svc->importPath(RDSvc::Traffic,RDSvc::Linux), outname=RDDateDecode(dg_svc->importPath(RDSvc::Traffic,RDSvc::Linux),
dg_date_edit->date(),dg_station, dg_date_edit->date(),rda->station(),
dg_config,dg_svc->name()); rda->config(),dg_svc->name());
if((f=fopen(outname,"w"))==NULL) { if((f=fopen(outname,"w"))==NULL) {
LogMessage(tr("WARNING: Unable to open traffic output file")+" \""+ LogMessage(tr("WARNING: Unable to open traffic output file")+" \""+
outname+"\" ["+strerror(errno)+"]."); outname+"\" ["+strerror(errno)+"].");
@@ -495,8 +474,8 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg)
// //
// Initialize Audio Importer // Initialize Audio Importer
// //
settings.setNormalizationLevel(dg_library_conf->ripperLevel()/100); settings.setNormalizationLevel(rda->libraryConf()->ripperLevel()/100);
settings.setChannels(dg_library_conf->defaultChannels()); settings.setChannels(rda->libraryConf()->defaultChannels());
if((dg_carts[evt->isci()]=dg_group->nextFreeCart())==0) { if((dg_carts[evt->isci()]=dg_group->nextFreeCart())==0) {
LogMessage(tr("Unable to allocate new cart for")+" "+evt->isci()+" ["+ LogMessage(tr("Unable to allocate new cart for")+" "+evt->isci()+" ["+
@@ -514,9 +493,9 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg)
} }
cart=new RDCart(dg_carts[evt->isci()]); cart=new RDCart(dg_carts[evt->isci()]);
if((cutnum=cart->addCut(dg_library_conf->defaultLayer(), if((cutnum=cart->addCut(rda->libraryConf()->defaultLayer(),
dg_library_conf->defaultBitrate(), rda->libraryConf()->defaultBitrate(),
dg_library_conf->defaultChannels(), rda->libraryConf()->defaultChannels(),
evt->isci(),evt->title()))<0) { evt->isci(),evt->title()))<0) {
LogMessage(tr("WARNING: Unable to create cut for cart")+" \""+ LogMessage(tr("WARNING: Unable to create cut for cart")+" \""+
QString().sprintf("%u",dg_carts[evt->isci()])+"\"."); QString().sprintf("%u",dg_carts[evt->isci()])+"\".");
@@ -529,14 +508,14 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg)
addDays(RDDGIMPORT_KILLDATE_OFFSET), addDays(RDDGIMPORT_KILLDATE_OFFSET),
QTime(23,59,59)),true); QTime(23,59,59)),true);
conv=new RDAudioImport(dg_station,dg_config,this); conv=new RDAudioImport(rda->station(),rda->config(),this);
conv->setCartNumber(dg_carts[evt->isci()]); conv->setCartNumber(dg_carts[evt->isci()]);
conv->setCutNumber(cutnum); conv->setCutNumber(cutnum);
conv->setSourceFile(audiofile); conv->setSourceFile(audiofile);
conv->setDestinationSettings(&settings); conv->setDestinationSettings(&settings);
conv->setUseMetadata(false); conv->setUseMetadata(false);
conv_err=conv-> conv_err=conv->
runImport(dg_user->name(),dg_user->password(),&audio_conv_err); runImport(rda->user()->name(),rda->user()->password(),&audio_conv_err);
switch(conv_err) { switch(conv_err) {
case RDAudioImport::ErrorOk: case RDAudioImport::ErrorOk:
break; break;

View File

@@ -2,7 +2,7 @@
// //
// A Qt-based application for importing Dial Global CDN downloads // A Qt-based application for importing Dial Global CDN downloads
// //
// (C) Copyright 2012,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2012,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@@ -35,17 +35,12 @@
#include <qdatetimeedit.h> #include <qdatetimeedit.h>
#include <qtextedit.h> #include <qtextedit.h>
#include <rdconfig.h> #include <rdbusybar.h>
#include <rddb.h> #include <rddb.h>
#include <rdgroup.h> #include <rdgroup.h>
#include <rdlibrary_conf.h>
#include <rdstation.h>
#include <rdbusybar.h>
#include <rdsvc.h> #include <rdsvc.h>
#include <rduser.h>
#include <rdripc.h>
#include <event.h> #include "event.h"
#define RDDGIMPORT_USAGE "\n" #define RDDGIMPORT_USAGE "\n"
#define RDDGIMPORT_KILLDATE_OFFSET 7 #define RDDGIMPORT_KILLDATE_OFFSET 7
@@ -100,12 +95,6 @@ class MainWidget : public QWidget
std::vector<Event *> dg_events; std::vector<Event *> dg_events;
RDGroup *dg_group; RDGroup *dg_group;
RDSvc *dg_svc; RDSvc *dg_svc;
RDRipc *dg_ripc;
RDUser *dg_user;
RDStation *dg_station;
RDLibraryConf *dg_library_conf;
RDConfig *dg_config;
QSqlDatabase *dg_db;
}; };

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -29,23 +29,6 @@
<source>Unable to open source file</source> <source>Unable to open source file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Database Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<comment>Unable to connect to mySQL Server!</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to connect to mySQL Server!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Unable to find event for ISCI code</source> <source>Unable to find event for ISCI code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -110,5 +93,9 @@
<source>Error</source> <source>Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Unknown command option</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>