Solid

ifaces/device.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "ifaces/device.h"
8
9#ifdef HAVE_DBUS
10#include <QDBusConnection>
11#include <QDBusMessage>
12#endif
13
15 : QObject(parent)
16{
17}
18
22
27
28void Solid::Ifaces::Device::registerAction(const QString &actionName, QObject *dest, const char *requestSlot, const char *doneSlot) const
29{
30#ifdef HAVE_DBUS
32 .connect(QString(), deviceDBusPath(), QStringLiteral("org.kde.Solid.Device"), actionName + QStringLiteral("Requested"), dest, requestSlot);
33
35 .connect(QString(), deviceDBusPath(), QStringLiteral("org.kde.Solid.Device"), actionName + QStringLiteral("Done"), dest, doneSlot);
36#endif
37}
38
39void Solid::Ifaces::Device::broadcastActionDone(const QString &actionName, int error, const QString &errorString) const
40{
41#ifdef HAVE_DBUS
42 QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), QStringLiteral("org.kde.Solid.Device"), actionName + QStringLiteral("Done"));
43 signal << error << errorString;
44
46#endif
47}
48
50{
51#ifdef HAVE_DBUS
52 QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), QStringLiteral("org.kde.Solid.Device"), actionName + QStringLiteral("Requested"));
54#endif
55}
56
57QString Solid::Ifaces::Device::deviceDBusPath() const
58{
59 const QByteArray encodedUdi = udi().toUtf8().toPercentEncoding(QByteArray(), ".~-", '_');
60 return QStringLiteral("/org/kde/solid/Device_") + QString::fromLatin1(encodedUdi);
61}
62
64{
65 return description();
66}
67
68#include "moc_device.cpp"
virtual QString displayName() const
Retrieves the display name to use for this device.
void broadcastActionRequested(const QString &actionName) const
Allows to broadcast that an action just got requested on a device to all the corresponding devices in...
~Device() override
Destruct the Device object.
void broadcastActionDone(const QString &actionName, int error=Solid::NoError, const QString &errorString=QString()) const
Allows to broadcast that an action just completed in a device to all the corresponding devices in oth...
virtual QString parentUdi() const
Retrieves the Universal Device Identifier (UDI) of the Device's parent.
void registerAction(const QString &actionName, QObject *dest, const char *requestSlot, const char *doneSlot) const
Register an action for the given device.
Device(QObject *parent=nullptr)
Constructs a Device.
QByteArray toPercentEncoding(const QByteArray &exclude, const QByteArray &include, char percent) const const
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
bool send(const QDBusMessage &message) const const
QDBusConnection sessionBus()
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
QString fromLatin1(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.