Abort current connection (if any) with new request.
authorMax Lapan <max.lapan@gmail.com>
Fri, 19 Mar 2010 11:43:31 +0000 (14:43 +0300)
committerMax Lapan <max.lapan@gmail.com>
Fri, 19 Mar 2010 11:43:31 +0000 (14:43 +0300)
http_fetcher.cpp
http_fetcher.hpp
traffic.cpp
traffic.hpp

index 543260d..433c990 100644 (file)
@@ -13,16 +13,13 @@ HttpFetcher::HttpFetcher ()
 }
 
 
-bool HttpFetcher::busy () const
-{
-    return _http.currentId () != 0;
-}
-
-
 void HttpFetcher::fetch (const QString& url)
 {
     QUrl u (url);
 
+    if (_http.currentId () != )
+        _http.abort ();
+
     if (u.isValid ()) {
         _http.setHost (u.host ());
         _http.get (u.encodedPath (), &_buffer);
@@ -40,11 +37,3 @@ void HttpFetcher::requestDone (bool err)
     _buffer.setBuffer (NULL);
 }
 
-
-void HttpFetcher::reset ()
-{
-    if (!busy ())
-        return;
-
-    _http.abort ();
-}
index 416d62f..25857bb 100644 (file)
@@ -22,9 +22,7 @@ signals:
 public:
     HttpFetcher ();
 
-    bool busy () const;
     void fetch (const QString& url);
-    void reset ();
 };
 
 
index 3cc7097..05d5adf 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "traffic.hpp"
 #include "log.hpp"
-#include "connection.hpp"
 
 
 // --------------------------------------------------
@@ -133,7 +132,6 @@ Traffic::Traffic ()
 {
     connect (&_fetcher, SIGNAL (done (const QByteArray&)),
              SLOT (fetchDone (const QByteArray&)));
-    connect (ConnectionChecker::instance (), SIGNAL (connected (bool)), SLOT (connectionChanged (bool)));
 }
 
 
@@ -142,11 +140,6 @@ Traffic::Traffic ()
 // successfully, updated() signal called.
 void Traffic::update ()
 {
-    if (_fetcher.busy ()) {
-        Log::instance ()->add ("Traffic::update: fetcher is busy");
-        return;
-    }
-
     Log::instance ()->add ("Traffic::update: Request status download");
     _fetcher.fetch ("http://trf.maps.yandex.net/trf/stat.xml");
 }
@@ -245,9 +238,3 @@ ExtendedTrafficInfo Traffic::lookup_ext (const QString &id) const
         return it.value ();
 }
 
-
-void Traffic::connectionChanged (bool active)
-{
-    if (!active)
-        _fetcher.reset ();
-}
index 4ec08e4..03283b8 100644 (file)
@@ -105,9 +105,6 @@ private:
 private slots:
     void fetchDone (const QByteArray& data);
 
-protected slots:
-    void connectionChanged (bool active);
-
 signals:
     void updated ();