File indexing completed on 2024-04-21 04:49:43

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_DISKINFO_H_
0007 #define _K3B_DISKINFO_H_
0008 
0009 #include "k3bdevicetypes.h"
0010 
0011 #include "k3btoc.h"
0012 #include "k3bmsf.h"
0013 #include "k3bdevice_export.h"
0014 
0015 #include <QSharedDataPointer>
0016 
0017 namespace K3b {
0018     namespace Device
0019     {
0020         class DiskInfoPrivate;
0021 
0022         /**
0023          * This class is directly associated to a structure from
0024          * the MMC draft READ_DISK_INFO.
0025          * It also holds some additional data.
0026          * This class' data will be retrieved by K3b::Device::Device.
0027          *
0028          * Before using any values one should check diskState != STATE_UNKNOWN or
0029          * diskState == STATE_NO_MEDIA.
0030          * That may mean that no disk is in the drive or an error occurred.
0031          * Writers should never give the STATE_UNKNOWN state. CD-ROM or DVD-ROM
0032          * drives on the other hand may have trouble determining the state of the disk.
0033          */
0034         class LIBK3BDEVICE_EXPORT DiskInfo
0035         {
0036         public:
0037             DiskInfo();
0038             DiskInfo( const DiskInfo& );
0039             ~DiskInfo();
0040 
0041             DiskInfo& operator=( const DiskInfo& );
0042 
0043             /**
0044              * Returns the state of the disk.
0045              * See enum State.
0046              */
0047             MediaState diskState() const;
0048 
0049             /**
0050              * Returns the state of the last session.
0051              * See enum State.
0052              */
0053             MediaState lastSessionState() const;
0054 
0055             /**
0056              * Returns the state of the background formatting. This does
0057              * only make sense for DVD+RW (and MRW which is not yet supported)
0058              */
0059             BackGroundFormattingState bgFormatState() const;
0060 
0061             /**
0062              * returns true if diskState() == STATE_EMPTY
0063              */
0064             bool empty() const;
0065 
0066             /**
0067              * Is this a rewritable media (e.g. a CD-RW, DVD-RW, or DVD+RW)
0068              */
0069             bool rewritable() const;
0070 
0071             /**
0072              * Is this disk appendable
0073              * returns true if diskState() == STATE_INCOMPLETE
0074              */
0075             bool appendable() const;
0076 
0077             /**
0078              * The type of the disk:
0079              * CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R(W), DVD+R(W)
0080              */
0081             MediaType mediaType() const;
0082 
0083             /**
0084              * This is the current profile of the drive. That means it may differ
0085              * from drive to drive.
0086              * -1 means no info.
0087              * Mainly interesting for the distinction of DVD-R(W) modes:
0088              * Sequential and Restricted Overwrite.
0089              */
0090             int currentProfile() const;
0091 
0092             /**
0093              * The number of sessions on the disk.
0094              * This does not include any leadout or the last empty session
0095              * on a DVD+-R(W)
0096              */
0097             int numSessions() const;
0098 
0099             /**
0100              * The number of finished tracks.
0101              * This does not include the empty track.
0102              */
0103             int numTracks() const;
0104 
0105             /**
0106              * Number of layers on a DVD media. For CD media this is always 1.
0107              */
0108             int numLayers() const;
0109 
0110             /**
0111              * Does only make sense for appendable disks.
0112              */
0113             K3b::Msf remainingSize() const;
0114 
0115             /**
0116              * The capacity of the disk.
0117              * For complete disks this may be the same as size()
0118              */
0119             K3b::Msf capacity() const;
0120 
0121             /**
0122              * Returns the size of the used part.
0123              * For appendable media this equals capacity() - remainingSize()
0124              */
0125             K3b::Msf size() const;
0126 
0127             /**
0128              * Returns the size of Data area in the first layer for DL DVD media.
0129              * Otherwise size() is returned.
0130              *
0131              * This does not specify the layer change sector as the data area on DVD media does
0132              * not start at sector 0 but at sector 30000h or 31000h depending on the type.
0133              */
0134             K3b::Msf firstLayerSize() const;
0135 
0136             QByteArray mediaId() const;
0137 
0138             void debug() const;
0139 
0140             bool operator==( const DiskInfo& ) const;
0141             bool operator!=( const DiskInfo& ) const;
0142 
0143         private:
0144             QSharedDataPointer<DiskInfoPrivate> d;
0145 
0146             friend class Device;
0147         };
0148 
0149         //  kdbgstream& operator<<( kdbgstream& s, const DiskInfo& ngInf );
0150     }
0151 }
0152 
0153 #endif