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 |
|
---|
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 | if (argc > 1 && QString(argv[1]) == "-nw") {
|
---|
33 | GUIenabled = false;
|
---|
34 | }
|
---|
35 |
|
---|
36 | bncApp app(argc, argv, GUIenabled);
|
---|
37 |
|
---|
38 | QCoreApplication::setOrganizationName("AIUB");
|
---|
39 | QCoreApplication::setOrganizationDomain("www.aiub.unibe.ch");
|
---|
40 | QCoreApplication::setApplicationName("Bernese NTRIP Client");
|
---|
41 |
|
---|
42 | if (GUIenabled) {
|
---|
43 | bncWindow* bncWin = new bncWindow();
|
---|
44 | bncWin->show();
|
---|
45 | }
|
---|
46 | else {
|
---|
47 | QSettings settings;
|
---|
48 | QString proxyHost = settings.value("proxyHost").toString();
|
---|
49 | int proxyPort = settings.value("proxyPort").toInt();
|
---|
50 | QByteArray user = settings.value("user").toString().toAscii();
|
---|
51 | QByteArray password = settings.value("password").toString().toAscii();
|
---|
52 |
|
---|
53 | bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
|
---|
54 | settings.value("outPort").toInt());
|
---|
55 |
|
---|
56 | app.connect(caster, SIGNAL(getThreadErrors()), &app, SLOT(quit()));
|
---|
57 | app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
|
---|
58 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
59 |
|
---|
60 | caster->start();
|
---|
61 |
|
---|
62 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
63 | while (it.hasNext()) {
|
---|
64 | QStringList hlp = it.next().split(" ");
|
---|
65 | if (hlp.size() <= 1) continue;
|
---|
66 | QUrl url(hlp[0]);
|
---|
67 | QByteArray mountPoint = url.path().mid(1).toAscii();
|
---|
68 | QByteArray format = hlp[1].toAscii();
|
---|
69 |
|
---|
70 | bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
|
---|
71 | proxyHost, proxyPort,
|
---|
72 | mountPoint, user, password,
|
---|
73 | format);
|
---|
74 | app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
|
---|
75 | &app, SLOT(slotMessage(const QByteArray&)));
|
---|
76 |
|
---|
77 | caster->addGetThread(getThread);
|
---|
78 |
|
---|
79 | getThread->start();
|
---|
80 | }
|
---|
81 | if (caster->nMountPoints() == 0) {
|
---|
82 | return 0;
|
---|
83 | }
|
---|
84 | }
|
---|
85 | return app.exec();
|
---|
86 | }
|
---|