Html entity handling improved. Fixed a bug in source that caused segmentation fault...
authoreshe <jessehakanen@gmail.com>
Mon, 14 Jun 2010 16:55:36 +0000 (17:55 +0100)
committereshe <jessehakanen@gmail.com>
Mon, 14 Jun 2010 16:55:36 +0000 (17:55 +0100)
debian/control
debian/postinst
src/common/mobil1881.cpp
src/common/source.cpp
src/common/source.h
src/gui/resultwindow.cpp
src/gui/settingsdialog.cpp

index 5e19a27..1c6accd 100644 (file)
@@ -8,12 +8,12 @@ Standards-Version: 3.7.2
 Package: jenirok
 Architecture: any
 Depends: ${shlibs:Depends}, libqt4-sql-sqlite
-Description: Searches unknown callers' details using Eniro person search.
+Description: Searches unknown callers' details automatically using Eniro person search or 1881.no.
  Jenirok finds unknown callers' details 
- automatically using Eniro person search. Person 
- search can also be done by using a gui application.
- Jenirok is currently mainly usable for Finnish, Swedish 
- and Danish users.
+ automatically using Eniro person search or 1881.no 
+ (for Norwegian users). Person search can also be done by 
+ using a gui application. Jenirok is currently mainly 
+ usable for Finnish, Swedish, Danish and Norwegian users.
 XB-Description-fi_FI: Hakee tuntemattoman soittajan tiedot Eniron henkilöhaulla.
  Jenirok hakee tuntemattoman soittajan tiedot
  automaattisesti Eniron henkilöhakua käyttämällä. 
index 79fb6dd..9dbc6dc 100644 (file)
@@ -1,5 +1,6 @@
 #!/bin/sh -e
 
 gtk-update-icon-cache -f /usr/share/icons/hicolor
+/etc/init.d/jenirokd start -boot
 
 exit 0
index 37b070e..e57816d 100644 (file)
@@ -262,7 +262,7 @@ int Mobil1881::sendQuery(Source::SearchDetails const& details,
 
     if(!details.location.isEmpty())
     {
-        query += details.location;
+        query += " " + details.location;
     }
 
     url.addQueryItem("s", query);
index 49fc999..a978b45 100644 (file)
@@ -86,7 +86,7 @@ void Source::getSources(QList<SourceDetails>& list)
 }
 
 Source::Source(QObject* parent): QObject(parent),
-maxResults_(DEFAULT_MAX_RESULTS), timeout_(0), timerId_(0), findNumber_(false),
+maxResults_(DEFAULT_MAX_RESULTS), timeout_(0), timerId_(0), findNumber_(true),
 error_(NO_ERROR), loggedIn_(false)
 {
     connect(&http_, SIGNAL(requestFinished(int, bool)), this, SLOT(httpReady(int, bool)));
@@ -366,6 +366,26 @@ QString& Source::htmlEntityDecode(QString& string)
         string = string.replace("&" + entities[i] + ";", QChar(entityValues[i]));
     }
 
+    static QRegExp entityCleaner("&#([0-9]{1,3});");
+    entityCleaner.setMinimal(true);
+
+    int pos = 0;
+
+    while((pos = entityCleaner.indexIn(string, pos)) != -1)
+    {
+        QString match = entityCleaner.cap(1);
+
+        int value = match.toInt();
+
+        if(value >= 1 && value <= 255)
+        {
+            string = string.replace(pos, match.length() + 3, QChar(value));
+        }
+
+        pos += entityCleaner.matchedLength();
+    }
+
+
    return string;
 }
 
index 7e0765c..b5fcbf6 100644 (file)
@@ -55,7 +55,7 @@ public:
 
 
     enum Error {NO_ERROR, CONNECTION_FAILURE, INVALID_LOGIN, TIMEOUT};
-    enum SourceId {SOURCE_NONE, ENIRO, MOBIL1881};
+    enum SourceId {ENIRO, MOBIL1881};
     static int const SOURCE_COUNT = 2;
 
     struct SourceDetails
index 07349ff..5d04f03 100644 (file)
@@ -30,7 +30,7 @@
 #include "sourcecoreconfig.h"
 
 ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
-sourceId_(Source::SOURCE_NONE), source_(0), list_(0), connectionManager_(0)
+source_(0), list_(0), connectionManager_(0)
 {
     setAttribute(Qt::WA_Maemo5StackedWindow);
     setWindowTitle(tr("Search results"));
index 337a9bd..10e4e2d 100644 (file)
@@ -151,7 +151,6 @@ void SettingsDialog::saveSettings()
 
     Settings::instance()->startEdit();
 
-    sourceConfig_->save();
     Settings::instance()->set("cache_size", cacheInput_->text());
     QString source = sourceSelector_->value().toString();
     Settings::instance()->set("source", source);
@@ -162,12 +161,13 @@ void SettingsDialog::saveSettings()
     Settings::instance()->set("connection_name", connectionSelector_->text());
     QString language = languageSelector_->value().toString();
     Settings::instance()->set("language", language);
+    sourceConfig_->save();
 
     Settings::instance()->endEdit();
 
     if(Daemon::isRunning())
     {
-        QMaemo5InformationBox::information(this, tr("Restarting daemon..."));
+        QMaemo5InformationBox::information(this, tr("Restarting daemon..."), 1500);
         Daemon::restart();
     }
 
@@ -200,7 +200,13 @@ void SettingsDialog::onSourceSelected(unsigned int index,
 
     if(source != currentSource_)
     {
-        tabs_->removeTab(tabs_->count() - 1);
+        int tabId = tabs_->indexOf(sourceConfig_);
+
+        if(tabId >= 0)
+        {
+            tabs_->removeTab(tabId);
+        }
+
         delete sourceConfig_;
         Source::SourceId sourceId = Source::stringToId(value.toString());
         sourceConfig_ = SourceGuiConfig::getGuiConfig(sourceId, this);