Add check for connection to http_fetcher.
authorMax Lapan <max.lapan@gmail.com>
Wed, 10 Mar 2010 18:44:50 +0000 (21:44 +0300)
committerMax Lapan <max.lapan@gmail.com>
Wed, 10 Mar 2010 18:44:50 +0000 (21:44 +0300)
Faced with problem: in scratchbox, we actually have no internet connection from
icd2 point of view.

globals.hpp [new file with mode: 0644]
http_fetcher.cpp
yandex-traffic-core.pri

diff --git a/globals.hpp b/globals.hpp
new file mode 100644 (file)
index 0000000..797942e
--- /dev/null
@@ -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__
index 787b543..a518e9f 100644 (file)
@@ -2,7 +2,8 @@
 #include <QtNetwork>
 
 #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);
+        }
 }
 
 
index 485b2c6..58e7c6f 100644 (file)
@@ -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