void MetadataJob::doStart() { if (!m_core) { emitFinishedWithError(Job::Canceled, tr("Missing package manager core engine.")); return; // We can't do anything here without core, so avoid tons of !m_core checks. } const ProductKeyCheck *const productKeyCheck = ProductKeyCheck::instance(); if (!m_addCompressedPackages) { reset(); emit infoMessage(this, tr("Preparing meta information download...")); const bool onlineInstaller = m_core->isInstaller() && !m_core->isOfflineOnly(); if (onlineInstaller || m_core->isMaintainer()) { QList<FileTaskItem> items; foreach (const Repository &repo, m_core->settings().repositories()) { if (repo.isEnabled() && productKeyCheck->isValidRepository(repo)) { QAuthenticator authenticator; authenticator.setUser(repo.username()); authenticator.setPassword(repo.password()); if (!repo.isCompressed()) { QString url = repo.url().toString() + QLatin1String("/Updates.xml?"); if (!m_core->value(scUrlQueryString).isEmpty()) url += m_core->value(scUrlQueryString) + QLatin1Char('&'); // also append a random string to avoid proxy caches FileTaskItem item(url.append(QString::number(qrand() * qrand()))); item.insert(TaskRole::UserRole, QVariant::fromValue(repo)); item.insert(TaskRole::Authenticator, QVariant::fromValue(authenticator)); items.append(item); } else { qDebug() << "Trying to parse compressed repo as normal repository."\ "Check repository syntax."; } } } if (items.count() > 0) { startXMLTask(items); } else { emitFinished(); } } else {
void K3bDvdFormattingJob::slotProcessFinished( KProcess* p ) { if( d->canceled ) { emit canceled(); d->success = false; } else if( p->normalExit() ) { if( !d->error && p->exitStatus() == 0 ) { emit infoMessage( i18n("Formatting successfully completed"), K3bJob::SUCCESS ); if( d->lastProgressValue < 100 ) { emit infoMessage( i18n("Do not be concerned with the progress stopping before 100%."), INFO ); emit infoMessage( i18n("The formatting will continue in the background while writing."), INFO ); } d->success = true; } else { emit infoMessage( i18n("%1 returned an unknown error (code %2).").arg(d->dvdFormatBin->name()).arg(p->exitStatus()), K3bJob::ERROR ); emit infoMessage( i18n("Please send me an email with the last output."), K3bJob::ERROR ); d->success = false; } } else { emit infoMessage( i18n("%1 did not exit cleanly.").arg(d->dvdFormatBin->name()), ERROR ); d->success = false; } if( d->forceNoEject || !k3bcore->globalSettings()->ejectMedia() ) { d->running = false; jobFinished(d->success); } else { emit infoMessage( i18n("Ejecting DVD..."), INFO ); connect( K3bDevice::eject( d->device ), SIGNAL(finished(K3bDevice::DeviceHandler*)), this, SLOT(slotEjectingFinished(K3bDevice::DeviceHandler*)) ); } }
void K3b::DvdFormattingJob::slotProcessFinished( int exitCode, QProcess::ExitStatus exitStatus ) { if( d->canceled ) { emit canceled(); d->success = false; } else if( exitStatus == QProcess::NormalExit ) { if( !d->error && (exitCode == 0) ) { emit infoMessage( i18n("Formatting successfully completed"), Job::MessageSuccess ); if( d->lastProgressValue < 100 ) { emit infoMessage( i18n("Do not be concerned with the progress stopping before 100%."), MessageInfo ); emit infoMessage( i18n("The formatting will continue in the background during writing."), MessageInfo ); } d->success = true; } else { emit infoMessage( i18n("%1 returned an unknown error (code %2).",d->dvdFormatBin->name(), exitCode), Job::MessageError ); emit infoMessage( i18n("Please send me an email with the last output."), Job::MessageError ); d->success = false; } } else { emit infoMessage( i18n("%1 did not exit cleanly.",d->dvdFormatBin->name()), MessageError ); d->success = false; } if( d->forceNoEject || !k3bcore->globalSettings()->ejectMedia() ) { d->running = false; jobFinished(d->success); } else { emit infoMessage( i18n("Ejecting medium..."), MessageInfo ); connect( Device::eject( d->device ), SIGNAL(finished(K3b::Device::DeviceHandler*)), this, SLOT(slotEjectingFinished(K3b::Device::DeviceHandler*)) ); } }
void K3b::VcdJob::parseInformation( const QString &text ) { // parse warning if ( text.contains( "mpeg user scan data: one or more BCD fields out of range for" ) ) { int index = text.indexOf( " for" ); emit infoMessage( i18n( "One or more BCD fields out of range for %1" , text.mid( index + 4 ).trimmed() ), K3b::Job::MessageWarning ); } else if ( text.contains( "mpeg user scan data: from now on, scan information data errors will not be reported anymore" ) ) { emit infoMessage( i18n( "From now on, scan information data errors will not be reported anymore" ), K3b::Job::MessageInfo ); emit infoMessage( i18n( "Consider enabling the 'update scan offsets' option, if it is not enabled already." ), K3b::Job::MessageInfo ); } else if ( text.contains( "APS' pts seems out of order (actual pts" ) ) { int index = text.indexOf( "(actual pts" ); int index2 = text.indexOf( ", last seen pts" ); int index3 = text.indexOf( ") -- ignoring this aps" ); emit infoMessage( i18n( "APS' pts seems out of order (actual pts %1, last seen pts %2)" , text.mid( index + 12, index2 - index - 12 ).trimmed() , text.mid( index2 + 14, index3 - index2 - 14 ).trimmed() ), K3b::Job::MessageWarning ); emit infoMessage( i18n( "Ignoring this aps" ), K3b::Job::MessageInfo ); } else if ( text.contains( "bad packet at packet" ) ) { int index = text.indexOf( "at packet #" ); int index2 = text.indexOf( "(stream byte offset" ); int index3 = text.indexOf( ") -- remaining " ); int index4 = text.indexOf( "bytes of stream will be ignored" ); emit infoMessage( i18n( "Bad packet at packet #%1 (stream byte offset %2)" , text.mid( index + 11, index2 - index - 11 ).trimmed() , text.mid( index2 + 19, index3 - index2 - 19 ).trimmed() ), K3b::Job::MessageWarning ); const QString ignoredString = text.mid( index3 + 15, index4 - index3 - 15 ).trimmed(); bool okay = true; const int ignoredBytes = ignoredString.toInt(&okay); if (okay) { emit infoMessage( i18np( "The remaining byte of the stream will be ignored.", "The remaining %1 bytes of the stream will be ignored." , ignoredBytes ), K3b::Job::MessageWarning ); } else { emit infoMessage( i18n( "An unknown number of remaining stream bytes will be ignored." ), K3b::Job::MessageWarning ); } } }
CopyApp::CopyApp(QString origin, QString destination, QString app, int timeToWait, QWidget *parent) : QMainWindow(parent), ui(new Ui::CopyApp), origin(origin), destination(destination), appToRun(app), timeToWait(timeToWait), started(false) { if(origin.isEmpty() | destination.isEmpty()) { QMessageBox::warning(this, "ERROR", "INVALID COMMAND LINE OPTIONS"); return; } qDebug() << origin << destination; ui->setupUi(this); emit infoMessage(tr("Waiting for application to close")); QTimer::singleShot(500, this, SLOT(doUpdate())); connect(this, &CopyApp::infoMessage, this, &CopyApp::onNewInfo); connect(this, &CopyApp::currentOperation, this, &CopyApp::onNewOperation); connect(this, &CopyApp::progress, this, &CopyApp::onProgress); started = true; }
void K3b::VcdJob::xmlGen() { delete d->xmlFile; d->xmlFile = new QTemporaryFile; if( d->xmlFile->open() ) { qDebug() << "(K3b::VcdJob) writing XML data to" << d->xmlFile->fileName(); K3b::VcdXmlView xmlView( m_doc ); xmlView.write( *d->xmlFile ); // emit infoMessage( i18n( "XML-file successfully created" ), K3b::Job::MessageSuccess ); emit debuggingOutput( "K3b::VcdXml:", xmlView.xmlString() ); vcdxBuild(); } else { qDebug() << "(K3b::VcdJob) could not write xmlfile."; emit infoMessage( i18n( "Could not write correct XML file." ), K3b::Job::MessageError ); cancelAll(); jobFinished( false ); } }
NetworkProgressBar::NetworkProgressBar( QWidget *parent, QNetworkReply *reply ) : ProgressBar( parent ) { connect( reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(infoMessage(QNetworkReply::NetworkError)) ); connect( reply, SIGNAL(finished()), SLOT(delayedDone()) ); connect( reply, SIGNAL(destroyed()), SLOT(delayedDone()) ); switch( reply->operation() ) { case QNetworkAccessManager::HeadOperation: case QNetworkAccessManager::GetOperation: connect( reply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(progressChanged(qint64,qint64)) ); break; case QNetworkAccessManager::PutOperation: case QNetworkAccessManager::PostOperation: connect( reply, SIGNAL(uploadProgress(qint64,qint64)), SLOT(progressChanged(qint64,qint64)) ); break; default: break; } }
/** get attribute value */ const char* xml_get_attrval( const XML_NODE* node, const char* name ) { XML_ATTR* a; assert(node != NULL); assert(name != NULL); for (a = node->attr_list; a != NULL; a = a->next) { if (!strcmp(name, a->name)) break; } #if 0 if (a == NULL) infoMessage("Error: Attribut %s in TAG <%s> not found\n", name, node->name); #endif return (a == NULL) ? NULL : a->value; }
void DiagnosticsDialog::dumpVersionInfo() { // We display this in Help->About as well but let us dump it as info message // in case workbench crashes before user can work with the GUI. infoMessage(QString("SCAP Workbench %1, compiled with Qt %2, using OpenSCAP %3").arg(SCAP_WORKBENCH_VERSION, QT_VERSION_STR, oscap_get_version())); }
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(); }
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 {
bool K3bIsoImager::addMkisofsParameters( bool printSize ) { // add multisession info if( !m_multiSessionInfo.isEmpty() ) { *m_process << "-cdrecord-params" << m_multiSessionInfo; if( m_device ) *m_process << "-prev-session" << m_device->blockDeviceName(); } // add the arguments *m_process << "-gui"; *m_process << "-graft-points"; if( printSize ) *m_process << "-print-size" << "-quiet"; if( !m_doc->isoOptions().volumeID().isEmpty() ) { QString s = m_doc->isoOptions().volumeID(); truncateTheHardWay(s, 32); // ensure max length *m_process << "-volid" << s; } else { emit infoMessage( i18n("No volume id specified. Using default."), WARNING ); *m_process << "-volid" << "CDROM"; } QString s = m_doc->isoOptions().volumeSetId(); truncateTheHardWay(s, 128); // ensure max length *m_process << "-volset" << s; s = m_doc->isoOptions().applicationID(); truncateTheHardWay(s, 128); // ensure max length *m_process << "-appid" << s; s = m_doc->isoOptions().publisher(); truncateTheHardWay(s, 128); // ensure max length *m_process << "-publisher" << s; s = m_doc->isoOptions().preparer(); truncateTheHardWay(s, 128); // ensure max length *m_process << "-preparer" << s; s = m_doc->isoOptions().systemId(); truncateTheHardWay(s, 32); // ensure max length *m_process << "-sysid" << s; s = m_doc->isoOptions().abstractFile(); truncateTheHardWay(s, 37); // ensure max length if ( !s.isEmpty() ) *m_process << "-abstract" << s; s = m_doc->isoOptions().copyrightFile(); truncateTheHardWay(s, 37); // ensure max length if ( !s.isEmpty() ) *m_process << "-copyright" << s; s = m_doc->isoOptions().bibliographFile(); truncateTheHardWay(s, 37); // ensure max length if ( !s.isEmpty() ) *m_process << "-biblio" << s; int volsetSize = m_doc->isoOptions().volumeSetSize(); int volsetSeqNo = m_doc->isoOptions().volumeSetNumber(); if( volsetSeqNo > volsetSize ) { kdDebug() << "(K3bIsoImager) invalid volume set sequence number: " << volsetSeqNo << " with volume set size: " << volsetSize << endl; volsetSeqNo = volsetSize; } *m_process << "-volset-size" << QString::number(volsetSize); *m_process << "-volset-seqno" << QString::number(volsetSeqNo); if( m_sortWeightFile ) { *m_process << "-sort" << m_sortWeightFile->name(); } if( m_doc->isoOptions().createRockRidge() ) { if( m_doc->isoOptions().preserveFilePermissions() ) *m_process << "-rock"; else *m_process << "-rational-rock"; if( m_rrHideFile ) *m_process << "-hide-list" << m_rrHideFile->name(); } if( m_doc->isoOptions().createJoliet() ) { *m_process << "-joliet"; if( m_doc->isoOptions().jolietLong() ) *m_process << "-joliet-long"; if( m_jolietHideFile ) *m_process << "-hide-joliet-list" << m_jolietHideFile->name(); } if( m_doc->isoOptions().doNotCacheInodes() ) *m_process << "-no-cache-inodes"; // // Check if we have files > 2 GB and enable udf in that case. // bool filesGreaterThan2Gb = false; K3bDataItem* item = m_doc->root(); while( (item = item->nextSibling()) ) { if( item->isFile() && item->size() > 2LL*1024LL*1024LL*1024LL ) { filesGreaterThan2Gb = true; break; } } if( filesGreaterThan2Gb ) { emit infoMessage( i18n("Found files bigger than 2 GB. These files will only be fully accessible if mounted with UDF."), WARNING ); // in genisoimage 1.1.3 "they" silently introduced this aweful parameter if ( d->mkisofsBin->hasFeature( "genisoimage" ) && d->mkisofsBin->version >= K3bVersion( 1, 1, 3 ) ) { *m_process << "-allow-limited-size"; } } bool udf = m_doc->isoOptions().createUdf(); if( !udf && filesGreaterThan2Gb ) { emit infoMessage( i18n("Enabling UDF extension."), INFO ); udf = true; } if( udf ) *m_process << "-udf"; if( m_doc->isoOptions().ISOuntranslatedFilenames() ) { *m_process << "-untranslated-filenames"; } else { if( m_doc->isoOptions().ISOallowPeriodAtBegin() ) *m_process << "-allow-leading-dots"; if( m_doc->isoOptions().ISOallow31charFilenames() ) *m_process << "-full-iso9660-filenames"; if( m_doc->isoOptions().ISOomitVersionNumbers() && !m_doc->isoOptions().ISOmaxFilenameLength() ) *m_process << "-omit-version-number"; if( m_doc->isoOptions().ISOrelaxedFilenames() ) *m_process << "-relaxed-filenames"; if( m_doc->isoOptions().ISOallowLowercase() ) *m_process << "-allow-lowercase"; if( m_doc->isoOptions().ISOnoIsoTranslate() ) *m_process << "-no-iso-translate"; if( m_doc->isoOptions().ISOallowMultiDot() ) *m_process << "-allow-multidot"; if( m_doc->isoOptions().ISOomitTrailingPeriod() ) *m_process << "-omit-period"; } if( m_doc->isoOptions().ISOmaxFilenameLength() ) *m_process << "-max-iso9660-filenames"; if( m_noDeepDirectoryRelocation ) *m_process << "-disable-deep-relocation"; // We do our own following // if( m_doc->isoOptions().followSymbolicLinks() || !m_doc->isoOptions().createRockRidge() ) // *m_process << "-follow-links"; if( m_doc->isoOptions().createTRANS_TBL() ) *m_process << "-translation-table"; if( m_doc->isoOptions().hideTRANS_TBL() ) *m_process << "-hide-joliet-trans-tbl"; *m_process << "-iso-level" << QString::number(m_doc->isoOptions().ISOLevel()); if( m_doc->isoOptions().forceInputCharset() ) *m_process << "-input-charset" << m_doc->isoOptions().inputCharset(); *m_process << "-path-list" << QFile::encodeName(m_pathSpecFile->name()); // boot stuff if( !m_doc->bootImages().isEmpty() ) { bool first = true; for( QPtrListIterator<K3bBootItem> it( m_doc->bootImages() ); *it; ++it ) { if( !first ) *m_process << "-eltorito-alt-boot"; K3bBootItem* bootItem = *it; *m_process << "-eltorito-boot"; *m_process << bootItem->writtenPath(); if( bootItem->imageType() == K3bBootItem::HARDDISK ) { *m_process << "-hard-disk-boot"; } else if( bootItem->imageType() == K3bBootItem::NONE ) { *m_process << "-no-emul-boot"; if( bootItem->loadSegment() > 0 ) *m_process << "-boot-load-seg" << QString::number(bootItem->loadSegment()); if( bootItem->loadSize() > 0 ) *m_process << "-boot-load-size" << QString::number(bootItem->loadSize()); } if( bootItem->imageType() != K3bBootItem::NONE && bootItem->noBoot() ) *m_process << "-no-boot"; if( bootItem->bootInfoTable() ) *m_process << "-boot-info-table"; first = false; } *m_process << "-eltorito-catalog" << m_doc->bootCataloge()->writtenPath(); } // additional parameters from config const QStringList& params = k3bcore->externalBinManager()->binObject( "mkisofs" )->userParameters(); for( QStringList::const_iterator it = params.begin(); it != params.end(); ++it ) *m_process << *it; return true; }
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 Basic::status::info(const QString& s) { emit infoMessage(s); }
bool AudioProjectConvertingJob::init() { emit newTask( i18n("Converting Audio Tracks") ); emit infoMessage( i18n("Starting audio conversion."), Job::MessageInfo ); return true; }
void OntologyUpdater::start() { QApplication::processEvents(); Soprano::Model *m_mainModel; bool m_nepomukInited = Utilities::nepomukInited(); if (m_nepomukInited) { m_mainModel = Nepomuk2::ResourceManager::instance()->mainModel(); } else { return; } m_stopUpdate = false; MediaVocabulary mediaVocabulary; //Update audio QString queryPrefix = QString("PREFIX xesam: <%1> " "PREFIX rdf: <%2> " "PREFIX xls: <%3> " "PREFIX nmm: <http://www.semanticdesktop.org/ontologies/nmm#> " "PREFIX nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#> " "PREFIX nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> ") .arg(Soprano::Vocabulary::Xesam::xesamNamespace().toString()) .arg(Soprano::Vocabulary::RDF::rdfNamespace().toString()) .arg(Soprano::Vocabulary::XMLSchema::xsdNamespace().toString()); QString queryStr = queryPrefix + QString("SELECT ?r " "WHERE { {?r rdf:type <http://www.semanticdesktop.org/ontologies/nfo#Audio>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicPiece>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum>} " "UNION " "{?r rdf:type <%1>} " "UNION " "{?r rdf:type <%2>} " "UNION " "{?r rdf:type <%3>} }") .arg(mediaVocabulary.typeAudio().toString()) .arg(mediaVocabulary.typeAudioMusic().toString()) .arg(mediaVocabulary.typeMediaStream().toString()); Soprano::QueryResultIterator it = m_mainModel->executeQuery(queryStr, Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); int i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); //Update types QUrl type = QUrl("http://www.semanticdesktop.org/ontologies/nfo#Audio"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeAudio())) { resource.addType(mediaVocabulary.typeAudio()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicPiece"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeAudioMusic())) { resource.addType(mediaVocabulary.typeAudioMusic()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#musicAlbum"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.musicAlbum(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#trackNumber"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.musicTrackNumber(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#DigitalRadio"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeMediaStream())) { resource.addType(mediaVocabulary.typeMediaStream()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#MusicAlbum"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeMusicAlbum())) { resource.addType(mediaVocabulary.typeMusicAlbum()); } } //Update common properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nfo#duration"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.duration(), value); } property = Nepomuk2::Vocabulary::NMM::artwork(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } property = Nepomuk2::Vocabulary::NIE::hasLogicalPart(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); if (value.toResource().hasType(Nepomuk2::Vocabulary::NFO::Image())) { resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#genre"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.genre(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#releaseDate"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.releaseDate(), value); } property = Soprano::Vocabulary::Xesam::useCount(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.playCount(), value); } property = Soprano::Vocabulary::Xesam::lastUsed(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.lastPlayed(), value); } emit infoMessage(i18n("<b>Updating audio types and properties</b><br>%1 audio items done...", i)); QApplication::processEvents(); } //Update video queryStr = queryPrefix + QString("SELECT ?r " "WHERE { {?r rdf:type <http://www.semanticdesktop.org/ontologies/nfo#Video>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#Movie>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/nmm#TVShow>} " "UNION " "{?r rdf:type <http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVSeries>} " "UNION " "{?r rdf:type <%1>} " "UNION " "{?r rdf:type <%2>} " "UNION " "{?r rdf:type <%3>} }") .arg(mediaVocabulary.typeVideo().toString()) .arg(mediaVocabulary.typeVideoMovie().toString()) .arg(mediaVocabulary.typeVideoTVShow().toString()); it = m_mainModel->executeQuery(queryStr, Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); //Update types QUrl type = QUrl("http://www.semanticdesktop.org/ontologies/nfo#Video"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideo())) { resource.addType(mediaVocabulary.typeVideo()); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#Movie"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideoMovie())) { resource.addType(mediaVocabulary.typeVideoMovie()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#synopsis"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSynopsis(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#writer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoWriter(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#actor"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoActor(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#director"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoDirector(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#producer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoProducer(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/nmm#TVShow"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeVideoTVShow())) { resource.addType(mediaVocabulary.typeVideoTVShow()); } //Update properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#series"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSeries(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#synopsis"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSynopsis(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#season"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoSeason(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#episodeNumber"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoEpisodeNumber(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#writer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoWriter(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#actor"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoActor(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#director"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoDirector(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#producer"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.videoProducer(), value); } } type = QUrl("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVSeries"); if (resource.hasType(type)) { removeType(resource, type); if (!resource.hasType(mediaVocabulary.typeTVSeries())) { resource.addType(mediaVocabulary.typeTVSeries()); } } //Update common properties QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/nfo#duration"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.duration(), value); } property = Nepomuk2::Vocabulary::NMM::artwork(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } property = Nepomuk2::Vocabulary::NIE::hasLogicalPart(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); if (value.toResource().hasType(Nepomuk2::Vocabulary::NFO::Image())) { resource.removeProperty(property); resource.setProperty(mediaVocabulary.artwork(), value); } } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#genre"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.genre(), value); } property = QUrl("http://www.semanticdesktop.org/ontologies/nmm#releaseDate"); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.releaseDate(), value); } property = Soprano::Vocabulary::Xesam::useCount(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.playCount(), value); } property = Soprano::Vocabulary::Xesam::lastUsed(); if (resource.hasProperty(property)) { Nepomuk2::Variant value = resource.property(property); resource.removeProperty(property); resource.setProperty(mediaVocabulary.lastPlayed(), value); } emit infoMessage(i18n("<b>Updating video types and properties</b><br>%1 video items done...", i)); QApplication::processEvents(); } //Fix screwed up properties MediaQuery query; QStringList bindings; bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.ratingBinding()); query.select(bindings, MediaQuery::Distinct); query.startWhere(); query.addCondition(mediaVocabulary.hasTypeAnyAudio(MediaQuery::Required)); query.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan)); query.endWhere(); it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating"); if (resource.hasProperty(property)) { int rating = resource.property(property).toInt(); if (rating > 10) { resource.removeProperty(property); } } emit infoMessage(i18n("<b>Cleaning up erroneous audio properties</b><br>%1 audio items done...", i)); QApplication::processEvents(); } MediaQuery query1; bindings.clear(); bindings.append(mediaVocabulary.mediaResourceBinding()); bindings.append(mediaVocabulary.ratingBinding()); query1.select(bindings, MediaQuery::Distinct); query1.startWhere(); query1.addCondition(mediaVocabulary.hasTypeAnyVideo(MediaQuery::Required)); query1.addCondition(mediaVocabulary.hasRating(MediaQuery::Required, 10, MediaQuery::GreaterThan)); query1.endWhere(); it = m_mainModel->executeQuery(query.query(), Soprano::Query::QueryLanguageSparql); emit infoMessage(i18n("<b>Updating audio types and properties</b><br>0 items updated...")); QApplication::processEvents(); i = 0; while( it.next() && !m_stopUpdate) { QApplication::processEvents(); i++; Nepomuk2::Resource resource = Nepomuk2::Resource(it.binding("r").uri()); QUrl property = QUrl("http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating"); if (resource.hasProperty(property)) { int rating = resource.property(property).toInt(); if (rating > 10) { resource.removeProperty(property); } } emit infoMessage(i18n("<b>Cleaning up erroneous video properties</b><br>%1 video items done...", i)); QApplication::processEvents(); } if (!m_stopUpdate) { emit infoMessage(i18n("<b>Update complete.</b>")); } else { emit infoMessage(i18n("<b>Update stopped.</b>")); } emit done(); }
void IpcClient::disconnectFromHost() { infoMessage("service disconnect"); m_Reader->stop(); m_Socket->close(); }
void IpcClient::connected() { sendHello(); infoMessage("connection established"); }
void shmTell(unsigned long long entrySize, unsigned long long workersAvailable, unsigned long long serverStarted, unsigned long long lastTask, unsigned long long totalTasks, unsigned long long infoTime, unsigned long long errorTime, unsigned long long *threadTasks, char *infoMess, char *errorMess, char *serverName) { int k; unsigned long long p, r; char dataBuffer[CONFIG_STRING_SIZE]; char timeBuffer[CONFIG_SPACE_SIZE]; struct tm *newTime; if(entrySize == sizeof(unsigned long long)) { // Server started k = 0; if(workersAvailable != 0) { newTime = localtime((time_t *) &serverStarted); strftime(timeBuffer, sizeof(timeBuffer), TIME_FORMAT, newTime); k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%c* %s started at %s, with %llu workers%c%c", CONFIG_LINEFEED, serverName, timeBuffer, workersAvailable, CONFIG_LINEFEED, CONFIG_LINEFEED ); } else { return; } // Connections served if(lastTask != 0) { newTime = localtime((time_t *) &lastTask); strftime(timeBuffer, sizeof(timeBuffer), TIME_FORMAT, newTime); k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%llu connections served, last at %s%c", totalTasks, timeBuffer, CONFIG_LINEFEED ); } else { k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%llu connections served%c", totalTasks, CONFIG_LINEFEED ); } // Workers r = 0; for(p = 0; p < workersAvailable; p++) { if(threadTasks[p] != 0) { k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "worker %llu has served %llu agents in last hour%c", p, threadTasks[p], CONFIG_LINEFEED ); r++; } } if(r == workersAvailable) { k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "All workers busy" ); } else if(r == 0) { k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "All workers idling" ); } else { p -= r; k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%llu workers idling", p ); } // Last info message if(infoMess[0] != 0) { newTime = localtime((time_t *) &infoTime); strftime(timeBuffer, sizeof(timeBuffer), TIME_FORMAT, newTime); k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%cLast message at %s, '%s'", CONFIG_LINEFEED, timeBuffer, infoMess ); } // Last error message if(errorMess[0] != 0) { newTime = localtime((time_t *) &errorTime); strftime(timeBuffer, sizeof(timeBuffer), TIME_FORMAT, newTime); k += snprintf( dataBuffer + k, sizeof(dataBuffer) - k, "%cLast error at %s, '%s'", CONFIG_LINEFEED, timeBuffer, errorMess ); } dataBuffer[k] = 0; infoMessage(ERROR_NOERROR, dataBuffer); } }
void K3bCddbLocalSubmit::doSubmit() { QString path = m_cddbDir; if( path.startsWith( "~" ) ) path.replace( 0, 1, QDir::homeDirPath() + "/" ); else if( !path.startsWith( "/" ) ) path.prepend( QDir::homeDirPath() + "/" ); if( path[path.length()-1] != '/' ) path.append( "/" ); if( !QFile::exists( path ) && !QDir().mkdir( path ) ) { kdDebug() << "(K3bCddbLocalSubmit) could not create directory: " << path << endl; setError( IO_ERROR ); emit submitFinished( this ); return; } if( QFile::exists( path ) ) { // if the category dir does not exists // create it path += resultEntry().category; if( !QFile::exists( path ) ) { if( !QDir().mkdir( path ) ) { kdDebug() << "(K3bCddbLocalSubmit) could not create directory: " << path << endl; setError( IO_ERROR ); emit submitFinished( this ); return; } } // we always overwrite existing entries path += "/" + resultEntry().discid; QFile entryFile( path ); if( entryFile.exists() ) { kdDebug() << "(K3bCddbLocalSubmit) file already exists: " << path << endl; } if( !entryFile.open( IO_WriteOnly ) ) { kdDebug() << "(K3bCddbLocalSubmit) could not create file: " << path << endl; setError( IO_ERROR ); emit submitFinished( this ); } else { kdDebug() << "(K3bCddbLocalSubmit) creating file: " << path << endl; QTextStream entryStream( &entryFile ); entryStream.setEncoding( QTextStream::UnicodeUTF8 ); entryStream << resultEntry().rawData; entryFile.close(); setError( SUCCESS ); emit submitFinished( this ); } } else { kdDebug() << "(K3bCddbLocalSubmit) could not find directory: " << path << endl; setError( IO_ERROR ); emit infoMessage( i18n("Could not find directory: %1").arg(path) ); emit submitFinished( this ); } }
int K3bIsoImager::writePathSpecForDir( K3bDirItem* dirItem, QTextStream& stream ) { if( !m_noDeepDirectoryRelocation && dirItem->depth() > 7 ) { kdDebug() << "(K3bIsoImager) found directory depth > 7. Enabling no deep directory relocation." << endl; m_noDeepDirectoryRelocation = true; } // now create the graft points int num = 0; for( QPtrListIterator<K3bDataItem> it( dirItem->children() ); it.current(); ++it ) { K3bDataItem* item = it.current(); bool writeItem = item->writeToCd(); if( item->isSymLink() ) { if( d->usedLinkHandling == Private::DISCARD_ALL || ( d->usedLinkHandling == Private::DISCARD_BROKEN && !item->isValid() ) ) writeItem = false; else if( d->usedLinkHandling == Private::FOLLOW ) { QFileInfo f( K3b::resolveLink( item->localPath() ) ); if( !f.exists() ) { emit infoMessage( i18n("Could not follow link %1 to non-existing file %2. Skipping...") .arg(item->k3bName()) .arg(f.filePath()), WARNING ); writeItem = false; } else if( f.isDir() ) { emit infoMessage( i18n("Ignoring link %1 to folder %2. K3b is unable to follow links to folders.") .arg(item->k3bName()) .arg(f.filePath()), WARNING ); writeItem = false; } } } else if( item->isFile() ) { QFileInfo f( item->localPath() ); if( !f.exists() ) { emit infoMessage( i18n("Could not find file %1. Skipping...").arg(item->localPath()), WARNING ); writeItem = false; } else if( !f.isReadable() ) { emit infoMessage( i18n("Could not read file %1. Skipping...").arg(item->localPath()), WARNING ); writeItem = false; } } if( writeItem ) { num++; // some versions of mkisofs seem to have a bug that prevents to use filenames // that contain one or more backslashes if( item->writtenPath().contains("\\") ) m_containsFilesWithMultibleBackslashes = true; if( item->isDir() ) { stream << escapeGraftPoint( item->writtenPath() ) << "=" << escapeGraftPoint( dummyDir( static_cast<K3bDirItem*>(item) ) ) << "\n"; int x = writePathSpecForDir( dynamic_cast<K3bDirItem*>(item), stream ); if( x >= 0 ) num += x; else return -1; } else { writePathSpecForFile( static_cast<K3bFileItem*>(item), stream ); } } } return num; }
void OscapScannerLocal::evaluate() { if (mDryRun) { signalCompletion(mCancelRequested); return; } emit infoMessage(QObject::tr("Querying capabilities...")); try { fillInCapabilities(); } catch (std::exception& e) { emit errorMessage(e.what()); return; } if (!checkPrerequisites()) { mCancelRequested = true; signalCompletion(mCancelRequested); return; } // TODO: Error handling! // This is mainly for check-engine-results and oval-results, to ensure // we get a full report, including info from these files. openscap's XSLT // uses info in the check engine results if it can find them. QProcess process(this); emit infoMessage(QObject::tr("Creating temporary files...")); // This is mainly for check-engine-results and oval-results, to ensure // we get a full report, including info from these files. openscap's XSLT // uses info in the check engine results if it can find them. TemporaryDir workingDir; process.setWorkingDirectory(workingDir.getPath()); QStringList args; QTemporaryFile inputARFFile; QTemporaryFile arfFile; arfFile.setAutoRemove(true); setFilenameToTempFile(arfFile); QTemporaryFile reportFile; reportFile.setAutoRemove(true); setFilenameToTempFile(reportFile); QTemporaryFile resultFile; resultFile.setAutoRemove(true); setFilenameToTempFile(resultFile); if (mScannerMode == SM_OFFLINE_REMEDIATION) { inputARFFile.open(); inputARFFile.write(getARFForRemediation()); inputARFFile.close(); args = buildOfflineRemediationArgs(inputARFFile.fileName(), resultFile.fileName(), reportFile.fileName(), arfFile.fileName()); } else { args = buildEvaluationArgs(mSession->getOpenedFilePath(), mSession->hasTailoring() ? mSession->getTailoringFilePath() : QString(), resultFile.fileName(), reportFile.fileName(), arfFile.fileName(), mScannerMode == SM_SCAN_ONLINE_REMEDIATION); } QString program = getOscapProgramAndAdaptArgs(args); emit infoMessage(QObject::tr("Starting the oscap process...")); process.start(program, args); process.waitForStarted(); if (process.state() != QProcess::Running) { emit errorMessage(QObject::tr("Failed to start local scanning process '%1'. Perhaps the executable was not found?").arg(program)); mCancelRequested = true; } unsigned int pollInterval = 100; emit infoMessage(QObject::tr("Processing...")); while (!process.waitForFinished(pollInterval)) { // read everything new readStdOut(process); watchStdErr(process); // pump the event queue, mainly because the user might want to cancel QAbstractEventDispatcher::instance(mScanThread)->processEvents(QEventLoop::AllEvents); if (mCancelRequested) { pollInterval = 1000; emit infoMessage(QObject::tr("Cancellation was requested! Terminating scanning...")); process.kill(); } } if (!mCancelRequested) { if (process.exitCode() == 1) // error happened { watchStdErr(process); // TODO: pass the diagnostics over emit errorMessage(QObject::tr("There was an error during evaluation! Exit code of the 'oscap' process was 1.")); // mark this run as canceled mCancelRequested = true; } else { // read everything left over readStdOut(process); watchStdErr(process); emit infoMessage(QObject::tr("The oscap tool has finished. Reading results...")); resultFile.open(); mResults = resultFile.readAll(); resultFile.close(); reportFile.open(); mReport = reportFile.readAll(); reportFile.close(); arfFile.open(); mARF = arfFile.readAll(); arfFile.close(); emit infoMessage(QObject::tr("Processing has been finished!")); } } else { emit infoMessage(QObject::tr("Scanning cancelled!")); } signalCompletion(mCancelRequested); }
bool OscapScannerBase::tryToReadStdOutChar(QProcess& process) { char readChar = '\0'; if (!process.getChar(&readChar)) return false; if (!mCapabilities.progressReporting()) return true; // We did read something but it's not in a format we can parse. if (readChar == ':') { switch (mReadingState) { case RS_READING_PREFIX: { // Openscap <= 1.2.10 (60fb9f0c98eee) sends this message through stdout if (mReadBuffer=="Downloading") { mReadingState = RS_READING_DOWNLOAD_FILE; } else { mLastRuleID = mReadBuffer; emit progressReport(mLastRuleID, "processing"); mReadingState = RS_READING_RULE_RESULT; } mReadBuffer = ""; } break; case RS_READING_RULE_RESULT: { emit warningMessage(QString( QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. " "':' encountered while not reading rule ID, newline and/or rule result are missing! " "Read buffer is '%1'.")).arg(mReadBuffer)); mReadBuffer = ""; } break; case RS_READING_DOWNLOAD_FILE: { // When fetching remote content, openscap will inform scap-workbench about // resources being downloaded. Keep any colon found in URL of file being downloaded. mReadBuffer.append(QChar::fromAscii(readChar)); } break; default: // noop break; } } else if (readChar == '\n') { switch(mReadingState) { case RS_READING_PREFIX: // If we found a '\n' while reading prefix, we might have received an error or // warning message through stdout. if (mReadBuffer.contains("--fetch-remote-resources")) { // If message is about --fetch-remote-resources, emit a nice warning. // This is needed for workbench to be able to handle messages from machines // running older versions of openscap. // From openscap version 1.2.11, this message is sent through stderr // and therefore is handled accordingly by workbench. emit warningMessage(guiFriendlyMessage(mReadBuffer)); } else { // No other error or warning messages are expected through stdout, // so it is likely that a parsing error occured. emit warningMessage(QString( QObject::tr("Error when parsing scan progress output from stdout of the 'oscap' process. " "Newline encountered while reading rule ID, rule result and/or ':' are missing! " "Read buffer is '%1'.")).arg(mReadBuffer)); } break; case RS_READING_RULE_RESULT: emit progressReport(mLastRuleID, mReadBuffer); break; case RS_READING_DOWNLOAD_FILE_STATUS: { QString downloadStatus = mReadBuffer.mid(1); if (downloadStatus == "ok") emit infoMessage(QString("Downloading of \"%1\" finished: %2").arg(mLastDownloadingFile).arg(downloadStatus)); else emit warningMessage(QString("Failed to download \"%1\"!").arg(mLastDownloadingFile)); } break; default: // noop break; } mReadingState = RS_READING_PREFIX; mReadBuffer = ""; } else if ( (readChar == '.') && (mReadingState == RS_READING_DOWNLOAD_FILE) && (mReadBuffer.endsWith(" .."))) { int urlLen = mReadBuffer.length(); urlLen -= 1; // without first space urlLen -= 3; // without "progress dots" mLastDownloadingFile = mReadBuffer.mid(1, urlLen); emit infoMessage(QString("Downloading of \"%1\"...").arg(mLastDownloadingFile)); mReadBuffer = ""; mReadingState = RS_READING_DOWNLOAD_FILE_STATUS; } else { // we know for sure that buffer[0] can only contain ASCII characters // (IDs and special keywords regarding rule status) mReadBuffer.append(QChar::fromAscii(readChar)); } return true; }
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 Job::onInfo(const QString& info) { emit infoMessage(this, info); }
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; } }
void AudioProjectConvertingJob::trackFinished( int trackIndex, const QString& /*filename*/ ) { emit infoMessage( i18n("Successfully converted track %1.", trackIndex), Job::MessageInfo ); }
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(); } }
void ConnectorOld::stringParser(QByteArray recv) { QString recvStr = codec->toUnicode(recv); QChar category = recvStr[0]; // First symbol of string QStringList message = recvStr.mid(1).split("\t"); // Remove first symbol & splitting QString cmd; switch (category.toAscii()) { case 'R': // Authentification request qDebug() << "CONN :: Auth_req:" << message; emit authRequestRecv(message.at(0)); break; case 'b': // Information qDebug() << "CONN :: Inform:" << message; emit infoMessage(message.at(0)); // Verify for success auth string if (message.at(0).split(" ").count() == 7) if (message.at(0).split(" ").at(2).at(8) == ',') emit authSuccess(); break; case 'd': // Board cmd = message.at(0); if (cmd == "channels") // Receved channel list { qDebug() << "CONN :: Board: channels recv"; message.pop_front(); // Remove command from message emit boardChannelsRecv(parseBoardChannels(message.join("\t"))); } else { if (cmd == "new") // New messages { qDebug() << "CONN :: Board: new messages avaible"; emit boardNewMessages(); } else { if (cmd == "skins") { qDebug() << "CONN :: Board: \"skins\" cmd recv"; } else { if (cmd == "admin") { qDebug() << "CONN :: Board: \"admin\" cmd recv"; } else { qDebug() << "CONN :: Board: messages recv"; emit boardMessagesRecv(parseBoardMessages(message.join("\t"))); } } } } // qDebug() << "DBoard :: " << message; break; case 'c': // Chat cmd = message.at(0); message.pop_front(); // Remove command from message if (cmd == "main") { qDebug() << "CONN :: Chat: channel message recv"; emit chatPublicMessage(message.at(0), getUserIdByName(message.at(0), message.at(2)), message.at(3)); } else { if (cmd == "enter") { QString channelId = message.at(0); if (QHostAddress().setAddress(channelId)) { qDebug() << "CONN :: Host entered" << message.at(2) << "@" << channelId; } else { qDebug() << "CONN :: Chat: new user entered" << message.at(3); emit chatUserEnter(channelId, parseEnteredUser(message)); } } else { if (cmd == "leave") { QString channelId = message.at(0); if (QHostAddress().setAddress(channelId)) { qDebug() << "CONN :: Host leave" << message.at(2) << "@" << channelId; } else { shared_ptr<ChatChannel> ch = getChatInstance()->getChannel(channelId); bool online; // Verify for user connect state ch->getUser(message.at(2), &online); if (online) { qDebug() << "CONN :: Chat: user leave" << message.at(3); emit chatUserLeave(channelId, message.at(2)); } } } else { if (cmd == "private") { qDebug() << "CONN :: Chat: new private message"; emit chatPrivateMessage(parseChatPrivate(message)); } else { if (cmd == "infoGet") { qDebug() << "CONN :: Chat: \"infoGet\" cmd recv"; } else { if (cmd == "channels") { qDebug() << "CONN :: Chat: channels recv"; emit chatChannelsRecv(parseChatChannels(message.join("\t"))); } else { if (cmd == "userlist") { qDebug() << "CONN :: Chat: userlist recv"; emit chatUsersRecv(message.at(0), parseChatUsers(message)); } else { if (cmd == "privateresived") { emit chatPrivateDelivered( message.at(0), message.at(1), message.at(2)); } else qDebug() << "CONN ::" << cmd << message; } } } } } } } // qDebug() << "Chat :: " << message; break; default: // Uncategorised qDebug() << "Unctg :: " << recvStr; } }
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 ); } }