summaryrefslogtreecommitdiff
path: root/src/opensearch
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-04-27 01:05:20 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-04-27 01:05:20 +0200
commit038facd4fcca60aa92fe29bbb47e9669029d0fe9 (patch)
tree61b57a16e83c5a170799f9abfc6b667911966992 /src/opensearch
parentFix opensearch add shortcut handling (diff)
downloadrekonq-038facd4fcca60aa92fe29bbb47e9669029d0fe9.tar.xz
Revert "Fix opensearch add shortcut handling"
This reverts commit d09b430f9835fd19f9a0088a5620af20bdf36b0e.
Diffstat (limited to 'src/opensearch')
-rw-r--r--src/opensearch/opensearchmanager.cpp100
-rw-r--r--src/opensearch/opensearchmanager.h4
-rw-r--r--src/opensearch/opensearchreader.cpp1
3 files changed, 50 insertions, 55 deletions
diff --git a/src/opensearch/opensearchmanager.cpp b/src/opensearch/opensearchmanager.cpp
index 120957fa..480e9a26 100644
--- a/src/opensearch/opensearchmanager.cpp
+++ b/src/opensearch/opensearchmanager.cpp
@@ -115,8 +115,9 @@ bool OpenSearchManager::isSuggestionAvailable()
void OpenSearchManager::addOpenSearchEngine(const KUrl &url, const QString &title, const QString &shortcut)
{
+ Q_UNUSED(title);
+
m_shortcut = shortcut;
- m_title = trimmedEngineName(title);
if (m_state != IDLE)
{
@@ -169,49 +170,67 @@ void OpenSearchManager::dataReceived(KIO::Job *job, const QByteArray &data)
void OpenSearchManager::jobFinished(KJob *job)
{
- if (!job->error() && m_state == REQ_DESCRIPTION)
+ // Do NOT parse if job had same errors or the typed string is empty
+ if (job->error() || _typedText.isEmpty())
+ {
+ emit suggestionsReceived(_typedText, ResponseList());
+ m_state = IDLE;
+ return; // just silently return
+ }
+
+ if (m_state == REQ_SUGGESTION)
+ {
+ ResponseList suggestionsList;
+ if (isSuggestionAvailable())
+ {
+ suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData);
+ }
+ emit suggestionsReceived(_typedText, suggestionsList);
+ idleJob();
+ return;
+ }
+
+ if (m_state == REQ_DESCRIPTION)
{
OpenSearchReader reader;
OpenSearchEngine *engine = reader.read(m_jobData);
if (engine)
{
- m_engineCache.insert(m_title, engine);
- m_engines.insert(m_jobUrl, m_shortcut);
+ m_engineCache.insert(engine->name(), engine);
+ m_engines.insert(m_jobUrl, trimmedEngineName(engine->name()));
saveEngines();
QString path;
- if (engine->providesSuggestions())
+ if (engine->providesSuggestions()) //save opensearch description only if it provides suggestions
{
- // save opensearch description only if it provides suggestions
OpenSearchWriter writer;
path = KGlobal::dirs()->findResource("data", "rekonq/opensearch/");
QFile file(path + trimmedEngineName(engine->name()) + ".xml");
writer.write(&file, engine);
-
- // save desktop file here
- QString searchUrl = OpenSearchEngine::parseTemplate("\\{@}", engine->searchUrlTemplate());
- m_currentJob = NULL;
-
- path = KGlobal::mainComponent().dirs()->saveLocation("services", "searchproviders/");
- KConfig _service(path + m_title + ".desktop", KConfig::SimpleConfig);
- KConfigGroup service(&_service, "Desktop Entry");
- service.writeEntry("Type", "Service");
- service.writeEntry("ServiceTypes", "SearchProvider");
- service.writeEntry("Name", m_title);
- service.writeEntry("Query", searchUrl);
- service.writeEntry("Keys", m_shortcut);
- // TODO charset
- service.writeEntry("Charset", "" /* provider->charset() */);
- // we might be overwriting a hidden entry
- service.writeEntry("Hidden", false);
- service.sync();
-
- // Update filters in running applications...
- QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KUriFilterPlugin", "configure");
- QDBusConnection::sessionBus().send(msg);
-
- emit openSearchEngineAdded(engine->name());
}
+
+ QString searchUrl = OpenSearchEngine::parseTemplate("\\{@}", engine->searchUrlTemplate());
+ m_currentJob = NULL;
+
+ path = KGlobal::mainComponent().dirs()->saveLocation("services", "searchproviders/");
+ KConfig _service(path + trimmedEngineName(engine->name()) + ".desktop", KConfig::SimpleConfig);
+ KConfigGroup service(&_service, "Desktop Entry");
+ service.writeEntry("Type", "Service");
+ service.writeEntry("ServiceTypes", "SearchProvider");
+ service.writeEntry("Name", engine->name());
+ service.writeEntry("Query", searchUrl);
+ service.writeEntry("Keys", m_shortcut);
+ // TODO charset
+ service.writeEntry("Charset", "" /* provider->charset() */);
+ // we might be overwriting a hidden entry
+ service.writeEntry("Hidden", false);
+ service.sync();
+
+ // Update filters in running applications...
+ QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KUriFilterPlugin", "configure");
+ QDBusConnection::sessionBus().send(msg);
+
+ emit openSearchEngineAdded(engine->name(), searchUrl, m_shortcut);
}
else
{
@@ -219,27 +238,6 @@ void OpenSearchManager::jobFinished(KJob *job)
}
idleJob();
- return;
- }
-
- // Do NOT parse if job had same errors or the typed string is empty
- if (job->error() || _typedText.isEmpty())
- {
- emit suggestionsReceived(_typedText, ResponseList());
- m_state = IDLE;
- return; // just silently return
- }
-
- if (m_state == REQ_SUGGESTION)
- {
- ResponseList suggestionsList;
- if (isSuggestionAvailable())
- {
- suggestionsList = m_activeEngine->parseSuggestion(_typedText, m_jobData);
- }
- emit suggestionsReceived(_typedText, suggestionsList);
- idleJob();
- return;
}
}
diff --git a/src/opensearch/opensearchmanager.h b/src/opensearch/opensearchmanager.h
index 38179318..e698e0ee 100644
--- a/src/opensearch/opensearchmanager.h
+++ b/src/opensearch/opensearchmanager.h
@@ -96,7 +96,7 @@ private Q_SLOTS:
Q_SIGNALS:
void suggestionsReceived(const QString &text, const ResponseList &suggestion);
- void openSearchEngineAdded(const QString &name);
+ void openSearchEngineAdded(const QString &name, const QString &searchUrl, const QString &fileName);
private:
QString trimmedEngineName(const QString &engineName) const;
@@ -116,9 +116,7 @@ private:
KUrl m_jobUrl;
QString _typedText;
-
QString m_shortcut;
- QString m_title;
};
#endif // OPENSEARCHMANAGER_H
diff --git a/src/opensearch/opensearchreader.cpp b/src/opensearch/opensearchreader.cpp
index a4f43b7a..897fca29 100644
--- a/src/opensearch/opensearchreader.cpp
+++ b/src/opensearch/opensearchreader.cpp
@@ -83,7 +83,6 @@ OpenSearchEngine *OpenSearchReader::read()
|| namespaceUri() != QL1S("http://a9.com/-/spec/opensearch/1.1/")
)
{
- kDebug() << "The file is not an OpenSearch 1.1 file: " << name();
raiseError(i18n("The file is not an OpenSearch 1.1 file."));
return engine;
}