/usr/include/solid/device.h is in kdelibs5-dev 4:4.14.16-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | /*
Copyright 2005-2007 Kevin Ottens <ervin@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOLID_DEVICE_H
#define SOLID_DEVICE_H
#include <QtCore/QVariant>
#include <QtCore/QMap>
#include <QtCore/QList>
#include <QtCore/QSharedData>
#include <solid/solid_export.h>
#include <solid/deviceinterface.h>
namespace Solid
{
class DevicePrivate;
/**
* This class allows applications to deal with devices available in the
* underlying system.
*
* Device stores a reference to device data provided by the backend.
* Device objects are designed to be used by value. Copying these objects
* is quite cheap, so using pointers to the me is generally not needed.
*
* @author Kevin Ottens <ervin@kde.org>
*/
class SOLID_EXPORT Device
{
public:
/**
* Retrieves all the devices available in the underlying system.
*
* @return the list of the devices available
*/
static QList<Device> allDevices();
/**
* Retrieves a list of devices of the system given matching the given
* constraints (parent and device interface type)
*
* @param type device interface type available on the devices we're looking for, or DeviceInterface::Unknown
* if there's no constraint on the device interfaces
* @param parentUdi UDI of the parent of the devices we're searching for, or QString()
* if there's no constraint on the parent
* @return the list of devices corresponding to the given constraints
* @see Solid::Predicate
*/
static QList<Device> listFromType(const DeviceInterface::Type &type,
const QString &parentUdi = QString());
/**
* Retrieves a list of devices of the system given matching the given
* constraints (parent and predicate)
*
* @param predicate Predicate that the devices we're searching for must verify
* @param parentUdi UDI of the parent of the devices we're searching for, or QString()
* if there's no constraint on the parent
* @return the list of devices corresponding to the given constraints
* @see Solid::Predicate
*/
static QList<Device> listFromQuery(const Predicate &predicate,
const QString &parentUdi = QString());
/**
* Convenience function see above.
*
* @param predicate
* @param parentUdi
* @return the list of devices
*/
static QList<Device> listFromQuery(const QString &predicate,
const QString &parentUdi = QString());
/**
* Constructs a device for a given Universal Device Identifier (UDI).
*
* @param udi the udi of the device to create
*/
explicit Device(const QString &udi = QString());
/**
* Constructs a copy of a device.
*
* @param device the device to copy
*/
Device(const Device &device);
/**
* Destroys the device.
*/
~Device();
/**
* Assigns a device to this device and returns a reference to it.
*
* @param device the device to assign
* @return a reference to the device
*/
Device &operator=(const Device &device);
/**
* Indicates if this device is valid.
* A device is considered valid if it's available in the system.
*
* @return true if this device is available, false otherwise
*/
bool isValid() const;
/**
* Retrieves the Universal Device Identifier (UDI).
*
* \warning Don't use the UDI for anything except communication with Solid. Also don't store
* UDIs as there's no guarantee that the UDI stays the same when the hardware setup changed.
* The UDI is a unique identifier that is local to the computer in question and for the
* current boot session. The UDIs may change after a reboot.
* Similar hardware in other computers may have different values; different
* hardware could have the same UDI.
*
* @return the udi of the device
*/
QString udi() const;
/**
* Retrieves the Universal Device Identifier (UDI)
* of the Device's parent.
*
* @return the udi of the device's parent
*/
QString parentUdi() const;
/**
* Retrieves the parent of the Device.
*
* @return the device's parent
* @see parentUdi()
*/
Device parent() const;
/**
* Retrieves the name of the device vendor.
*
* @return the vendor name
*/
QString vendor() const;
/**
* Retrieves the name of the product corresponding to this device.
*
* @return the product name
*/
QString product() const;
/**
* Retrieves the name of the icon representing this device.
* The naming follows the freedesktop.org specification.
*
* @return the icon name
*/
QString icon() const;
/**
* Retrieves the names of the emblems representing the state of this device.
* The naming follows the freedesktop.org specification.
*
* @return the emblem names
* @since 4.4
*/
QStringList emblems() const;
/**
* Retrieves the description of device.
*
* @return the description
* @since 4.4
*/
QString description() const;
/**
* Tests if a device interface is available from the device.
*
* @param type the device interface type to query
* @return true if the device interface is available, false otherwise
*/
bool isDeviceInterface(const DeviceInterface::Type &type) const;
/**
* Retrieves a specialized interface to interact with the device corresponding to
* a particular device interface.
*
* @param type the device interface type
* @returns a pointer to the device interface interface if it exists, 0 otherwise
*/
DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type);
/**
* Retrieves a specialized interface to interact with the device corresponding to
* a particular device interface.
*
* @param type the device interface type
* @returns a pointer to the device interface interface if it exists, 0 otherwise
*/
const DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type) const;
/**
* Retrieves a specialized interface to interact with the device corresponding
* to a given device interface.
*
* @returns a pointer to the device interface if it exists, 0 otherwise
*/
template <class DevIface> DevIface *as()
{
DeviceInterface::Type type = DevIface::deviceInterfaceType();
DeviceInterface *iface = asDeviceInterface(type);
return qobject_cast<DevIface *>(iface);
}
/**
* Retrieves a specialized interface to interact with the device corresponding
* to a given device interface.
*
* @returns a pointer to the device interface if it exists, 0 otherwise
*/
template <class DevIface> const DevIface *as() const
{
DeviceInterface::Type type = DevIface::deviceInterfaceType();
const DeviceInterface *iface = asDeviceInterface(type);
return qobject_cast<const DevIface *>(iface);
}
/**
* Tests if a device provides a given device interface.
*
* @returns true if the interface is available, false otherwise
*/
template <class DevIface> bool is() const
{
return isDeviceInterface(DevIface::deviceInterfaceType());
}
private:
QExplicitlySharedDataPointer<DevicePrivate> d;
friend class DeviceManagerPrivate;
};
}
#endif
|