From f435f09a54e1f8eeba120b3512920f7dd163b47f Mon Sep 17 00:00:00 2001 From: eshe Date: Thu, 17 Jun 2010 15:43:33 +0100 Subject: [PATCH] Changed daemon to search both people and companies instead of only people. Tuned some banner delays in gui. --- src/common/eniro.cpp | 22 ++++++---------------- src/common/mobil1881.cpp | 27 ++++++++++++++++++++++----- src/common/mobil1881.h | 2 ++ src/common/source.h | 2 +- src/daemon/calllistener.cpp | 4 ++-- src/daemon/calllistener.h | 2 +- src/gui/mainwindow.cpp | 2 +- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/common/eniro.cpp b/src/common/eniro.cpp index d20c441..49763e7 100644 --- a/src/common/eniro.cpp +++ b/src/common/eniro.cpp @@ -45,7 +45,8 @@ namespace static const QString INVALID_LOGIN_STRING = "Invalid login details"; static const QString TIMEOUT_STRING = "Request timed out"; static const QString PERSON_REGEXP = "(.*)(.*)"; - static const QString YELLOW_REGEXP = "(.*)(.*)"; + static const QString YELLOW_REGEXP = "(.*)(.*)"; + static const QString SINGLE_REGEXP = "
(.*)
(.*)
(.*)
"; static const QString NUMBER_REGEXP = "
(.*)
"; static const QString LOGIN_CHECK = "details.type) - { - case YELLOW_PAGES: - expr = YELLOW_REGEXP; - break; - case PERSONS: - expr = PERSON_REGEXP; - break; - default: - return; - } - QRegExp rx(expr); + QRegExp rx("((" + YELLOW_REGEXP + ")|(" + PERSON_REGEXP + ")|(" + SINGLE_REGEXP + "))"); rx.setMinimal(true); bool requestsPending = false; @@ -289,7 +278,8 @@ void Eniro::loadResults(int id, QString const& httpData) { pos += rx.matchedLength(); - data = rx.cap(2); + data = rx.cap(1); + data = stripTags(data); QStringList rows = data.split('\n'); diff --git a/src/common/mobil1881.cpp b/src/common/mobil1881.cpp index e57816d..1bd0c3a 100644 --- a/src/common/mobil1881.cpp +++ b/src/common/mobil1881.cpp @@ -47,12 +47,28 @@ void Mobil1881::search(Source::SearchDetails const& details) { resetTimeout(); - int id = sendQuery(details, 1); - SearchData* newData = new SearchData; newData->details = details; - newData->searchIds.insert(id); newData->currentPage = 1; + newData->finishedSearches = 0; + + if(details.type == Source::BOTH) + { + newData->totalSearches = 2; + Source::SearchDetails tmpDetails = details; + tmpDetails.type = Source::PERSONS; + int id1 = sendQuery(tmpDetails, 1); + tmpDetails.type = Source::YELLOW_PAGES; + int id2 = sendQuery(tmpDetails, 1); + newData->searchIds.insert(id1); + newData->searchIds.insert(id2); + } + else + { + newData->totalSearches = 1; + int id = sendQuery(details, 1); + newData->searchIds.insert(id); + } pendingSearches_.push_back(newData); } @@ -150,20 +166,21 @@ void Mobil1881::addNumbers(SearchData* searchData, } + searchData->finishedSearches++; + if(searchData->results.size() >= maxResults) { emitRequestFinished(searchData, false, index); } else { - if(data.indexOf("Neste") > 0) { searchData->currentPage++; int id = sendQuery(searchData->details, searchData->currentPage); searchData->searchIds.insert(id); } - else + else if(searchData->finishedSearches >= searchData->totalSearches) { emitRequestFinished(searchData, false, index); } diff --git a/src/common/mobil1881.h b/src/common/mobil1881.h index ef376c8..2f8308e 100644 --- a/src/common/mobil1881.h +++ b/src/common/mobil1881.h @@ -23,6 +23,8 @@ private: Source::SearchDetails details; QVector results; int currentPage; + int totalSearches; + int finishedSearches; }; void addNumbers(SearchData* searchData, QString const& data, int index); diff --git a/src/common/source.h b/src/common/source.h index b5fcbf6..573563f 100644 --- a/src/common/source.h +++ b/src/common/source.h @@ -41,7 +41,7 @@ public: QString number; }; - enum SearchType {YELLOW_PAGES, PERSONS}; + enum SearchType {YELLOW_PAGES, PERSONS, BOTH}; struct SearchDetails { diff --git a/src/daemon/calllistener.cpp b/src/daemon/calllistener.cpp index 5e2dd75..d977f36 100644 --- a/src/daemon/calllistener.cpp +++ b/src/daemon/calllistener.cpp @@ -168,7 +168,7 @@ void CallListener::requestFinished(QVector const& results, if(retries_ < SEARCH_RETRIES && retries_ >= 0) { retries_++; - source_->search(Source::SearchDetails(currentSearch_)); + source_->search(Source::SearchDetails(currentSearch_, "", Source::BOTH)); return; } else @@ -265,7 +265,7 @@ void CallListener::incomingCall(QDBusObjectPath path, QString number) this, SLOT(callTerminate())); - search(Source::SearchDetails(number)); + search(Source::SearchDetails(number, "", Source::BOTH)); } else { diff --git a/src/daemon/calllistener.h b/src/daemon/calllistener.h index cbc4698..682ea1b 100644 --- a/src/daemon/calllistener.h +++ b/src/daemon/calllistener.h @@ -40,7 +40,7 @@ public: static const int BANNER_DELAY = 350; static const int SEARCH_RETRIES = 2; static const int CONNECT_RETRIES = 2; - static const int CONNECTION_LOOKUP_RETRIES = 8; + static const int CONNECTION_LOOKUP_RETRIES = 10; static const int GPRS_SCANS = 2; static const int WLAN_SCANS = 5; static const int WAIT_BETWEEN_RETRIES = 500; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 8d75fea..8a5c71d 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -158,7 +158,7 @@ void MainWindow::toggleDaemon() } else { - QMaemo5InformationBox::information(this, readyText); + QMaemo5InformationBox::information(this, readyText, 800); toggleButton_->setText(buttonText); toggleButton_->setIcon(QIcon(running_ ? START_ICON : CLOSE_ICON)); running_ = !running_; -- 1.7.9.5