From 11dc201fad01443c74fd221774881e1daad94ea3 Mon Sep 17 00:00:00 2001 From: eshe Date: Mon, 14 Jun 2010 17:55:36 +0100 Subject: [PATCH] Html entity handling improved. Fixed a bug in source that caused segmentation fault in some cases. --- debian/control | 10 +++++----- debian/postinst | 1 + src/common/mobil1881.cpp | 2 +- src/common/source.cpp | 22 +++++++++++++++++++++- src/common/source.h | 2 +- src/gui/resultwindow.cpp | 2 +- src/gui/settingsdialog.cpp | 12 +++++++++--- 7 files changed, 39 insertions(+), 12 deletions(-) diff --git a/debian/control b/debian/control index 5e19a27..1c6accd 100644 --- a/debian/control +++ b/debian/control @@ -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ä. diff --git a/debian/postinst b/debian/postinst index 79fb6dd..9dbc6dc 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,5 +1,6 @@ #!/bin/sh -e gtk-update-icon-cache -f /usr/share/icons/hicolor +/etc/init.d/jenirokd start -boot exit 0 diff --git a/src/common/mobil1881.cpp b/src/common/mobil1881.cpp index 37b070e..e57816d 100644 --- a/src/common/mobil1881.cpp +++ b/src/common/mobil1881.cpp @@ -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); diff --git a/src/common/source.cpp b/src/common/source.cpp index 49fc999..a978b45 100644 --- a/src/common/source.cpp +++ b/src/common/source.cpp @@ -86,7 +86,7 @@ void Source::getSources(QList& 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; } diff --git a/src/common/source.h b/src/common/source.h index 7e0765c..b5fcbf6 100644 --- a/src/common/source.h +++ b/src/common/source.h @@ -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 diff --git a/src/gui/resultwindow.cpp b/src/gui/resultwindow.cpp index 07349ff..5d04f03 100644 --- a/src/gui/resultwindow.cpp +++ b/src/gui/resultwindow.cpp @@ -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")); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 337a9bd..10e4e2d 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -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); -- 1.7.9.5