From 7aa320e48ab4896be05a1f4468329fb33cd6ad7b Mon Sep 17 00:00:00 2001 From: Max Lapan Date: Wed, 10 Mar 2010 21:44:50 +0300 Subject: [PATCH] Add check for connection to http_fetcher. Faced with problem: in scratchbox, we actually have no internet connection from icd2 point of view. --- globals.hpp | 10 ++++++++++ http_fetcher.cpp | 12 +++++++----- yandex-traffic-core.pri | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 globals.hpp diff --git a/globals.hpp b/globals.hpp new file mode 100644 index 0000000..797942e --- /dev/null +++ b/globals.hpp @@ -0,0 +1,10 @@ +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + + +// Will widget check for internet connection presence? +// For debuggin in scratchbox must be set to 0, for real device, set 1 +#define CHECK_FOR_CONNECTION 0 + + +#endif // __GLOBALS_H__ diff --git a/http_fetcher.cpp b/http_fetcher.cpp index 787b543..a518e9f 100644 --- a/http_fetcher.cpp +++ b/http_fetcher.cpp @@ -2,7 +2,8 @@ #include #include "http_fetcher.hpp" - +#include "connection.hpp" +#include "globals.hpp" // -------------------------------------------------- // HttpFetcher @@ -24,10 +25,11 @@ void HttpFetcher::fetch (const QString& url) { QUrl u (url); - if (u.isValid ()) { - _http.setHost (u.host ()); - _http.get (u.encodedPath (), &_buffer); - } + if (!CHECK_FOR_CONNECTION || ConnectionChecker::instance ()->isConnected ()) + if (u.isValid ()) { + _http.setHost (u.host ()); + _http.get (u.encodedPath (), &_buffer); + } } diff --git a/yandex-traffic-core.pri b/yandex-traffic-core.pri index 485b2c6..58e7c6f 100644 --- a/yandex-traffic-core.pri +++ b/yandex-traffic-core.pri @@ -1,7 +1,7 @@ HEADERS += $$PWD/regions.hpp $$PWD/settings.hpp $$PWD/traffic.hpp $$PWD/http_fetcher.hpp $$PWD/connection.hpp SOURCES += $$PWD/regions.cpp $$PWD/settings.cpp $$PWD/traffic.cpp $$PWD/http_fetcher.cpp $$PWD/connection.cpp -HEADERS += $$PWD/icd2_light.h +HEADERS += $$PWD/icd2_light.h $$PWD/globals.hpp QT += network xml dbus CONFIG += qdbus -- 1.7.9.5