[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 |
|
---|
| 25 | using namespace std;
|
---|
| 26 |
|
---|
[82] | 27 | // Main Program
|
---|
| 28 | /////////////////////////////////////////////////////////////////////////////
|
---|
[35] | 29 | int main(int argc, char *argv[]) {
|
---|
| 30 |
|
---|
| 31 | bool GUIenabled = true;
|
---|
[100] | 32 | for (int ii = 1; ii < argc; ii++) {
|
---|
| 33 | if (QString(argv[ii]) == "-nw") {
|
---|
| 34 | GUIenabled = false;
|
---|
| 35 | break;
|
---|
| 36 | }
|
---|
[35] | 37 | }
|
---|
| 38 |
|
---|
[82] | 39 | bncApp app(argc, argv, GUIenabled);
|
---|
[35] | 40 |
|
---|
[93] | 41 | QCoreApplication::setOrganizationName("BKG");
|
---|
| 42 | QCoreApplication::setOrganizationDomain("www.ifag.de");
|
---|
| 43 | QCoreApplication::setApplicationName("BKG_NTRIP_Client");
|
---|
[35] | 44 |
|
---|
[113] | 45 | QSettings settings;
|
---|
[114] | 46 |
|
---|
[35] | 47 | if (GUIenabled) {
|
---|
[113] | 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 | }
|
---|
[142] | 56 |
|
---|
| 57 | app.setWindowIcon(QPixmap(":ntrip-logo-grau.bmp"));
|
---|
[113] | 58 |
|
---|
[82] | 59 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 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()));
|
---|
[82] | 67 | app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 68 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
[35] | 69 |
|
---|
| 70 | caster->start();
|
---|
| 71 |
|
---|
| 72 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 73 | while (it.hasNext()) {
|
---|
[59] | 74 | QStringList hlp = it.next().split(" ");
|
---|
[82] | 75 | if (hlp.size() <= 1) continue;
|
---|
[59] | 76 | QUrl url(hlp[0]);
|
---|
[88] | 77 | QByteArray format = hlp[1].toAscii();
|
---|
| 78 | bncGetThread* getThread = new bncGetThread(url, format);
|
---|
[82] | 79 | app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 80 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
| 81 |
|
---|
[35] | 82 | caster->addGetThread(getThread);
|
---|
| 83 |
|
---|
| 84 | getThread->start();
|
---|
| 85 | }
|
---|
[88] | 86 | if (caster->numStations() == 0) {
|
---|
[82] | 87 | return 0;
|
---|
| 88 | }
|
---|
[35] | 89 | }
|
---|
| 90 | return app.exec();
|
---|
| 91 | }
|
---|