[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 |
|
---|
[180] | 45 | // Default Settings
|
---|
| 46 | // ----------------
|
---|
[113] | 47 | QSettings settings;
|
---|
[180] | 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 | }
|
---|
[114] | 55 |
|
---|
[180] | 56 | // Interactive Mode - open the main window
|
---|
| 57 | // ---------------------------------------
|
---|
[35] | 58 | if (GUIenabled) {
|
---|
[113] | 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 | }
|
---|
[142] | 67 |
|
---|
[173] | 68 | app.setWindowIcon(QPixmap(":ntrip-logo.png"));
|
---|
[113] | 69 |
|
---|
[82] | 70 | bncWindow* bncWin = new bncWindow();
|
---|
[35] | 71 | bncWin->show();
|
---|
| 72 | }
|
---|
[180] | 73 |
|
---|
| 74 | // Non-Interactive (Batch) Mode
|
---|
| 75 | // ----------------------------
|
---|
[35] | 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()));
|
---|
[82] | 81 | app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 82 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
[35] | 83 |
|
---|
| 84 | caster->start();
|
---|
| 85 |
|
---|
| 86 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 87 | while (it.hasNext()) {
|
---|
[59] | 88 | QStringList hlp = it.next().split(" ");
|
---|
[82] | 89 | if (hlp.size() <= 1) continue;
|
---|
[59] | 90 | QUrl url(hlp[0]);
|
---|
[88] | 91 | QByteArray format = hlp[1].toAscii();
|
---|
| 92 | bncGetThread* getThread = new bncGetThread(url, format);
|
---|
[82] | 93 | app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
| 94 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
| 95 |
|
---|
[35] | 96 | caster->addGetThread(getThread);
|
---|
| 97 |
|
---|
| 98 | getThread->start();
|
---|
| 99 | }
|
---|
[88] | 100 | if (caster->numStations() == 0) {
|
---|
[82] | 101 | return 0;
|
---|
| 102 | }
|
---|
[35] | 103 | }
|
---|
[180] | 104 |
|
---|
| 105 | // Start the application
|
---|
| 106 | // ---------------------
|
---|
[35] | 107 | return app.exec();
|
---|
| 108 | }
|
---|