/*! (Re)-creates the temporary file and opens it in \a mode. \internal */ bool recreateTemporaryFile( QIODevice::OpenMode mode ) { deleteTempFile(); bool ok = false; // first try, create it in the target directory tmpFile = createFile( generateTempFileName( filename, false ), mode, permissions, ok, error ); // second try, create it in the temp directory if( tmpFile == 0 ) tmpFile = createFile( generateTempFileName( filename, true ), mode, permissions, ok, error ); if( tmpFile != 0 ) { KDMetaMethodIterator it( QIODevice::staticMetaObject, KDMetaMethodIterator::Signal, KDMetaMethodIterator::IgnoreQObjectMethods ); while( it.hasNext() ) { it.next(); connect( tmpFile, it.connectableSignature(), q, it.connectableSignature() ); } #ifdef Q_OS_WIN makeFileHidden( tmpFile->fileName(), true ); #endif } return tmpFile != 0 && ok; }
void ProcessThread::processFile() { m_aborted = false; bool bSuccess = true; qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData()); emit processStateInitialized(m_jobId, QFileInfo(m_audioFile.filePath()).fileName(), tr("Starting..."), ProgressModel::JobRunning); handleMessage(QString().sprintf("LameXP v%u.%02u (Build #%u), compiled on %s at %s", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(), lamexp_version_time())); handleMessage("\n-------------------------------\n"); //Generate output file name QString outFileName = generateOutFileName(); if(outFileName.isEmpty()) { emit processStateChanged(m_jobId, tr("Not found!"), ProgressModel::JobFailed); emit processStateFinished(m_jobId, outFileName, false); return; } //Do we need to take care of downsampling the input? if(m_encoder->requiresDownsample()) { insertDownsampleFilter(); } //Do we need Stereo downmix? if(m_encoder->requiresDownmix()) { insertDownmixFilter(); } QString sourceFile = m_audioFile.filePath(); //Decode source file if(!m_filters.isEmpty() || !m_encoder->isFormatSupported(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion())) { m_currentStep = DecodingStep; AbstractDecoder *decoder = DecoderRegistry::lookup(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion()); if(decoder) { QString tempFile = generateTempFileName(); connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection); connect(decoder, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection); bSuccess = decoder->decode(sourceFile, tempFile, &m_aborted); LAMEXP_DELETE(decoder); if(bSuccess) { sourceFile = tempFile; handleMessage("\n-------------------------------\n"); } } else {