source: ntrip/trunk/BNC/bncmain.cpp@ 87

Last change on this file since 87 was 82, checked in by mervart, 18 years ago

* empty log message *

File size: 2.6 KB
RevLine 
[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
18#include <QApplication>
19#include <QFile>
20#include <iostream>
21
[82]22#include "bncapp.h"
[35]23#include "bncwindow.h"
24
25using namespace std;
26
[82]27// Main Program
28/////////////////////////////////////////////////////////////////////////////
[35]29int main(int argc, char *argv[]) {
30
31 bool GUIenabled = true;
32 if (argc > 1 && QString(argv[1]) == "-nw") {
33 GUIenabled = false;
34 }
35
[82]36 bncApp app(argc, argv, GUIenabled);
[35]37
38 QCoreApplication::setOrganizationName("AIUB");
39 QCoreApplication::setOrganizationDomain("www.aiub.unibe.ch");
40 QCoreApplication::setApplicationName("Bernese NTRIP Client");
41
42 if (GUIenabled) {
[82]43 bncWindow* bncWin = new bncWindow();
[35]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()));
[82]57 app.connect(caster, SIGNAL(newMessage(const QByteArray&)),
58 &app, SLOT(slotMessage(const QByteArray&)));
[35]59
60 caster->start();
61
62 QListIterator<QString> it(settings.value("mountPoints").toStringList());
63 while (it.hasNext()) {
[59]64 QStringList hlp = it.next().split(" ");
[82]65 if (hlp.size() <= 1) continue;
[59]66 QUrl url(hlp[0]);
[35]67 QByteArray mountPoint = url.path().mid(1).toAscii();
[59]68 QByteArray format = hlp[1].toAscii();
[35]69
70 bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
71 proxyHost, proxyPort,
[59]72 mountPoint, user, password,
73 format);
[82]74 app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
75 &app, SLOT(slotMessage(const QByteArray&)));
76
[35]77 caster->addGetThread(getThread);
78
79 getThread->start();
80 }
[82]81 if (caster->nMountPoints() == 0) {
82 return 0;
83 }
[35]84 }
85 return app.exec();
86}
Note: See TracBrowser for help on using the repository browser.