File indexing completed on 2024-04-28 04:49:41
0001 /* 0002 SPDX-FileCopyrightText: 1998-2010 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 0007 #include "k3babstractwriter.h" 0008 #include "k3bcore.h" 0009 #include "k3bdevicemanager.h" 0010 #include "k3bdevicehandler.h" 0011 #include "k3bglobalsettings.h" 0012 #include "k3b_i18n.h" 0013 0014 0015 0016 K3b::AbstractWriter::AbstractWriter( K3b::Device::Device* dev, K3b::JobHandler* jh, QObject* parent ) 0017 : K3b::Job( jh, parent ), 0018 m_burnDevice(dev), 0019 m_burnSpeed(0), 0020 m_simulate(false), 0021 m_sourceUnreadable(false) 0022 { 0023 } 0024 0025 0026 K3b::AbstractWriter::~AbstractWriter() 0027 { 0028 } 0029 0030 0031 K3b::Device::Device* K3b::AbstractWriter::burnDevice() 0032 { 0033 if( m_burnDevice ) 0034 return m_burnDevice; 0035 else 0036 return k3bcore->deviceManager()->burningDevices()[0]; 0037 } 0038 0039 0040 void K3b::AbstractWriter::cancel() 0041 { 0042 if( burnDevice() ) { 0043 // we need to unlock the writer because cdrecord locked it while writing 0044 emit infoMessage( i18n("Unlocking drive..."), MessageInfo ); 0045 connect( K3b::Device::unblock( burnDevice() ), SIGNAL(finished(bool)), 0046 this, SLOT(slotUnblockWhileCancellationFinished(bool)) ); 0047 } 0048 else { 0049 emit canceled(); 0050 jobFinished(false); 0051 } 0052 } 0053 0054 0055 void K3b::AbstractWriter::slotUnblockWhileCancellationFinished( bool success ) 0056 { 0057 if( !success ) 0058 emit infoMessage( i18n("Could not unlock drive."), K3b::Job::MessageError ); 0059 0060 if( k3bcore->globalSettings()->ejectMedia() ) { 0061 emit newSubTask( i18n("Ejecting Medium") ); 0062 connect( K3b::Device::eject( burnDevice() ), SIGNAL(finished(bool)), 0063 this, SLOT(slotEjectWhileCancellationFinished(bool)) ); 0064 } 0065 else { 0066 emit canceled(); 0067 jobFinished( false ); 0068 } 0069 } 0070 0071 0072 void K3b::AbstractWriter::slotEjectWhileCancellationFinished( bool success ) 0073 { 0074 if( !success ) { 0075 emit infoMessage( i18n("Unable to eject medium."), K3b::Job::MessageError ); 0076 } 0077 0078 emit canceled(); 0079 jobFinished( false ); 0080 } 0081 0082 #include "moc_k3babstractwriter.cpp"