Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Fri, 28 May 2010 20:47:41 +0000 (21:47 +0100)
committereshe <jessehakanen@gmail.com>
Fri, 28 May 2010 20:47:41 +0000 (21:47 +0100)
src/daemon/calllistener.cpp
src/daemon/calllistener.h

index 061c83a..16ee0d5 100644 (file)
@@ -37,7 +37,7 @@ namespace
 
 QDBusConnection CallListener::systemBus_ = QDBusConnection::systemBus();
 
-CallListener::CallListener(): eniro_(0), contactManager_(0), box_(0), label_(0)
+CallListener::CallListener(): eniro_(0), contactManager_(0), box_(0), label_(0), retries_(-1)
 {
 }
 
@@ -124,6 +124,8 @@ void CallListener::search(Eniro::SearchDetails const& details)
     else
     {
         showResult(tr("Searching..."));
+        retries_ = 0;
+        currentSearch_ = details;
         eniro_->search(details);
     }
 
@@ -146,7 +148,17 @@ void CallListener::requestFinished(QVector <Eniro::Result> const& results,
     if(error)
     {
         qDebug() << "Error: " << eniro_->errorString();
-        message = tr("Search failed:") + " " + eniro_->errorString() + ".";
+
+        if(retries_ < NUMBER_OF_RETRIES && retries_ >= 0)
+        {
+               retries_++;
+               eniro_->search(currentSearch_);
+               return;
+        }
+        else
+        {
+               message = tr("Search failed:") + " " + eniro_->errorString() + ".";
+        }
     }
     else if(results.size() == 0)
     {
@@ -160,6 +172,8 @@ void CallListener::requestFinished(QVector <Eniro::Result> const& results,
         Cache::instance().addItem(result);
     }
 
+    retries_ = -1;
+
     timedMessage_ = message;
 
     // Show banner after small delay
index b7c6edf..a2f5e88 100644 (file)
@@ -38,8 +38,9 @@ public:
     ~CallListener();
     void begin();
     void end();
-    static const int REQUEST_TIMEOUT = 15000;
-    static const int BANNER_DELAY = 350;
+    static const int REQUEST_TIMEOUT = 10000;
+    static const int BANNER_DELAY = 300;
+    static const int NUMBER_OF_RETRIES = 3;
 
 private slots:
     void requestFinished(QVector <Eniro::Result> const& results, Eniro::SearchDetails const& details, bool error);
@@ -60,6 +61,8 @@ private:
     InformationBox* box_;
     QLabel* label_;
     static QDBusConnection systemBus_;
+    int retries_;
+    Eniro::SearchDetails currentSearch_;
 };
 
 #endif // CALLLISTENER_H

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment