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

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

* empty log message *

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