}
-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);
_buffer.setBuffer (NULL);
}
-
-void HttpFetcher::reset ()
-{
- if (!busy ())
- return;
-
- _http.abort ();
-}
#include "traffic.hpp"
#include "log.hpp"
-#include "connection.hpp"
// --------------------------------------------------
{
connect (&_fetcher, SIGNAL (done (const QByteArray&)),
SLOT (fetchDone (const QByteArray&)));
- connect (ConnectionChecker::instance (), SIGNAL (connected (bool)), SLOT (connectionChanged (bool)));
}
// 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");
}
return it.value ();
}
-
-void Traffic::connectionChanged (bool active)
-{
- if (!active)
- _fetcher.reset ();
-}