Changeset 1374 in ntrip


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

* empty log message *

Location:
trunk/BNC
Files:
2 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}
  • trunk/BNC/bncnetquery.h

    r1373 r1374  
    99
    1010 public:
     11  enum queryStatus {init, running, finished, error};
     12
    1113  bncNetQuery();
    1214  ~bncNetQuery();
    13   t_irc waitForRequestResult(const QUrl& url, QByteArray& outData);
    14   t_irc startRequest(const QUrl& url);
    15   t_irc waitForReadyRead(QByteArray& outData);
     15
     16  void waitForRequestResult(const QUrl& url, QByteArray& outData);
     17  void startRequest(const QUrl& url);
     18  void waitForReadyRead(QByteArray& outData);
     19
     20  queryStatus status() const {return _status;}
    1621
    1722 signals:
     
    2429
    2530 private:
    26   t_irc startRequest(const QUrl& url, bool full);
     31  void startRequest(const QUrl& url, bool full);
    2732
    2833  QNetworkAccessManager* _manager;
    2934  QNetworkReply*         _reply;
    3035  QEventLoop*            _eventLoop;
     36  queryStatus            _status;
    3137};
    3238
Note: See TracChangeset for help on using the changeset viewer.