File indexing completed on 2024-05-12 04:51:08

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "k3bmovixjob.h"
0007 #include "k3bmovixdoc.h"
0008 #include "k3bmovixfileitem.h"
0009 #include "k3bmovixdocpreparer.h"
0010 #include "k3bcore.h"
0011 #include "k3bdatajob.h"
0012 #include "k3bdevice.h"
0013 #include "k3bisooptions.h"
0014 #include "k3b_i18n.h"
0015 
0016 #include <QDebug>
0017 
0018 
0019 K3b::MovixJob::MovixJob( K3b::MovixDoc* doc, K3b::JobHandler* jh, QObject* parent )
0020     : K3b::BurnJob( jh, parent ),
0021       m_doc(doc)
0022 {
0023     m_dataJob = new K3b::DataJob( doc, this, this );
0024     m_movixDocPreparer = new K3b::MovixDocPreparer( doc, this, this );
0025 
0026     // pipe signals
0027     connect( m_dataJob, SIGNAL(percent(int)), this, SIGNAL(percent(int)) );
0028     connect( m_dataJob, SIGNAL(subPercent(int)), this, SIGNAL(subPercent(int)) );
0029     connect( m_dataJob, SIGNAL(processedSubSize(int,int)), this, SIGNAL(processedSubSize(int,int)) );
0030     connect( m_dataJob, SIGNAL(processedSize(int,int)), this, SIGNAL(processedSize(int,int)) );
0031     connect( m_dataJob, SIGNAL(bufferStatus(int)), this, SIGNAL(bufferStatus(int)) );
0032     connect( m_dataJob, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) );
0033     connect( m_dataJob, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)), this, SIGNAL(writeSpeed(int,K3b::Device::SpeedMultiplicator)) );
0034     connect( m_dataJob, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) );
0035     connect( m_dataJob, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) );
0036     connect( m_dataJob, SIGNAL(debuggingOutput(QString,QString)),
0037              this, SIGNAL(debuggingOutput(QString,QString)) );
0038     connect( m_dataJob, SIGNAL(infoMessage(QString,int)),
0039              this, SIGNAL(infoMessage(QString,int)) );
0040     connect( m_dataJob, SIGNAL(burning(bool)), this, SIGNAL(burning(bool)) );
0041 
0042     // we need to clean up here
0043     connect( m_dataJob, SIGNAL(finished(bool)), this, SLOT(slotDataJobFinished(bool)) );
0044 
0045     connect( m_movixDocPreparer, SIGNAL(infoMessage(QString,int)),
0046              this, SIGNAL(infoMessage(QString,int)) );
0047 }
0048 
0049 
0050 K3b::MovixJob::~MovixJob()
0051 {
0052 }
0053 
0054 
0055 K3b::Device::Device* K3b::MovixJob::writer() const
0056 {
0057     return m_dataJob->writer();
0058 }
0059 
0060 
0061 K3b::Doc* K3b::MovixJob::doc() const
0062 {
0063     return m_doc;
0064 }
0065 
0066 
0067 void K3b::MovixJob::start()
0068 {
0069     jobStarted();
0070 
0071     m_canceled = false;
0072     m_dataJob->setWritingApp( writingApp() );
0073 
0074     if( m_movixDocPreparer->createMovixStructures() ) {
0075         m_dataJob->start();
0076     }
0077     else {
0078         m_movixDocPreparer->removeMovixStructures();
0079         jobFinished(false);
0080     }
0081 }
0082 
0083 
0084 void K3b::MovixJob::cancel()
0085 {
0086     m_canceled = true;
0087     m_dataJob->cancel();
0088 }
0089 
0090 
0091 void K3b::MovixJob::slotDataJobFinished( bool success )
0092 {
0093     m_movixDocPreparer->removeMovixStructures();
0094 
0095     if( m_canceled || m_dataJob->hasBeenCanceled() )
0096         emit canceled();
0097 
0098     jobFinished( success );
0099 }
0100 
0101 
0102 QString K3b::MovixJob::jobDescription() const
0103 {
0104     if( m_doc->isoOptions().volumeID().isEmpty() )
0105         return i18n("Writing eMovix Project");
0106     else
0107         return i18n("Writing eMovix Project (%1)",m_doc->isoOptions().volumeID());
0108 }
0109 
0110 
0111 QString K3b::MovixJob::jobDetails() const
0112 {
0113     return ( i18np("One file (%2) and about 8 MB eMovix data",
0114                    "%1 files (%2) and about 8 MB eMovix data",
0115                    m_doc->movixFileItems().count(), KIO::convertSize(m_doc->size()))
0116              + ( m_doc->copies() > 1
0117                  ? i18np(" – One copy", " – %1 copies", m_doc->copies())
0118                  : QString() ) );
0119 }
0120 
0121 #include "moc_k3bmovixjob.cpp"