KRunner
dbusrunner.cpp
26 DBusRunner::DBusRunner(QObject *parent, const KPluginMetaData &pluginMetaData, const QVariantList &args)
36 QString requestedServiceName = pluginMetaData.value(QStringLiteral("X-Plasma-DBusRunner-Service"));
38 m_hasUniqueResults = pluginMetaData.value(QStringLiteral("X-Plasma-Runner-Unique-Results"), false);
39 m_callLifecycleMethods = pluginMetaData.value(QStringLiteral("X-Plasma-API")) == QLatin1String("DBus2");
62 [this, requestedServiceName](const QString &serviceName, const QString &oldOwner, const QString &newOwner) {
83 m_requestActionsOnce = pluginMetaData.value(QStringLiteral("X-Plasma-Request-Actions-Once"), false);
87 const QJsonValue syntaxesJson = pluginMetaData.rawData().value(QStringLiteral("X-Plasma-Runner-Syntaxes"));
88 const QStringList syntaxes = syntaxesJson.isArray() ? syntaxesJson.toVariant().toStringList() : syntaxesJson.toString().split(QLatin1Char(','), Qt::SkipEmptyParts);
89 const QJsonValue syntaxDescriptionsJson = pluginMetaData.rawData().value(QStringLiteral("X-Plasma-Runner-Syntax-Descriptions"));
91 syntaxDescriptionsJson.isArray() ? syntaxDescriptionsJson.toVariant().toStringList() : syntaxDescriptionsJson.toString().split(QLatin1Char(','), Qt::SkipEmptyParts);
111 void DBusRunner::createQActionsFromRemoteActions(const QMap<QString, RemoteActions> &remoteActions)
131 auto method = QDBusMessage::createMethodCall(service, m_path, QStringLiteral(IFACE_NAME), QStringLiteral("Teardown"));
141 // in the multi-services case, register separate actions from each plugin in case they happen to be somehow different
155 auto getActionsMethod = QDBusMessage::createMethodCall(service, m_path, QStringLiteral(IFACE_NAME), QStringLiteral("Actions"));
158 qCDebug(KRUNNER) << "Error requesting actions; calling" << service << " :" << reply.error().name() << reply.error().message();
169 auto getConfigMethod = QDBusMessage::createMethodCall(service, m_path, QStringLiteral(IFACE_NAME), QStringLiteral("Config"));
170 QDBusPendingReply<QVariantMap> reply = QDBusConnection::sessionBus().asyncCall(getConfigMethod);
178 qCDebug(KRUNNER) << "Error requesting config; calling" << service << " :" << reply.error().name() << reply.error().message();
210 if ((m_requestActionsOnce && !m_actionsOnceRequested) // We only want to fetch the actions once but haven't done so yet
215 QMetaObject::invokeMethod(this, "createQActionsFromRemoteActions", QArgument("QMap<QString, RemoteActions>", actions));
218 // we scope watchers to make sure the lambda that captures context by reference definitely gets disconnected when this function ends
222 auto matchMethod = QDBusMessage::createMethodCall(service, m_path, QStringLiteral(IFACE_NAME), QStringLiteral("Match"));
233 qCDebug(KRUNNER) << "Error requesting matches; calling" << service << " :" << reply.error().name() << reply.error().message();
245 // split is essential items are as native DBus types, optional extras are in the property map (which is obviously a lot slower to parse)
273 qCWarning(KRUNNER) << "Invalid signature of icon-data property:" << iconDataArgument.currentSignature();
280 Qt::DirectConnection); // process reply in the watcher's thread (aka the one running ::match not the one owning the runner)
315 matchId = match.id().mid(id().length() + 1); // QueryMatch::setId mangles the match ID with runnerID + '_'. This unmangles it
323 auto runMethod = QDBusMessage::createMethodCall(service, m_path, QStringLiteral(IFACE_NAME), QStringLiteral("Run"));
344 if (remoteImage.width <= 0 || remoteImage.width >= 2048 || remoteImage.height <= 0 || remoteImage.height >= 2048 || remoteImage.rowStride <= 0) {
345 qCWarning(KRUNNER) << "Invalid image metadata (width:" << remoteImage.width << "height:" << remoteImage.height << "rowStride:" << remoteImage.rowStride
registeredServiceNames
bool isValid() const const
QJsonObject rawData() const
void finished(QDBusPendingCallWatcher *self)
std::optional< QSqlQuery > query(const QString &queryStatement)
bool isValid() const const
QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags)
Format
const T value(const Key &key, const T &defaultValue) const const
QString message() const const
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
int count(const T &value) const const
T value() const const
bool isValid() const const
QMap::iterator begin()
A match returned by an AbstractRunner in response to a given RunnerContext.
Definition: querymatch.h:34
QIcon fromTheme(const QString &name)
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const const
void chop(int n)
QString toString() const const
void teardown()
This signal is emitted when a session of matches is complete, giving runners the opportunity to tear ...
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QList< QUrl > fromStringList(const QStringList &urls, QUrl::ParsingMode mode)
QMap::iterator insert(const Key &key, const T &value)
QMap::iterator end()
void addSyntax(const RunnerSyntax &syntax)
Adds a registered syntax that this runner understands.
Definition: abstractrunner.cpp:115
QString::const_iterator constBegin() const const
QDBusConnection sessionBus()
StructureType
SkipEmptyParts
QString name() const
bool isEmpty() const const
bool isNull() const const
const T & at(int i) const const
DirectConnection
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner)
QJsonValue value(const QString &key) const const
QVariant toVariant() const const
T1 value() const const
KSharedConfigPtr config()
QDBusMessage createMethodCall(const QString &service, const QString &path, const QString &interface, const QString &method)
QDBusError error() const const
QDBusConnectionInterface * interface() const const
bool value(const QString &key, bool defaultValue) const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
The RunnerContext class provides information related to a search, including the search term,...
Definition: runnercontext.h:31
QStringList toStringList() const const
bool addMatch(const QueryMatch &match)
Appends a match to the existing list of matches.
Definition: runnercontext.cpp:338
int length() const const
bool isArray() const const
QString name() const const
NoBlock
QList< RunnerSyntax > syntaxes() const
Definition: abstractrunner.cpp:143
QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout) const const
QList< StandardAction > actionIds()
const QList< QKeySequence > & end()
T value(int i) const const
QDBusReply::Type value() const const
char * data()
char * toString(const EngineQuery &query)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 03:50:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 03:50:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.