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

* Converted wings_filter(1) to use RDApplication.
This commit is contained in:
Fred Gleason 2018-02-02 20:23:44 -05:00
parent c1fc4d20ae
commit 12989969c7
3 changed files with 16 additions and 56 deletions

View File

@ -16657,3 +16657,5 @@
* Converted nexgen_filter(1) to use RDApplication.
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted sas_filter(1) to use RDApplication.
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted wings_filter(1) to use RDApplication.

View File

@ -2,7 +2,7 @@
//
// A Library import filter for the Airforce Wings system
//
// (C) Copyright 2002-2004 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2004,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,31 +26,17 @@
#include <qapplication.h>
#include <rddb.h>
#include <rd.h>
#include <rdconfig.h>
#include <rdcmd_switch.h>
#include <rdapplication.h>
#include <rddb.h>
#include <rdcut.h>
#include <rdescape_string.h>
#include <wings_filter.h>
//
// Global Variables
//
RDConfig *rdconfig;
#include "wings_filter.h"
MainObject::MainObject(QObject *parent)
: QObject(parent)
{
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"wings_filter",
WINGS_FILTER_USAGE);
delete cmd;
WingsRecord wr;
QString audioname;
bool found;
@ -59,41 +45,21 @@ MainObject::MainObject(QObject *parent)
QString audio_extension=WINGS_DEFAULT_AUDIO_EXT;
QString groupname;
RDWaveFile *wavefile=NULL;
rdconfig=new RDConfig(RD_CONF_FILE);
rdconfig->load();
rdconfig->setModuleName("wings_filter");
QString err_msg;
//
// Open Database
// Open the Database
//
filter_db=QSqlDatabase::addDatabase(rdconfig->mysqlDriver());
if(!filter_db) {
fprintf(stderr,"wings_filter: can't open mySQL database\n");
rda=new RDApplication("wings_filter","wings_filter",WINGS_FILTER_USAGE,this);
if(!rda->open(&err_msg)) {
fprintf(stderr,"wings_filter: %s\n",(const char *)err_msg);
exit(1);
}
filter_db->setDatabaseName(rdconfig->mysqlDbname());
filter_db->setUserName(rdconfig->mysqlUsername());
filter_db->setPassword(rdconfig->mysqlPassword());
filter_db->setHostName(rdconfig->mysqlHostname());
if(!filter_db->open()) {
fprintf(stderr,"wings_filter: unable to connect to mySQL Server\n");
filter_db->removeDatabase(rdconfig->mysqlDbname());
exit(1);
}
//
// Station Configuration
//
filter_rdstation=new RDStation(rdconfig->stationName());
//
// RIPCD Connection
//
filter_ripc=new RDRipc(filter_rdstation,rdconfig,this);
filter_ripc->connectHost("localhost",RIPCD_TCP_PORT,rdconfig->password());
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
//
// Read Arguments
@ -251,7 +217,7 @@ bool MainObject::ImportCut(RDGroup *group,struct WingsRecord *rec,
sql=QString("update CUTS set ")+
"DESCRIPTION=\""+RDEscapeString(rec->title)+"\","+
"ORIGIN_DATETIME=now(),"+
"ORIGIN_NAME=\""+RDEscapeString(rdconfig->stationName())+"\","+
"ORIGIN_NAME=\""+RDEscapeString(rda->config()->stationName())+"\","+
QString().sprintf("CODING_FORMAT=%d,",format)+
QString().sprintf("SAMPLE_RATE=%u,",wavefile->getSamplesPerSec())+
QString().sprintf("CHANNELS=%d,",wavefile->getChannels())+

View File

@ -2,7 +2,7 @@
//
// A Library import filter for the Crown Wings system
//
// (C) Copyright 2002-2005 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2005,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
@ -24,15 +24,10 @@
#include <stdio.h>
#include <qobject.h>
#include <qapplication.h>
#include <qsqldatabase.h>
#include <rdwavefile.h>
#include <rdstation.h>
#include <rdripc.h>
#include <rdcatch_connect.h>
#include <rdcae.h>
#include <rdgroup.h>
#include <rdwavefile.h>
#define WINGS_RECORD_LENGTH 613
#define WINGS_FILTER_USAGE "-g <default-group> -d <db-file> -A <audio-dir> [-e <audio-ext>]\n"
@ -59,10 +54,7 @@ class MainObject : public QObject
bool ImportCut(RDGroup *group,struct WingsRecord *rec,RDWaveFile *wavefile);
bool ReadLine(FILE *fp,struct WingsRecord *rec);
void TrimSpaces(char *str);
RDStation *filter_rdstation;
RDRipc *filter_ripc;
QSqlDatabase *filter_db;
};
#endif
#endif // WINGS_FILTER_H