Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Thu, 17 Jun 2010 14:43:33 +0000 (15:43 +0100)
committereshe <jessehakanen@gmail.com>
Thu, 17 Jun 2010 14:43:33 +0000 (15:43 +0100)
src/common/eniro.cpp
src/common/mobil1881.cpp
src/common/mobil1881.h
src/common/source.h
src/daemon/calllistener.cpp
src/daemon/calllistener.h
src/gui/mainwindow.cpp

index d20c441..49763e7 100644 (file)
@@ -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 = "<td class=\"hTd2\">(.*)<b>(.*)</td>";
-    static const QString YELLOW_REGEXP = "<td class=\"hTd2\">(.*)<span class=\"gray\"\\}>(.*)</td>";
+    static const QString YELLOW_REGEXP = "<td class=\"hTd2\">(.*)<span class=\"gray\">(.*)</td>";
+    static const QString SINGLE_REGEXP = "<div class=\"header\">(.*)</div>(.*)<div class=\"callRow\">(.*)</div>";
     static const QString NUMBER_REGEXP = "<div class=\"callRow\">(.*)</div>";
     static const QString LOGIN_CHECK = "<input class=\"inpTxt\" id=\"loginformUsername\"";
 }
@@ -163,6 +164,7 @@ void Eniro::search(SearchDetails const& details)
 
         default:
             what = "moball";
+            break;
         }
 
     }
@@ -263,21 +265,8 @@ void Eniro::handleHttpError(int id)
 void Eniro::loadResults(int id, QString const& httpData)
 {
     searchMap::iterator it = pendingSearches_.find(id);
-    QString expr;
-
-    switch(it.value()->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');
 
index e57816d..1bd0c3a 100644 (file)
@@ -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);
         }
index ef376c8..2f8308e 100644 (file)
@@ -23,6 +23,8 @@ private:
         Source::SearchDetails details;
         QVector<Source::Result> results;
         int currentPage;
+        int totalSearches;
+        int finishedSearches;
     };
 
     void addNumbers(SearchData* searchData, QString const& data, int index);
index b5fcbf6..573563f 100644 (file)
@@ -41,7 +41,7 @@ public:
         QString number;
     };
 
-    enum SearchType {YELLOW_PAGES, PERSONS};
+    enum SearchType {YELLOW_PAGES, PERSONS, BOTH};
 
     struct SearchDetails
     {
index 5e2dd75..d977f36 100644 (file)
@@ -168,7 +168,7 @@ void CallListener::requestFinished(QVector <Source::Result> 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
     {
index cbc4698..682ea1b 100644 (file)
@@ -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;
index 8d75fea..8a5c71d 100644 (file)
@@ -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_;

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment