K3b::MovixJob::MovixJob( K3b::MovixDoc* doc, K3b::JobHandler* jh, QObject* parent ) : K3b::BurnJob( jh, parent ), m_doc(doc) { m_dataJob = new K3b::DataJob( doc, this, this ); m_movixDocPreparer = new K3b::MovixDocPreparer( doc, this, this ); // pipe signals connect( m_dataJob, SIGNAL(percent(int)), this, SIGNAL(percent(int)) ); connect( m_dataJob, SIGNAL(subPercent(int)), this, SIGNAL(subPercent(int)) ); connect( m_dataJob, SIGNAL(processedSubSize(int,int)), this, SIGNAL(processedSubSize(int,int)) ); connect( m_dataJob, SIGNAL(processedSize(int,int)), this, SIGNAL(processedSize(int,int)) ); connect( m_dataJob, SIGNAL(bufferStatus(int)), this, SIGNAL(bufferStatus(int)) ); connect( m_dataJob, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) ); connect( m_dataJob, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)), this, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)) ); connect( m_dataJob, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) ); connect( m_dataJob, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) ); connect( m_dataJob, SIGNAL(debuggingOutput(QString,QString)), this, SIGNAL(debuggingOutput(QString,QString)) ); connect( m_dataJob, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); connect( m_dataJob, SIGNAL(burning(bool)), this, SIGNAL(burning(bool)) ); // we need to clean up here connect( m_dataJob, SIGNAL(finished(bool)), this, SLOT(slotDataJobFinished(bool)) ); connect( m_movixDocPreparer, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); }
K3b::AudioCueFileWritingJob::AudioCueFileWritingJob( K3b::JobHandler* jh, QObject* parent ) : K3b::BurnJob( jh, parent ), d( new Private() ) { d->analyserJob = new K3b::AudioFileAnalyzerJob( this, this ); connect( d->analyserJob, SIGNAL(finished(bool)), this, SLOT(slotAnalyserJobFinished(bool)) ); d->audioDoc = new K3b::AudioDoc( this ); d->audioDoc->newDocument(); d->audioJob = new K3b::AudioJob( d->audioDoc, this, this ); // just loop all through connect( d->audioJob, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) ); connect( d->audioJob, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) ); connect( d->audioJob, SIGNAL(debuggingOutput(QString,QString)), this, SIGNAL(debuggingOutput(QString,QString)) ); connect( d->audioJob, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); connect( d->audioJob, SIGNAL(finished(bool)), this, SIGNAL(finished(bool)) ); connect( d->audioJob, SIGNAL(canceled()), this, SIGNAL(canceled()) ); connect( d->audioJob, SIGNAL(percent(int)), this, SIGNAL(percent(int)) ); connect( d->audioJob, SIGNAL(subPercent(int)), this, SIGNAL(subPercent(int)) ); connect( d->audioJob, SIGNAL(processedSize(int,int)), this, SIGNAL(processedSubSize(int,int)) ); connect( d->audioJob, SIGNAL(processedSubSize(int,int)), this, SIGNAL(processedSubSize(int,int)) ); connect( d->audioJob, SIGNAL(burning(bool)), this, SIGNAL(burning(bool)) ); connect( d->audioJob, SIGNAL(bufferStatus(int)), this, SIGNAL(bufferStatus(int)) ); connect( d->audioJob, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) ); connect( d->audioJob, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)), this, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)) ); d->canceled = false; d->audioJobRunning = false; }
void AudioProjectConvertingJob::trackStarted( int trackIndex ) { if( !cddbEntry().track( trackIndex-1 ).get( KCDDB::Artist ).toString().isEmpty() && !cddbEntry().track( trackIndex-1 ).get( KCDDB::Title ).toString().isEmpty() ) emit newSubTask( i18n( "Converting track %1 (%2 - %3)", trackIndex, cddbEntry().track( trackIndex-1 ).get( KCDDB::Artist ).toString(), cddbEntry().track( trackIndex-1 ).get( KCDDB::Title ).toString() ) ); else emit newSubTask( i18n("Converting track %1", trackIndex) ); }
bool K3b::VcdJob::prepareWriterJob() { if ( m_writerJob ) delete m_writerJob; const K3b::ExternalBin* cdrecordBin = k3bcore->externalBinManager() ->binObject( "cdrecord" ); if ( writingApp() == K3b::WritingAppAuto && cdrecordBin->hasFeature( "cuefile" ) && m_doc->burner() ->dao() ) setWritingApp( K3b::WritingAppCdrecord ); if ( writingApp() == K3b::WritingAppCdrdao || writingApp() == K3b::WritingAppAuto ) { K3b::CdrdaoWriter * writer = new K3b::CdrdaoWriter( m_doc->burner(), this, this ); // create cdrdao job writer->setCommand( K3b::CdrdaoWriter::WRITE ); writer->setSimulate( m_doc->dummy() ); writer->setBurnSpeed( m_doc->speed() ); writer->setTocFile( m_cueFile ); m_writerJob = writer; } else if ( writingApp() == K3b::WritingAppCdrecord ) { K3b::CdrecordWriter * writer = new K3b::CdrecordWriter( m_doc->burner(), this, this ); // create cdrecord job writer->setSimulate( m_doc->dummy() ); writer->setBurnSpeed( m_doc->speed() ); writer->setDao( true ); writer->setCueFile( m_cueFile ); m_writerJob = writer; } connect( m_writerJob, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); connect( m_writerJob, SIGNAL(percent(int)), this, SLOT(slotWriterJobPercent(int)) ); connect( m_writerJob, SIGNAL(processedSize(int,int)), this, SLOT(slotProcessedSize(int,int)) ); connect( m_writerJob, SIGNAL(subPercent(int)), this, SIGNAL(subPercent(int)) ); connect( m_writerJob, SIGNAL(processedSubSize(int,int)), this, SIGNAL(processedSubSize(int,int)) ); connect( m_writerJob, SIGNAL(nextTrack(int,int)), this, SLOT(slotWriterNextTrack(int,int)) ); connect( m_writerJob, SIGNAL(buffer(int)), this, SIGNAL(bufferStatus(int)) ); connect( m_writerJob, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) ); connect( m_writerJob, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)), this, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)) ); connect( m_writerJob, SIGNAL(finished(bool)), this, SLOT(slotWriterJobFinished(bool)) ); connect( m_writerJob, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) ); connect( m_writerJob, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) ); connect( m_writerJob, SIGNAL(debuggingOutput(QString,QString)), this, SIGNAL(debuggingOutput(QString,QString)) ); return true; }
void K3bMixedJob::startFirstCopy() { // // if not onthefly create the iso image and then the wavs // and write then // if onthefly calculate the iso size // if( m_doc->onTheFly() ) { if( m_doc->speed() == 0 ) { emit newSubTask( i18n("Determining maximum writing speed") ); // // try to determine the max possible speed // no need to check the data track's max speed. Most current systems are able // to handle the maxium possible // if( !d->maxSpeedJob ) { // the maxspeed job gets the device from the doc: m_doc->audioDoc()->setBurner( m_doc->burner() ); d->maxSpeedJob = new K3bAudioMaxSpeedJob( m_doc->audioDoc(), this, this ); connect( d->maxSpeedJob, SIGNAL(percent(int)), this, SIGNAL(subPercent(int)) ); connect( d->maxSpeedJob, SIGNAL(finished(bool)), this, SLOT(slotMaxSpeedJobFinished(bool)) ); } d->maxSpeedJob->start(); }
void K3b::VerificationJob::readTrack() { if( d->currentTrackEntry == d->trackEntries.end() ) { jobFinished(true); return; } d->readSuccessful = true; d->currentTrackSize = d->trackLength( *d->currentTrackEntry ); if( d->currentTrackSize == 0 ) { jobFinished(false); return; } emit newTask( i18n("Verifying track %1", d->currentTrackEntry->trackNumber ) ); K3b::Device::Track& track = d->toc[ d->currentTrackEntry->trackNumber-1 ]; d->pipe.open(); if( track.type() == K3b::Device::Track::TYPE_DATA ) { if( !d->dataTrackReader ) { d->dataTrackReader = new K3b::DataTrackReader( this ); connect( d->dataTrackReader, SIGNAL(percent(int)), this, SLOT(slotReaderProgress(int)) ); connect( d->dataTrackReader, SIGNAL(finished(bool)), this, SLOT(slotReaderFinished(bool)) ); connect( d->dataTrackReader, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); connect( d->dataTrackReader, SIGNAL(newTask(QString)), this, SIGNAL(newSubTask(QString)) ); connect( d->dataTrackReader, SIGNAL(debuggingOutput(QString,QString)), this, SIGNAL(debuggingOutput(QString,QString)) ); } d->dataTrackReader->setDevice( d->device ); d->dataTrackReader->setIgnoreErrors( false ); d->dataTrackReader->setSectorSize( K3b::DataTrackReader::MODE1 ); d->dataTrackReader->writeTo( &d->pipe ); // in case a session was grown the track size does not say anything about the verification data size if( d->diskInfo.mediaType() & (K3b::Device::MEDIA_DVD_PLUS_RW|K3b::Device::MEDIA_DVD_RW_OVWR) && d->grownSessionSize > 0 ) { K3b::Iso9660 isoF( d->device ); if( isoF.open() ) { int firstSector = isoF.primaryDescriptor().volumeSpaceSize - d->grownSessionSize.lba(); d->dataTrackReader->setSectorRange( firstSector, isoF.primaryDescriptor().volumeSpaceSize -1 ); } else { emit infoMessage( i18n("Unable to determine the ISO 9660 filesystem size."), MessageError ); jobFinished( false ); return; } } else d->dataTrackReader->setSectorRange( track.firstSector(), track.firstSector() + d->currentTrackSize -1 ); d->pipe.open(); d->dataTrackReader->start(); }
void K3bThreadJob::customEvent( QCustomEvent* e ) { if( K3bDataEvent* de = dynamic_cast<K3bDataEvent*>(e) ) { emit data( de->data(), de->length() ); } else { K3bProgressInfoEvent* be = static_cast<K3bProgressInfoEvent*>(e); switch( be->type() ) { case K3bProgressInfoEvent::Progress: emit percent( be->firstValue() ); break; case K3bProgressInfoEvent::SubProgress: emit subPercent( be->firstValue() ); break; case K3bProgressInfoEvent::ProcessedSize: emit processedSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::ProcessedSubSize: emit processedSubSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::InfoMessage: emit infoMessage( be->firstString(), be->firstValue() ); break; case K3bProgressInfoEvent::Started: jobStarted(); break; case K3bProgressInfoEvent::Canceled: emit canceled(); break; case K3bProgressInfoEvent::Finished: // we wait until the thred really finished // although this may be dangerous if some thread // emits the finished signal although it has not finished yet // but makes a lot stuff easier. kdDebug() << "(K3bThreadJob) waiting for the thread to finish." << endl; m_thread->wait(); kdDebug() << "(K3bThreadJob) thread finished." << endl; cleanupJob( be->firstValue() ); m_running = false; jobFinished( be->firstValue() ); break; case K3bProgressInfoEvent::NewTask: emit newTask( be->firstString() ); break; case K3bProgressInfoEvent::NewSubTask: emit newSubTask( be->firstString() ); break; case K3bProgressInfoEvent::DebuggingOutput: emit debuggingOutput( be->firstString(), be->secondString() ); break; case K3bProgressInfoEvent::NextTrack: emit nextTrack( be->firstValue(), be->secondValue() ); break; } } }
JobInterface::JobInterface( Job* job ) : QObject( job ), m_job( job ), m_lastProgress( 0 ), m_lastSubProgress( 0 ) { if( m_job ) { connect( m_job, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) ); connect( m_job, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) ); connect( m_job, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); connect( m_job, SIGNAL(finished(bool)), this, SIGNAL(finished(bool)) ); connect( m_job, SIGNAL(started()), this, SIGNAL(started()) ); connect( m_job, SIGNAL(canceled()), this, SIGNAL(canceled()) ); connect( m_job, SIGNAL(percent(int)), this, SLOT(slotProgress(int)) ); connect( m_job, SIGNAL(subPercent(int)), this, SLOT(slotSubProgress(int)) ); connect( m_job, SIGNAL(nextTrack(int,int)), this, SIGNAL(nextTrack(int,int)) ); if( m_job->inherits( "K3b::BurnJob" ) ) { connect( m_job, SIGNAL(bufferStatus(int)), this, SIGNAL(buffer(int)) ); connect( m_job, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) ); } }
void K3b::AudioCueFileWritingJob::importCueInProject() { // cleanup the project (this wil also delete the decoder) // we do not use newDocument as that would overwrite the settings already made while( d->audioDoc->firstTrack() ) delete d->audioDoc->firstTrack()->take(); d->decoder = 0; K3b::CueFileParser parser( d->cueFile ); if( parser.isValid() && parser.toc().contentType() == K3b::Device::AUDIO ) { kDebug() << "(K3b::AudioCueFileWritingJob::importCueFile) parsed with image: " << parser.imageFilename(); // global cd-text d->audioDoc->setTitle( parser.cdText().title() ); d->audioDoc->setPerformer( parser.cdText().performer() ); d->audioDoc->writeCdText( !parser.cdText().title().isEmpty() ); d->decoder = K3b::AudioDecoderFactory::createDecoder( parser.imageFilename() ); if( d->decoder ) { d->decoder->setFilename( parser.imageFilename() ); K3b::AudioTrack* after = 0; K3b::AudioFile* newFile = 0; unsigned int i = 0; for( K3b::Device::Toc::const_iterator it = parser.toc().constBegin(); it != parser.toc().constEnd(); ++it ) { const K3b::Device::Track& track = *it; newFile = new K3b::AudioFile( d->decoder, d->audioDoc ); newFile->setStartOffset( track.firstSector() ); newFile->setEndOffset( track.lastSector()+1 ); K3b::AudioTrack* newTrack = new K3b::AudioTrack( d->audioDoc ); newTrack->addSource( newFile ); newTrack->moveAfter( after ); // cd-text newTrack->setTitle( parser.cdText()[i].title() ); newTrack->setPerformer( parser.cdText()[i].performer() ); // add the next track after this one after = newTrack; ++i; } // let the last source use the data up to the end of the file if( newFile ) newFile->setEndOffset(0); // now analyze the source emit newTask( i18n("Analysing the audio file") ); emit newSubTask( i18n("Analysing %1", parser.imageFilename() ) ); // start the analyser job d->analyserJob->setDecoder( d->decoder ); d->analyserJob->start(); } else { emit infoMessage( i18n("Unable to handle '%1' due to an unsupported format.", d->cueFile ), MessageError ); jobFinished(false); } } else { emit infoMessage( i18n("No valid audio cue file: '%1'", d->cueFile ), MessageError ); jobFinished(false); } }
void K3bDvdFormattingJob::startFormatting( const K3bDevice::DiskInfo& diskInfo ) { // // Now check the media type: // if DVD-RW: use d->mode // emit warning if formatting is full and stuff // // in overwrite mode: emit info that progress might stop before 100% since formatting will continue // in the background once the media gets rewritten (only DVD+RW?) // // emit info about what kind of media has been found if( !(diskInfo.mediaType() & (K3bDevice::MEDIA_DVD_RW| K3bDevice::MEDIA_DVD_RW_SEQ| K3bDevice::MEDIA_DVD_RW_OVWR| K3bDevice::MEDIA_DVD_PLUS_RW)) ) { emit infoMessage( i18n("No rewritable DVD media found. Unable to format."), ERROR ); d->running = false; jobFinished(false); return; } bool format = true; // do we need to format bool blank = false; // blank is for DVD-RW sequential incremental // DVD-RW restricted overwrite and DVD+RW uses the force option (or no option at all) // // DVD+RW is quite easy to handle. There is only one possible mode and it is always recommended to not // format it more than once but to overwrite it once it is formatted // Once the initial formatting has been done it's always "appendable" (or "complete"???) // if( diskInfo.mediaType() == K3bDevice::MEDIA_DVD_PLUS_RW ) { emit infoMessage( i18n("Found %1 media.").arg(K3bDevice::mediaTypeString(K3bDevice::MEDIA_DVD_PLUS_RW)), INFO ); // mode is ignored if( diskInfo.empty() ) { // // The DVD+RW is blank and needs to be initially formatted // blank = false; } else { emit infoMessage( i18n("No need to format %1 media more than once.") .arg(K3bDevice::mediaTypeString(K3bDevice::MEDIA_DVD_PLUS_RW)), INFO ); emit infoMessage( i18n("It may simply be overwritten."), INFO ); if( d->force ) { emit infoMessage( i18n("Forcing formatting anyway."), INFO ); emit infoMessage( i18n("It is not recommended to force formatting of DVD+RW media."), INFO ); emit infoMessage( i18n("Already after 10-20 reformats the media might be unusable."), INFO ); blank = false; } else { format = false; } } if( format ) emit newSubTask( i18n("Formatting DVD+RW") ); } // // DVD-RW has two modes: incremental sequential (the default which is also needed for DAO writing) // and restricted overwrite which compares to the DVD+RW mode. // else { // MEDIA_DVD_RW emit infoMessage( i18n("Found %1 media.").arg(K3bDevice::mediaTypeString(K3bDevice::MEDIA_DVD_RW)), INFO ); if( diskInfo.currentProfile() != K3bDevice::MEDIA_UNKNOWN ) { emit infoMessage( i18n("Formatted in %1 mode.").arg(K3bDevice::mediaTypeString(diskInfo.currentProfile())), INFO ); // // Is it possible to have an empty DVD-RW in restricted overwrite mode???? I don't think so. // if( diskInfo.empty() && (d->mode == K3b::WRITING_MODE_AUTO || (d->mode == K3b::WRITING_MODE_INCR_SEQ && diskInfo.currentProfile() == K3bDevice::MEDIA_DVD_RW_SEQ) || (d->mode == K3b::WRITING_MODE_RES_OVWR && diskInfo.currentProfile() == K3bDevice::MEDIA_DVD_RW_OVWR) ) ) { emit infoMessage( i18n("Media is already empty."), INFO ); if( d->force ) emit infoMessage( i18n("Forcing formatting anyway."), INFO ); else format = false; } else if( diskInfo.currentProfile() == K3bDevice::MEDIA_DVD_RW_OVWR && d->mode != K3b::WRITING_MODE_INCR_SEQ ) { emit infoMessage( i18n("No need to format %1 media more than once.") .arg(K3bDevice::mediaTypeString(diskInfo.currentProfile())), INFO ); emit infoMessage( i18n("It may simply be overwritten."), INFO ); if( d->force ) emit infoMessage( i18n("Forcing formatting anyway."), INFO ); else format = false; } if( format ) { if( d->mode == K3b::WRITING_MODE_AUTO ) { // just format in the same mode as the media is currently formatted blank = (diskInfo.currentProfile() == K3bDevice::MEDIA_DVD_RW_SEQ); } else { blank = (d->mode == K3b::WRITING_MODE_INCR_SEQ); } emit newSubTask( i18n("Formatting" " DVD-RW in %1 mode.").arg(K3bDevice::mediaTypeString( blank ? K3bDevice::MEDIA_DVD_RW_SEQ : K3bDevice::MEDIA_DVD_RW_OVWR )) ); } } else { emit infoMessage( i18n("Unable to determine the current formatting state of the DVD-RW media."), ERROR ); d->running = false; jobFinished(false); return; } } if( format ) { delete d->process; d->process = new K3bProcess(); d->process->setRunPrivileged(true); // d->process->setSuppressEmptyLines(false); connect( d->process, SIGNAL(stderrLine(const QString&)), this, SLOT(slotStderrLine(const QString&)) ); connect( d->process, SIGNAL(processExited(KProcess*)), this, SLOT(slotProcessFinished(KProcess*)) ); d->dvdFormatBin = k3bcore->externalBinManager()->binObject( "dvd+rw-format" ); if( !d->dvdFormatBin ) { emit infoMessage( i18n("Could not find %1 executable.").arg("dvd+rw-format"), ERROR ); d->running = false; jobFinished(false); return; } if( !d->dvdFormatBin->copyright.isEmpty() ) emit infoMessage( i18n("Using %1 %2 - Copyright (C) %3").arg(d->dvdFormatBin->name()).arg(d->dvdFormatBin->version).arg(d->dvdFormatBin->copyright), INFO ); *d->process << d->dvdFormatBin; if( d->dvdFormatBin->version >= K3bVersion( 4, 6 ) ) *d->process << "-gui"; QString p; if( blank ) p = "-blank"; else p = "-force"; if( !d->quick ) p += "=full"; *d->process << p; *d->process << d->device->blockDeviceName(); // additional user parameters from config const QStringList& params = d->dvdFormatBin->userParameters(); for( QStringList::const_iterator it = params.begin(); it != params.end(); ++it ) *d->process << *it; kdDebug() << "***** dvd+rw-format parameters:\n"; const QValueList<QCString>& args = d->process->args(); QString s; for( QValueList<QCString>::const_iterator it = args.begin(); it != args.end(); ++it ) { s += *it + " "; } kdDebug() << s << endl << flush; emit debuggingOutput( "dvd+rw-format command:", s ); if( !d->process->start( KProcess::NotifyOnExit, KProcess::All ) ) { // something went wrong when starting the program // it "should" be the executable kdDebug() << "(K3bDvdFormattingJob) could not start " << d->dvdFormatBin->path << endl; emit infoMessage( i18n("Could not start %1.").arg(d->dvdFormatBin->name()), K3bJob::ERROR ); d->running = false; jobFinished(false); } else { emit newTask( i18n("Formatting") ); } } else {
void K3b::VcdJob::slotWriterNextTrack( int t, int tt ) { emit newSubTask( i18n( "Writing Track %1 of %2" , t , tt ) ); }
void K3b::VcdJob::slotParseVcdxBuildOutput( const QString& line ) { QDomDocument xml_doc; QDomElement xml_root; QString str = line.trimmed(); emit debuggingOutput( "vcdxbuild", str ); xml_doc.setContent( QString( "<?xml version='1.0'?><vcdxbuild>" ) + str + "</vcdxbuild>" ); xml_root = xml_doc.documentElement(); // There should be only one... but ... for ( QDomNode node = xml_root.firstChild(); !node.isNull(); node = node.nextSibling() ) { QDomElement el = node.toElement(); if ( el.isNull() ) continue; const QString tagName = el.tagName().toLower(); if ( tagName == "progress" ) { const QString oper = el.attribute( "operation" ).toLower(); const unsigned long long pos = el.attribute( "position" ).toLong(); const long long size = el.attribute( "size" ).toLong(); if ( oper == "scan" ) { // Scan Video Files if ( m_stage == stageUnknown || pos < m_bytesFinished ) { const uint index = el.attribute( "id" ).remove( QRegExp( "sequence-" ) ).toUInt(); m_currentWrittenTrack = m_doc->at( m_currentWrittenTrackNumber ); emit newSubTask( i18n( "Scanning video file %1 of %2 (%3)" , index + 1 , doc() ->numOfTracks() , m_currentWrittenTrack->fileName() ) ); m_bytesFinished = 0; if ( !firstTrack ) { m_bytesFinishedTracks += m_doc->at( m_currentWrittenTrackNumber ) ->size(); m_currentWrittenTrackNumber++; } else firstTrack = false; } emit subPercent( ( int ) ( 100.0 * ( double ) pos / ( double ) size ) ); emit processedSubSize( pos / 1024 / 1024, size / 1024 / 1024 ); // this is the first of three processes. double relOverallWritten = ( ( double ) m_bytesFinishedTracks + ( double ) pos ) / ( double ) doc() ->size(); emit percent( ( int ) ( m_createimageonlypercent * relOverallWritten ) ); m_bytesFinished = pos; m_stage = stageScan; } else if ( oper == "write" ) { emit subPercent( ( int ) ( 100.0 * ( double ) pos / ( double ) size ) ); emit processedSubSize( ( pos * 2048 ) / 1024 / 1024, ( size * 2048 ) / 1024 / 1024 ); emit percent( ( int ) ( m_createimageonlypercent + ( m_createimageonlypercent * ( double ) pos / ( double ) size ) ) ); m_stage = stageWrite; } else { return ; } } else if ( tagName == "log" ) { QDomText tel = el.firstChild().toText(); const QString level = el.attribute( "level" ).toLower(); if ( tel.isText() ) { const QString text = tel.data(); if ( m_stage == stageWrite && level == "information" ) qDebug() << QString( "(K3b::VcdJob) VcdxBuild information, %1" ).arg( text ); if ( ( text ).startsWith( "writing track" ) ) emit newSubTask( i18n( "Creating Image for track %1" , ( text ).mid( 14 ) ) ); else { if ( level != "error" ) { qDebug() << QString( "(K3b::VcdJob) vcdxbuild warning, %1" ).arg( text ); parseInformation( text ); } else { qDebug() << QString( "(K3b::VcdJob) vcdxbuild error, %1" ).arg( text ); emit infoMessage( text, K3b::Job::MessageError ); } } } } } }
void K3b::DvdFormattingJob::startFormatting( const Device::DiskInfo& diskInfo ) { // // Now check the media type: // if DVD-RW: use d->mode // emit warning if formatting is full and stuff // // in overwrite mode: emit info that progress might stop before 100% since formatting will continue // in the background once the media gets rewritten (only DVD+RW/BD-RE?) // // emit info about what kind of media has been found if( diskInfo.mediaType() & (Device::MEDIA_REWRITABLE_DVD | Device::MEDIA_BD_RE) ) { emit infoMessage( i18n("Found %1 medium.", Device::mediaTypeString(diskInfo.mediaType())), MessageInfo ); } else { emit infoMessage( i18n("No rewritable DVD or BD medium found. Unable to format."), MessageError ); d->running = false; jobFinished(false); return; } bool format = true; // do we need to format bool blank = false; // blank is for DVD-RW sequential incremental // DVD-RW restricted overwrite and DVD+RW uses the force option (or no option at all) // // DVD+RW/BD-RE is quite easy to handle. There is only one possible mode and it is always recommended to not // format it more than once but to overwrite it once it is formatted // Once the initial formatting has been done it's always "appendable" (or "complete"???) // if( diskInfo.mediaType() & (Device::MEDIA_DVD_PLUS_ALL | Device::MEDIA_BD_RE) ) { if( diskInfo.empty() ) { // // The DVD+RW/BD is blank and needs to be initially formatted // blank = false; } else { emit infoMessage( i18n("No need to format %1 media more than once.", Device::mediaTypeString(diskInfo.mediaType())), MessageInfo ); emit infoMessage( i18n("It may simply be overwritten."), MessageInfo ); if( d->force ) { emit infoMessage( i18n("Forcing formatting anyway."), MessageInfo ); emit infoMessage( i18n("It is not recommended to force formatting of %1 media.", Device::mediaTypeString(diskInfo.mediaType())), MessageInfo ); emit infoMessage( i18n("After 10-20 reformats the media might become unusable."), MessageInfo ); blank = false; } else { format = false; } } if( format ) emit newSubTask( i18n("Formatting %1 medium", Device::mediaTypeString(diskInfo.mediaType())) ); } // // DVD-RW has two modes: incremental sequential (the default which is also needed for DAO writing) // and restricted overwrite which compares to the DVD+RW mode. // else { // MEDIA_DVD_RW if( diskInfo.currentProfile() != Device::MEDIA_UNKNOWN ) { emit infoMessage( i18n("Formatted in %1 mode.",Device::mediaTypeString(diskInfo.currentProfile())), MessageInfo ); // // Is it possible to have an empty DVD-RW in restricted overwrite mode???? I don't think so. // if( diskInfo.empty() && (d->mode == WritingModeAuto || (d->mode == WritingModeIncrementalSequential && diskInfo.currentProfile() == Device::MEDIA_DVD_RW_SEQ) || (d->mode == WritingModeRestrictedOverwrite && diskInfo.currentProfile() == Device::MEDIA_DVD_RW_OVWR) ) ) { emit infoMessage( i18n("Media is already empty."), MessageInfo ); if( d->force ) emit infoMessage( i18n("Forcing formatting anyway."), MessageInfo ); else format = false; } else if( diskInfo.currentProfile() == Device::MEDIA_DVD_RW_OVWR && d->mode != WritingModeIncrementalSequential ) { emit infoMessage( i18n("No need to format %1 media more than once.", Device::mediaTypeString(diskInfo.currentProfile())), MessageInfo ); emit infoMessage( i18n("It may simply be overwritten."), MessageInfo ); if( d->force ) emit infoMessage( i18n("Forcing formatting anyway."), MessageInfo ); else format = false; } if( format ) { if( d->mode == WritingModeAuto ) { // just format in the same mode as the media is currently formatted blank = (diskInfo.currentProfile() == Device::MEDIA_DVD_RW_SEQ); } else { blank = (d->mode == WritingModeIncrementalSequential); } emit newSubTask( i18n("Formatting" " DVD-RW in %1 mode.",Device::mediaTypeString( blank ? Device::MEDIA_DVD_RW_SEQ : Device::MEDIA_DVD_RW_OVWR )) ); } } else { emit infoMessage( i18n("Unable to determine the current formatting state of the DVD-RW medium."), MessageError ); d->running = false; jobFinished(false); return; } } if( format ) { delete d->process; d->process = new Process(); connect( d->process, SIGNAL(stderrLine(QString)), this, SLOT(slotStderrLine(QString)) ); connect( d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)) ); d->dvdFormatBin = k3bcore->externalBinManager()->binObject( "dvd+rw-format" ); if( !d->dvdFormatBin ) { emit infoMessage( i18n("Could not find %1 executable.",QString("dvd+rw-format")), MessageError ); d->running = false; jobFinished(false); return; } if( !d->dvdFormatBin->copyright().isEmpty() ) emit infoMessage( i18n("Using %1 %2 – Copyright © %3",d->dvdFormatBin->name(),d->dvdFormatBin->version(),d->dvdFormatBin->copyright()), MessageInfo ); *d->process << d->dvdFormatBin; if( d->dvdFormatBin->version() >= Version( 4, 6 ) ) *d->process << "-gui"; QString p; if( blank ) p = "-blank"; else p = "-force"; if( d->formattingMode == FormattingComplete ) p += "=full"; *d->process << p; *d->process << d->device->blockDeviceName(); // additional user parameters from config const QStringList& params = d->dvdFormatBin->userParameters(); for( QStringList::const_iterator it = params.begin(); it != params.end(); ++it ) *d->process << *it; qDebug() << "***** dvd+rw-format parameters:\n"; QString s = d->process->joinedArgs(); qDebug() << s << endl << flush; emit debuggingOutput( "dvd+rw-format command:", s ); if( !d->process->start( KProcess::OnlyStderrChannel ) ) { // something went wrong when starting the program // it "should" be the executable qDebug() << "(K3b::DvdFormattingJob) could not start " << d->dvdFormatBin->path(); emit infoMessage( i18n("Could not start %1.",d->dvdFormatBin->name()), Job::MessageError ); d->running = false; jobFinished(false); } else { emit newTask( i18n("Formatting") ); } } else {
void K3bGrowisofsWriter::start() { jobStarted(); d->lastWritingSpeed = 0; d->lastProgressed = 0; d->lastProgress = 0; d->firstSizeFromOutput = -1; d->lastSpeedCalculationTime = QTime::currentTime(); d->lastSpeedCalculationBytes = 0; d->writingStarted = false; d->canceled = false; d->speedEst->reset(); d->finished = false; if( !prepareProcess() ) { jobFinished( false ); } else { kdDebug() << "***** " << d->growisofsBin->name() << " parameters:\n"; const QValueList<QCString>& args = d->process->args(); QString s; for( QValueList<QCString>::const_iterator it = args.begin(); it != args.end(); ++it ) { s += *it + " "; } kdDebug() << s << flush << endl; emit debuggingOutput( d->growisofsBin->name() + " command:", s); emit newSubTask( i18n("Preparing write process...") ); // FIXME: check the return value if( K3b::isMounted( burnDevice() ) ) { emit infoMessage( i18n("Unmounting medium"), INFO ); K3b::unmount( burnDevice() ); } // block the device (including certain checks) k3bcore->blockDevice( burnDevice() ); // lock the device for good in this process since it will // be opened in the growisofs process burnDevice()->close(); burnDevice()->usageLock(); if( !d->process->start( KProcess::NotifyOnExit, KProcess::All ) ) { // something went wrong when starting the program // it "should" be the executable kdDebug() << "(K3bGrowisofsWriter) could not start " << d->growisofsBin->path << endl; emit infoMessage( i18n("Could not start %1.").arg(d->growisofsBin->name()), K3bJob::ERROR ); jobFinished(false); } else { if( simulate() ) { emit newTask( i18n("Simulating") ); emit infoMessage( i18n("Starting simulation..."), K3bJob::INFO ); } else { emit newTask( i18n("Writing") ); emit infoMessage( i18n("Starting disc write..."), K3bJob::INFO ); } d->gh->handleStart(); // create the ring buffer if( d->usingRingBuffer ) { if( !d->ringBuffer ) { d->ringBuffer = new K3bPipeBuffer( this, this ); connect( d->ringBuffer, SIGNAL(percent(int)), this, SIGNAL(buffer(int)) ); connect( d->ringBuffer, SIGNAL(finished(bool)), this, SLOT(slotRingBufferFinished(bool)) ); } d->ringBuffer->writeToFd( d->process->stdinFd() ); bool manualBufferSize = k3bcore->globalSettings()->useManualBufferSize(); int bufSize = ( manualBufferSize ? k3bcore->globalSettings()->bufferSize() : 20 ); d->ringBuffer->setBufferSize( bufSize ); if( !d->image.isEmpty() ) d->ringBuffer->readFromFd( d->inputFile.handle() ); d->ringBuffer->start(); } } }