Пример #1
0
void K3b::IsoImager::start()
{
    jobStarted();

    cleanup();

    d->mkisofsBin = initMkisofs();
    if( !d->mkisofsBin ) {
        jobFinished( false );
        return;
    }

    initVariables();

    delete m_process;
    m_process = new K3b::Process( this );
    m_process->setFlags( K3bQProcess::RawStdout );

    *m_process << d->mkisofsBin;

    // prepare the filenames as written to the image
    m_doc->prepareFilenames();

    if( !prepareMkisofsFiles() ||
        !addMkisofsParameters() ) {
        cleanup();
        jobFinished( false );
        return;
    }

    connect( m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
             this, SLOT(slotProcessExited(int,QProcess::ExitStatus)) );
    connect( m_process, SIGNAL(stderrLine(QString)),
             this, SLOT(slotReceivedStderr(QString)) );

    qDebug() << "***** mkisofs parameters:\n";
    QString s = m_process->joinedArgs();
    qDebug() << s << endl << flush;
    emit debuggingOutput("mkisofs command:", s);

    if( !m_process->start( KProcess::SeparateChannels ) ) {
        // something went wrong when starting the program
        // it "should" be the executable
        qDebug() << "(K3b::IsoImager) could not start mkisofs";
        emit infoMessage( i18n("Could not start %1.", QLatin1String("mkisofs")), K3b::Job::MessageError );
        jobFinished( false );
        cleanup();
    }
}
Пример #2
0
void K3bIsoImager::start()
{
  jobStarted();

  cleanup();

  d->mkisofsBin = initMkisofs();
  if( !d->mkisofsBin ) {
    jobFinished( false );
    return;
  }

  initVariables();

  m_process = new K3bProcess();
  m_process->setRunPrivileged(true);

  *m_process << d->mkisofsBin;

  // prepare the filenames as written to the image
  m_doc->prepareFilenames();

  if( !prepareMkisofsFiles() ||
      !addMkisofsParameters() ) {
    cleanup();
    jobFinished( false );
    return;
  }

  connect( m_process, SIGNAL(processExited(KProcess*)),
	   this, SLOT(slotProcessExited(KProcess*)) );

  connect( m_process, SIGNAL(stderrLine( const QString& )),
	   this, SLOT(slotReceivedStderr( const QString& )) );

  //
  // Check the image file
  if( m_fdToWriteTo == -1 ) {
    d->imageFile.setName( d->imagePath );
    if( !d->imageFile.open( IO_WriteOnly ) ) {
      emit infoMessage( i18n("Could not open %1 for writing").arg(d->imagePath), ERROR );
      cleanup();
      jobFinished(false);
      return;
    }
  }

  //
  // Open the active pipe which does the streaming
  delete d->pipe;
  if( m_doc->verifyData() )
    d->pipe = new K3bChecksumPipe();
  else
    d->pipe = new K3bActivePipe();

  if( m_fdToWriteTo == -1 )
    d->pipe->writeToIODevice( &d->imageFile );
  else
    d->pipe->writeToFd( m_fdToWriteTo );
  d->pipe->open();
  m_process->writeToFd( d->pipe->in() );


  kdDebug() << "***** mkisofs parameters:\n";
  const QValueList<QCString>& args = m_process->args();
  QString s;
  for( QValueList<QCString>::const_iterator it = args.begin(); it != args.end(); ++it ) {
    s += *it + " ";
  }
  kdDebug() << s << endl << flush;
  emit debuggingOutput("mkisofs command:", s);

  if( !m_process->start( KProcess::NotifyOnExit, KProcess::AllOutput) ) {
    // something went wrong when starting the program
    // it "should" be the executable
    kdDebug() << "(K3bIsoImager) could not start mkisofs" << endl;
    emit infoMessage( i18n("Could not start %1.").arg("mkisofs"), K3bJob::ERROR );
    jobFinished( false );
    cleanup();
  }
}
Пример #3
0
void K3bIsoImager::startSizeCalculation()
{
  d->mkisofsBin = initMkisofs();
  if( !d->mkisofsBin ) {
    jobFinished( false );
    return;
  }

  initVariables();

  delete m_process;
  m_process = new K3bProcess();
  m_process->setRunPrivileged(true);
  m_process->setSplitStdout(true);

  emit debuggingOutput( "Used versions", "mkisofs: " + 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();

  kdDebug() << "***** mkisofs calculate size parameters:\n";
  const QValueList<QCString>& args = m_process->args();
  QString s;
  for( QValueList<QCString>::const_iterator it = args.begin(); it != args.end(); ++it ) {
    s += *it + " ";
  }
  kdDebug() << 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"

  // TODO: use K3bProcess::OutputCollector instead iof our own two slots.

  connect( m_process, SIGNAL(receivedStderr(KProcess*, char*, int)),
	   this, SLOT(slotCollectMkisofsPrintSizeStderr(KProcess*, char*, int)) );
  connect( m_process, SIGNAL(stdoutLine(const QString&)),
	   this, SLOT(slotCollectMkisofsPrintSizeStdout(const QString&)) );
  connect( m_process, SIGNAL(processExited(KProcess*)),
	   this, SLOT(slotMkisofsPrintSizeFinished()) );

  // we also want error messages
  connect( m_process, SIGNAL(stderrLine( const QString& )),
	   this, SLOT(slotReceivedStderr( const QString& )) );

  m_collectedMkisofsPrintSizeStdout = QString::null;
  m_collectedMkisofsPrintSizeStderr = QString::null;
  m_mkisofsPrintSizeResult = 0;

  if( !m_process->start( KProcess::NotifyOnExit, KProcess::AllOutput ) ) {
    emit infoMessage( i18n("Could not start %1.").arg("mkisofs"), K3bJob::ERROR );
    cleanup();

    jobFinished( false );
    return;
  }
}
Пример #4
0
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;
    }
}