From 3b351b70de898f507f94a3d1b5a6654cfbd32bea Mon Sep 17 00:00:00 2001 From: eshe Date: Fri, 28 May 2010 21:47:41 +0100 Subject: [PATCH] Added automatic retries to call listener. --- src/daemon/calllistener.cpp | 18 ++++++++++++++++-- src/daemon/calllistener.h | 7 +++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/daemon/calllistener.cpp b/src/daemon/calllistener.cpp index 061c83a..16ee0d5 100644 --- a/src/daemon/calllistener.cpp +++ b/src/daemon/calllistener.cpp @@ -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 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 const& results, Cache::instance().addItem(result); } + retries_ = -1; + timedMessage_ = message; // Show banner after small delay diff --git a/src/daemon/calllistener.h b/src/daemon/calllistener.h index b7c6edf..a2f5e88 100644 --- a/src/daemon/calllistener.h +++ b/src/daemon/calllistener.h @@ -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 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 -- 1.7.9.5