dl-fldigi/src/main.cxx

182 wiersze
4.1 KiB
C++
Czysty Zwykły widok Historia

2007-06-22 22:10:49 +00:00
//
// Digital Modem Program for the Fast Light Toolkit
//
// Copyright W1HKJ, Dave Freese 2006
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "w1hkj@w1hkj.com".
//
#include <FL/Fl_Shared_Image.H>
2007-06-22 22:04:50 +00:00
#include "main.h"
#include "waterfall.h"
2007-06-22 22:10:49 +00:00
#include "fft.h"
2007-06-22 22:04:50 +00:00
#include "sound.h"
#include "complex.h"
#include "fl_digi.h"
#include "rigio.h"
#include "globals.h"
#include "psk.h"
#include "cw.h"
#include "mfsk.h"
#include "Config.h"
#include "configuration.h"
#include "macros.h"
#include "status.h"
#ifndef NOHAMLIB
#include "rigclass.h"
#endif
#include "rigsupport.h"
#include "log.h"
using namespace std;
string scDevice = "/dev/dsp1";
char szHomedir[120] = "";
2007-06-22 22:10:49 +00:00
char szPskMailDir[120] = "";
string PskMailDir;
string PskMailFile;
2007-06-22 22:04:50 +00:00
string HomeDir;
string xmlfname;
2007-06-22 22:24:50 +00:00
bool testmenu = false;
2007-06-22 22:10:49 +00:00
2007-06-22 22:04:50 +00:00
PTT *push2talk = (PTT *)0;
#ifndef NOHAMLIB
Rig *xcvr = (Rig *)0;
#endif
cLogfile *logfile = 0;;
2007-06-22 22:24:50 +00:00
bool gmfskmail = false;
2007-06-22 22:04:50 +00:00
cLogfile *Maillogfile = (cLogfile *)0;
FILE *server;
FILE *client;
bool mailserver = false, mailclient = false;
extern void start_pskmail();
2007-06-22 22:10:49 +00:00
int main(int argc, char ** argv) {
2007-06-22 22:04:50 +00:00
fl_filename_expand(szHomedir, 119, "$HOME/.fldigi/");
2007-06-22 22:10:49 +00:00
if (fl_filename_isdir(szHomedir) == 0)
2007-06-22 22:04:50 +00:00
HomeDir = "./";
else
HomeDir = szHomedir;
xmlfname = HomeDir;
xmlfname.append("rig.xml");
string lfname = HomeDir;
lfname.append("fldigi.log");
logfile = new cLogfile(lfname);
logfile->log_to_file_start();
2007-06-22 22:10:49 +00:00
fl_filename_expand(szPskMailDir, 119, "$HOME/pskmail.files/");
PskMailDir = szPskMailDir;
PskMailFile = PskMailDir;
PskMailFile += "PSKmailserver";
ifstream testFile;
testFile.open(PskMailFile.c_str());
if (testFile.is_open()) {
2007-06-22 22:04:50 +00:00
mailserver = true;
2007-06-22 22:10:49 +00:00
testFile.close();
} else {
PskMailFile = PskMailDir;
PskMailFile += "PSKmailclient";
testFile.open(PskMailFile.c_str());
if (testFile.is_open()) {
mailclient = true;
testFile.close();
} else {
PskMailDir = "./";
PskMailFile = PskMailDir;
PskMailFile += "PSKmailserver";
testFile.open(PskMailFile.c_str());
if (testFile.is_open()) {
mailserver = true;
testFile.close();
gmfskmail = true;
} else {
PskMailFile = PskMailDir;
PskMailFile += "PSKmailclient";
testFile.open(PskMailFile.c_str());
if (testFile.is_open()) {
mailclient = true;
testFile.close();
gmfskmail = true;
}
}
}
2007-06-22 22:04:50 +00:00
}
2007-06-22 22:10:49 +00:00
2007-06-22 22:04:50 +00:00
Fl::lock(); // start the gui thread!!
Fl::visual(FL_RGB); // insure 24 bit color operation
fl_register_images();
2007-06-22 22:19:01 +00:00
Fl::set_fonts(0);
2007-06-22 22:24:50 +00:00
if (argc == 2)
if (strcasecmp(argv[1], "TEST") == 0)
testmenu = true;
2007-06-22 22:04:50 +00:00
rigcontrol = createRigDialog();
create_fl_digi_main();
2007-06-22 22:24:50 +00:00
activate_test_menu_item(testmenu);
2007-06-22 22:04:50 +00:00
createConfig();
macros.loadDefault();
#ifndef NOHAMLIB
xcvr = new Rig();
#endif
push2talk = new PTT();
if (progdefaults.openDefaults())
push2talk->reset( progdefaults.btnPTTis,
progdefaults.btnRTSDTRis,
progdefaults.btnPTTREVis );
2007-06-22 22:24:50 +00:00
scDevice = progdefaults.SCdevice;
2007-06-22 22:04:50 +00:00
trx_start(scDevice.c_str());
progdefaults.initInterface();
2007-06-22 22:19:01 +00:00
progStatus.initLastState();
wf->opmode();
2007-06-22 22:04:50 +00:00
if (mailserver || mailclient) {
2007-06-22 22:10:49 +00:00
std::cout << "Starting pskmail transport layer" << std::endl; fflush(stdout);
string PskMailLogName = PskMailDir;
if (gmfskmail == false)
PskMailLogName += "mail-io.log";
else
PskMailLogName += "gMFSK.log";
Maillogfile = new cLogfile(PskMailLogName.c_str());
2007-06-22 22:04:50 +00:00
Maillogfile->log_to_file_start();
Fl::add_timeout(10.0, pskmail_loop);
}
fl_digi_main->show();
return Fl::run();
2007-06-22 22:10:49 +00:00
}