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 QT_DBUS_LIB
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 QT_DBUS_LIB
31 QDBusConnection::sessionBus().connect(QString(), deviceDBusPath(), "org.kde.Solid.Device", actionName + "Requested", dest, requestSlot);
32
33 QDBusConnection::sessionBus().connect(QString(), deviceDBusPath(), "org.kde.Solid.Device", actionName + "Done", dest, doneSlot);
34#endif
35}
36
37void Solid::Ifaces::Device::broadcastActionDone(const QString &actionName, int error, const QString &errorString) const
38{
39#ifdef QT_DBUS_LIB
40 QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), "org.kde.Solid.Device", actionName + "Done");
41 signal << error << errorString;
42
44#endif
45}
46
48{
49#ifdef QT_DBUS_LIB
50 QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), "org.kde.Solid.Device", actionName + "Requested");
52#endif
53}
54
55QString Solid::Ifaces::Device::deviceDBusPath() const
56{
57 const QByteArray encodedUdi = udi().toUtf8().toPercentEncoding(QByteArray(), ".~-", '_');
58 return QString("/org/kde/solid/Device_") + QString::fromLatin1(encodedUdi);
59}
60
62{
63 return description();
64}
65
66#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 Fri May 24 2024 11:56:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.