File indexing completed on 2024-04-28 04:49:41
0001 /* 0002 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 0007 #ifndef K3B_ABSTRACT_WRITER_H 0008 #define K3B_ABSTRACT_WRITER_H 0009 0010 0011 #include "k3bjob.h" 0012 #include "k3bdevicetypes.h" 0013 0014 #include <QDateTime> 0015 0016 class QIODevice; 0017 0018 namespace K3b { 0019 class JobHandler; 0020 0021 class AbstractWriter : public Job 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 ~AbstractWriter() override; 0027 0028 Device::Device* burnDevice(); 0029 int burnSpeed() const { return m_burnSpeed; } 0030 bool simulate() const { return m_simulate; } 0031 0032 /** 0033 * This can be used to setup direct streaming between two processes 0034 * for example the cdrecordwriter returns the stdin fd which can be 0035 * connected to the stdout fd of mkisofs in the isoimager 0036 */ 0037 virtual QIODevice* ioDevice() const { return 0; } 0038 0039 public Q_SLOTS: 0040 /** 0041 * If the burnDevice is set this will try to unlock the drive and 0042 * eject the disk if K3b is configured to do so. 0043 * Will also emit canceled and finished signals. 0044 * may be called by subclasses. 0045 */ 0046 void cancel() override; 0047 0048 void setBurnDevice( K3b::Device::Device* dev ) { m_burnDevice = dev; } 0049 void setBurnSpeed( int s ) { m_burnSpeed = s; } 0050 void setSimulate( bool b ) { m_simulate = b; } 0051 0052 /** 0053 * Used to inform the writer that the source (especially useful when reading from 0054 * another cd/dvd media) could not be read. 0055 * 0056 * Basically it should be used to make sure no "write an email" message is thrown. 0057 */ 0058 void setSourceUnreadable( bool b = true ) { m_sourceUnreadable = b; } 0059 0060 Q_SIGNALS: 0061 void buffer( int ); 0062 void deviceBuffer( int ); 0063 void writeSpeed( int speed, K3b::Device::SpeedMultiplicator multiplicator ); 0064 0065 protected: 0066 AbstractWriter( Device::Device* dev, JobHandler* hdl, 0067 QObject* parent = 0 ); 0068 0069 bool wasSourceUnreadable() const { return m_sourceUnreadable; } 0070 0071 protected Q_SLOTS: 0072 void slotUnblockWhileCancellationFinished( bool success ); 0073 void slotEjectWhileCancellationFinished( bool success ); 0074 0075 private: 0076 Device::Device* m_burnDevice; 0077 int m_burnSpeed; 0078 bool m_simulate; 0079 bool m_sourceUnreadable; 0080 }; 0081 } 0082 0083 #endif