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

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

* empty log message *

File size: 2.4 KB
Line 
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#ifdef WIN32
19#include <windows.h>
20#endif
21
22#include <QApplication>
23#include <QFile>
24#include <iostream>
25
26#include "bncwindow.h"
27
28using namespace std;
29
30#ifdef WIN32
31QFile logFile("BNC.LOG");
32QTextStream logStream;
33#endif
34
35void 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
44int 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()) {
85 QUrl url(it.next());
86 QByteArray mountPoint = url.path().mid(1).toAscii();
87
88 bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
89 proxyHost, proxyPort,
90 mountPoint, user, password);
91 caster->addGetThread(getThread);
92
93 getThread->start();
94 }
95 }
96 return app.exec();
97}
Note: See TracBrowser for help on using the repository browser.