Changeset 1356 in ntrip
- Timestamp:
- Dec 27, 2008, 2:54:58 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncsocket.cpp
r1355 r1356 52 52 void bncSocket::connectToHost(const QString &hostName, quint16 port, 53 53 QIODevice::OpenMode mode) { 54 #if QT_VERSION >= 0x040400 55 if (_reply) { 56 } 57 else 58 #endif 54 59 if (_socket) { 55 60 _socket->connectToHost(hostName, port, mode); … … 60 65 //////////////////////////////////////////////////////////////////////////// 61 66 bool bncSocket::waitForConnected(int msecs) { 67 #if QT_VERSION >= 0x040400 68 if (_reply) { 69 return true; 70 } 71 else 72 #endif 62 73 if (_socket) { 63 74 return _socket->waitForConnected(msecs); … … 71 82 //////////////////////////////////////////////////////////////////////////// 72 83 QAbstractSocket::SocketState bncSocket::state() const { 84 #if QT_VERSION >= 0x040400 85 if (_reply) { 86 return QAbstractSocket::ConnectedState; 87 } 88 else 89 #endif 73 90 if (_socket) { 74 91 return _socket->state(); … … 82 99 //////////////////////////////////////////////////////////////////////////// 83 100 void bncSocket::close() { 101 #if QT_VERSION >= 0x040400 102 if (_reply) { 103 _reply->close(); 104 } 105 else 106 #endif 84 107 if (_socket) { 85 108 _socket->close(); … … 90 113 //////////////////////////////////////////////////////////////////////////// 91 114 qint64 bncSocket::bytesAvailable() const { 115 #if QT_VERSION >= 0x040400 116 if (_reply) { 117 return _reply->bytesAvailable(); 118 } 119 else 120 #endif 92 121 if (_socket) { 93 122 return _socket->bytesAvailable(); … … 101 130 //////////////////////////////////////////////////////////////////////////// 102 131 bool bncSocket::canReadLine() const { 132 #if QT_VERSION >= 0x040400 133 if (_reply) { 134 return _reply->canReadLine(); 135 } 136 else 137 #endif 103 138 if (_socket) { 104 139 return _socket->canReadLine(); … … 112 147 //////////////////////////////////////////////////////////////////////////// 113 148 QByteArray bncSocket::readLine(qint64 maxlen) { 149 #if QT_VERSION >= 0x040400 150 if (_reply) { 151 return _reply->readLine(maxlen); 152 } 153 else 154 #endif 114 155 if (_socket) { 115 156 return _socket->readLine(maxlen); … … 123 164 //////////////////////////////////////////////////////////////////////////// 124 165 bool bncSocket::waitForReadyRead(int msecs) { 166 #if QT_VERSION >= 0x040400 167 if (_reply) { 168 return _reply->waitForReadyRead(msecs); 169 } 170 else 171 #endif 125 172 if (_socket) { 126 173 return _socket->waitForReadyRead(msecs); … … 134 181 //////////////////////////////////////////////////////////////////////////// 135 182 qint64 bncSocket::read(char* data, qint64 maxlen) { 183 #if QT_VERSION >= 0x040400 184 if (_reply) { 185 return _reply->read(data, maxlen); 186 } 187 else 188 #endif 136 189 if (_socket) { 137 190 return _socket->read(data, maxlen); … … 145 198 //////////////////////////////////////////////////////////////////////////// 146 199 qint64 bncSocket::write(const char* data, qint64 len) { 200 #if QT_VERSION >= 0x040400 201 if (_reply) { 202 return -1; 203 } 204 else 205 #endif 147 206 if (_socket) { 148 207 return _socket->write(data, len); … … 156 215 //////////////////////////////////////////////////////////////////////////// 157 216 bool bncSocket::waitForBytesWritten(int msecs) { 217 #if QT_VERSION >= 0x040400 218 if (_reply) { 219 return _reply->waitForBytesWritten(msecs); 220 } 221 else 222 #endif 158 223 if (_socket) { 159 224 return _socket->waitForBytesWritten(msecs); … … 330 395 // Connect to Caster NTRIP Version 2 331 396 //////////////////////////////////////////////////////////////////////////// 332 t_irc bncSocket::request2(const QUrl& mountPoint, const QByteArray& latitude,397 t_irc bncSocket::request2(const QUrl& url, const QByteArray& latitude, 333 398 const QByteArray& longitude, const QByteArray& nmea, 334 399 int timeOut, QString& msg) { … … 337 402 return failure; 338 403 #else 339 340 #endif 341 } 404 // Network Access Manager 405 // ---------------------- 406 if (_manager == 0) { 407 _manager = new QNetworkAccessManager(this); 408 } 409 else { 410 return failure; 411 } 412 413 // Network Request 414 // --------------- 415 QNetworkRequest request; 416 request.setUrl(url); 417 request.setRawHeader("Host" , url.host().toAscii()); 418 request.setRawHeader("Ntrip-Version", "NTRIP/2.0"); 419 request.setRawHeader("User-Agent" , "NTRIP BNC/1.7"); 420 if (!url.userName().isEmpty()) { 421 request.setRawHeader("Authorization", "Basic " + 422 (url.userName() + ":" + url.password()).toAscii().toBase64()); 423 } 424 request.setRawHeader("Connection" , "close"); 425 426 _reply = _manager->get(request); 427 428 connect(_reply, SIGNAL(finished()), this, SLOT(slotReplyFinished())); 429 connect(_reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); 430 connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), 431 this, SLOT(slotError(QNetworkReply::NetworkError))); 432 connect(_reply, SIGNAL(sslErrors(const QList<QSslError>&)), 433 this, SLOT(slotSslErrors(const QList<QSslError>&))); 434 435 return success; 436 #endif 437 } -
trunk/BNC/bncsocket.h
r1355 r1356 41 41 42 42 private: 43 t_irc request2(const QUrl& mountPoint, const QByteArray& latitude,43 t_irc request2(const QUrl& url, const QByteArray& latitude, 44 44 const QByteArray& longitude, const QByteArray& nmea, 45 45 int timeOut, QString& msg);
Note:
See TracChangeset
for help on using the changeset viewer.