Changeset 1374 in ntrip for trunk/BNC/bncnetquery.cpp


Ignore:
Timestamp:
Dec 28, 2008, 9:53:04 PM (16 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncnetquery.cpp

    r1373 r1374  
    3535  _reply     = 0;
    3636  _eventLoop = new QEventLoop(this);
     37
     38  _status    = init;
    3739}
    3840
     
    4850////////////////////////////////////////////////////////////////////////////
    4951void bncNetQuery::slotError(QNetworkReply::NetworkError) {
     52  _status = error;
    5053  cout << "slotError " << endl;
    5154  emit newMessage("slotError " + _reply->errorString().toAscii(), true);
     
    5457
    5558void bncNetQuery::slotFinished() {
     59  if (_status != error) {
     60    _status = finished;
     61  }
    5662  cout << "slotFinished" << endl;
    5763}
     
    6369// Start request, block till the next read (public)
    6470////////////////////////////////////////////////////////////////////////////
    65 t_irc bncNetQuery::startRequest(const QUrl& url) {
    66   return startRequest(url, true);
     71void bncNetQuery::startRequest(const QUrl& url) {
     72  startRequest(url, true);
    6773}
    6874
    6975// Start request
    7076////////////////////////////////////////////////////////////////////////////
    71 t_irc bncNetQuery::startRequest(const QUrl& url, bool full) {
     77void bncNetQuery::startRequest(const QUrl& url, bool full) {
     78
     79  _status = running;
    7280
    7381  // Default scheme and path
     
    107115  connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)),
    108116          this, SLOT(slotError(QNetworkReply::NetworkError)));
    109 
    110   return success;
    111117}
    112118
    113119// Start Request, wait for its completion
    114120////////////////////////////////////////////////////////////////////////////
    115 t_irc bncNetQuery::waitForRequestResult(const QUrl& url, QByteArray& outData) {
     121void bncNetQuery::waitForRequestResult(const QUrl& url, QByteArray& outData) {
    116122
    117123  // Send Request
    118124  // ------------
    119   if (startRequest(url) != success) {
    120     return failure;
    121   }
     125  startRequest(url);
    122126
    123127  // Wait Loop
     
    128132  // --------------------
    129133  outData = _reply->readAll();
    130 
    131   if (_reply->error() == QNetworkReply::NoError) {
    132     return success;
    133   }
    134   else {
    135     return failure;
    136   }
    137134}
    138135
    139136// Wait for next data
    140137////////////////////////////////////////////////////////////////////////////
    141 t_irc bncNetQuery::waitForReadyRead(QByteArray& outData) {
     138void bncNetQuery::waitForReadyRead(QByteArray& outData) {
    142139
    143140  // Wait Loop
     
    147144  }
    148145
    149   // Append Data and Return
    150   // -----------------------
     146  // Append Data
     147  // -----------
    151148  outData.append(_reply->readAll());
    152 
    153   if (_reply->error() == QNetworkReply::NoError) {
    154     return success;
    155   }
    156   else {
    157     return failure;
    158   }
    159149}
Note: See TracChangeset for help on using the changeset viewer.