Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Fri, 20 Aug 2010 19:19:04 +0000 (20:19 +0100)
committereshe <jessehakanen@gmail.com>
Fri, 20 Aug 2010 19:19:04 +0000 (20:19 +0100)
src/common/connectionmanager.cpp
src/common/dastelefonbuch.cpp
src/common/eniro.cpp
src/common/mobil1881.cpp
src/gui/resultwindow.cpp
src/gui/resultwindow.h

index f7b0f32..baa6e2d 100644 (file)
@@ -429,10 +429,10 @@ bool ConnectionManager::waitSignal(bool* ready)
 
     killTimer(timer_);
 
-    if(timeout_)
+    /*if(timeout_)
     {
         qDebug() << "Connection request timed out";
-    }
+    }*/
 
     return *ready || !timeout_;
 }
index 7cb36ad..68352e1 100644 (file)
@@ -106,6 +106,14 @@ void DasTelefonbuch::addNumbers(SearchData* searchData,
                            QString const& data,
                            int index)
 {
+    if(data.isEmpty())
+    {
+        qDebug() << "Server returned no data";
+        setError(CONNECTION_FAILURE, "Server returned no data");
+        emitRequestFinished(searchData, true, index);
+        return;
+    }
+
     if(data.indexOf("<span>1&nbsp;Gesamttreffer</span>") > 0)
     {
         addOnlyNumber(searchData, data, index);
index 46fda30..edffeed 100644 (file)
@@ -201,6 +201,13 @@ void Eniro::handleHttpData(int id, QByteArray const& data)
     if((searchIt = pendingSearches_.find(id)) !=
         pendingSearches_.end())
     {
+        if(data.isEmpty())
+        {
+            setError(CONNECTION_FAILURE, "Server returned empty data");
+            emitRequestFinished(id, searchIt.value(), true);
+            return;
+        }
+
         // Load results from html data
         loadResults(id, data);
     }
@@ -209,6 +216,13 @@ void Eniro::handleHttpData(int id, QByteArray const& data)
     else if((numberIt = pendingNumberRequests_.find(id)) !=
         pendingNumberRequests_.end())
     {
+        if(data.isEmpty())
+        {
+            setError(CONNECTION_FAILURE, "Server returned empty data");
+            emitRequestFinished(id, searchIt.value(), true);
+            return;
+        }
+
         // Load number from html data
         loadNumber(id, data);
     }
index 69327b0..a51d293 100644 (file)
@@ -109,7 +109,9 @@ void Mobil1881::addNumbers(SearchData* searchData,
     if(data.isEmpty())
     {
         qDebug() << "Server returned no data";
-        qDebug() << "Headers: " << http_.lastResponse().toString();
+        setError(CONNECTION_FAILURE, "Server returned no data");
+        emitRequestFinished(searchData, true, index);
+        return;
     }
 
     if(data.indexOf("<b>Last ned vCard</b>") > 0)
index dc1509f..1bd7cb4 100644 (file)
@@ -30,7 +30,7 @@
 #include "sourcecoreconfig.h"
 
 ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
-source_(0), list_(0), connectionManager_(0), timer_(0), searching_(false)
+source_(0), list_(0), connectionManager_(0), timer_(0), searching_(false), retries_(0)
 {
     setAttribute(Qt::WA_Maemo5StackedWindow);
     setWindowTitle(tr("Search results"));
@@ -113,7 +113,9 @@ void ResultWindow::search(SearchDialog::SearchDetails& details)
 
     list_->clear();
     searching_ = true;
-    source_->search(Source::SearchDetails(details.name, details.location, details.type));
+    retries_ = 0;
+    currentSearch_ = Source::SearchDetails(details.name, details.location, details.type);
+    source_->search(currentSearch_);
 
 }
 
@@ -165,6 +167,15 @@ void ResultWindow::requestFinished(QVector <Source::Result> const& results,
 
     if(error)
     {
+        if(retries_ < RETRIES)
+        {
+            qDebug() << "Searching failed, retrying...";
+            retries_++;
+            list_->clear();
+            source_->search(currentSearch_);
+            return;
+        }
+
         QString errorString;
         Source::Error error = source_->error();
 
@@ -197,12 +208,6 @@ void ResultWindow::requestFinished(QVector <Source::Result> const& results,
 
     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
 
-    if(timer_)
-    {
-        killTimer(timer_);
-    }
-
-    timer_ = startTimer(SEARCH_INTERVAL);
     searching_ = false;
 
 }
index 3391f7d..dde6501 100644 (file)
@@ -35,7 +35,8 @@ public:
     ResultWindow(QWidget* parent = 0);
     ~ResultWindow();
     static const int REQUEST_TIMEOUT = 30000;
-    static const int SEARCH_INTERVAL = 2000;
+    static const int SEARCH_INTERVAL = 1000;
+    static const int RETRIES = 2;
 
 signals:
     void itemSelected(Source::Result const& result);
@@ -59,6 +60,8 @@ private:
     ConnectionManager* connectionManager_;
     int timer_;
     bool searching_;
+    int retries_;
+    Source::SearchDetails currentSearch_;
 
 };
 

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment