projects
/
jenirok
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d93782e
)
Changed search to retry automatically couple of times before failing.
author
eshe
<jessehakanen@gmail.com>
Fri, 20 Aug 2010 19:19:04 +0000
(20:19 +0100)
committer
eshe
<jessehakanen@gmail.com>
Fri, 20 Aug 2010 19:19:04 +0000
(20:19 +0100)
src/common/connectionmanager.cpp
patch
|
blob
|
history
src/common/dastelefonbuch.cpp
patch
|
blob
|
history
src/common/eniro.cpp
patch
|
blob
|
history
src/common/mobil1881.cpp
patch
|
blob
|
history
src/gui/resultwindow.cpp
patch
|
blob
|
history
src/gui/resultwindow.h
patch
|
blob
|
history
diff --git
a/src/common/connectionmanager.cpp
b/src/common/connectionmanager.cpp
index
f7b0f32
..
baa6e2d
100644
(file)
--- a/
src/common/connectionmanager.cpp
+++ b/
src/common/connectionmanager.cpp
@@
-429,10
+429,10
@@
bool ConnectionManager::waitSignal(bool* ready)
killTimer(timer_);
killTimer(timer_);
- if(timeout_)
+ /*if(timeout_)
{
qDebug() << "Connection request timed out";
{
qDebug() << "Connection request timed out";
- }
+ }*/
return *ready || !timeout_;
}
return *ready || !timeout_;
}
diff --git
a/src/common/dastelefonbuch.cpp
b/src/common/dastelefonbuch.cpp
index
7cb36ad
..
68352e1
100644
(file)
--- a/
src/common/dastelefonbuch.cpp
+++ b/
src/common/dastelefonbuch.cpp
@@
-106,6
+106,14
@@
void DasTelefonbuch::addNumbers(SearchData* searchData,
QString const& data,
int index)
{
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(data.indexOf("<span>1 Gesamttreffer</span>") > 0)
{
addOnlyNumber(searchData, data, index);
diff --git
a/src/common/eniro.cpp
b/src/common/eniro.cpp
index
46fda30
..
edffeed
100644
(file)
--- a/
src/common/eniro.cpp
+++ b/
src/common/eniro.cpp
@@
-201,6
+201,13
@@
void Eniro::handleHttpData(int id, QByteArray const& data)
if((searchIt = pendingSearches_.find(id)) !=
pendingSearches_.end())
{
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);
}
// 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())
{
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);
}
// Load number from html data
loadNumber(id, data);
}
diff --git
a/src/common/mobil1881.cpp
b/src/common/mobil1881.cpp
index
69327b0
..
a51d293
100644
(file)
--- a/
src/common/mobil1881.cpp
+++ b/
src/common/mobil1881.cpp
@@
-109,7
+109,9
@@
void Mobil1881::addNumbers(SearchData* searchData,
if(data.isEmpty())
{
qDebug() << "Server returned no 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)
}
if(data.indexOf("<b>Last ned vCard</b>") > 0)
diff --git
a/src/gui/resultwindow.cpp
b/src/gui/resultwindow.cpp
index
dc1509f
..
1bd7cb4
100644
(file)
--- a/
src/gui/resultwindow.cpp
+++ b/
src/gui/resultwindow.cpp
@@
-30,7
+30,7
@@
#include "sourcecoreconfig.h"
ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
#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"));
{
setAttribute(Qt::WA_Maemo5StackedWindow);
setWindowTitle(tr("Search results"));
@@
-113,7
+113,9
@@
void ResultWindow::search(SearchDialog::SearchDetails& details)
list_->clear();
searching_ = true;
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(error)
{
+ if(retries_ < RETRIES)
+ {
+ qDebug() << "Searching failed, retrying...";
+ retries_++;
+ list_->clear();
+ source_->search(currentSearch_);
+ return;
+ }
+
QString errorString;
Source::Error error = source_->error();
QString errorString;
Source::Error error = source_->error();
@@
-197,12
+208,6
@@
void ResultWindow::requestFinished(QVector <Source::Result> const& results,
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
- if(timer_)
- {
- killTimer(timer_);
- }
-
- timer_ = startTimer(SEARCH_INTERVAL);
searching_ = false;
}
searching_ = false;
}
diff --git
a/src/gui/resultwindow.h
b/src/gui/resultwindow.h
index
3391f7d
..
dde6501
100644
(file)
--- a/
src/gui/resultwindow.h
+++ b/
src/gui/resultwindow.h
@@
-35,7
+35,8
@@
public:
ResultWindow(QWidget* parent = 0);
~ResultWindow();
static const int REQUEST_TIMEOUT = 30000;
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);
signals:
void itemSelected(Source::Result const& result);
@@
-59,6
+60,8
@@
private:
ConnectionManager* connectionManager_;
int timer_;
bool searching_;
ConnectionManager* connectionManager_;
int timer_;
bool searching_;
+ int retries_;
+ Source::SearchDetails currentSearch_;
};
};