Commit 76d41e08 authored by David Edmundson's avatar David Edmundson

Run the Baloo runner out of process

Summary:
KRunner now supports querying data from running processes rather than
being plugins.

Due the number of crash reports of Baloo in both krunner and more
importantly plasmashell, we can move this out of process to make the UX
better in the event of an issue.

This also means we share the database instance between both krunner and plasmashell.

Test Plan:
Searched, typing really quickly
All works as before; including forcing a delay when you only type a few letters
Results are just as fast as before to the human eye (bustle show calls as 0ms)

Tested open with folder and open normally actions
Tested dragging from krunner to dolphin
Tested we had correct icons

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7404
parent 403b7348
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_baloosearch5\")
add_library(krunner_baloosearchrunner MODULE baloosearchrunner.cpp)
target_link_libraries(krunner_baloosearchrunner
set(baloosearchrunner_SRCS
baloosearchrunner.cpp)
qt5_add_dbus_adaptor(baloosearchrunner_SRCS "org.kde.krunner1.xml" baloosearchrunner.h SearchRunner)
add_executable(baloorunner ${baloosearchrunner_SRCS})
target_link_libraries(baloorunner
KF5::Runner
KF5::KIOWidgets
KF5::I18n
KF5::Baloo
Qt5::DBus
)
configure_file(org.kde.baloorunner.service.in
${CMAKE_CURRENT_BINARY_DIR}/org.kde.baloorunner.service)
install(
TARGETS krunner_baloosearchrunner
DESTINATION ${KDE_INSTALL_PLUGINDIR}
TARGETS baloorunner
DESTINATION ${LIBEXEC_INSTALL_DIR}
)
install(
FILES plasma-runner-baloosearch.desktop
DESTINATION ${KDE_INSTALL_KSERVICES5DIR}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.baloorunner.service
DESTINATION ${KDE_INSTALL_DBUSSERVICEDIR})
This diff is collapsed.
/*
* This file is part of the KDE Baloo Project
* Copyright (C) 2014 Vishesh Handa <me@vhanda.in>
* Copyright (C) 2017 David Edmundson <davidedmundson@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -21,35 +22,35 @@
#ifndef _BALOO_SEARCH_RUNNER_H_
#define _BALOO_SEARCH_RUNNER_H_
#include <KRunner/AbstractRunner>
#include <QObject>
#include <QDBusContext>
#include <QDBusMessage>
#include <KRunner/QueryMatch>
#include "dbusutils_p.h"
class QMimeData;
class QTimer;
class SearchRunner : public Plasma::AbstractRunner
class SearchRunner : public QObject, protected QDBusContext
{
Q_OBJECT
public:
SearchRunner(QObject* parent, const QVariantList& args);
SearchRunner(QObject* parent, const QString& serviceId = QString());
SearchRunner(QObject* parent=0);
~SearchRunner() override;
void match(Plasma::RunnerContext& context) override;
void run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& action) override;
QStringList categories() const override;
QIcon categoryIcon(const QString& category) const override;
QList<QAction *> actionsForMatch(const Plasma::QueryMatch &match) override;
QMimeData *mimeDataForMatch(const Plasma::QueryMatch &match) override;
protected Q_SLOTS:
void init() override;
RemoteActions Actions();
RemoteMatches Match(const QString &searchTerm);
void Run(const QString &id, const QString &actionId);
private:
QList<Plasma::QueryMatch> match(Plasma::RunnerContext& context, const QString& type,
void performMatch();
RemoteMatches matchInternal(const QString &searchTerm, const QString& type,
const QString& category);
QDBusMessage m_lastRequest;
QString m_searchTerm;
QTimer *m_timer;
};
#endif // _BALOO_SEARCH_RUNNER_H_
#pragma once
#include <QList>
#include <QString>
#include <QDBusArgument>
#include <QVariantMap>
#include <KRunner/QueryMatch>
struct RemoteMatch
{
//sssuda{sv}
QString id;
QString text;
QString iconName;
Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch;
qreal relevance = 0;
QVariantMap properties;
};
typedef QList<RemoteMatch> RemoteMatches;
struct RemoteAction
{
QString id;
QString text;
QString iconName;
};
typedef QList<RemoteAction> RemoteActions;
inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteMatch &match) {
argument.beginStructure();
argument << match.id;
argument << match.text;
argument << match.iconName;
argument << match.type;
argument << match.relevance;
argument << match.properties;
argument.endStructure();
return argument;
}
inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match) {
argument.beginStructure();
argument >> match.id;
argument >> match.text;
argument >> match.iconName;
uint type;
argument >> type;
match.type = (Plasma::QueryMatch::Type)type;
argument >> match.relevance;
argument >> match.properties;
argument.endStructure();
return argument;
}
inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteAction &action)
{
argument.beginStructure();
argument << action.id;
argument << action.text;
argument << action.iconName;
argument.endStructure();
return argument;
}
inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action) {
argument.beginStructure();
argument >> action.id;
argument >> action.text;
argument >> action.iconName;
argument.endStructure();
return argument;
}
Q_DECLARE_METATYPE(RemoteMatch);
Q_DECLARE_METATYPE(RemoteMatches);
Q_DECLARE_METATYPE(RemoteAction);
Q_DECLARE_METATYPE(RemoteActions);
[D-BUS Service]
Name=org.kde.runners.baloo
Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/baloorunner
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.krunner1">
<!--
Returns a list of actions supported by this runner.
For example, a song match returned by a music player runner can be queued, added to the playlist, or played.
This should be constant
Structure is:
- ID
- Text
- IconName
-->
<method name="Actions">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="RemoteActions" />
<arg name="matches" type="a(sss)" direction="out">
</arg>
</method>
<!--
Execute an action
-->
<method name="Run">
<!--
The Unique ID from Match.
-->
<arg name="matchId" type="s" direction="in"/>
<!--
The action ID to run. For the default action this will be empty.
-->
<arg name="actionId" type="s" direction="in"/>
</method>
<!--
Fetch matching results for a given query.
Note: Multiple Match calls may be made with new queries before a call has returned
has returned.
-->
<method name="Match">
<arg name="query" type="s" direction="in"/>
<!--
Return a list of items that match the
Structure is:
- Id
- Text
- IconName
- Type (see PlasmaQuery::Type)
- Relevance
- Properties (VariantMap)
-->
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="RemoteMatches"/>
<arg name="matches" type="a(sssuda{sv})" direction="out"/>
</method>
</interface>
</node>
......@@ -83,7 +83,6 @@ Comment[zh_TW]=搜尋檔案、電子郵件與聯絡人
X-KDE-ServiceTypes=Plasma/Runner
Type=Service
Icon=baloo
X-KDE-Library=krunner_baloosearchrunner
X-KDE-PluginInfo-Author=Vishesh Handa
X-KDE-PluginInfo-Email=me@vhanda.in
X-KDE-PluginInfo-Name=baloosearch
......@@ -91,3 +90,6 @@ X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=LGPL
X-Plasma-AdvertiseSingleRunnerQueryMode=true
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=DBus
X-Plasma-DBusRunner-Service=org.kde.runners.baloo
X-Plasma-DBusRunner-Path=/runner
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment