Esempio n. 1
0
void K3b::VerificationJob::slotDiskInfoReady( K3b::Device::DeviceHandler* dh )
{
    if( d->canceled ) {
        // signal already emitted in cancel()
        return;
    }

    if ( !dh->success() ) {
        blockingInformation( i18n("Please reload the medium and press 'OK'"),
                             i18n("Failed to reload the medium") );
    }

    d->diskInfo = dh->diskInfo();
    d->toc = dh->toc();
    d->totalSectors = 0;

    // just to be sure check if we actually have all the tracks
    for( TrackEntries::iterator it = d->trackEntries.begin(); it != d->trackEntries.end(); ++it ) {

        // 0 means "last track"
        if( it->trackNumber == 0 )
            it->trackNumber = d->toc.count();

        if( it->trackNumber <= 0 || it->trackNumber > d->toc.count() ) {
            if ( d->mediumHasBeenReloaded ) {
                emit infoMessage( i18n("Internal Error: Verification job improperly initialized (%1)",
                                       i18n("specified track number '%1' not found on medium", it->trackNumber) ), MessageError );
                jobFinished( false );
                return;
            }
            else {
                d->reloadMedium();
                return;
            }
        }

        d->totalSectors += d->trackLength( *it );
    }

    Q_ASSERT( d->currentTrackEntry != d->trackEntries.end() );

    if( d->currentTrackEntry->trackNumber >= d->toc.count() ) {
        readTrack();
    }
    else if( !d->mediumHasBeenReloaded ) {
        d->reloadMedium();
    }
    else {
        emit infoMessage( i18n("Internal Error: Verification job improperly initialized (%1)",
                               i18n("specified track number '%1' not found on medium", d->currentTrackEntry->trackNumber) ), MessageError );
        jobFinished( false );
    }
}
Esempio n. 2
0
void K3b::VcdJob::slotWriterJobFinished( bool success )
{
    if ( m_canceled )
        return ;

    if ( m_currentcopy >= m_doc->copies() ) {
        // remove bin-file if it is unfinished or the user selected to remove image
        if ( QFile::exists( m_doc->vcdImage() ) ) {
            if ( (!m_doc->onTheFly() && m_doc->removeImages()) || !m_imageFinished ) {
                emit infoMessage( i18n( "Removing Binary file %1" , m_doc->vcdImage() ), K3b::Job::MessageSuccess );
                QFile::remove
                    ( m_doc->vcdImage() );
                m_doc->setVcdImage( "" );
            }
        }

        // remove cue-file if it is unfinished or the user selected to remove image
        if ( QFile::exists( m_cueFile ) ) {
            if ( (!m_doc->onTheFly() && m_doc->removeImages()) || !m_imageFinished ) {
                emit infoMessage( i18n( "Removing Cue file %1" , m_cueFile ), K3b::Job::MessageSuccess );
                QFile::remove
                    ( m_cueFile );
                m_cueFile = "";
            }
        }
    }

    if ( success ) {
        // allright
        // the writerJob should have emitted the "simulation/writing successful" signal
        if ( m_currentcopy >= m_doc->copies() ) {
            if ( k3bcore->globalSettings()->ejectMedia() ) {
                K3b::Device::eject( m_doc->burner() );
            }
            jobFinished( true );
        } else {
            if( !K3b::eject( m_doc->burner() ) ) {
                blockingInformation( i18n("K3b was unable to eject the written disk. Please do so manually.") );
            }
            m_currentcopy++;
            startWriterjob();
        }
    } else {
        cancelAll();
        jobFinished( false );
    }
}