source: ntrip/trunk/BNC/bncmain.cpp@ 243

Last change on this file since 243 was 243, checked in by mervart, 18 years ago

* empty log message *

File size: 2.9 KB
RevLine 
[35]1
2/* -------------------------------------------------------------------------
[93]3 * BKG NTRIP Client
[35]4 * -------------------------------------------------------------------------
5 *
6 * Class: main
7 *
8 * Purpose: Application starts here
9 *
10 * Author: L. Mervart
11 *
12 * Created: 24-Dec-2005
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <QApplication>
19#include <QFile>
20#include <iostream>
21
[82]22#include "bncapp.h"
[35]23#include "bncwindow.h"
24
25using namespace std;
26
[243]27bncCaster* _global_caster = 0;
28
[82]29// Main Program
30/////////////////////////////////////////////////////////////////////////////
[35]31int main(int argc, char *argv[]) {
32
33 bool GUIenabled = true;
[100]34 for (int ii = 1; ii < argc; ii++) {
35 if (QString(argv[ii]) == "-nw") {
36 GUIenabled = false;
37 break;
38 }
[35]39 }
40
[82]41 bncApp app(argc, argv, GUIenabled);
[35]42
[93]43 QCoreApplication::setOrganizationName("BKG");
44 QCoreApplication::setOrganizationDomain("www.ifag.de");
45 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
[35]46
[180]47 // Default Settings
48 // ----------------
[113]49 QSettings settings;
[180]50 if (settings.allKeys().size() == 0) {
51 settings.setValue("casterHost", "www.euref-ip.net");
52 settings.setValue("casterPort", 80);
53 settings.setValue("rnxIntr", "15 min");
54 settings.setValue("rnxSkel", "SKL");
55 settings.setValue("waitTime", 2);
56 }
[114]57
[180]58 // Interactive Mode - open the main window
59 // ---------------------------------------
[35]60 if (GUIenabled) {
[113]61
62 QString fontString = settings.value("font").toString();
63 if ( !fontString.isEmpty() ) {
64 QFont newFont;
65 if (newFont.fromString(fontString)) {
66 QApplication::setFont(newFont);
67 }
68 }
[142]69
[173]70 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
[113]71
[82]72 bncWindow* bncWin = new bncWindow();
[35]73 bncWin->show();
74 }
[180]75
76 // Non-Interactive (Batch) Mode
77 // ----------------------------
[35]78 else {
[243]79 _global_caster = new bncCaster(settings.value("outFile").toString(),
80 settings.value("outPort").toInt());
[35]81
[243]82 app.connect(_global_caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
83 app.connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
[82]84 &app, SLOT(slotMessage(const QByteArray&)));
[35]85
86 QListIterator<QString> it(settings.value("mountPoints").toStringList());
87 while (it.hasNext()) {
[59]88 QStringList hlp = it.next().split(" ");
[82]89 if (hlp.size() <= 1) continue;
[59]90 QUrl url(hlp[0]);
[88]91 QByteArray format = hlp[1].toAscii();
92 bncGetThread* getThread = new bncGetThread(url, format);
[82]93 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
94 &app, SLOT(slotMessage(const QByteArray&)));
95
[243]96 _global_caster->addGetThread(getThread);
[35]97
98 getThread->start();
99 }
[243]100 if (_global_caster->numStations() == 0) {
[82]101 return 0;
102 }
[35]103 }
[180]104
105 // Start the application
106 // ---------------------
[35]107 return app.exec();
108}
Note: See TracBrowser for help on using the repository browser.