Changeset 1367 in ntrip
- Timestamp:
- Dec 27, 2008, 11:22:13 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r1353 r1367 323 323 // Read Caster Response 324 324 // -------------------- 325 _socket->waitForReadyRead(_timeOut); 326 if (_socket->canReadLine()) { 327 QString line = _socket->readLine(); 328 329 // Skip messages from proxy server 330 // ------------------------------- 331 if (line.indexOf("ICY 200 OK") == -1 && 332 line.indexOf("200 OK") != -1 ) { 333 bool proxyRespond = true; 334 while (true) { 335 if (_socket->canReadLine()) { 336 line = _socket->readLine(); 337 if (!proxyRespond) { 338 break; 339 } 340 if (line.trimmed().isEmpty()) { 341 proxyRespond = false; 342 } 343 } 344 else { 345 _socket->waitForReadyRead(_timeOut); 346 if (_socket->bytesAvailable() <= 0) { 347 break; 348 } 349 } 350 } 351 } 352 353 if (line.indexOf("Unauthorized") != -1) { 354 QStringList table; 355 bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(), 356 _ntripVersion, table); 357 QString net; 358 QStringListIterator it(table); 359 while (it.hasNext()) { 360 QString line = it.next(); 361 if (line.indexOf("STR") == 0) { 362 QStringList tags = line.split(";"); 363 if (tags.at(1) == _staID_orig) { 364 net = tags.at(7); 365 break; 366 } 367 } 368 } 369 370 QString reg; 371 it.toFront(); 372 while (it.hasNext()) { 373 QString line = it.next(); 374 if (line.indexOf("NET") == 0) { 375 QStringList tags = line.split(";"); 376 if (tags.at(1) == net) { 377 reg = tags.at(7); 378 break; 379 } 380 } 381 } 382 emit(newMessage((_staID + ": Caster Response: " + line + 383 " Adjust User-ID and Password Register, see" 384 "\n " + reg).toAscii(), true)); 385 return fatal; 386 } 387 if (line.indexOf("ICY 200 OK") != 0) { 388 emit(newMessage((_staID + ": Wrong Caster Response:\n" + line).toAscii(), true)); 325 if (_ntripVersion == "1") { 326 _socket->waitForReadyRead(_timeOut); 327 if (_socket->canReadLine()) { 328 QString line = _socket->readLine(); 329 330 // Skip messages from proxy server 331 // ------------------------------- 332 if (line.indexOf("ICY 200 OK") == -1 && 333 line.indexOf("200 OK") != -1 ) { 334 bool proxyRespond = true; 335 while (true) { 336 if (_socket->canReadLine()) { 337 line = _socket->readLine(); 338 if (!proxyRespond) { 339 break; 340 } 341 if (line.trimmed().isEmpty()) { 342 proxyRespond = false; 343 } 344 } 345 else { 346 _socket->waitForReadyRead(_timeOut); 347 if (_socket->bytesAvailable() <= 0) { 348 break; 349 } 350 } 351 } 352 } 353 354 if (line.indexOf("Unauthorized") != -1) { 355 QStringList table; 356 bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(), 357 _ntripVersion, table); 358 QString net; 359 QStringListIterator it(table); 360 while (it.hasNext()) { 361 QString line = it.next(); 362 if (line.indexOf("STR") == 0) { 363 QStringList tags = line.split(";"); 364 if (tags.at(1) == _staID_orig) { 365 net = tags.at(7); 366 break; 367 } 368 } 369 } 370 371 QString reg; 372 it.toFront(); 373 while (it.hasNext()) { 374 QString line = it.next(); 375 if (line.indexOf("NET") == 0) { 376 QStringList tags = line.split(";"); 377 if (tags.at(1) == net) { 378 reg = tags.at(7); 379 break; 380 } 381 } 382 } 383 emit(newMessage((_staID + ": Caster Response: " + line + 384 " Adjust User-ID and Password Register, see" 385 "\n " + reg).toAscii(), true)); 386 return fatal; 387 } 388 if (line.indexOf("ICY 200 OK") != 0) { 389 emit(newMessage((_staID + ": Wrong Caster Response:\n" + line).toAscii(), true)); 390 return failure; 391 } 392 } 393 else { 394 emit(newMessage(_staID + ": Response Timeout", true)); 389 395 return failure; 390 396 } 391 }392 else {393 emit(newMessage(_staID + ": Response Timeout", true));394 return failure;395 397 } 396 398 } -
trunk/BNC/bncsocket.cpp
r1366 r1367 5 5 * Class: bncSocket 6 6 * 7 * Purpose: Combines QTcpSocket (NTRIP v1) and QNetworkReply(NTRIP v2)7 * Purpose: Combines QTcpSocket (NTRIP v1) and QHttp (NTRIP v2) 8 8 * 9 9 * Author: L. Mervart … … 17 17 #include <iostream> 18 18 #include <iomanip> 19 20 #include <string.h> 19 21 20 22 #include "bncsocket.h" … … 46 48 //////////////////////////////////////////////////////////////////////////// 47 49 QAbstractSocket::SocketState bncSocket::state() const { 48 if (_socket) { 50 if (_http) { 51 if (_http->state() != QHttp::Unconnected) { 52 return QAbstractSocket::ConnectedState; 53 } 54 else { 55 return QAbstractSocket::UnconnectedState; 56 } 57 } 58 else if (_socket) { 49 59 return _socket->state(); 50 60 } … … 136 146 //////////////////////////////////////////////////////////////////////////// 137 147 qint64 bncSocket::read(char* data, qint64 maxlen) { 138 if (_socket) { 148 if (_http) { 149 strncpy(data, _buffer.data(), maxlen); 150 _buffer = _buffer.right(_buffer.size()-maxlen); 151 return maxlen; 152 } 153 else if (_socket) { 139 154 return _socket->read(data, maxlen); 140 155 }
Note:
See TracChangeset
for help on using the changeset viewer.