File indexing completed on 2024-05-05 04:51:14

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 #ifndef _K3B_GROWISOFS_WRITER_H_
0006 #define _K3B_GROWISOFS_WRITER_H_
0007 
0008 #include "k3babstractwriter.h"
0009 
0010 #include <QProcess>
0011 
0012 
0013 namespace K3b {
0014     namespace Device {
0015         class Device;
0016     }
0017 
0018     class GrowisofsWriter : public AbstractWriter
0019     {
0020         Q_OBJECT
0021 
0022     public:
0023         GrowisofsWriter( Device::Device*, JobHandler*,
0024                          QObject* parent = 0 );
0025         ~GrowisofsWriter() override;
0026 
0027         bool active() const override;
0028 
0029         /**
0030          * Write to the writer process.
0031          * FIXME: make this an overloaded method from AbstractWriter
0032          */
0033         qint64 write( const char* data, qint64 maxSize );
0034 
0035         QIODevice* ioDevice() const override;
0036 
0037     public Q_SLOTS:
0038         void start() override;
0039         void cancel() override;
0040 
0041         void setWritingMode( K3b::WritingMode mode );
0042 
0043         /**
0044          * If true the growisofs parameter -M is used in favor of -Z.
0045          */
0046         void setMultiSession( bool b );
0047 
0048         /**
0049          * Only used in DAO mode and only supported with growisofs >= 5.15
0050          * @param size size in blocks
0051          */
0052         void setTrackSize( long size );
0053 
0054         /**
0055          * Use this in combination with setTrackSize when writing double layer media.
0056          * @param lb The number of data sectors in the first layer. It needs to be less or equal
0057          *           to tracksize/2. The writer will pad the second layer with zeros if
0058          *           break < tracksize/2.
0059          *           If set to 0 this setting will be ignored.
0060          */
0061         void setLayerBreak( long lb );
0062 
0063         /**
0064          * Close the DVD to enable max DVD compatibility (uses the growisofs --dvd-compat parameter)
0065          * This will also be used in DAO mode and when the layerBreak has been set.
0066          */
0067         void setCloseDvd( bool );
0068 
0069         /**
0070          * set this to QString() or an empty string to let the writer
0071          * read it's data from fd()
0072          */
0073         void setImageToWrite( const QString& );
0074 
0075         /**
0076          * While reading the image from stdin growisofs needs
0077          * a valid -C parameter for multisession.
0078          */
0079         void setMultiSessionInfo( const QString& );
0080 
0081     protected:
0082         bool prepareProcess();
0083 
0084     protected Q_SLOTS:
0085         void slotReceivedStderr( const QString& );
0086         void slotProcessExited( int, QProcess::ExitStatus );
0087         void slotThroughput( int t );
0088         void slotFlushingCache();
0089 
0090     private:
0091         class Private;
0092         Private* d;
0093     };
0094 }
0095 
0096 #endif