[35] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * Bernese 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 |
|
---|
[36] | 18 | #ifdef WIN32
|
---|
[35] | 19 | #include <windows.h>
|
---|
[36] | 20 | #endif
|
---|
[35] | 21 |
|
---|
| 22 | #include <QApplication>
|
---|
| 23 | #include <QFile>
|
---|
| 24 | #include <iostream>
|
---|
| 25 |
|
---|
| 26 | #include "bncwindow.h"
|
---|
| 27 |
|
---|
| 28 | using namespace std;
|
---|
| 29 |
|
---|
| 30 | #ifdef WIN32
|
---|
| 31 | QFile logFile("BNC.LOG");
|
---|
| 32 | QTextStream logStream;
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | void myMessageOutput(QtMsgType, const char *msg) {
|
---|
| 36 | #ifdef WIN32
|
---|
| 37 | logStream << msg << endl;
|
---|
| 38 | logStream.flush();
|
---|
| 39 | #else
|
---|
| 40 | cerr << msg << endl;
|
---|
| 41 | #endif
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | int main(int argc, char *argv[]) {
|
---|
| 45 |
|
---|
| 46 | bool GUIenabled = true;
|
---|
| 47 | if (argc > 1 && QString(argv[1]) == "-nw") {
|
---|
| 48 | GUIenabled = false;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | QApplication app(argc, argv, GUIenabled);
|
---|
| 52 |
|
---|
| 53 | #ifdef WIN32
|
---|
| 54 | logFile.open(QIODevice::WriteOnly);
|
---|
| 55 | logStream.setDevice(&logFile);
|
---|
| 56 | #endif
|
---|
| 57 | qInstallMsgHandler(myMessageOutput);
|
---|
| 58 |
|
---|
| 59 | QCoreApplication::setOrganizationName("AIUB");
|
---|
| 60 | QCoreApplication::setOrganizationDomain("www.aiub.unibe.ch");
|
---|
| 61 | QCoreApplication::setApplicationName("Bernese NTRIP Client");
|
---|
| 62 |
|
---|
| 63 | bncWindow* bncWin = 0;
|
---|
| 64 |
|
---|
| 65 | if (GUIenabled) {
|
---|
| 66 | bncWin = new bncWindow();
|
---|
| 67 | bncWin->show();
|
---|
| 68 | }
|
---|
| 69 | else {
|
---|
| 70 | QSettings settings;
|
---|
| 71 | QString proxyHost = settings.value("proxyHost").toString();
|
---|
| 72 | int proxyPort = settings.value("proxyPort").toInt();
|
---|
| 73 | QByteArray user = settings.value("user").toString().toAscii();
|
---|
| 74 | QByteArray password = settings.value("password").toString().toAscii();
|
---|
| 75 |
|
---|
| 76 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
| 77 | settings.value("outPort").toInt());
|
---|
| 78 |
|
---|
| 79 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
| 80 |
|
---|
| 81 | caster->start();
|
---|
| 82 |
|
---|
| 83 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 84 | while (it.hasNext()) {
|
---|
[59] | 85 | QStringList hlp = it.next().split(" ");
|
---|
| 86 | QUrl url(hlp[0]);
|
---|
[35] | 87 | QByteArray mountPoint = url.path().mid(1).toAscii();
|
---|
[59] | 88 | QByteArray format = hlp[1].toAscii();
|
---|
[35] | 89 |
|
---|
| 90 | bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
|
---|
| 91 | proxyHost, proxyPort,
|
---|
[59] | 92 | mountPoint, user, password,
|
---|
| 93 | format);
|
---|
[35] | 94 | caster->addGetThread(getThread);
|
---|
| 95 |
|
---|
| 96 | getThread->start();
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 | return app.exec();
|
---|
| 100 | }
|
---|