source: ntrip/trunk/BNC/bncapp.cpp@ 275

Last change on this file since 275 was 275, checked in by mervart, 17 years ago

* empty log message *

File size: 1.9 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncApp
7 *
8 * Purpose: This class implements the main application
9 *
10 * Author: L. Mervart
11 *
12 * Created: 29-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19#include <QSettings>
20#include <QMessageBox>
21
22#include "bncapp.h"
23#include "bncutils.h"
24
25using namespace std;
26
27// Constructor
28////////////////////////////////////////////////////////////////////////////
29bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
30 QApplication(argc, argv, GUIenabled) {
31
32 _logFileFlag = 0;
33 _logFile = 0;
34 _logStream = 0;
35
36 _bncVersion = "BNC 1.0b";
37}
38
39// Destructor
40////////////////////////////////////////////////////////////////////////////
41bncApp::~bncApp() {
42 delete _logStream;
43 delete _logFile;
44}
45
46// Write a Program Message
47////////////////////////////////////////////////////////////////////////////
48void bncApp::slotMessage(const QByteArray msg) {
49
50 QMutexLocker locker(&_mutex);
51
52 // First time resolve the log file name
53 // ------------------------------------
54 if (_logFileFlag == 0) {
55 _logFileFlag = 1;
56 QSettings settings;
57 QString logFileName = settings.value("logFile").toString();
58 if ( !logFileName.isEmpty() ) {
59 expandEnvVar(logFileName);
60 _logFile = new QFile(logFileName);
61 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
62 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
63 }
64 else {
65 _logFile->open(QIODevice::WriteOnly);
66 }
67 _logStream = new QTextStream();
68 _logStream->setDevice(_logFile);
69 }
70 }
71
72 if (_logStream) {
73 *_logStream << QTime::currentTime().toString("hh:mm:ss ").toAscii().data();
74 *_logStream << msg.data() << endl;
75 _logStream->flush();
76 }
77}
Note: See TracBrowser for help on using the repository browser.