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

View File

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