Changeset 88 in ntrip


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

* empty log message *

Location:
trunk/BNC
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnccaster.cpp

    r82 r88  
    6969// New Observations
    7070////////////////////////////////////////////////////////////////////////////
    71 void bncCaster::slotNewObs(const QByteArray& mountPoint, Observation* obs) {
     71void bncCaster::slotNewObs(const QByteArray& staID, Observation* obs) {
    7272
    7373  long newTime = obs->GPSWeek * 7*24*3600 + obs->GPSWeeks;
     
    8888  // Rename the station and save the observation
    8989  // -------------------------------------------
    90   strncpy(obs->StatID, mountPoint.constData(),sizeof(obs->StatID));
     90  strncpy(obs->StatID, staID.constData(),sizeof(obs->StatID));
    9191  _epochs->insert(newTime, obs);
    9292
     
    113113          this, SLOT(slotGetThreadError(const QByteArray&)));
    114114
    115   _mountPoints.push_back(getThread->mountPoint());
     115  _staIDs.push_back(getThread->staID());
    116116}
    117117
    118118// Error in get thread
    119119////////////////////////////////////////////////////////////////////////////
    120 void bncCaster::slotGetThreadError(const QByteArray& mountPoint) {
    121   _mountPoints.removeAll(mountPoint);
     120void bncCaster::slotGetThreadError(const QByteArray& staID) {
     121  _staIDs.removeAll(staID);
    122122  emit( newMessage(
    123            QString("Mountpoint size %1").arg(_mountPoints.size()).toAscii()) );
    124   if (_mountPoints.size() == 0) {
     123           QString("Mountpoint size %1").arg(_staIDs.size()).toAscii()) );
     124  if (_staIDs.size() == 0) {
    125125    emit(newMessage("bncCaster:: last get thread terminated"));
    126126    emit getThreadErrors();
  • trunk/BNC/bnccaster.h

    r82 r88  
    2020   ~bncCaster();
    2121   void addGetThread(bncGetThread* getThread);
    22    int  nMountPoints() const {return _mountPoints.size();}
     22   int  numStations() const {return _staIDs.size();}
    2323
    2424 signals:
     
    2727
    2828 public slots:
    29    void slotNewObs(const QByteArray& mountPoint, Observation* obs);
     29   void slotNewObs(const QByteArray& staID, Observation* obs);
    3030
    3131 private slots:
    3232   void slotNewConnection();
    33    void slotGetThreadError(const QByteArray& mountPoint);
     33   void slotGetThreadError(const QByteArray& staID);
    3434
    3535 protected:
     
    4646   QTcpServer*                    _server;
    4747   QList<QTcpSocket*>*            _sockets;
    48    QList<QByteArray>              _mountPoints;
     48   QList<QByteArray>              _staIDs;
    4949   QMap<QString, bncRinex*>       _rinexWriters;
    5050};
  • 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);
  • trunk/BNC/bncgetthread.h

    r82 r88  
    1212
    1313 public:
    14    bncGetThread(const QString& host, int port,
    15                 const QString& proxyHost, int proxyPort,
    16                 const QByteArray& mountPoint,
    17                 const QByteArray& user,
    18                 const QByteArray& password,
    19                 const QByteArray& format);
     14   bncGetThread(const QUrl& mountPoint, const QByteArray& format);
    2015   ~bncGetThread();
    21    static QTcpSocket* bncGetThread::request(const QString& host, int port,
    22                                       const QString& proxyHost, int proxyPort,
    23                                       const QByteArray& mountPoint,
    24                                       const QByteArray& user,
    25                                       const QByteArray& password,
    26                                       QString& msg);
    27    QByteArray mountPoint() {return _mountPoint;}
     16
     17   static QTcpSocket* bncGetThread::request(const QUrl& mountPoint,
     18                                            QString& msg);
     19
     20   QByteArray staID() const {return _staID;}
    2821
    2922 signals:
    30    void newObs(const QByteArray& mountPoint, Observation* obs);
    31    void error(const QByteArray& mountPoint);
     23   void newObs(const QByteArray& staID, Observation* obs);
     24   void error(const QByteArray& staID);
    3225   void newMessage(const QByteArray& msg);
    3326
     
    3831   void exit(int exitCode = 0);
    3932   QTcpSocket* _socket;
    40    QString     _host;
    41    int         _port;
    42    QString     _proxyHost;
    43    int         _proxyPort;
    44    QByteArray  _mountPoint;
    45    QByteArray  _user;
    46    QByteArray  _password;
     33   QUrl        _mountPoint;
     34   QByteArray  _staID;
    4735   QByteArray  _format;
    4836};
  • trunk/BNC/bncmain.cpp

    r82 r88  
    4646  else {
    4747    QSettings settings;
    48     QString    proxyHost = settings.value("proxyHost").toString();
    49     int        proxyPort = settings.value("proxyPort").toInt();
    50     QByteArray user      = settings.value("user").toString().toAscii();
    51     QByteArray password  = settings.value("password").toString().toAscii();
    52    
    5348    bncCaster* caster = new bncCaster(settings.value("outFile").toString(),
    5449                                      settings.value("outPort").toInt());
     
    6560      if (hlp.size() <= 1) continue;
    6661      QUrl url(hlp[0]);
    67       QByteArray mountPoint = url.path().mid(1).toAscii();
    68       QByteArray format     = hlp[1].toAscii();
    69 
    70       bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
    71                                                  proxyHost, proxyPort,
    72                                                  mountPoint, user, password,
    73                                                  format);
     62      QByteArray format = hlp[1].toAscii();
     63      bncGetThread* getThread = new bncGetThread(url, format);
    7464      app.connect(getThread, SIGNAL(newMessage(const QByteArray&)),
    7565                  &app, SLOT(slotMessage(const QByteArray&)));
     
    7969      getThread->start();
    8070    }
    81     if (caster->nMountPoints() == 0) {
     71    if (caster->numStations() == 0) {
    8272      return 0;
    8373    }
  • trunk/BNC/bnctabledlg.cpp

    r83 r88  
    3131  QVBoxLayout* mainLayout = new QVBoxLayout(this);
    3232
    33   _casterHostLabel    = new QLabel(tr("caster host"));
    34   _casterPortLabel    = new QLabel(tr("caster port"));
     33  _casterHostLabel     = new QLabel(tr("caster host"));
     34  _casterPortLabel     = new QLabel(tr("caster port"));
     35  _casterUserLabel     = new QLabel(tr("user"));
     36  _casterPasswordLabel = new QLabel(tr("password"));
    3537  QSettings settings;
    36   _casterHostLineEdit = new QLineEdit(settings.value("casterHost").toString());
    37   _casterPortLineEdit = new QLineEdit(settings.value("casterPort").toString());
    38 
    39   QHBoxLayout* editLayout = new QHBoxLayout;
    40   editLayout->addWidget(_casterHostLabel);
    41   editLayout->addWidget(_casterHostLineEdit);
    42   editLayout->addWidget(_casterPortLabel);
    43   editLayout->addWidget(_casterPortLineEdit);
     38  _casterHostLineEdit     = new QLineEdit(settings.value("casterHost").toString());
     39  int ww = QFontMetrics(_casterHostLineEdit->font()).width('w');
     40  _casterHostLineEdit->setMaximumWidth(18*ww);
     41  _casterPortLineEdit     = new QLineEdit(settings.value("casterPort").toString());
     42  _casterPortLineEdit->setMaximumWidth(9*ww);
     43  _casterUserLineEdit     = new QLineEdit(settings.value("casterUser").toString());
     44  _casterUserLineEdit->setMaximumWidth(9*ww);
     45  _casterPasswordLineEdit = new QLineEdit(settings.value("casterPassword").toString());
     46  _casterPasswordLineEdit->setMaximumWidth(9*ww);
     47  _casterPasswordLineEdit->setEchoMode(QLineEdit::Password);
     48
     49  QGridLayout* editLayout = new QGridLayout;
     50  editLayout->addWidget(_casterHostLabel, 0, 0);
     51  editLayout->addWidget(_casterHostLineEdit, 0, 1);
     52  editLayout->addWidget(_casterPortLabel, 0, 2);
     53  editLayout->addWidget(_casterPortLineEdit, 0, 3);
     54  editLayout->addWidget(_casterUserLabel, 1, 0);
     55  editLayout->addWidget(_casterUserLineEdit, 1, 1);
     56  editLayout->addWidget(_casterPasswordLabel, 1, 2);
     57  editLayout->addWidget(_casterPasswordLineEdit, 1, 3);
     58
    4459  mainLayout->addLayout(editLayout);
    4560
     
    8196void bncTableDlg::slotGetTable() {
    8297
    83   QString    host       = _casterHostLineEdit->text();
    84   int        port       = _casterPortLineEdit->text().toInt();
    85   QByteArray mountPoint = "/";
    86   QByteArray user;
    87   QByteArray password;
     98  QUrl url;
     99  url.setHost(_casterHostLineEdit->text());
     100  url.setPort(_casterPortLineEdit->text().toInt());
    88101
    89102  // Send the Request
    90103  // ----------------
    91104  QString msg;
    92   QTcpSocket* socket = bncGetThread::request(host, port, _proxyHost,
    93                                              _proxyPort, mountPoint,
    94                                              user, password, msg);
     105  QTcpSocket* socket = bncGetThread::request(url, msg);
     106
    95107  if (!socket) {
    96108    QMessageBox::warning(0, "BNC", msg);
     
    163175  settings.setValue("casterHost", _casterHostLineEdit->text());
    164176  settings.setValue("casterPort", _casterPortLineEdit->text());
     177  settings.setValue("casterUser", _casterUserLineEdit->text());
     178  settings.setValue("casterPassword", _casterPasswordLineEdit->text());
    165179
    166180  QStringList* mountPoints = new QStringList;
     
    173187      if (_table->isItemSelected(item)) {
    174188        QUrl url;
     189        url.setUserName(_casterUserLineEdit->text());
     190        url.setPassword(_casterPasswordLineEdit->text());
    175191        url.setHost(_casterHostLineEdit->text());
    176192        url.setPort(_casterPortLineEdit->text().toInt());
  • trunk/BNC/bnctabledlg.h

    r82 r88  
    2727    QLineEdit*   _casterHostLineEdit;
    2828    QLineEdit*   _casterPortLineEdit;
     29    QLabel*      _casterUserLabel;
     30    QLabel*      _casterPasswordLabel;
     31    QLineEdit*   _casterUserLineEdit;
     32    QLineEdit*   _casterPasswordLineEdit;
    2933
    3034    QPushButton* _buttonGet;
  • trunk/BNC/bncwindow.cpp

    r83 r88  
    7676  _canvas->setLayout(layout);
    7777
    78   _userLabel          = new QLabel("user");
    79   _passwordLabel      = new QLabel("password");
     78  _timeOutLabel       = new QLabel("timeout (sec)");
    8079  _proxyHostLabel     = new QLabel("proxy host");
    8180  _proxyPortLabel     = new QLabel("proxy port");
     
    9594  _proxyPortLineEdit  = new QLineEdit(settings.value("proxyPort").toString());
    9695  _proxyPortLineEdit->setMaximumWidth(9*ww);
    97   _userLineEdit       = new QLineEdit(settings.value("user").toString());
    98   _userLineEdit->setMaximumWidth(9*ww);
    99   _passwordLineEdit   = new QLineEdit(settings.value("password").toString());
    100   _passwordLineEdit->setMaximumWidth(9*ww);
    101   _passwordLineEdit->setEchoMode(QLineEdit::Password);
     96  _timeOutLineEdit    = new QLineEdit(settings.value("timeOut").toString());
     97  _timeOutLineEdit->setMaximumWidth(9*ww);
    10298  _outFileLineEdit    = new QLineEdit(settings.value("outFile").toString());
    10399  _outPortLineEdit    = new QLineEdit(settings.value("outPort").toString());
     
    144140  _log->setReadOnly(true);
    145141
    146   layout->addWidget(_userLabel,          0, 0);
    147   layout->addWidget(_userLineEdit,       0, 1);
    148   layout->addWidget(_passwordLabel,      0, 2);
    149   layout->addWidget(_passwordLineEdit,   0, 3);
    150   layout->addWidget(_proxyHostLabel,     1, 0);
    151   layout->addWidget(_proxyHostLineEdit,  1, 1);
    152   layout->addWidget(_proxyPortLabel,     1, 2);
    153   layout->addWidget(_proxyPortLineEdit,  1, 3);
     142  layout->addWidget(_proxyHostLabel,     0, 0);
     143  layout->addWidget(_proxyHostLineEdit,  0, 1);
     144  layout->addWidget(_proxyPortLabel,     0, 2);
     145  layout->addWidget(_proxyPortLineEdit,  0, 3);
     146  layout->addWidget(_timeOutLabel,       1, 1);
     147  layout->addWidget(_timeOutLineEdit,    1, 2);
    154148  layout->addWidget(_outFileLabel,       2, 1);
    155149  layout->addWidget(_outFileLineEdit,    2, 2, 1, 2);
     
    234228  settings.setValue("proxyHost",   _proxyHostLineEdit->text());
    235229  settings.setValue("proxyPort",   _proxyPortLineEdit->text());
    236   settings.setValue("user",        _userLineEdit->text());
    237   settings.setValue("password",    _passwordLineEdit->text());
     230  settings.setValue("timeOut",     _timeOutLineEdit->text());
    238231  settings.setValue("outFile",     _outFileLineEdit->text());
    239232  settings.setValue("outPort",     _outPortLineEdit->text());
     
    264257  _actGetData->setEnabled(false);
    265258
    266   QString    proxyHost = _proxyHostLineEdit->text();
    267   int        proxyPort = _proxyPortLineEdit->text().toInt();
    268   QByteArray user      = _userLineEdit->text().toAscii();
    269   QByteArray password  = _passwordLineEdit->text().toAscii();
    270 
    271259  _bncCaster = new bncCaster(_outFileLineEdit->text(),
    272260                             _outPortLineEdit->text().toInt());
     
    282270  for (int iRow = 0; iRow < _mountPointsTable->rowCount(); iRow++) {
    283271    QUrl url(_mountPointsTable->item(iRow, 0)->text());
    284     QByteArray mountPoint = url.path().mid(1).toAscii();
    285272    QByteArray format     = _mountPointsTable->item(iRow, 1)->text().toAscii();
    286273
    287     bncGetThread* getThread = new bncGetThread(url.host(), url.port(),
    288                                                proxyHost, proxyPort,
    289                                                mountPoint, user, password,
    290                                                format);
     274    bncGetThread* getThread = new bncGetThread(url, format);
    291275
    292276    connect(getThread, SIGNAL(newMessage(const QByteArray&)),
  • trunk/BNC/bncwindow.h

    r83 r88  
    4343    QLabel*    _proxyHostLabel;
    4444    QLabel*    _proxyPortLabel;
    45     QLabel*    _userLabel;
    46     QLabel*    _passwordLabel;
     45    QLabel*    _timeOutLabel;
    4746    QLabel*    _rnxPathLabel;
    4847    QLabel*    _rnxSkelLabel;
     
    5554    QLineEdit* _proxyHostLineEdit;
    5655    QLineEdit* _proxyPortLineEdit;
    57     QLineEdit* _userLineEdit;
    58     QLineEdit* _passwordLineEdit;
     56    QLineEdit* _timeOutLineEdit;
    5957    QLineEdit* _outFileLineEdit;
    6058    QLineEdit* _outPortLineEdit;
Note: See TracChangeset for help on using the changeset viewer.