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
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
27bncCaster* _global_caster = 0;
28
29// Main Program
30/////////////////////////////////////////////////////////////////////////////
31int main(int argc, char *argv[]) {
32
33 bool GUIenabled = true;
34 for (int ii = 1; ii < argc; ii++) {
35 if (QString(argv[ii]) == "-nw") {
36 GUIenabled = false;
37 break;
38 }
39 }
40
41 bncApp app(argc, argv, GUIenabled);
42
43 QCoreApplication::setOrganizationName("BKG");
44 QCoreApplication::setOrganizationDomain("www.ifag.de");
45 QCoreApplication::setApplicationName("BKG_NTRIP_Client");
46
47 // Default Settings
48 // ----------------
49 QSettings settings;
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 }
57
58 // Interactive Mode - open the main window
59 // ---------------------------------------
60 if (GUIenabled) {
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 }
69
70 app.setWindowIcon(QPixmap(":ntrip-logo.png"));
71
72 bncWindow* bncWin = new bncWindow();
73 bncWin->show();
74 }
75
76 // Non-Interactive (Batch) Mode
77 // ----------------------------
78 else {
79 _global_caster = new bncCaster(settings.value("outFile").toString(),
80 settings.value("outPort").toInt());
81
82 app.connect(_global_caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
83 app.connect(_global_caster, SIGNAL(newMessage(const QByteArray&)),
84 &app, SLOT(slotMessage(const QByteArray&)));
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 _global_caster->addGetThread(getThread);
97
98 getThread->start();
99 }
100 if (_global_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.