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 |
|
---|
25 | using namespace std;
|
---|
26 |
|
---|
27 | // Main Program
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 | int 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 | QSettings settings;
|
---|
46 |
|
---|
47 | if (GUIenabled) {
|
---|
48 |
|
---|
49 | QString fontString = settings.value("font").toString();
|
---|
50 | if ( !fontString.isEmpty() ) {
|
---|
51 | QFont newFont;
|
---|
52 | if (newFont.fromString(fontString)) {
|
---|
53 | QApplication::setFont(newFont);
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
58 |
|
---|
59 | bncWindow* bncWin = new bncWindow();
|
---|
60 | bncWin->show();
|
---|
61 | }
|
---|
62 | else {
|
---|
63 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
64 | settings.value("outPort").toInt());
|
---|
65 |
|
---|
66 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
67 | app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
68 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
69 |
|
---|
70 | caster->start();
|
---|
71 |
|
---|
72 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
73 | while (it.hasNext()) {
|
---|
74 | QStringList hlp = it.next().split(" ");
|
---|
75 | if (hlp.size() <= 1) continue;
|
---|
76 | QUrl url(hlp[0]);
|
---|
77 | QByteArray format = hlp[1].toAscii();
|
---|
78 | bncGetThread* getThread = new bncGetThread(url, format);
|
---|
79 | app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
80 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
81 |
|
---|
82 | caster->addGetThread(getThread);
|
---|
83 |
|
---|
84 | getThread->start();
|
---|
85 | }
|
---|
86 | if (caster->numStations() == 0) {
|
---|
87 | return 0;
|
---|
88 | }
|
---|
89 | }
|
---|
90 | return app.exec();
|
---|
91 | }
|
---|