File indexing completed on 2024-05-12 04:01:51
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef SOLID_OPTICALDRIVE_H 0008 #define SOLID_OPTICALDRIVE_H 0009 0010 #include <QList> 0011 #include <QVariant> 0012 0013 #include <solid/solid_export.h> 0014 #include <solid/solidnamespace.h> 0015 0016 #include <solid/storagedrive.h> 0017 0018 namespace Solid 0019 { 0020 class OpticalDrivePrivate; 0021 class Device; 0022 0023 /** 0024 * @class Solid::OpticalDrive opticaldrive.h <Solid/OpticalDrive> 0025 * 0026 * This device interface is available on CD-R*,DVD*,Blu-Ray,HD-DVD drives. 0027 * 0028 * An OpticalDrive is a storage that can handle optical discs. 0029 */ 0030 class SOLID_EXPORT OpticalDrive : public StorageDrive 0031 { 0032 Q_OBJECT 0033 Q_PROPERTY(MediumTypes supportedMedia READ supportedMedia) 0034 Q_PROPERTY(int readSpeed READ readSpeed) 0035 Q_PROPERTY(int writeSpeed READ writeSpeed) 0036 Q_PROPERTY(QList<int> writeSpeeds READ writeSpeeds) 0037 Q_DECLARE_PRIVATE(OpticalDrive) 0038 friend class Device; 0039 0040 public: 0041 /** 0042 * This enum type defines the type of medium an optical drive supports. 0043 * 0044 * - Cdr : A Recordable Compact Disc (CD-R) 0045 * - Cdrw : A ReWritable Compact Disc (CD-RW) 0046 * - Dvd : A Digital Versatile Disc (DVD) 0047 * - Dvdr : A Recordable Digital Versatile Disc (DVD-R) 0048 * - Dvdrw : A ReWritable Digital Versatile Disc (DVD-RW) 0049 * - Dvdram : A Random Access Memory Digital Versatile Disc (DVD-RAM) 0050 * - Dvdplusr : A Recordable Digital Versatile Disc (DVD+R) 0051 * - Dvdplusrw : A ReWritable Digital Versatile Disc (DVD+RW) 0052 * - Dvdplusdl : A Dual Layer Digital Versatile Disc (DVD+R DL) 0053 * - Dvdplusdlrw : A Dual Layer Digital Versatile Disc (DVD+RW DL) 0054 * - Bd : A Blu-ray Disc (BD) 0055 * - Bdr : A Blu-ray Disc Recordable (BD-R) 0056 * - Bdre : A Blu-ray Disc Recordable and Eraseable (BD-RE) 0057 * - HdDvd : A High Density Digital Versatile Disc (HD DVD) 0058 * - HdDvdr : A High Density Digital Versatile Disc Recordable (HD DVD-R) 0059 * - HdDvdrw : A High Density Digital Versatile Disc ReWritable (HD DVD-RW) 0060 * 0061 * @see MediumTypes 0062 */ 0063 enum MediumType { 0064 UnknownMediumType = 0x00000, 0065 Cdr = 0x00001, 0066 Cdrw = 0x00002, 0067 Dvd = 0x00004, 0068 Dvdr = 0x00008, 0069 Dvdrw = 0x00010, 0070 Dvdram = 0x00020, 0071 Dvdplusr = 0x00040, 0072 Dvdplusrw = 0x00080, 0073 Dvdplusdl = 0x00100, 0074 Dvdplusdlrw = 0x00200, 0075 Bd = 0x00400, 0076 Bdr = 0x00800, 0077 Bdre = 0x01000, 0078 HdDvd = 0x02000, 0079 HdDvdr = 0x04000, 0080 HdDvdrw = 0x08000, 0081 }; 0082 Q_ENUM(MediumType) 0083 0084 /** 0085 * Stores a combination of #MediumType values. 0086 */ 0087 Q_DECLARE_FLAGS(MediumTypes, MediumType) 0088 Q_FLAG(MediumTypes) 0089 0090 private: 0091 /** 0092 * Creates a new OpticalDrive object. 0093 * You generally won't need this. It's created when necessary using 0094 * Device::as(). 0095 * 0096 * @param backendObject the device interface object provided by the backend 0097 * @see Solid::Device::as() 0098 */ 0099 SOLID_NO_EXPORT explicit OpticalDrive(QObject *backendObject); 0100 0101 public: 0102 /** 0103 * Destroys an OpticalDrive object. 0104 */ 0105 ~OpticalDrive() override; 0106 0107 /** 0108 * Get the Solid::DeviceInterface::Type of the OpticalDrive device interface. 0109 * 0110 * @return the OpticalDrive device interface type 0111 * @see Solid::Ifaces::Enums::DeviceInterface::Type 0112 */ 0113 static Type deviceInterfaceType() 0114 { 0115 return DeviceInterface::OpticalDrive; 0116 } 0117 0118 /** 0119 * Retrieves the medium types this drive supports. 0120 * 0121 * @return the flag set indicating the supported medium types 0122 */ 0123 MediumTypes supportedMedia() const; 0124 0125 /** 0126 * Retrieves the maximum read speed of this drive in kilobytes per second. 0127 * 0128 * @return the maximum read speed 0129 */ 0130 int readSpeed() const; 0131 0132 /** 0133 * Retrieves the maximum write speed of this drive in kilobytes per second. 0134 * 0135 * @return the maximum write speed 0136 */ 0137 int writeSpeed() const; 0138 0139 /** 0140 * Retrieves the list of supported write speeds of this drive in 0141 * kilobytes per second. 0142 * 0143 * @return the list of supported write speeds 0144 */ 0145 QList<int> writeSpeeds() const; 0146 0147 /** 0148 * Ejects any disc that could be contained in this drive. 0149 * If this drive is empty, but has a tray it'll be opened. 0150 * 0151 * @return the status of the eject operation 0152 */ 0153 bool eject(); 0154 0155 Q_SIGNALS: 0156 /** 0157 * This signal is emitted when the eject button is pressed 0158 * on the drive. 0159 * 0160 * Please note that some (broken) drives doesn't report this event. 0161 * @param udi the UDI of the drive 0162 */ 0163 void ejectPressed(const QString &udi); 0164 0165 /** 0166 * This signal is emitted when the attempted eject process on this 0167 * drive is completed. The signal might be spontaneous, i.e. 0168 * it can be triggered by another process. 0169 * 0170 * @param error type of error that occurred, if any 0171 * @param errorData more information about the error, if any 0172 * @param udi the UDI of the volume 0173 */ 0174 void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); 0175 0176 /** 0177 * This signal is emitted when eject on this drive is 0178 * requested. The signal might be spontaneous, i.e. it 0179 * can be triggered by another process. 0180 * 0181 * @param udi the UDI of the volume 0182 */ 0183 void ejectRequested(const QString &udi); 0184 }; 0185 0186 Q_DECLARE_OPERATORS_FOR_FLAGS(OpticalDrive::MediumTypes) 0187 0188 } 0189 0190 #endif // SOLID_OPTICALDRIVE_H