killTimer(timer_);
- if(timeout_)
+ /*if(timeout_)
{
qDebug() << "Connection request timed out";
- }
+ }*/
return *ready || !timeout_;
}
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 Gesamttreffer</span>") > 0)
{
addOnlyNumber(searchData, data, index);
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);
}
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);
}
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)
#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"));
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_);
}
if(error)
{
+ if(retries_ < RETRIES)
+ {
+ qDebug() << "Searching failed, retrying...";
+ retries_++;
+ list_->clear();
+ source_->search(currentSearch_);
+ return;
+ }
+
QString errorString;
Source::Error error = source_->error();
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
- if(timer_)
- {
- killTimer(timer_);
- }
-
- timer_ = startTimer(SEARCH_INTERVAL);
searching_ = false;
}
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);
ConnectionManager* connectionManager_;
int timer_;
bool searching_;
+ int retries_;
+ Source::SearchDetails currentSearch_;
};