| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006-2007 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 | #ifndef SOLID_OPTICALDRIVE_H |
| 8 | #define SOLID_OPTICALDRIVE_H |
| 9 | |
| 10 | #include <QList> |
| 11 | #include <QVariant> |
| 12 | |
| 13 | #include <solid/solid_export.h> |
| 14 | #include <solid/solidnamespace.h> |
| 15 | |
| 16 | #include <solid/storagedrive.h> |
| 17 | |
| 18 | namespace Solid |
| 19 | { |
| 20 | class OpticalDrivePrivate; |
| 21 | class Device; |
| 22 | |
| 23 | /*! |
| 24 | * \class Solid::OpticalDrive |
| 25 | * \inheaderfile Solid/OpticalDrive |
| 26 | * \inmodule Solid |
| 27 | * |
| 28 | * \brief This device interface is available on CD-R*,DVD*,Blu-Ray,HD-DVD drives. |
| 29 | * |
| 30 | * An OpticalDrive is a storage that can handle optical discs. |
| 31 | */ |
| 32 | class SOLID_EXPORT OpticalDrive : public StorageDrive |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | |
| 36 | /*! |
| 37 | * \property Solid::OpticalDrive::supportedMedia |
| 38 | */ |
| 39 | Q_PROPERTY(MediumTypes supportedMedia READ supportedMedia) |
| 40 | |
| 41 | /*! |
| 42 | * \property Solid::OpticalDrive::readSpeed |
| 43 | */ |
| 44 | Q_PROPERTY(int readSpeed READ readSpeed) |
| 45 | |
| 46 | /*! |
| 47 | * \property Solid::OpticalDrive::writeSpeed |
| 48 | */ |
| 49 | Q_PROPERTY(int writeSpeed READ writeSpeed) |
| 50 | |
| 51 | /*! |
| 52 | * \property Solid::OpticalDrive::writeSpeeds |
| 53 | */ |
| 54 | Q_PROPERTY(QList<int> writeSpeeds READ writeSpeeds) |
| 55 | |
| 56 | Q_DECLARE_PRIVATE(OpticalDrive) |
| 57 | friend class Device; |
| 58 | |
| 59 | public: |
| 60 | /*! |
| 61 | * This enum type defines the type of medium an optical drive supports. |
| 62 | * |
| 63 | * \value UnknownMediumType |
| 64 | * \value Cdr A Recordable Compact Disc (CD-R) |
| 65 | * \value Cdrw A ReWritable Compact Disc (CD-RW) |
| 66 | * \value Dvd A Digital Versatile Disc (DVD) |
| 67 | * \value Dvdr A Recordable Digital Versatile Disc (DVD-R) |
| 68 | * \value Dvdrw A ReWritable Digital Versatile Disc (DVD-RW) |
| 69 | * \value Dvdram A Random Access Memory Digital Versatile Disc (DVD-RAM) |
| 70 | * \value Dvdplusr A Recordable Digital Versatile Disc (DVD+R) |
| 71 | * \value Dvdplusrw A ReWritable Digital Versatile Disc (DVD+RW) |
| 72 | * \value Dvdplusdl A Dual Layer Digital Versatile Disc (DVD+R DL) |
| 73 | * \value Dvdplusdlrw A Dual Layer Digital Versatile Disc (DVD+RW DL) |
| 74 | * \value Bd A Blu-ray Disc (BD) |
| 75 | * \value Bdr A Blu-ray Disc Recordable (BD-R) |
| 76 | * \value Bdre A Blu-ray Disc Recordable and Eraseable (BD-RE) |
| 77 | * \value HdDvd A High Density Digital Versatile Disc (HD DVD) |
| 78 | * \value HdDvdr A High Density Digital Versatile Disc Recordable (HD DVD-R) |
| 79 | * \value HdDvdrw A High Density Digital Versatile Disc ReWritable (HD DVD-RW) |
| 80 | */ |
| 81 | enum MediumType { |
| 82 | UnknownMediumType = 0x00000, |
| 83 | Cdr = 0x00001, |
| 84 | Cdrw = 0x00002, |
| 85 | Dvd = 0x00004, |
| 86 | Dvdr = 0x00008, |
| 87 | Dvdrw = 0x00010, |
| 88 | Dvdram = 0x00020, |
| 89 | Dvdplusr = 0x00040, |
| 90 | Dvdplusrw = 0x00080, |
| 91 | Dvdplusdl = 0x00100, |
| 92 | Dvdplusdlrw = 0x00200, |
| 93 | Bd = 0x00400, |
| 94 | Bdr = 0x00800, |
| 95 | Bdre = 0x01000, |
| 96 | HdDvd = 0x02000, |
| 97 | HdDvdr = 0x04000, |
| 98 | HdDvdrw = 0x08000, |
| 99 | }; |
| 100 | Q_ENUM(MediumType) |
| 101 | |
| 102 | Q_DECLARE_FLAGS(MediumTypes, MediumType) |
| 103 | Q_FLAG(MediumTypes) |
| 104 | |
| 105 | private: |
| 106 | /*! |
| 107 | * \internal |
| 108 | * Creates a new OpticalDrive object. |
| 109 | * You generally won't need this. It's created when necessary using |
| 110 | * Device::as(). |
| 111 | * |
| 112 | * \a backendObject the device interface object provided by the backend |
| 113 | * \sa Solid::Device::as() |
| 114 | */ |
| 115 | SOLID_NO_EXPORT explicit OpticalDrive(QObject *backendObject); |
| 116 | |
| 117 | public: |
| 118 | ~OpticalDrive() override; |
| 119 | |
| 120 | /*! |
| 121 | * Get the Solid::DeviceInterface::Type of the OpticalDrive device interface. |
| 122 | * |
| 123 | * Returns the OpticalDrive device interface type |
| 124 | * \sa Solid::Ifaces::Enums::DeviceInterface::Type |
| 125 | */ |
| 126 | static Type deviceInterfaceType() |
| 127 | { |
| 128 | return DeviceInterface::OpticalDrive; |
| 129 | } |
| 130 | |
| 131 | /*! |
| 132 | * Retrieves the medium types this drive supports. |
| 133 | * |
| 134 | * Returns the flag set indicating the supported medium types |
| 135 | */ |
| 136 | MediumTypes supportedMedia() const; |
| 137 | |
| 138 | /*! |
| 139 | * Retrieves the maximum read speed of this drive in kilobytes per second. |
| 140 | * |
| 141 | * Returns the maximum read speed |
| 142 | */ |
| 143 | int readSpeed() const; |
| 144 | |
| 145 | /*! |
| 146 | * Retrieves the maximum write speed of this drive in kilobytes per second. |
| 147 | * |
| 148 | * Returns the maximum write speed |
| 149 | */ |
| 150 | int writeSpeed() const; |
| 151 | |
| 152 | /*! |
| 153 | * Retrieves the list of supported write speeds of this drive in |
| 154 | * kilobytes per second. |
| 155 | * |
| 156 | * Returns the list of supported write speeds |
| 157 | */ |
| 158 | QList<int> writeSpeeds() const; |
| 159 | |
| 160 | /*! |
| 161 | * Ejects any disc that could be contained in this drive. |
| 162 | * If this drive is empty, but has a tray it'll be opened. |
| 163 | * |
| 164 | * Returns the status of the eject operation |
| 165 | */ |
| 166 | bool eject(); |
| 167 | |
| 168 | Q_SIGNALS: |
| 169 | /*! |
| 170 | * This signal is emitted when the eject button is pressed |
| 171 | * on the drive. |
| 172 | * |
| 173 | * Please note that some (broken) drives doesn't report this event. |
| 174 | * |
| 175 | * \a udi the UDI of the drive |
| 176 | */ |
| 177 | void ejectPressed(const QString &udi); |
| 178 | |
| 179 | /*! |
| 180 | * This signal is emitted when the attempted eject process on this |
| 181 | * drive is completed. The signal might be spontaneous, i.e. |
| 182 | * it can be triggered by another process. |
| 183 | * |
| 184 | * \a error type of error that occurred, if any |
| 185 | * |
| 186 | * \a errorData more information about the error, if any |
| 187 | * |
| 188 | * \a udi the UDI of the volume |
| 189 | */ |
| 190 | void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); |
| 191 | |
| 192 | /*! |
| 193 | * This signal is emitted when eject on this drive is |
| 194 | * requested. The signal might be spontaneous, i.e. it |
| 195 | * can be triggered by another process. |
| 196 | * |
| 197 | * \a udi the UDI of the volume |
| 198 | */ |
| 199 | void ejectRequested(const QString &udi); |
| 200 | }; |
| 201 | |
| 202 | Q_DECLARE_OPERATORS_FOR_FLAGS(OpticalDrive::MediumTypes) |
| 203 | |
| 204 | } |
| 205 | |
| 206 | #endif // SOLID_OPTICALDRIVE_H |
| 207 | |