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

Last change on this file since 2220 was 2105, checked in by mervart, 15 years ago

* empty log message *

File size: 20.8 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: bncApp
30 *
31 * Purpose: This class implements the main application
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <QMessageBox>
43#include <cmath>
44#include <unistd.h>
45
46#include "bncapp.h"
47#include "bncutils.h"
48#include "bncrinex.h"
49#include "bncsettings.h"
50#include "bncversion.h"
51
52using namespace std;
53
54struct converttimeinfo {
55 int second; /* seconds of GPS time [0..59] */
56 int minute; /* minutes of GPS time [0..59] */
57 int hour; /* hour of GPS time [0..24] */
58 int day; /* day of GPS time [1..28..30(31)*/
59 int month; /* month of GPS time [1..12]*/
60 int year; /* year of GPS time [1980..] */
61};
62
63extern "C" {
64 void converttime(struct converttimeinfo *c, int week, int tow);
65 void updatetime(int *week, int *tow, int tk, int fixnumleap);
66}
67
68// Constructor
69////////////////////////////////////////////////////////////////////////////
70bncApp::bncApp(int& argc, char* argv[], bool GUIenabled) :
71 QApplication(argc, argv, GUIenabled) {
72
73 _logFileFlag = 0;
74 _logFile = 0;
75 _logStream = 0;
76 _caster = 0;
77
78 // Lists of Ephemeris
79 // ------------------
80 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
81 _gpsEph[ii-PRN_GPS_START] = 0;
82 }
83 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
84 _glonassEph[ii-PRN_GLONASS_START] = 0;
85 }
86
87 // Eph file(s)
88 // -----------
89 _rinexVers = 0;
90 _ephFileGPS = 0;
91 _ephStreamGPS = 0;
92 _ephFileGlonass = 0;
93 _ephStreamGlonass = 0;
94
95 _port = 0;
96 _server = 0;
97 _sockets = 0;
98
99 _portCorr = 0;
100 _serverCorr = 0;
101 _socketsCorr = 0;
102
103 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
104#ifdef WIN32
105 _userName = QString("${USERNAME}");
106#else
107 _userName = QString("${USER}");
108#endif
109 expandEnvVar(_userName);
110 _userName = _userName.leftJustified(20, ' ', true);
111
112 _lastDumpCoSec = 0;
113
114 _corrs = new QMultiMap<long, QString>;
115
116 _currentDateAndTimeGPS = 0;
117}
118
119// Destructor
120////////////////////////////////////////////////////////////////////////////
121bncApp::~bncApp() {
122 delete _logStream;
123 delete _logFile;
124 delete _ephStreamGPS;
125 delete _ephFileGPS;
126 delete _server;
127 delete _sockets;
128 delete _serverCorr;
129 delete _socketsCorr;
130 if (_rinexVers == 2) {
131 delete _ephStreamGlonass;
132 delete _ephFileGlonass;
133 }
134 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
135 delete _gpsEph[ii-PRN_GPS_START];
136 }
137 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
138 delete _glonassEph[ii-PRN_GLONASS_START];
139 }
140
141 delete _corrs;
142
143 delete _currentDateAndTimeGPS;
144}
145
146// Write a Program Message
147////////////////////////////////////////////////////////////////////////////
148void bncApp::slotMessage(QByteArray msg, bool showOnScreen) {
149
150 QMutexLocker locker(&_mutexMessage);
151
152 messagePrivate(msg);
153 emit newMessage(msg, showOnScreen);
154}
155
156// Write a Program Message (private, no lock)
157////////////////////////////////////////////////////////////////////////////
158void bncApp::messagePrivate(const QByteArray& msg) {
159
160 // First time resolve the log file name
161 // ------------------------------------
162 QDate currDate = currentDateAndTimeGPS().date();
163 if (_logFileFlag == 0 || _fileDate != currDate) {
164 delete _logFile;
165 _logFileFlag = 1;
166 bncSettings settings;
167 QString logFileName = settings.value("logFile").toString();
168 if ( !logFileName.isEmpty() ) {
169 expandEnvVar(logFileName);
170 _logFile = new QFile(logFileName + "_" +
171 currDate.toString("yyMMdd").toAscii().data());
172 _fileDate = currDate;
173 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
174 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
175 }
176 else {
177 _logFile->open(QIODevice::WriteOnly);
178 }
179 _logStream = new QTextStream();
180 _logStream->setDevice(_logFile);
181 }
182 }
183
184 if (_logStream) {
185 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
186 *_logStream << msg.data() << endl;
187 _logStream->flush();
188 }
189}
190
191// New GPS Ephemeris
192////////////////////////////////////////////////////////////////////////////
193void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
194
195 QMutexLocker locker(&_mutex);
196
197 gpsephemeris copy_gpseph = *gpseph;
198 emit newEphGPS(copy_gpseph);
199
200 printEphHeader();
201
202 gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
203
204 if ( *ee == 0 ||
205 gpseph->GPSweek > (*ee)->GPSweek ||
206 (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
207 delete *ee;
208 *ee = gpseph;
209 printGPSEph(gpseph, true);
210 }
211 else {
212 printGPSEph(gpseph, false);
213 delete gpseph;
214 }
215}
216
217// New Glonass Ephemeris
218////////////////////////////////////////////////////////////////////////////
219void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
220
221 QMutexLocker locker(&_mutex);
222
223 glonassephemeris copy_glonasseph = *glonasseph;
224 emit newEphGlonass(copy_glonasseph);
225
226 printEphHeader();
227
228 glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
229
230 int wwOld, towOld, wwNew, towNew;
231 if (*ee != 0) {
232 wwOld = (*ee)->GPSWeek;
233 towOld = (*ee)->GPSTOW;
234 updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0);
235
236 wwNew = glonasseph->GPSWeek;
237 towNew = glonasseph->GPSTOW;
238 updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0);
239 }
240
241 if ( *ee == 0 ||
242 wwNew > wwOld ||
243 (wwNew == wwOld && towNew > towOld) ) {
244 delete *ee;
245 *ee = glonasseph;
246 printGlonassEph(glonasseph, true);
247 }
248 else {
249 printGlonassEph(glonasseph, false);
250 delete glonasseph;
251 }
252}
253
254// Print Header of the output File(s)
255////////////////////////////////////////////////////////////////////////////
256void bncApp::printEphHeader() {
257
258 bncSettings settings;
259
260 // Initialization
261 // --------------
262 if (_rinexVers == 0) {
263
264 if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
265 _rinexVers = 3;
266 }
267 else {
268 _rinexVers = 2;
269 }
270
271 _ephPath = settings.value("ephPath").toString();
272
273 if ( !_ephPath.isEmpty() ) {
274 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
275 _ephPath += QDir::separator();
276 }
277 expandEnvVar(_ephPath);
278 }
279 }
280
281 // (Re-)Open output File(s)
282 // ------------------------
283 if (!_ephPath.isEmpty()) {
284
285 QDateTime datTim = currentDateAndTimeGPS();
286
287 QString ephFileNameGPS = _ephPath + "BRDC" +
288 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
289
290 QString hlpStr = bncRinex::nextEpochStr(datTim,
291 settings.value("ephIntr").toString());
292
293 if (_rinexVers == 3) {
294 ephFileNameGPS += hlpStr + datTim.toString(".yyP");
295 }
296 else {
297 ephFileNameGPS += hlpStr + datTim.toString(".yyN");
298 }
299
300 if (_ephFileNameGPS == ephFileNameGPS) {
301 return;
302 }
303 else {
304 _ephFileNameGPS = ephFileNameGPS;
305 }
306
307 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
308 delete _gpsEph[ii-PRN_GPS_START];
309 _gpsEph[ii-PRN_GPS_START] = 0;
310 }
311 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
312 delete _glonassEph[ii-PRN_GLONASS_START];
313 _glonassEph[ii-PRN_GLONASS_START] = 0;
314 }
315
316 delete _ephStreamGPS;
317 delete _ephFileGPS;
318
319 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
320 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
321
322 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
323 QFile::exists(ephFileNameGPS) ) {
324 appendFlagGPS = QIODevice::Append;
325 }
326
327 _ephFileGPS = new QFile(ephFileNameGPS);
328 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
329 _ephStreamGPS = new QTextStream();
330 _ephStreamGPS->setDevice(_ephFileGPS);
331
332 if (_rinexVers == 3) {
333 _ephFileGlonass = _ephFileGPS;
334 _ephStreamGlonass = _ephStreamGPS;
335 }
336 else if (_rinexVers == 2) {
337 QString ephFileNameGlonass = _ephPath + "BRDC" +
338 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
339 hlpStr + datTim.toString(".yyG");
340
341 delete _ephStreamGlonass;
342 delete _ephFileGlonass;
343
344 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
345 QFile::exists(ephFileNameGlonass) ) {
346 appendFlagGlonass = QIODevice::Append;
347 }
348
349 _ephFileGlonass = new QFile(ephFileNameGlonass);
350 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
351 _ephStreamGlonass = new QTextStream();
352 _ephStreamGlonass->setDevice(_ephFileGlonass);
353 }
354
355 // Header - RINEX Version 3
356 // ------------------------
357 if (_rinexVers == 3) {
358 if ( ! (appendFlagGPS & QIODevice::Append)) {
359 QString line;
360 line.sprintf(
361 "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
362 3.0, "", "");
363 *_ephStreamGPS << line;
364
365 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
366 *_ephStreamGPS << _pgmName.toAscii().data()
367 << _userName.toAscii().data()
368 << hlp.toAscii().data()
369 << "PGM / RUN BY / DATE" << endl;
370
371 line.sprintf("%60sEND OF HEADER\n", "");
372 *_ephStreamGPS << line;
373
374 _ephStreamGPS->flush();
375 }
376 }
377
378 // Headers - RINEX Version 2
379 // -------------------------
380 else if (_rinexVers == 2) {
381 if (! (appendFlagGPS & QIODevice::Append)) {
382 QString line;
383 line.sprintf(
384 "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.11, "", "");
385 *_ephStreamGPS << line;
386
387 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
388 *_ephStreamGPS << _pgmName.toAscii().data()
389 << _userName.toAscii().data()
390 << hlp.toAscii().data()
391 << "PGM / RUN BY / DATE" << endl;
392
393 line.sprintf("%60sEND OF HEADER\n", "");
394 *_ephStreamGPS << line;
395
396 _ephStreamGPS->flush();
397 }
398 if (! (appendFlagGlonass & QIODevice::Append)) {
399 QString line;
400 line.sprintf(
401 "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",2.11,"","");
402 *_ephStreamGlonass << line;
403
404 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
405 *_ephStreamGlonass << _pgmName.toAscii().data()
406 << _userName.toAscii().data()
407 << hlp.toAscii().data()
408 << "PGM / RUN BY / DATE" << endl;
409
410 line.sprintf("%60sEND OF HEADER\n", "");
411 *_ephStreamGlonass << line;
412
413 _ephStreamGlonass->flush();
414 }
415 }
416 }
417}
418
419// Print One GPS Ephemeris
420////////////////////////////////////////////////////////////////////////////
421void bncApp::printGPSEph(gpsephemeris* ep, bool printFile) {
422
423 QString lineV2;
424 QString lineV3;
425
426 struct converttimeinfo cti;
427 converttime(&cti, ep->GPSweek, ep->TOC);
428
429 lineV3.sprintf("G%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
430 ep->satellite, cti.year, cti.month, cti.day, cti.hour,
431 cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
432 ep->clock_driftrate);
433
434 lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
435 ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
436 cti.minute, (double) cti.second, ep->clock_bias,
437 ep->clock_drift, ep->clock_driftrate);
438
439 QString line;
440 QByteArray allLines;
441
442 QByteArray fmt;
443 QByteArray fmt2;
444 if (_rinexVers == 2) {
445 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
446 fmt2 = " %18.11e %18.11e\n";
447 }
448 else {
449 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
450 fmt2 = " %18.11e %18.11e\n";
451 }
452
453 line.sprintf(fmt.data(), (double)ep->IODE, ep->Crs, ep->Delta_n, ep->M0);
454 allLines += line;
455
456 line.sprintf(fmt.data(), ep->Cuc, ep->e, ep->Cus, ep->sqrt_A);
457 allLines += line;
458
459 line.sprintf(fmt.data(), (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
460 allLines += line;
461
462 line.sprintf(fmt.data(), ep->i0, ep->Crc, ep->omega, ep->OMEGADOT);
463 allLines += line;
464
465 double dd = 0;
466 unsigned long ii = ep->flags;
467 if(ii & GPSEPHF_L2CACODE)
468 dd += 2.0;
469 if(ii & GPSEPHF_L2PCODE)
470 dd += 1.0;
471 line.sprintf(fmt.data(), ep->IDOT, dd, (double) ep->GPSweek,
472 ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
473 allLines += line;
474
475 if(ep->URAindex <= 6) /* URA index */
476 dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
477 else
478 dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
479 line.sprintf(fmt.data(), dd, ((double) ep->SVhealth), ep->TGD,
480 ((double) ep->IODC));
481 allLines += line;
482
483 line.sprintf(fmt2.data(), ((double)ep->TOW), 0.0);
484 allLines += line;
485
486 printOutput(printFile, _ephStreamGPS, lineV2, lineV3, allLines);
487}
488
489// Print One Glonass Ephemeris
490////////////////////////////////////////////////////////////////////////////
491void bncApp::printGlonassEph(glonassephemeris* ep, bool printFile) {
492
493 int ww = ep->GPSWeek;
494 int tow = ep->GPSTOW;
495 struct converttimeinfo cti;
496
497 updatetime(&ww, &tow, ep->tb*1000, 1);
498 converttime(&cti, ww, tow);
499
500 int tk = ep->tk-3*60*60;
501 if (tk < 0) {
502 tk += 86400;
503 }
504
505 QString lineV2;
506 QString lineV3;
507
508 lineV3.sprintf("R%02d %04d %02d %02d %02d %02d %02d %18.11e %18.11e %18.11e\n",
509 ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
510 cti.minute, cti.second, -ep->tau, ep->gamma, (double) tk);
511
512 lineV2.sprintf("%02d %02d %02d %02d %02d %02d%5.1f %18.11e %18.11e %18.11e\n",
513 ep->almanac_number, cti.year%100, cti.month, cti.day,
514 cti.hour, cti.minute, (double) cti.second, -ep->tau,
515 ep->gamma, (double) tk);
516
517 QString line;
518 QByteArray allLines;
519
520 QByteArray fmt;
521 if (_rinexVers == 2) {
522 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
523 }
524 else {
525 fmt = " %18.11e %18.11e %18.11e %18.11e\n";
526 }
527
528 line.sprintf(fmt.data(), ep->x_pos, ep->x_velocity, ep->x_acceleration,
529 (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
530 allLines += line;
531
532 line.sprintf(fmt.data(), ep->y_pos, ep->y_velocity, ep->y_acceleration,
533 (double) ep->frequency_number);
534 allLines += line;
535
536 line.sprintf(fmt.data(), ep->z_pos, ep->z_velocity, ep->z_acceleration,
537 (double) ep->E);
538 allLines += line;
539
540 printOutput(printFile, _ephStreamGlonass, lineV2, lineV3, allLines);
541}
542
543// Output
544////////////////////////////////////////////////////////////////////////////
545void bncApp::printOutput(bool printFile, QTextStream* stream,
546 const QString& lineV2,
547 const QString& lineV3,
548 const QByteArray& allLines) {
549 // Output into file
550 // ----------------
551 if (printFile && stream) {
552 if (_rinexVers == 2) {
553 *stream << lineV2.toAscii();
554 }
555 else {
556 *stream << lineV3.toAscii();
557 }
558 *stream << allLines;
559 stream->flush();
560 }
561
562 // Output into the socket
563 // ----------------------
564 if (_sockets) {
565 QMutableListIterator<QTcpSocket*> is(*_sockets);
566 while (is.hasNext()) {
567 QTcpSocket* sock = is.next();
568 if (sock->state() == QAbstractSocket::ConnectedState) {
569 if (sock->write(lineV3.toAscii()) == -1 ||
570 sock->write(allLines) == -1) {
571 delete sock;
572 is.remove();
573 }
574 }
575 else if (sock->state() != QAbstractSocket::ConnectingState) {
576 delete sock;
577 is.remove();
578 }
579 }
580 }
581}
582
583// Set Port Number
584////////////////////////////////////////////////////////////////////////////
585void bncApp::setPort(int port) {
586 _port = port;
587 if (_port != 0) {
588 delete _server;
589 _server = new QTcpServer;
590 if ( !_server->listen(QHostAddress::Any, _port) ) {
591 slotMessage("bncApp: Cannot listen on ephemeris port", true);
592 }
593 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
594 delete _sockets;
595 _sockets = new QList<QTcpSocket*>;
596 }
597}
598
599// Set Port Number
600////////////////////////////////////////////////////////////////////////////
601void bncApp::setPortCorr(int port) {
602 _portCorr = port;
603 if (_portCorr != 0) {
604 delete _serverCorr;
605 _serverCorr = new QTcpServer;
606 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
607 slotMessage("bncApp: Cannot listen on correction port", true);
608 }
609 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
610 delete _socketsCorr;
611 _socketsCorr = new QList<QTcpSocket*>;
612 }
613}
614
615// New Connection
616////////////////////////////////////////////////////////////////////////////
617void bncApp::slotNewConnection() {
618 _sockets->push_back( _server->nextPendingConnection() );
619}
620
621// New Connection
622////////////////////////////////////////////////////////////////////////////
623void bncApp::slotNewConnectionCorr() {
624 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
625}
626
627//
628////////////////////////////////////////////////////////////////////////////
629void bncApp::slotQuit() {
630 cout << "bncApp::slotQuit" << endl;
631 delete _caster;
632 quit();
633}
634
635//
636////////////////////////////////////////////////////////////////////////////
637void bncApp::slotNewCorrLine(QString line, QString staID, long coTime) {
638
639 QMutexLocker locker(&_mutex);
640
641 bncSettings settings;
642 _waitCoTime = settings.value("corrTime").toInt();
643 if (_waitCoTime < 1) {
644 _waitCoTime = 1;
645 }
646
647 // First time, set the _lastDumpSec immediately
648 // --------------------------------------------
649 if (_lastDumpCoSec == 0) {
650 _lastDumpCoSec = coTime - 1;
651 }
652
653 // An old correction - throw it away
654 // ---------------------------------
655 if (coTime <= _lastDumpCoSec) {
656 QString line = staID + ": Correction for one sat neglected because overaged by " +
657 QString().sprintf(" %ld sec",
658 _lastDumpCoSec - coTime + _waitCoTime);
659 messagePrivate(line.toAscii());
660 emit( newMessage(line.toAscii(), true) );
661 return;
662 }
663
664 _corrs->insert(coTime, QString(line + " " + staID));
665
666 // Dump Corrections
667 // ----------------
668 if (coTime - _waitCoTime > _lastDumpCoSec) {
669 dumpCorrs(_lastDumpCoSec + 1, coTime - _waitCoTime);
670 _lastDumpCoSec = coTime - _waitCoTime;
671 }
672}
673
674// Dump Complete Correction Epochs
675////////////////////////////////////////////////////////////////////////////
676void bncApp::dumpCorrs(long minTime, long maxTime) {
677
678 for (long sec = minTime; sec <= maxTime; sec++) {
679 QList<QString> allCorrs = _corrs->values(sec);
680 emit newCorrections(allCorrs);
681 if (_socketsCorr) {
682 QListIterator<QString> it(allCorrs);
683 while (it.hasNext()) {
684 QString corrLine = it.next() + "\n";
685
686 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
687 while (is.hasNext()) {
688 QTcpSocket* sock = is.next();
689 if (sock->state() == QAbstractSocket::ConnectedState) {
690 if (sock->write(corrLine.toAscii()) == -1) {
691 delete sock;
692 is.remove();
693 }
694 }
695 else if (sock->state() != QAbstractSocket::ConnectingState) {
696 delete sock;
697 is.remove();
698 }
699 }
700 }
701 }
702 _corrs->remove(sec);
703 }
704}
705
706//
707////////////////////////////////////////////////////////////////////////////
708void bncApp::setConfFileName(const QString& confFileName) {
709 if (confFileName.isEmpty()) {
710 _confFileName = QDir::homePath() + QDir::separator()
711 + ".config" + QDir::separator()
712 + organizationName() + QDir::separator()
713 + applicationName() + ".ini";
714 }
715 else {
716 _confFileName = confFileName;
717 }
718}
Note: See TracBrowser for help on using the repository browser.