7#include <PhosphorProtocol/phosphorprotocol_export.h>
11#include <QDBusConnection>
12#include <QDBusPendingCall>
13#include <QDBusPendingCallWatcher>
14#include <QDBusPendingReply>
15#include <QLoggingCategory>
48namespace ClientHelpers {
52inline void fireAndForget(QObject* parent,
const QString& interface,
const QString& method,
const QVariantList& args,
53 const QString& logContext = {})
60inline void sendOneWay(
const QString& interface,
const QString& method,
const QVariantList& args = {})
67inline QDBusPendingCall
asyncCall(
const QString& interface,
const QString& method,
const QVariantList& args = {})
75inline QDBusMessage
syncCall(
const QString& interface,
const QString& method,
const QVariantList& args = {})
94 auto* watcher =
new QDBusPendingCallWatcher(
96 QObject::connect(watcher, &QDBusPendingCallWatcher::finished, parent,
97 [name, onValue = std::forward<Fn>(onValue)](QDBusPendingCallWatcher* w) {
99 QDBusPendingReply<QVariant> reply = *w;
100 if (reply.isValid()) {
101 QVariant value = reply.value();
102 if (value.canConvert<QDBusVariant>()) {
103 value = value.value<QDBusVariant>().variant();
109 <<
"loadSettingAsync: failed to load" << name <<
":" << reply.error().message();
A lightweight, service-agnostic D-Bus method-call client.
Definition Client.h:36
void sendOneWay(const QString &interface, const QString &method, const QVariantList &args={}) const
Send a one-way notification with no expected reply.
QDBusMessage syncCall(const QString &interface, const QString &method, const QVariantList &args={}, int timeoutMs=-1) const
Blocking method call with an explicit timeout.
QDBusPendingCall asyncCall(const QString &interface, const QString &method, const QVariantList &args={}) const
Issue an async method call and return the pending result.
void fireAndForget(QObject *parent, const QString &interface, const QString &method, const QVariantList &args, const QString &logContext={}) const
Fire-and-forget async call with error logging.
QDBusPendingCall asyncCall(const QString &interface, const QString &method, const QVariantList &args={})
Async method call to the daemon; caller attaches its own watcher.
Definition ClientHelpers.h:67
void sendOneWay(const QString &interface, const QString &method, const QVariantList &args={})
One-way notification to the daemon with no expected reply.
Definition ClientHelpers.h:60
void loadSettingAsync(QObject *parent, const QString &name, Fn &&onValue)
Async helper for loading a single daemon setting.
Definition ClientHelpers.h:92
void fireAndForget(QObject *parent, const QString &interface, const QString &method, const QVariantList &args, const QString &logContext={})
Fire-and-forget async call to the daemon, with error logging.
Definition ClientHelpers.h:52
QDBusMessage syncCall(const QString &interface, const QString &method, const QVariantList &args={})
Blocking daemon call bounded by Service::SyncCallTimeoutMs.
Definition ClientHelpers.h:75
constexpr QLatin1String Settings("org.plasmazones.Settings")
constexpr int SyncCallTimeoutMs
Definition ServiceConstants.h:99
constexpr QLatin1String Name("org.plasmazones")
D-Bus service constants shared by all compositor plugins.
constexpr QLatin1String ObjectPath("/PlasmaZones")
D-Bus marshalling for the autotile value types (see AutotileTypes.h).
Definition AutotileMarshalling.h:16
PHOSPHORPROTOCOL_EXPORT const QLoggingCategory & lcPhosphorProtocol()
PhosphorDBus::Client daemonClient()
A PhosphorDBus::Client bound to the PlasmaZones daemon.
Definition ClientHelpers.h:36