1 /*
2     Copyright 2006-2007 Kevin Ottens <ervin@kde.org>
3 
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) version 3, or any
8     later version accepted by the membership of KDE e.V. (or its
9     successor approved by the membership of KDE e.V.), which shall
10     act as a proxy defined in Section 6 of version 3 of the license.
11 
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Lesser General Public License for more details.
16 
17     You should have received a copy of the GNU Lesser General Public
18     License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SOLID_OPTICALDRIVE_H
22 #define SOLID_OPTICALDRIVE_H
23 
24 #include <QtCore/QList>
25 #include <QtCore/QVariant>
26 
27 #include <solid-lite/solid_export.h>
28 #include <solid-lite/solidnamespace.h>
29 
30 #include <solid-lite/storagedrive.h>
31 
32 namespace Solid
33 {
34     class OpticalDrivePrivate;
35     class Device;
36 
37     /**
38      * This device interface is available on CD-R*,DVD*,Blu-Ray,HD-DVD drives.
39      *
40      * An OpticalDrive is a storage that can handle optical discs.
41      */
42     class SOLID_EXPORT OpticalDrive : public StorageDrive
43     {
44         Q_OBJECT
45         Q_ENUMS(MediumType)
46         Q_FLAGS(MediumTypes)
47         Q_PROPERTY(MediumTypes supportedMedia READ supportedMedia)
48         Q_PROPERTY(int readSpeed READ readSpeed)
49         Q_PROPERTY(int writeSpeed READ writeSpeed)
50         Q_PROPERTY(QList<int> writeSpeeds READ writeSpeeds)
51         Q_DECLARE_PRIVATE(OpticalDrive)
52         friend class Device;
53 
54     public:
55         /**
56          * This enum type defines the type of medium an optical drive supports.
57          *
58          * - Cdr : A Recordable Compact Disc (CD-R)
59          * - Cdrw : A ReWritable Compact Disc (CD-RW)
60          * - Dvd : A Digital Versatile Disc (DVD)
61          * - Dvdr : A Recordable Digital Versatile Disc (DVD-R)
62          * - Dvdrw : A ReWritable Digital Versatile Disc (DVD-RW)
63          * - Dvdram : A Random Access Memory Digital Versatile Disc (DVD-RAM)
64          * - Dvdplusr : A Recordable Digital Versatile Disc (DVD+R)
65          * - Dvdplusrw : A ReWritable Digital Versatile Disc (DVD+RW)
66          * - Dvdplusdl : A Dual Layer Digital Versatile Disc (DVD+R DL)
67          * - Dvdplusdlrw : A Dual Layer Digital Versatile Disc (DVD+RW DL)
68          * - Bd : A Blu-ray Disc (BD)
69          * - Bdr : A Blu-ray Disc Recordable (BD-R)
70          * - Bdre : A Blu-ray Disc Recordable and Eraseable (BD-RE)
71          * - HdDvd : A High Density Digital Versatile Disc (HD DVD)
72          * - HdDvdr : A High Density Digital Versatile Disc Recordable (HD DVD-R)
73          * - HdDvdrw : A High Density Digital Versatile Disc ReWritable (HD DVD-RW)
74          */
75         enum MediumType { Cdr=0x00001, Cdrw=0x00002, Dvd=0x00004, Dvdr=0x00008,
76                           Dvdrw=0x00010, Dvdram=0x00020, Dvdplusr=0x00040,
77                           Dvdplusrw=0x00080, Dvdplusdl=0x00100, Dvdplusdlrw=0x00200,
78                           Bd=0x00400, Bdr=0x00800, Bdre=0x01000,
79                           HdDvd=0x02000, HdDvdr=0x04000, HdDvdrw=0x08000 };
80 
81         /**
82          * This type stores an OR combination of MediumType values.
83          */
84         Q_DECLARE_FLAGS(MediumTypes, MediumType)
85 
86 
87     private:
88         /**
89          * Creates a new OpticalDrive object.
90          * You generally won't need this. It's created when necessary using
91          * Device::as().
92          *
93          * @param backendObject the device interface object provided by the backend
94          * @see Solid::Device::as()
95          */
96         explicit OpticalDrive(QObject *backendObject);
97 
98     public:
99         /**
100          * Destroys an OpticalDrive object.
101          */
102         ~OpticalDrive() override;
103 
104 
105         /**
106          * Get the Solid::DeviceInterface::Type of the OpticalDrive device interface.
107          *
108          * @return the OpticalDrive device interface type
109          * @see Solid::Ifaces::Enums::DeviceInterface::Type
110          */
deviceInterfaceType()111         static Type deviceInterfaceType() { return DeviceInterface::OpticalDrive; }
112 
113 
114         /**
115          * Retrieves the medium types this drive supports.
116          *
117          * @return the flag set indicating the supported medium types
118          */
119         MediumTypes supportedMedia() const;
120 
121         /**
122          * Retrieves the maximum read speed of this drive in kilobytes per second.
123          *
124          * @return the maximum read speed
125          */
126         int readSpeed() const;
127 
128         /**
129          * Retrieves the maximum write speed of this drive in kilobytes per second.
130          *
131          * @return the maximum write speed
132          */
133         int writeSpeed() const;
134 
135         /**
136          * Retrieves the list of supported write speeds of this drive in
137          * kilobytes per second.
138          *
139          * @return the list of supported write speeds
140          */
141         QList<int> writeSpeeds() const;
142 
143         /**
144          * Ejects any disc that could be contained in this drive.
145          * If this drive is empty, but has a tray it'll be opened.
146          *
147          * @return the status of the eject operation
148          */
149         bool eject();
150 
151     Q_SIGNALS:
152         /**
153          * This signal is emitted when the eject button is pressed
154          * on the drive.
155          *
156          * Please note that some (broken) drives doesn't report this event.
157          * @param udi the UDI of the drive
158          */
159         void ejectPressed(const QString &udi);
160 
161         /**
162          * This signal is emitted when the attempted eject process on this
163          * drive is completed. The signal might be spontaneous, i.e.
164          * it can be triggered by another process.
165          *
166          * @param error type of error that occurred, if any
167          * @param errorData more information about the error, if any
168          * @param udi the UDI of the volume
169          */
170         void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
171 
172         /**
173          * This signal is emitted when eject on this drive is
174          * requested. The signal might be spontaneous, i.e. it
175          * can be triggered by another process.
176          *
177          * @param udi the UDI of the volume
178          */
179         void ejectRequested(const QString &udi);
180 
181     };
182 }
183 
184 Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::OpticalDrive::MediumTypes)
185 
186 #endif // SOLID_OPTICALDRIVE_H
187