Esempio n. 1
0
void K3b::VerificationJob::start()
{
    jobStarted();

    d->canceled = false;
    d->alreadyReadSectors = 0;

    waitForMedium( d->device,
                   K3b::Device::STATE_COMPLETE|K3b::Device::STATE_INCOMPLETE,
                   K3b::Device::MEDIA_WRITABLE );

    // make sure the job is initialized
    if( !d->trackEntries.isEmpty() ) {
        d->currentTrackEntry = d->trackEntries.begin();
    }
    else {
        emit infoMessage( i18n( "Internal Error: Verification job improperly initialized (%1)",
                                i18n("no tracks added") ), MessageError );
        jobFinished( false );
        return;
    }

    emit newTask( i18n("Checking medium") );

    d->mediumHasBeenReloaded = false;
    connect( K3b::Device::sendCommand( K3b::Device::DeviceHandler::CommandLoad, d->device ),
             SIGNAL(finished(K3b::Device::DeviceHandler*)),
             this,
             SLOT(slotMediaLoaded()) );
}
void K3b::Iso9660ImageWritingJob::start()
{
    d->canceled = d->finished = false;
    d->currentCopy = 1;

    jobStarted();

    if( m_simulate )
        m_verifyData = false;

    emit newTask( i18n("Preparing data") );

    if( !QFile::exists( m_imagePath ) ) {
        emit infoMessage( i18n("Could not find image %1", m_imagePath), K3b::Job::MessageError );
        jobFinished( false );
        return;
    }

    KIO::filesize_t mb = K3b::imageFilesize( m_imagePath )/1024ULL/1024ULL;

    // very rough test but since most dvd images are 4,x or 8,x GB it should be enough
    d->isDvdImage = ( mb > 900ULL );

    startWriting();
}
bool BackupFileSystemJob::run(Report& parent)
{
	bool rval = false;
	
	Report* report = jobStarted(parent);
	
	if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportFileSystem)
		rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName());
	else if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportCore)
	{
		CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector());
		CopyTargetFile copyTarget(fileName(), sourceDevice().logicalSectorSize());

		if (!copySource.open())
			report->line() << i18nc("@info/plain", "Could not open file system on source partition <filename>%1</filename> for backup.", sourcePartition().deviceNode());
		else if (!copyTarget.open())
			report->line() << i18nc("@info/plain", "Could not create backup file <filename>%1</filename>.", fileName());
		else
			rval = copyBlocks(*report, copyTarget, copySource);
	}
	
	jobFinished(*report, rval);

	return rval;
}
void K3b::AudioCueFileWritingJob::start()
{
    // FIXME: here we trust that a job won't be started twice :(
    jobStarted();
    d->canceled = false;
    d->audioJobRunning = false;
    importCueInProject();
}
Esempio n. 5
0
void K3bIsoImager::init()
{
  jobStarted();

  cleanup();

  d->dataPreparationJob->start();
}
Esempio n. 6
0
void K3bDvdFormattingJob::start( const K3bDevice::DiskInfo& di )
{
  d->canceled = false;
  d->running = true;

  jobStarted();

  startFormatting( di );
}
bool ResizeFileSystemJob::run(Report& parent)
{
	Q_ASSERT(partition().fileSystem().firstSector() != -1);
	Q_ASSERT(partition().fileSystem().lastSector() != -1);
	Q_ASSERT(newLength() <= partition().length());

	if (partition().fileSystem().firstSector() == -1 || partition().fileSystem().lastSector() == -1 || newLength() > partition().length())
	{
		kWarning() << "file system first sector: " << partition().fileSystem().firstSector() << ", last sector: " << partition().fileSystem().lastSector() << ", new length: " << newLength() << ", partition length: " << partition().length();
		return false;
	}

	bool rval = false;

	Report* report = jobStarted(parent);

	if (partition().fileSystem().length() == newLength())
	{
		report->line() << i18ncp("@info/plain", "The file system on partition <filename>%2</filename> already has the requested length of 1 sector.", "The file system on partition <filename>%2</filename> already has the requested length of %1 sectors.", newLength(), partition().deviceNode());
		rval = true;
	}
	else
	{
		report->line() << i18nc("@info/plain", "Resizing file system from %1 to %2 sectors.", partition().fileSystem().length(), newLength());

		FileSystem::CommandSupportType support = (newLength() < partition().fileSystem().length()) ? partition().fileSystem().supportShrink() : partition().fileSystem().supportGrow();

		switch(support)
		{
			case FileSystem::cmdSupportBackend:
			{
				Report* childReport = report->newChild();
				childReport->line() << i18nc("@info/plain", "Resizing a %1 file system using internal backend functions.", partition().fileSystem().name());
				rval = resizeFileSystemBackend(*childReport);
				break;
			}

			case FileSystem::cmdSupportFileSystem:
			{
				const qint64 newLengthInByte = Capacity(newLength() * device().logicalSectorSize()).toInt(Capacity::Byte);
				rval = partition().fileSystem().resize(*report, partition().deviceNode(), newLengthInByte);
				break;
			}

			default:
				report->line() << i18nc("@info/plain", "The file system on partition <filename>%1</filename> cannot be resized because there is no support for it.", partition().deviceNode());
				break;
		}

		if (rval)
			partition().fileSystem().setLastSector(partition().fileSystem().firstSector() + newLength() - 1);
	}

	jobFinished(*report, rval);

	return rval;
}
Esempio n. 8
0
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;
    }
  }
}
Esempio n. 9
0
void K3b::MusicBrainzJob::start()
{
    jobStarted();

    d->canceled = false;
    d->currentTrackIndex = 0;

    d->mbTrackLookupJob->setAudioTrack( d->tracks.first() );
    d->mbTrackLookupJob->start();
}
Esempio n. 10
0
void QueueLocal::runProgram(int jobId)
{
  if (!m_process) {
    m_process = new QProcess(this);
    connect(m_process, SIGNAL(started()), this, SLOT(jobStarted()));
    connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
            this, SLOT(jobFinished(int,QProcess::ExitStatus)));
    connect(m_process, SIGNAL(stateChanged(QProcess::ProcessState)),
            this, SLOT(processStateChanged(QProcess::ProcessState)));
  }
Esempio n. 11
0
void K3b::BlankingJob::start()
{
    if( m_device == 0 )
        return;

    jobStarted();

    emit newTask( i18n( "Erasing CD-RW" ) );
    emit infoMessage( i18n( "When erasing a CD-RW no progress information is available." ), MessageWarning );

    slotStartErasing();
}
/*!
 * This slot handles a new job being started by updating our job member, and
 * emitting an appropriate signal.
 *
 * \param j The string describing the job.
 * \param i Whether or not the job is interruptible.
 */
void CSCollectionTypeResolver::doJobStarted(const QString &j, bool i)
{ /* SLOT */

	CSAbstractCollection *s =
		dynamic_cast<CSAbstractCollection *>(sender());

	if(s != NULL)
		s->setEnabled(false);

	Q_EMIT jobStarted(j, i);

}
void TaskEditor::saveChanges() {
  if (!m_service)
    return; // No index (and hence no task) has been set, or something is really wrong.
  
  if (m_name != nameEdit->text()) {
    kDebug() << "Name Change: " << nameEdit->text();
    KConfigGroup cg = m_service->operationDescription("setName");
    cg.writeEntry("name", nameEdit->text());
    emit jobStarted(m_service->startOperationCall(cg));
  }

  if (m_date != dateEdit->text()) {
    kDebug() << "Date Change: " << dateEdit->text();
    KConfigGroup cg = m_service->operationDescription("setDueText");
    cg.writeEntry("dueText", dateEdit->text());
    emit jobStarted(m_service->startOperationCall(cg));
  }

  if (m_tags != tagsEdit->text()) {
    QStringList tags = tagsEdit->text().split(',');
    KConfigGroup cg = m_service->operationDescription("setTags");
    cg.writeEntry("tags", tags);
    emit jobStarted(m_service->startOperationCall(cg));
  }

  if (priorityEdit->nativeWidget()->currentIndex() != m_priority) {
    KConfigGroup cg = m_service->operationDescription("setPriority");
    cg.writeEntry("priority", priorityEdit->nativeWidget()->currentIndex() + 1);
    emit jobStarted(m_service->startOperationCall(cg));
  }
  
  if (completeBox->isChecked()) {
    KConfigGroup cg = m_service->operationDescription("setCompleted");
    cg.writeEntry("completed", true);
    emit jobStarted(m_service->startOperationCall(cg));
  }

  startAnimation(fullSize, false);
}
bool CheckFileSystemJob::run(Report& parent)
{
	Report* report = jobStarted(parent);

	// if we cannot check, assume everything is fine
	bool rval = true;

	if (partition().fileSystem().supportCheck() == FileSystem::cmdSupportFileSystem)
		rval = partition().fileSystem().check(*report, partition().deviceNode());

	jobFinished(*report, rval);

	return rval;
}
Esempio n. 15
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();
    }
}
Esempio n. 16
0
void K3b::MovixJob::start()
{
    jobStarted();

    m_canceled = false;
    m_dataJob->setWritingApp( writingApp() );

    if( m_movixDocPreparer->createMovixStructures() ) {
        m_dataJob->start();
    }
    else {
        m_movixDocPreparer->removeMovixStructures();
        jobFinished(false);
    }
}
Esempio n. 17
0
void K3b::DvdFormattingJob::start()
{
    d->canceled = false;
    d->running = true;
    d->error = false;

    jobStarted();

    if( !d->device ) {
        emit infoMessage( i18n("No device set"), MessageError );
        d->running = false;
        jobFinished(false);
        return;
    }

    // FIXME: check the return value
    if( K3b::isMounted( d->device ) ) {
        emit infoMessage( i18n("Unmounting medium"), MessageInfo );
        K3b::unmount( d->device );
    }

    //
    // first wait for a dvd+rw, dvd-rw, or bd-re
    // Be aware that an empty DVD-RW might be reformatted to another writing mode
    // so we also wait for empty dvds
    //
    if( waitForMedium( d->device,
                       Device::STATE_COMPLETE|Device::STATE_INCOMPLETE|Device::STATE_EMPTY,
                       Device::MEDIA_REWRITABLE_DVD|Device::MEDIA_BD_RE,
                       0,
                       i18n("Please insert a rewritable DVD or Blu-ray medium into drive<p><b>%1 %2 (%3)</b>.",
                            d->device->vendor(),
                            d->device->description(),
                            d->device->blockDeviceName()) ) == Device::MEDIA_UNKNOWN ) {
        emit canceled();
        d->running = false;
        jobFinished(false);
        return;
    }

    emit infoMessage( i18n("Checking medium"), MessageInfo );
    emit newTask( i18n("Checking medium") );

    connect( Device::sendCommand( Device::DeviceHandler::CommandDiskInfo, d->device ),
             SIGNAL(finished(K3b::Device::DeviceHandler*)),
             this,
             SLOT(slotDeviceHandlerFinished(K3b::Device::DeviceHandler*)) );
}
Esempio n. 18
0
void K3bDvdFormattingJob::start()
{
  d->canceled = false;
  d->running = true;
  d->error = false;

  jobStarted();

  if( !d->device ) {
    emit infoMessage( i18n("No device set"), ERROR );
    d->running = false;
    jobFinished(false);
    return;
  }

  // FIXME: check the return value
  if( K3b::isMounted( d->device ) ) {
      emit infoMessage( i18n("Unmounting medium"), INFO );
      K3b::unmount( d->device );
  }

  //
  // first wait for a dvd+rw or dvd-rw
  // Be aware that an empty DVD-RW might be reformatted to another writing mode
  // so we also wait for empty dvds
  //
  if( waitForMedia( d->device,
		    K3bDevice::STATE_COMPLETE|K3bDevice::STATE_INCOMPLETE|K3bDevice::STATE_EMPTY,
		    K3bDevice::MEDIA_WRITABLE_DVD,
		    i18n("Please insert a rewritable DVD medium into drive<p><b>%1 %2 (%3)</b>.")
		    .arg(d->device->vendor()).arg(d->device->description()).arg(d->device->devicename()) ) == -1 ) {
    emit canceled();
    d->running = false;
    jobFinished(false);
    return;
  }

  emit infoMessage( i18n("Checking media..."), INFO );
  emit newTask( i18n("Checking media") );

  connect( K3bDevice::sendCommand( K3bDevice::DeviceHandler::NG_DISKINFO, d->device ),
	   SIGNAL(finished(K3bDevice::DeviceHandler*)),
	   this,
	   SLOT(slotDeviceHandlerFinished(K3bDevice::DeviceHandler*)) );
}
Esempio n. 19
0
void K3b::Md5Job::start()
{
    cancel();

    jobStarted();
    d->readData = 0;

    if( d->isoFile ) {
        d->imageSize = d->isoFile->size();
    }
    else if( !d->filename.isEmpty() ) {
        if( !QFile::exists( d->filename ) ) {
            emit infoMessage( i18n("Could not find file %1",d->filename), MessageError );
            jobFinished(false);
            return;
        }

        d->file.setName( d->filename );
        if( !d->file.open( QIODevice::ReadOnly ) ) {
            emit infoMessage( i18n("Could not open file %1",d->filename), MessageError );
            jobFinished(false);
            return;
        }

        d->imageSize = K3b::filesize( QUrl::fromLocalFile(d->filename) );
    }
    else
        d->imageSize = 0;

    if( d->device ) {
        //
        // Let the drive determine the optimal reading speed
        //
        d->device->setSpeed( 0xffff, 0xffff );
    }

    d->md5.reset();
    d->finished = false;
    if( d->ioDevice )
        connect( d->ioDevice, SIGNAL(readyRead()), this, SLOT(slotUpdate()) );
    else
        d->timer.start(0);
}
bool CreatePartitionJob::run(Report& parent)
{
	Q_ASSERT(partition().devicePath() == device().deviceNode());

	bool rval = false;

	Report* report = jobStarted(parent);

	CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());

	if (backendDevice)
	{
		CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();

		if (backendPartitionTable)
		{
			QString partitionPath = backendPartitionTable->createPartition(*report, partition());

			if (partitionPath != QString())
			{
				rval = true;
				partition().setPartitionPath(partitionPath);
				partition().setState(Partition::StateNone);
				backendPartitionTable->commit();
			}
			else
				report->line() << xi18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());

			delete backendPartitionTable;
		}
		else
			report->line() << xi18nc("@info/plain", "Could not open partition table on device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());

		delete backendDevice;
	}
	else
		report->line() << xi18nc("@info/plain", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());

	jobFinished(*report, rval);

	return rval;
}
Esempio n. 21
0
QDBusObjectPath JobManager::startJob(const QString &command)
{
	if (command.isEmpty()) {
		qWarning("%s: 'command' must be specified", Q_FUNC_INFO);
		return QDBusObjectPath();
	}

	const int jobId = m_nextJobId++;

	m_jobs[jobId] = new Job(jobId, command, this);
	connect(m_jobs[jobId], SIGNAL(finished(Job*)),
			this, SLOT(onJobFinished(Job*)));
	new JobViewAdaptor(m_jobs[jobId]);
	const QString path = QString("/com/tieto/sysjt/JobView%1").arg(jobId);
	QDBusConnection::sessionBus().registerObject(path, m_jobs[jobId]);

	emit jobStarted(m_jobs[jobId]);

	return QDBusObjectPath(path);
}
Esempio n. 22
0
bool SetPartFlagsJob::run(Report& parent)
{
    bool rval = true;

    Report* report = jobStarted(parent);

    CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());

    if (backendDevice) {
        CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();

        if (backendPartitionTable) {
            CoreBackendPartition* backendPartition = (partition().roles().has(PartitionRole::Extended))
                    ? backendPartitionTable->getExtendedPartition()
                    : backendPartitionTable->getPartitionBySector(partition().firstSector());

            if (backendPartition) {
                quint32 count = 0;

                foreach(const PartitionTable::Flag & f, PartitionTable::flagList()) {
                    emit progress(++count);

                    const bool state = (flags() & f) ? true : false;

                    if (!backendPartition->setFlag(*report, f, state)) {
                        report->line() << xi18nc("@info:progress", "There was an error setting flag %1 for partition <filename>%2</filename> to state %3.", PartitionTable::flagName(f), partition().deviceNode(), state ? xi18nc("@info:progress flag turned on, active", "on") : xi18nc("@info:progress flag turned off, inactive", "off"));

                        rval = false;
                    }
                }

                delete backendPartition;
            } else
                report->line() << xi18nc("@info:progress", "Could not find partition <filename>%1</filename> on device <filename>%2</filename> to set partition flags.", partition().deviceNode(), device().deviceNode());

            if (rval)
                backendPartitionTable->commit();

            delete backendPartitionTable;
        } else
Esempio n. 23
0
void K3b::VcdJob::start()
{
    qDebug() << "(K3b::VcdJob) starting job";

    jobStarted();
    emit burning( false );
    m_canceled = false;

    int pos = QString( m_doc->vcdImage() ).indexOf( ".bin", QString( m_doc->vcdImage() ).length() - 4 );
    if ( pos > 0 ) {
        m_cueFile = m_doc->vcdImage().left( pos ) + ".cue";
    } else {
        m_cueFile = m_doc->vcdImage() + ".cue";
        m_doc->setVcdImage( m_doc->vcdImage() + ".bin" );
    }

    if ( vcdDoc() ->onlyCreateImages() )
        m_createimageonlypercent = 50.0;

    // vcdxGen();
    xmlGen();
}
Esempio n. 24
0
bool CreateFileSystemJob::run(Report& parent)
{
    bool rval = false;

    Report* report = jobStarted(parent);

    if (partition().fileSystem().type() == FileSystem::Unformatted)
        return true;

    if (partition().fileSystem().supportCreate() == FileSystem::cmdSupportFileSystem) {
        if (partition().fileSystem().create(*report, partition().deviceNode())) {
            CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());

            if (backendDevice) {
                CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();

                if (backendPartitionTable) {
                    if (backendPartitionTable->setPartitionSystemType(*report, partition())) {
                        rval = true;
                        backendPartitionTable->commit();
                    } else
                        report->line() << xi18nc("@info:progress", "Failed to set the system type for the file system on partition <filename>%1</filename>.", partition().deviceNode());

                    delete backendPartitionTable;
                } else
                    report->line() << xi18nc("@info:progress", "Could not open partition table on device <filename>%1</filename> to set the system type for partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());

                delete backendDevice;
            } else
                report->line() << xi18nc("@info:progress", "Could not open device <filename>%1</filename> to set the system type for partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
        }
    }

    jobFinished(*report, rval);

    return rval;
}
Esempio n. 25
0
 void RunManagerWatcher::started(const openstudio::UUID &id)
 {
   jobStarted(id);
 }
void PlotTableWidget::bagReaderReadingStarted() {
  emit jobStarted("Reading bag from [file://"+
    bagReader_->getFileName()+"]...");
}
Esempio n. 27
0
tstMainWindow::tstMainWindow(QWidget *parent) : QMainWindow(parent)
{
    d = new tstMainWindowPrivate;

    d->controller = new dtkDistributedController;

    d->status_model = new dtkDistributedControllerStatusModel(this);
    d->status_model->setController(d->controller);

    d->status_view = new dtkDistributedControllerStatusView(this);
    d->status_view->setModel(d->status_model);

    d->host_address = new QLineEdit("dtk://nef-devel.inria.fr:9999", this);
    d->host_address->setAttribute(Qt::WA_MacShowFocusRect, false);

    d->host_button = new QPushButton("Connect", this);
    d->host_button->setAttribute(Qt::WA_MacShowFocusRect, false);
    d->host_button->setFixedWidth(200);

    d->submit_nodes = new QSpinBox(this);
    d->submit_nodes->setMaximum(100);
    d->submit_nodes->setValue(2);

    d->submit_cores = new QSpinBox(this);
    d->submit_cores->setMaximum(48);
    d->submit_cores->setValue(8);

    d->submit_value = new QSpinBox(this);
    d->submit_value->setMaximum(100000);
    d->submit_value->setValue(100000);

    d->submit_button = new QPushButton("Submit", this);
    d->submit_button->setAttribute(Qt::WA_MacShowFocusRect, false);
    d->submit_button->setFixedWidth(200);

    QHBoxLayout *host_layout = new QHBoxLayout;
    host_layout->addWidget(d->host_address);
    host_layout->addWidget(d->host_button);

    QHBoxLayout *submit_layout = new QHBoxLayout;
    submit_layout->addWidget(d->submit_nodes);
    submit_layout->addWidget(d->submit_cores);
    submit_layout->addWidget(d->submit_value);
    submit_layout->addWidget(d->submit_button);

    QWidget *host_widget = new QWidget(this);
    host_widget->setLayout(host_layout);

    QWidget *submit_widget = new QWidget(this);
    submit_widget->setLayout(submit_layout);

    QWidget *central = new QWidget(this);

    QVBoxLayout *central_layout = new QVBoxLayout(central);
    central_layout->setContentsMargins(0, 0, 0, 0);
    central_layout->setSpacing(0);
    central_layout->addWidget(host_widget);
    central_layout->addWidget(d->status_view);
    central_layout->addWidget(submit_widget);

    this->setCentralWidget(central);
    this->setUnifiedTitleAndToolBarOnMac(true);
    this->setWindowTitle("dtkDistributedTutorial - Step #6");

    connect(d->host_button, SIGNAL(clicked()), this, SLOT(onConnect()));
    connect(d->submit_button, SIGNAL(clicked()), this, SLOT(onSubmit()));

    connect(d->controller, SIGNAL(dataPosted(const QByteArray&)), this, SLOT(onDataPosted(const QByteArray&)));
    connect(d->controller, SIGNAL(jobStarted(QString)), this, SLOT(onJobStarted(QString)));
}
Esempio n. 28
0
void K3bMixedJob::start()
{
  jobStarted();

  m_canceled = false;
  m_errorOccuredAndAlreadyReported = false;
  d->copiesDone = 0;
  d->copies = m_doc->copies();
  m_currentAction = PREPARING_DATA;
  d->maxSpeed = false;

  if( m_doc->dummy() )
    d->copies = 1;

  prepareProgressInformation();

  //
  // Check if all files exist
  //
  QValueList<K3bAudioFile*> nonExistingFiles;
  K3bAudioTrack* track = m_doc->audioDoc()->firstTrack();
  while( track ) {
    K3bAudioDataSource* source = track->firstSource();
    while( source ) {
      if( K3bAudioFile* file = dynamic_cast<K3bAudioFile*>( source ) ) {
	if( !QFile::exists( file->filename() ) )
	  nonExistingFiles.append( file );
      }
      source = source->next();
    }
    track = track->next();
  }
  if( !nonExistingFiles.isEmpty() ) {
    if( questionYesNo( "<p>" + i18n("The following files could not be found. Do you want to remove them from the "
				    "project and continue without adding them to the image?") +
		       "<p>" + createNonExistingFilesString( nonExistingFiles, 10 ),
		       i18n("Warning"),
		       i18n("Remove missing files and continue"),
		       i18n("Cancel and go back") ) ) {
      for( QValueList<K3bAudioFile*>::const_iterator it = nonExistingFiles.begin();
	   it != nonExistingFiles.end(); ++it ) {
	delete *it;
      }
    }
    else {
      m_canceled = true;
      emit canceled();
      jobFinished(false);
      return;
    }
  }

  //
  // Make sure the project is not empty
  //
  if( m_doc->audioDoc()->numOfTracks() == 0 ) {
    emit infoMessage( i18n("Please add files to your project first."), ERROR );
    jobFinished(false);
    return;
  }


  // set some flags that are needed
  m_doc->audioDoc()->setOnTheFly( m_doc->onTheFly() );  // for the toc writer
  m_doc->audioDoc()->setHideFirstTrack( false );   // unsupported
  m_doc->dataDoc()->setBurner( m_doc->burner() );  // so the isoImager can read ms data

  emit newTask( i18n("Preparing data") );

  determineWritingMode();

  //
  // First we make sure the data portion is valid
  //

  // we do not have msinfo yet
  m_currentAction = INITIALIZING_IMAGER;
  m_isoImager->setMultiSessionInfo( QString::null );
  m_isoImager->init();
}
Esempio n. 29
0
bool CreatePartitionJob::run(Report& parent)
{
	Q_ASSERT(partition().devicePath() == device().deviceNode());

	bool rval = false;

	Report* report = jobStarted(parent);

	// According to libParted docs, PedPartitionType can be "NULL if unknown". That's obviously wrong,
	// it's a typedef for an enum. So let's use something the libparted devs will hopefully never
	// use...
	PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff);

	if (partition().roles().has(PartitionRole::Extended))
		pedType = PED_PARTITION_EXTENDED;
	else if (partition().roles().has(PartitionRole::Logical))
		pedType = PED_PARTITION_LOGICAL;
	else if (partition().roles().has(PartitionRole::Primary))
		pedType = PED_PARTITION_NORMAL;
			
	if (pedType == static_cast<int>(0xffffffff))
	{
		report->line() << i18nc("@info/plain", "Unknown partition role for new partition <filename>%1</filename> (roles: %2)", partition().deviceNode(), partition().roles().toString());
	}
	else if (openPed(device().deviceNode()))
	{
		PedFileSystemType* pedFsType = (partition().roles().has(PartitionRole::Extended) || partition().fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition().fileSystem().type());

		PedPartition* pedPartition = ped_partition_new(pedDisk(), pedType, pedFsType, partition().firstSector(), partition().lastSector());

		if (pedPartition)
		{
			PedConstraint* pedConstraint = NULL;
			PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition().firstSector(), partition().length());

			if (pedGeometry)
				pedConstraint = ped_constraint_exact(pedGeometry);

			if (pedConstraint)
			{
				if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint) && commit())
				{
					partition().setNumber(pedPartition->num);
					partition().setState(Partition::StateNone);

					partition().setFirstSector(pedPartition->geom.start);
					partition().setLastSector(pedPartition->geom.end);

					rval = true;
				}
				else
					report->line() << i18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());

				ped_constraint_destroy(pedConstraint);
			}
			else
				report->line() << i18nc("@info/plain", "Failed to create a new partition: could not get geometry for constraint.");
		}
		else
			report->line() << i18nc("@info/plain", "Failed to create new partition <filename>%1</filename>.", partition().deviceNode());
	
		closePed();
	}
	else
		report->line() << i18nc("@info/plain", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
	
	jobFinished(*report, rval);
	
	return rval;
}
void TaskEditor::saveAsCompleted() {
    KConfigGroup cg = m_service->operationDescription("setCompleted");
    cg.writeEntry("completed", true);
    emit jobStarted(m_service->startOperationCall(cg));
}