Changeset 88 in ntrip for trunk/BNC/bncgetthread.cpp


Ignore:
Timestamp:
Aug 31, 2006, 7:20:36 PM (18 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncgetthread.cpp

    r87 r88  
    3232// Constructor
    3333////////////////////////////////////////////////////////////////////////////
    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;
     34bncGetThread::bncGetThread(const QUrl& mountPoint, const QByteArray& format) {
    4435  _mountPoint = mountPoint;
    45   _user       = user;
    46   _password   = password;
     36  _staID      = mountPoint.path().toAscii();
    4737  _format     = format;
    4838  _socket     = 0;
     
    5747// Connect to Caster, send the Request (static)
    5848////////////////////////////////////////////////////////////////////////////
    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) {
     49QTcpSocket* bncGetThread::request(const QUrl& mountPoint, QString& msg) {
    6550
    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 
    6857  QTcpSocket* socket = new QTcpSocket();
    69 
    70   QByteArray l_mountPoint = mountPoint;
    71 
    7258  if ( proxyHost.isEmpty() ) {
    73     socket->connectToHost(host, port);
     59    socket->connectToHost(mountPoint.host(), mountPoint.port());
    7460  }
    7561  else {
    7662    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     }
    8463  }
    85 
    8664  if (!socket->waitForConnected(timeOut)) {
    8765    msg += "Connect timeout\n";
     
    9270  // Send Request
    9371  // ------------
    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";
    9979
    10080  msg += reqStr;
     
    11898  // ----------------
    11999  QString msg;
    120   _socket = bncGetThread::request(_host, _port, _proxyHost, _proxyPort,
    121                                   _mountPoint, _user, _password, msg);
     100
     101  _socket = bncGetThread::request(_mountPoint, msg);
     102
    122103  emit(newMessage(msg.toAscii()));
    123104
     
    146127
    147128  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"));
    149130    decoder = new RTCM('A',true);
    150131  }
    151132  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"));
    153134    decoder = new rtcm3();
    154135  }
    155136  else if (_format.indexOf("RTIGS") != -1) {
    156     emit(newMessage("Get Data: " + _mountPoint + " in RTIGS format"));
     137    emit(newMessage("Get Data: " + _staID + " in RTIGS format"));
    157138    decoder = new rtigs();
    158139  }
    159140  else {
    160     emit(newMessage(_mountPoint + " Unknown data format " + _format));
     141    emit(newMessage(_staID + " Unknown data format " + _format));
    161142    return exit(1);
    162143  }
     
    174155      for (list<Observation*>::iterator it = decoder->m_lObsList.begin();
    175156           it != decoder->m_lObsList.end(); it++) {
    176         emit newObs(_mountPoint, *it);
     157        emit newObs(_staID, *it);
    177158      }
    178159      decoder->m_lObsList.clear();
     
    190171void bncGetThread::exit(int exitCode) {
    191172  if (exitCode!= 0) {
    192     emit error(_mountPoint);
     173    emit error(_staID);
    193174  }
    194175  QThread::exit(exitCode);
Note: See TracChangeset for help on using the changeset viewer.