From 914d903dc696d068e72ca05c549a95df24cfe75d Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Wed, 31 Jan 2018 17:35:04 -0500 Subject: [PATCH] 2018-02-01 Fred Gleason * Converted rddgimport(1) to use RDApplication. --- ChangeLog | 2 + utils/rddgimport/rddgimport.cpp | 105 +++++++++++---------------- utils/rddgimport/rddgimport.h | 17 +---- utils/rddgimport/rddgimport_de.ts | 21 +----- utils/rddgimport/rddgimport_es.ts | 21 +----- utils/rddgimport/rddgimport_fr.ts | 21 +----- utils/rddgimport/rddgimport_nb.ts | 21 +----- utils/rddgimport/rddgimport_nn.ts | 21 +----- utils/rddgimport/rddgimport_pt_BR.ts | 21 +----- 9 files changed, 71 insertions(+), 179 deletions(-) diff --git a/ChangeLog b/ChangeLog index d510f747..1235f7c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16627,3 +16627,5 @@ * Converted rddelete(1) to use RDApplication. 2018-02-01 Fred Gleason * Added an 'RDApplication::userChanged() signal. +2018-02-01 Fred Gleason + * Converted rddgimport(1) to use RDApplication. diff --git a/utils/rddgimport/rddgimport.cpp b/utils/rddgimport/rddgimport.cpp index 78a26810..20b76277 100644 --- a/utils/rddgimport/rddgimport.cpp +++ b/utils/rddgimport/rddgimport.cpp @@ -2,7 +2,7 @@ // // A Qt-based application for importing Dial Global CDN downloads // -// (C) Copyright 2012,2016 Fred Gleason +// (C) Copyright 2012,2016-2018 Fred Gleason // // 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 @@ -30,33 +30,48 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include #include +#include +#include +#include -#include +#include "rddgimport.h" MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { - dg_user=NULL; + QString sql; + RDSqlQuery *q; + QString err_msg; + dg_group=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 // - RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rddgimport","\n"); - delete cmd; + for(unsigned i=0;icmdSwitch()->keys();i++) { + if(!rda->cmdSwitch()->processed(i)) { + QMessageBox::critical(this,"RDDgImport - "+tr("Error"), + tr("Unknown command option")+": "+ + rda->cmdSwitch()->key(i)); + exit(2); + } + } // // Set Window Size @@ -66,33 +81,6 @@ MainWidget::MainWidget(QWidget *parent) 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 // @@ -105,11 +93,8 @@ MainWidget::MainWidget(QWidget *parent) // // Configuration Elements // - dg_station=new RDStation(dg_config->stationName(),this); - dg_library_conf=new RDLibraryConf(dg_config->stationName()); - 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()); + connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData())); + rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password()); // // Service Selector @@ -209,7 +194,7 @@ void MainWidget::serviceActivatedData(int index) if(dg_svc!=NULL) { 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) { delete dg_group; } @@ -269,10 +254,6 @@ void MainWidget::processData() void MainWidget::userChangedData() { - if(dg_user!=NULL) { - delete dg_user; - } - dg_user=new RDUser(dg_ripc->user()); SetCaption(); } @@ -304,9 +285,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) void MainWidget::SetCaption() { QString username=tr("[unknown]"); - if(dg_user!=NULL) { - username=dg_user->name(); - } + username=rda->user()->name(); setCaption(tr("RDDgImport")+" v"+VERSION+" "+tr("User")+": "+username); } @@ -391,8 +370,8 @@ bool MainWidget::WriteTrafficFile() // Open Output File // outname=RDDateDecode(dg_svc->importPath(RDSvc::Traffic,RDSvc::Linux), - dg_date_edit->date(),dg_station, - dg_config,dg_svc->name()); + dg_date_edit->date(),rda->station(), + rda->config(),dg_svc->name()); if((f=fopen(outname,"w"))==NULL) { LogMessage(tr("WARNING: Unable to open traffic output file")+" \""+ outname+"\" ["+strerror(errno)+"]."); @@ -495,8 +474,8 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg) // // Initialize Audio Importer // - settings.setNormalizationLevel(dg_library_conf->ripperLevel()/100); - settings.setChannels(dg_library_conf->defaultChannels()); + settings.setNormalizationLevel(rda->libraryConf()->ripperLevel()/100); + settings.setChannels(rda->libraryConf()->defaultChannels()); if((dg_carts[evt->isci()]=dg_group->nextFreeCart())==0) { 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()]); - if((cutnum=cart->addCut(dg_library_conf->defaultLayer(), - dg_library_conf->defaultBitrate(), - dg_library_conf->defaultChannels(), + if((cutnum=cart->addCut(rda->libraryConf()->defaultLayer(), + rda->libraryConf()->defaultBitrate(), + rda->libraryConf()->defaultChannels(), evt->isci(),evt->title()))<0) { LogMessage(tr("WARNING: Unable to create cut for cart")+" \""+ QString().sprintf("%u",dg_carts[evt->isci()])+"\"."); @@ -529,14 +508,14 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg) addDays(RDDGIMPORT_KILLDATE_OFFSET), 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->setCutNumber(cutnum); conv->setSourceFile(audiofile); conv->setDestinationSettings(&settings); conv->setUseMetadata(false); 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) { case RDAudioImport::ErrorOk: break; diff --git a/utils/rddgimport/rddgimport.h b/utils/rddgimport/rddgimport.h index 5a542f93..19df2003 100644 --- a/utils/rddgimport/rddgimport.h +++ b/utils/rddgimport/rddgimport.h @@ -2,7 +2,7 @@ // // A Qt-based application for importing Dial Global CDN downloads // -// (C) Copyright 2012,2016 Fred Gleason +// (C) Copyright 2012,2016-2018 Fred Gleason // // 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 @@ -35,17 +35,12 @@ #include #include -#include +#include #include #include -#include -#include -#include #include -#include -#include -#include +#include "event.h" #define RDDGIMPORT_USAGE "\n" #define RDDGIMPORT_KILLDATE_OFFSET 7 @@ -100,12 +95,6 @@ class MainWidget : public QWidget std::vector dg_events; RDGroup *dg_group; RDSvc *dg_svc; - RDRipc *dg_ripc; - RDUser *dg_user; - RDStation *dg_station; - RDLibraryConf *dg_library_conf; - RDConfig *dg_config; - QSqlDatabase *dg_db; }; diff --git a/utils/rddgimport/rddgimport_de.ts b/utils/rddgimport/rddgimport_de.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_de.ts +++ b/utils/rddgimport/rddgimport_de.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + + diff --git a/utils/rddgimport/rddgimport_es.ts b/utils/rddgimport/rddgimport_es.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_es.ts +++ b/utils/rddgimport/rddgimport_es.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + + diff --git a/utils/rddgimport/rddgimport_fr.ts b/utils/rddgimport/rddgimport_fr.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_fr.ts +++ b/utils/rddgimport/rddgimport_fr.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + + diff --git a/utils/rddgimport/rddgimport_nb.ts b/utils/rddgimport/rddgimport_nb.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_nb.ts +++ b/utils/rddgimport/rddgimport_nb.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + + diff --git a/utils/rddgimport/rddgimport_nn.ts b/utils/rddgimport/rddgimport_nn.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_nn.ts +++ b/utils/rddgimport/rddgimport_nn.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + + diff --git a/utils/rddgimport/rddgimport_pt_BR.ts b/utils/rddgimport/rddgimport_pt_BR.ts index 58bf8b01..d64f7c4b 100644 --- a/utils/rddgimport/rddgimport_pt_BR.ts +++ b/utils/rddgimport/rddgimport_pt_BR.ts @@ -29,23 +29,6 @@ Unable to open source file - - Database Error - - - - Can't Connect - Unable to connect to mySQL Server! - - - - Can't Connect - - - - Unable to connect to mySQL Server! - - Unable to find event for ISCI code @@ -110,5 +93,9 @@ Error + + Unknown command option + +