void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { if( EchoMode ) { write( 1, Buf, len ); return; } char * LB = (char *)alloca( len + 1 ); memcpy( LB, Buf, len ); LB[len] = '\0'; // now input is zero terminated StdoutBuffer += LB; odebug << "Received " << len << " bytes on stdout" << oendl; // see if we have some lines (allow empty lines) QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE ); for( unsigned int i = 0; i < SL.count()-1; i ++ ) { Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) ); emit stdoutLine( SL[i] ); } // last line is rest StdoutBuffer = SL[ SL.count()-1 ]; }
void K3b::VcdJob::vcdxBuild() { emit newTask( i18n( "Creating image files" ) ); m_stage = stageUnknown; firstTrack = true; delete m_process; m_process = new K3b::Process(); m_process->setSplitStdout( true ); emit infoMessage( i18n( "Creating Cue/Bin files..." ), K3b::Job::MessageInfo ); const K3b::ExternalBin* bin = k3bcore ->externalBinManager() ->binObject( "vcdxbuild" ); if ( !bin ) { qDebug() << "(K3b::VcdJob) could not find vcdxbuild executable"; emit infoMessage( i18n( "Could not find %1 executable." , QString("vcdxbuild") ), K3b::Job::MessageError ); emit infoMessage( i18n( "To create Video CDs you have to install VcdImager version %1." ,QString( ">= 0.7.12") ), K3b::Job::MessageInfo ); emit infoMessage( i18n( "You can find this on your distribution disks or download it from http://www.vcdimager.org" ), K3b::Job::MessageInfo ); cancelAll(); jobFinished( false ); return ; } if ( bin->version() < K3b::Version( "0.7.12" ) ) { qDebug() << "(K3b::VcdJob) vcdxbuild executable too old!"; emit infoMessage( i18n( "%1 executable too old: need version %2 or greater." ,QString( "Vcdxbuild" ),QString( "0.7.12" )), K3b::Job::MessageError ); emit infoMessage( i18n( "You can find this on your distribution disks or download it from http://www.vcdimager.org" ), K3b::Job::MessageInfo ); cancelAll(); jobFinished( false ); return ; } if ( !bin->copyright().isEmpty() ) emit infoMessage( i18n( "Using %1 %2 – Copyright © %3" , bin->name() , bin->version() ,bin->copyright() ), MessageInfo ); *m_process << bin; // additional user parameters from config const QStringList& params = k3bcore->externalBinManager() ->program( "vcdxbuild" ) ->userParameters(); for ( QStringList::const_iterator it = params.begin(); it != params.end(); ++it ) *m_process << *it; if ( vcdDoc() ->vcdOptions() ->Sector2336() ) { qDebug() << "(K3b::VcdJob) Write 2336 Sectors = on"; *m_process << "--sector-2336"; } *m_process << "--progress" << "--gui"; *m_process << QString( "--cue-file=%1" ).arg( m_cueFile ); *m_process << QString( "--bin-file=%1" ).arg( m_doc->vcdImage() ); *m_process << d->xmlFile->fileName(); connect( m_process, SIGNAL(stdoutLine(QString)), this, SLOT(slotParseVcdxBuildOutput(QString)) ); connect( m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotVcdxBuildFinished(int,QProcess::ExitStatus)) ); // vcdxbuild commandline parameters qDebug() << "***** vcdxbuild parameters:"; QString s = m_process->joinedArgs(); qDebug() << s << flush; emit debuggingOutput( "vcdxbuild command:", s ); if ( !m_process->start( KProcess::MergedChannels ) ) { qDebug() << "(K3b::VcdJob) could not start vcdxbuild"; emit infoMessage( i18n( "Could not start %1." , QString("vcdxbuild") ), K3b::Job::MessageError ); cancelAll(); jobFinished( false ); } }
void K3b::IsoImager::startSizeCalculation() { d->mkisofsBin = initMkisofs(); if( !d->mkisofsBin ) { jobFinished( false ); return; } initVariables(); delete m_process; m_process = new K3b::Process( this ); m_process->setSplitStdout(true); emit debuggingOutput( QLatin1String( "Used versions" ), QString::fromLatin1( "mkisofs: %1").arg(d->mkisofsBin->version()) ); *m_process << d->mkisofsBin; if( !prepareMkisofsFiles() || !addMkisofsParameters(true) ) { cleanup(); jobFinished( false ); return; } // add empty dummy dir since one path-spec is needed // ??? Seems it is not needed after all. At least mkisofs 1.14 and above don't need it. ??? // *m_process << dummyDir(); qDebug() << "***** mkisofs calculate size parameters:"; QString s = m_process->joinedArgs(); qDebug() << s << endl << flush; emit debuggingOutput("mkisofs calculate size command:", s); // since output changed during mkisofs version changes we grab both // stdout and stderr // mkisofs version >= 1.15 (don't know about 1.14!) // the extends on stdout (as lonely number) // and error and warning messages on stderr // mkisofs >= 1.13 // everything is written to stderr // last line is: "Total extents scheduled to be written = XXXXX" connect( m_process, SIGNAL(stdoutLine(QString)), this, SLOT(slotCollectMkisofsPrintSizeStdout(QString)) ); connect( m_process, SIGNAL(stderrLine(QString)), this, SLOT(slotCollectMkisofsPrintSizeStderr(QString)) ); connect( m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotMkisofsPrintSizeFinished()) ); // we also want error messages connect( m_process, SIGNAL(stderrLine(QString)), this, SLOT(slotReceivedStderr(QString)) ); m_collectedMkisofsPrintSizeStdout = QString(); m_collectedMkisofsPrintSizeStderr = QString(); m_mkisofsPrintSizeResult = 0; if( !m_process->start( KProcess::SeparateChannels ) ) { emit infoMessage( i18n("Could not start %1.",QString("mkisofs")), K3b::Job::MessageError ); cleanup(); jobFinished( false ); return; } }