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

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

Imported sources

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