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

Last change on this file since 278 was 278, checked in by mervart, 17 years ago

* empty log message *

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