Changeset 88 in ntrip for trunk/BNC/bncgetthread.cpp
- Timestamp:
- Aug 31, 2006, 7:20:36 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncgetthread.cpp
r87 r88 32 32 // Constructor 33 33 //////////////////////////////////////////////////////////////////////////// 34 bncGetThread::bncGetThread(const QString& host, int port, 35 const QString& proxyHost, int proxyPort, 36 const QByteArray& mountPoint, 37 const QByteArray& user, 38 const QByteArray& password, 39 const QByteArray& format) { 40 _host = host; 41 _port = port; 42 _proxyHost = proxyHost; 43 _proxyPort = proxyPort; 34 bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format) { 44 35 _mountPoint = mountPoint; 45 _user = user; 46 _password = password; 36 _staID = mountPoint.path().toAscii(); 47 37 _format = format; 48 38 _socket = 0; … … 57 47 // Connect to Caster, send the Request (static) 58 48 //////////////////////////////////////////////////////////////////////////// 59 QTcpSocket* bncGetThread::request(const QString& host, int port, 60 const QString& proxyHost, int proxyPort, 61 const QByteArray& mountPoint, 62 const QByteArray& user, 63 const QByteArray& password, 64 QString& msg) { 49 QTcpSocket* bncGetThread::request(const QUrl& mountPoint, QString& msg) { 65 50 66 msg.clear(); 67 51 // Connect the Socket 52 // ------------------ 53 QSettings settings; 54 QString proxyHost = settings.value("proxyHost").toString(); 55 int proxyPort = settings.value("proxyPort").toInt(); 56 68 57 QTcpSocket* socket = new QTcpSocket(); 69 70 QByteArray l_mountPoint = mountPoint;71 72 58 if ( proxyHost.isEmpty() ) { 73 socket->connectToHost( host, port);59 socket->connectToHost(mountPoint.host(), mountPoint.port()); 74 60 } 75 61 else { 76 62 socket->connectToHost(proxyHost, proxyPort); 77 if (!proxyHost.isEmpty()) {78 QUrl proxyUrl;79 proxyUrl.setScheme("http");80 proxyUrl.setHost(host);81 proxyUrl.setPort(port);82 l_mountPoint = proxyUrl.resolved(QUrl(mountPoint)).toEncoded();83 }84 63 } 85 86 64 if (!socket->waitForConnected(timeOut)) { 87 65 msg += "Connect timeout\n"; … … 92 70 // Send Request 93 71 // ------------ 94 QByteArray userAndPwd = user + ":" + password; 95 QByteArray reqStr = "GET " + l_mountPoint + " HTTP/1.0\r\n" 96 "User-Agent: NTRIP BNC 1.0\r\n" 97 "Authorization: Basic " + userAndPwd.toBase64() + 98 "\r\n\r\n"; 72 QByteArray userAndPwd = mountPoint.userName().toAscii() + ":" + 73 mountPoint.password().toAscii(); 74 QByteArray reqStr = "GET " + mountPoint.path().toAscii() + 75 " HTTP/1.0\r\n" 76 "User-Agent: NTRIP BNC 1.0\r\n" 77 "Authorization: Basic " + 78 userAndPwd.toBase64() + "\r\n\r\n"; 99 79 100 80 msg += reqStr; … … 118 98 // ---------------- 119 99 QString msg; 120 _socket = bncGetThread::request(_host, _port, _proxyHost, _proxyPort, 121 _mountPoint, _user, _password, msg); 100 101 _socket = bncGetThread::request(_mountPoint, msg); 102 122 103 emit(newMessage(msg.toAscii())); 123 104 … … 146 127 147 128 if (_format.indexOf("RTCM_2") != -1) { 148 emit(newMessage("Get Data: " + _ mountPoint+ " in RTCM 2.x format"));129 emit(newMessage("Get Data: " + _staID + " in RTCM 2.x format")); 149 130 decoder = new RTCM('A',true); 150 131 } 151 132 else if (_format.indexOf("RTCM_3") != -1) { 152 emit(newMessage("Get Data: " + _ mountPoint+ " in RTCM 3.0 format"));133 emit(newMessage("Get Data: " + _staID + " in RTCM 3.0 format")); 153 134 decoder = new rtcm3(); 154 135 } 155 136 else if (_format.indexOf("RTIGS") != -1) { 156 emit(newMessage("Get Data: " + _ mountPoint+ " in RTIGS format"));137 emit(newMessage("Get Data: " + _staID + " in RTIGS format")); 157 138 decoder = new rtigs(); 158 139 } 159 140 else { 160 emit(newMessage(_ mountPoint+ " Unknown data format " + _format));141 emit(newMessage(_staID + " Unknown data format " + _format)); 161 142 return exit(1); 162 143 } … … 174 155 for (list<Observation*>::iterator it = decoder->m_lObsList.begin(); 175 156 it != decoder->m_lObsList.end(); it++) { 176 emit newObs(_ mountPoint, *it);157 emit newObs(_staID, *it); 177 158 } 178 159 decoder->m_lObsList.clear(); … … 190 171 void bncGetThread::exit(int exitCode) { 191 172 if (exitCode!= 0) { 192 emit error(_ mountPoint);173 emit error(_staID); 193 174 } 194 175 QThread::exit(exitCode);
Note:
See TracChangeset
for help on using the changeset viewer.