From 50b48aec6ddd451a6d1709c0942477b503457663 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 3 Feb 2010 02:15:56 +0000 Subject: Added abandoned KDE3 version of K3B git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k3b@1084400 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libk3b/projects/datadvd/Makefile.am | 21 ++ libk3b/projects/datadvd/k3bdvdbooktypejob.cpp | 350 ++++++++++++++++++++++++++ libk3b/projects/datadvd/k3bdvdbooktypejob.h | 99 ++++++++ libk3b/projects/datadvd/k3bdvddoc.cpp | 39 +++ libk3b/projects/datadvd/k3bdvddoc.h | 37 +++ libk3b/projects/datadvd/k3bdvdjob.cpp | 344 +++++++++++++++++++++++++ libk3b/projects/datadvd/k3bdvdjob.h | 57 +++++ libk3b/projects/datadvd/k3bdvdview.cpp | 48 ++++ libk3b/projects/datadvd/k3bdvdview.h | 40 +++ 9 files changed, 1035 insertions(+) create mode 100644 libk3b/projects/datadvd/Makefile.am create mode 100644 libk3b/projects/datadvd/k3bdvdbooktypejob.cpp create mode 100644 libk3b/projects/datadvd/k3bdvdbooktypejob.h create mode 100644 libk3b/projects/datadvd/k3bdvddoc.cpp create mode 100644 libk3b/projects/datadvd/k3bdvddoc.h create mode 100644 libk3b/projects/datadvd/k3bdvdjob.cpp create mode 100644 libk3b/projects/datadvd/k3bdvdjob.h create mode 100644 libk3b/projects/datadvd/k3bdvdview.cpp create mode 100644 libk3b/projects/datadvd/k3bdvdview.h (limited to 'libk3b/projects/datadvd') diff --git a/libk3b/projects/datadvd/Makefile.am b/libk3b/projects/datadvd/Makefile.am new file mode 100644 index 0000000..99ae10c --- /dev/null +++ b/libk3b/projects/datadvd/Makefile.am @@ -0,0 +1,21 @@ +# we need the ../datacd for the uic generated header files +AM_CPPFLAGS= -I$(srcdir)/../../core \ + -I$(srcdir)/../../../libk3bdevice \ + -I$(srcdir)/../../../src \ + -I$(srcdir)/../../tools \ + -I$(srcdir)/../../jobs \ + -I$(srcdir)/../datacd \ + -I$(srcdir)/.. \ + -I../datacd \ + $(all_includes) + +METASOURCES = AUTO + +noinst_LTLIBRARIES = libdvd.la + +libdvd_la_SOURCES = k3bdvddoc.cpp \ + k3bdvdjob.cpp \ + k3bdvdbooktypejob.cpp + +include_HEADERS = k3bdvddoc.h \ + k3bdvdjob.h diff --git a/libk3b/projects/datadvd/k3bdvdbooktypejob.cpp b/libk3b/projects/datadvd/k3bdvdbooktypejob.cpp new file mode 100644 index 0000000..f703452 --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdbooktypejob.cpp @@ -0,0 +1,350 @@ +/* + * + * $Id: k3bdvdbooktypejob.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#include "k3bdvdbooktypejob.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + + +class K3bDvdBooktypeJob::Private +{ +public: + Private() + : device(0), + process(0), + dvdBooktypeBin(0), + running(false), + forceNoEject(false) { + } + + K3bDevice::Device* device; + K3bProcess* process; + const K3bExternalBin* dvdBooktypeBin; + + bool success; + bool canceled; + bool running; + + bool forceNoEject; + + int foundMediaType; +}; + + +K3bDvdBooktypeJob::K3bDvdBooktypeJob( K3bJobHandler* jh, QObject* parent, const char* name ) + : K3bJob( jh, parent, name ), + m_action(0) +{ + d = new Private; +} + + +K3bDvdBooktypeJob::~K3bDvdBooktypeJob() +{ + delete d->process; + delete d; +} + + +void K3bDvdBooktypeJob::setForceNoEject( bool b ) +{ + d->forceNoEject = b; +} + + +QString K3bDvdBooktypeJob::jobDescription() const +{ + return i18n("Changing DVD Booktype"); // Changing DVD±R(W) Booktype +} + + +QString K3bDvdBooktypeJob::jobDetails() const +{ + return QString::null; +} + + +void K3bDvdBooktypeJob::start() +{ + d->canceled = false; + d->running = true; + + jobStarted(); + + if( !d->device ) { + emit infoMessage( i18n("No device set"), ERROR ); + jobFinished(false); + d->running = false; + return; + } + + // + // In case we want to change the writers default we do not need to wait for a media + // + if( m_action == SET_MEDIA_DVD_ROM || + m_action == SET_MEDIA_DVD_R_W ) { + emit newSubTask( i18n("Waiting for media") ); + if( waitForMedia( d->device, + K3bDevice::STATE_COMPLETE|K3bDevice::STATE_INCOMPLETE|K3bDevice::STATE_EMPTY, + K3bDevice::MEDIA_DVD_PLUS_RW|K3bDevice::MEDIA_DVD_PLUS_R, + i18n("Please insert an empty DVD+R or a DVD+RW medium into drive

%1 %2 (%3).") + .arg(d->device->vendor()).arg(d->device->description()).arg(d->device->devicename()) ) == -1 ) { + emit canceled(); + jobFinished(false); + d->running = 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*)) ); + } + else { + // change writer defaults + startBooktypeChange(); + } +} + + +void K3bDvdBooktypeJob::start( K3bDevice::DeviceHandler* dh ) +{ + d->canceled = false; + d->running = true; + + jobStarted(); + + slotDeviceHandlerFinished( dh ); +} + + +void K3bDvdBooktypeJob::cancel() +{ + if( d->running ) { + d->canceled = true; + if( d->process ) + d->process->kill(); + } + else { + kdDebug() << "(K3bDvdBooktypeJob) not running." << endl; + } +} + + +void K3bDvdBooktypeJob::setDevice( K3bDevice::Device* dev ) +{ + d->device = dev; +} + + +void K3bDvdBooktypeJob::slotStderrLine( const QString& line ) +{ + emit debuggingOutput( "dvd+rw-booktype", line ); + // FIXME +} + + +void K3bDvdBooktypeJob::slotProcessFinished( KProcess* p ) +{ + if( d->canceled ) { + emit canceled(); + d->success = false; + } + else if( p->normalExit() ) { + if( p->exitStatus() == 0 ) { + emit infoMessage( i18n("Booktype successfully changed"), K3bJob::SUCCESS ); + d->success = true; + } + else { + emit infoMessage( i18n("%1 returned an unknown error (code %2).").arg(d->dvdBooktypeBin->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->dvdBooktypeBin->name()), + ERROR ); + d->success = false; + } + + // + // No need to eject the media if we changed the writer's default + // + if( m_action == SET_MEDIA_DVD_ROM || + m_action == SET_MEDIA_DVD_R_W ) { + + 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*)) ); + } + } + else { + d->running = false; + jobFinished(d->success); + } +} + + +void K3bDvdBooktypeJob::slotEjectingFinished( K3bDevice::DeviceHandler* dh ) +{ + if( !dh->success() ) + emit infoMessage( i18n("Unable to eject media."), ERROR ); + + d->running = false; + jobFinished(d->success); +} + + +void K3bDvdBooktypeJob::slotDeviceHandlerFinished( K3bDevice::DeviceHandler* dh ) +{ + if( d->canceled ) { + emit canceled(); + d->running = false; + jobFinished(false); + } + + if( dh->success() ) { + + d->foundMediaType = dh->diskInfo().mediaType(); + if( d->foundMediaType == K3bDevice::MEDIA_DVD_PLUS_R ) { + // the media needs to be empty + if( dh->diskInfo().empty() ) + startBooktypeChange(); + else { + emit infoMessage( i18n("Cannot change booktype on non-empty DVD+R media."), ERROR ); + jobFinished(false); + } + } + else if( d->foundMediaType == K3bDevice::MEDIA_DVD_PLUS_RW ) { + startBooktypeChange(); + } + else { + emit infoMessage( i18n("No DVD+R(W) media found."), ERROR ); + jobFinished(false); + } + } + else { + emit infoMessage( i18n("Unable to determine media state."), ERROR ); + d->running = false; + jobFinished(false); + } +} + + +void K3bDvdBooktypeJob::startBooktypeChange() +{ + delete d->process; + d->process = new K3bProcess(); + d->process->setRunPrivileged(true); + d->process->setSuppressEmptyLines(true); + connect( d->process, SIGNAL(stderrLine(const QString&)), this, SLOT(slotStderrLine(const QString&)) ); + connect( d->process, SIGNAL(processExited(KProcess*)), this, SLOT(slotProcessFinished(KProcess*)) ); + + d->dvdBooktypeBin = k3bcore->externalBinManager()->binObject( "dvd+rw-booktype" ); + if( !d->dvdBooktypeBin ) { + emit infoMessage( i18n("Could not find %1 executable.").arg("dvd+rw-booktype"), ERROR ); + d->running = false; + jobFinished(false); + return; + } + + *d->process << d->dvdBooktypeBin; + + switch( m_action ) { + case SET_MEDIA_DVD_ROM: + *d->process << "-dvd-rom-spec" + << "-media"; + break; + case SET_MEDIA_DVD_R_W: + if( d->foundMediaType == K3bDevice::MEDIA_DVD_PLUS_RW ) + *d->process << "-dvd+rw-spec"; + else + *d->process << "-dvd+r-spec"; + *d->process << "-media"; + break; + case SET_UNIT_DVD_ROM_ON_NEW_DVD_R: + *d->process << "-dvd-rom-spec" + << "-unit+r"; + break; + case SET_UNIT_DVD_ROM_ON_NEW_DVD_RW: + *d->process << "-dvd-rom-spec" + << "-unit+rw"; + break; + case SET_UNIT_DVD_R_ON_NEW_DVD_R: + *d->process << "-dvd+r-spec" + << "-unit+r"; + break; + case SET_UNIT_DVD_RW_ON_NEW_DVD_RW: + *d->process << "-dvd+rw-spec" + << "-unit+rw"; + break; + } + + *d->process << d->device->blockDeviceName(); + + kdDebug() << "***** dvd+rw-booktype parameters:\n"; + const QValueList& args = d->process->args(); + QString s; + for( QValueList::const_iterator it = args.begin(); it != args.end(); ++it ) { + s += *it + " "; + } + kdDebug() << s << endl << flush; + emit debuggingOutput( "dvd+rw-booktype command:", s ); + + + if( !d->process->start( KProcess::NotifyOnExit, KProcess::All ) ) { + // something went wrong when starting the program + // it "should" be the executable + emit infoMessage( i18n("Could not start %1.").arg(d->dvdBooktypeBin->name()), K3bJob::ERROR ); + d->running = false; + jobFinished(false); + } + else { + emit newTask( i18n("Changing Booktype") ); + } +} + +#include "k3bdvdbooktypejob.moc" diff --git a/libk3b/projects/datadvd/k3bdvdbooktypejob.h b/libk3b/projects/datadvd/k3bdvdbooktypejob.h new file mode 100644 index 0000000..b9e7e4b --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdbooktypejob.h @@ -0,0 +1,99 @@ +/* + * + * $Id: k3bdvdbooktypejob.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#ifndef _K3B_DVD_BOOKTYPE_JOB_H_ +#define _K3B_DVD_BOOKTYPE_JOB_H_ + + +#include + + +class KProcess; +namespace K3bDevice { + class Device; + class DeviceHandler; +} + + +/** + * This job can change the compatibility bit of DVD+R(W) media + * with supported dvd writers. + */ +class K3bDvdBooktypeJob : public K3bJob +{ + Q_OBJECT + + public: + K3bDvdBooktypeJob( K3bJobHandler*, QObject* parent = 0, const char* name = 0 ); + ~K3bDvdBooktypeJob(); + + QString jobDescription() const; + QString jobDetails() const; + + /** + * @list SET_MEDIA_DVD_ROM Change media identification on current media to DVD-ROM. + * @list SET_MEDIA_DVD_R_W Change media identification on current media to DVD+R or DVD+RW. + * @list SET_UNIT_DVD_ROM_ON_NEW_DVD_R Set the drive to write DVD-ROM specification on future written DVD+R discs. + * @list SET_UNIT_DVD_ROM_ON_NEW_DVD_RW Set the drive to write DVD-ROM specification on future written DVD+RW discs. + * @list SET_UNIT_DVD_R_ON_NEW_DVD_R Set the drive to write DVD+R specification on future written DVD+R discs. + * @list SET_UNIT_DVD_RW_ON_NEW_DVD_RW Set the drive to write DVD+RW specification on future written DVD+RW discs. + */ + enum Action { + SET_MEDIA_DVD_ROM, + SET_MEDIA_DVD_R_W, + SET_UNIT_DVD_ROM_ON_NEW_DVD_R, + SET_UNIT_DVD_ROM_ON_NEW_DVD_RW, + SET_UNIT_DVD_R_ON_NEW_DVD_R, + SET_UNIT_DVD_RW_ON_NEW_DVD_RW + }; + + public slots: + void start(); + + /** + * The devicehandler needs to have a valid NgDiskInfo + * Use this to prevent the job from searching a media. + */ + void start( K3bDevice::DeviceHandler* ); + + void cancel(); + + void setDevice( K3bDevice::Device* ); + + void setAction( int a ) { m_action = a; } + + /** + * If set true the job ignores the global K3b setting + * and does not eject the CD-RW after finishing + */ + void setForceNoEject( bool ); + + private slots: + void slotStderrLine( const QString& ); + void slotProcessFinished( KProcess* ); + void slotDeviceHandlerFinished( K3bDevice::DeviceHandler* ); + void slotEjectingFinished( K3bDevice::DeviceHandler* ); + + private: + void startBooktypeChange(); + + int m_action; + + class Private; + Private* d; +}; + + +#endif diff --git a/libk3b/projects/datadvd/k3bdvddoc.cpp b/libk3b/projects/datadvd/k3bdvddoc.cpp new file mode 100644 index 0000000..4ab8b9f --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvddoc.cpp @@ -0,0 +1,39 @@ +/* + * + * $Id: k3bdvddoc.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#include "k3bdvddoc.h" +#include "k3bdvdjob.h" + +#include + +#include + + +K3bDvdDoc::K3bDvdDoc( QObject* parent ) + : K3bDataDoc( parent ) +{ +} + +K3bDvdDoc::~K3bDvdDoc() +{ +} + +K3bBurnJob* K3bDvdDoc::newBurnJob( K3bJobHandler* hdl, QObject* parent ) +{ + return new K3bDvdJob( this, hdl, parent ); +} + +//#include "k3bdvddoc.moc" diff --git a/libk3b/projects/datadvd/k3bdvddoc.h b/libk3b/projects/datadvd/k3bdvddoc.h new file mode 100644 index 0000000..03b5c3d --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvddoc.h @@ -0,0 +1,37 @@ +/* + * + * $Id: k3bdvddoc.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#ifndef _K3B_DVDDOC_H_ +#define _K3B_DVDDOC_H_ + +#include +#include "k3b_export.h" +class KConfig; + +class LIBK3B_EXPORT K3bDvdDoc : public K3bDataDoc +{ + public: + K3bDvdDoc( QObject* parent = 0 ); + virtual ~K3bDvdDoc(); + + virtual int type() const { return DVD; } + + virtual K3bBurnJob* newBurnJob( K3bJobHandler* hdl, QObject* parent = 0 ); + + protected: + virtual QString typeString() const { return "dvd"; } +}; + +#endif diff --git a/libk3b/projects/datadvd/k3bdvdjob.cpp b/libk3b/projects/datadvd/k3bdvdjob.cpp new file mode 100644 index 0000000..3cd1521 --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdjob.cpp @@ -0,0 +1,344 @@ +/* + * + * $Id: k3bdvdjob.cpp 690187 2007-07-20 09:18:03Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#include "k3bdvdjob.h" +#include "k3bdvddoc.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +class K3bDvdJob::Private +{ +public: +}; + + +K3bDvdJob::K3bDvdJob( K3bDataDoc* doc, K3bJobHandler* hdl, QObject* parent ) + : K3bDataJob( doc, hdl, parent ), + m_doc( doc ) +{ + d = new Private(); +} + + +K3bDvdJob::~K3bDvdJob() +{ + delete d; +} + + +void K3bDvdJob::prepareData() +{ +} + + +bool K3bDvdJob::prepareWriterJob() +{ + K3bGrowisofsWriter* writer = new K3bGrowisofsWriter( m_doc->burner(), this, this ); + + // these do only make sense with DVD-R(W) + writer->setSimulate( m_doc->dummy() ); + writer->setBurnSpeed( m_doc->speed() ); + + // Andy said incremental sequential is the default mode and it seems uses have more problems with DAO anyway + // BUT: I also had a report that incremental sequential produced unreadable media! + if( m_doc->writingMode() == K3b::DAO ) +// || ( m_doc->writingMode() == K3b::WRITING_MODE_AUTO && +// usedMultiSessionMode() == K3bDataDoc::NONE ) ) + writer->setWritingMode( K3b::DAO ); + + writer->setMultiSession( usedMultiSessionMode() == K3bDataDoc::CONTINUE || + usedMultiSessionMode() == K3bDataDoc::FINISH ); + + writer->setCloseDvd( usedMultiSessionMode() == K3bDataDoc::NONE || + usedMultiSessionMode() == K3bDataDoc::FINISH ); + + writer->setImageToWrite( QString::null ); // read from stdin + writer->setTrackSize( m_isoImager->size() ); + + if( usedMultiSessionMode() != K3bDataDoc::NONE ) { + // + // growisofs wants a valid -C parameter for multisession, so we get it from the + // K3bMsInfoFetcher (see K3bDataJob::slotMsInfoFetched) + // + writer->setMultiSessionInfo( m_msInfoFetcher->msInfo() ); + } + + setWriterJob( writer ); + + return true; +} + + +void K3bDvdJob::determineMultiSessionMode() +{ + int m = requestMedia( K3bDevice::STATE_INCOMPLETE|K3bDevice::STATE_EMPTY ); + + if( m < 0 ) { + cancel(); + } + else { + connect( K3bDevice::sendCommand( K3bDevice::DeviceHandler::NG_DISKINFO, m_doc->burner() ), + SIGNAL(finished(K3bDevice::DeviceHandler*)), + this, + SLOT(slotDetermineMultiSessionMode(K3bDevice::DeviceHandler*)) ); + } +} + + +K3bDataDoc::MultiSessionMode K3bDvdJob::getMultiSessionMode( const K3bDevice::DiskInfo& info ) +{ + K3bDataDoc::MultiSessionMode mode = K3bDataDoc::NONE; + + if( info.mediaType() & (K3bDevice::MEDIA_DVD_PLUS_RW|K3bDevice::MEDIA_DVD_RW_OVWR) ) { + // + // we need to handle DVD+RW and DVD-RW overwrite media differently since remainingSize() is not valid + // in both cases + // Since one never closes a DVD+RW we only differ between CONTINUE and START + // + + // try to check the filesystem size + K3bIso9660 iso( m_doc->burner() ); + if( iso.open() && info.capacity() - iso.primaryDescriptor().volumeSpaceSize >= m_doc->burningLength() ) { + mode = K3bDataDoc::CONTINUE; + } + else { + mode = K3bDataDoc::START; + } + } + else if( info.appendable() ) { + // + // 3 cases: + // 1. the project does not fit -> no multisession (resulting in asking for another media above) + // 2. the project does fit and fills up the CD (No new sessions after the 4GB boundary) -> finish multisession + // 3. the project does fit and does not fill up the CD -> continue multisession + // + if( m_doc->size() > info.remainingSize().mode1Bytes() && !m_doc->sessionImported() ) + mode = K3bDataDoc::NONE; + else if( info.size() + m_doc->burningLength() + 11400 /* used size + project size + session gap */ > 2097152 /* 4 GB */ ) + mode = K3bDataDoc::FINISH; + else + mode = K3bDataDoc::CONTINUE; + } + else { + // + // We only close the DVD if the project fills it beyond the 4GB boundary + // + if( info.size() + m_doc->burningLength() + 11400 /* used size + project size + session gap */ > 2097152 /* 4 GB */ || + m_doc->writingMode() == K3b::DAO ) + mode = K3bDataDoc::NONE; + else + mode = K3bDataDoc::START; + } + + return mode; +} + + +int K3bDvdJob::requestMedia( int state ) +{ + int mt = 0; + if( m_doc->writingMode() == K3b::WRITING_MODE_RES_OVWR ) // we treat DVD+R(W) as restricted overwrite media + mt = K3bDevice::MEDIA_DVD_RW_OVWR|K3bDevice::MEDIA_DVD_PLUS_RW|K3bDevice::MEDIA_DVD_PLUS_R; + else + mt = K3bDevice::MEDIA_WRITABLE_DVD; + + // double layer media + // in case overburn is enabled we allow some made up max size + // before we force a DL medium + if( m_doc->size() > 4700372992LL ) { + if( !k3bcore->globalSettings()->overburn() || + m_doc->size() > 4900000000LL ) { + mt = K3bDevice::MEDIA_WRITABLE_DVD_DL; + } + } + + return waitForMedia( m_doc->burner(), + state, + mt ); +} + + +bool K3bDvdJob::waitForMedium() +{ + emit infoMessage( i18n("Waiting for media") + "...", INFO ); + + int foundMedium = requestMedia( usedMultiSessionMode() == K3bDataDoc::CONTINUE || + usedMultiSessionMode() == K3bDataDoc::FINISH ? + K3bDevice::STATE_INCOMPLETE : + K3bDevice::STATE_EMPTY ); + + if( foundMedium < 0 || hasBeenCanceled() ) { + return false; + } + + if( foundMedium == 0 ) { + emit infoMessage( i18n("Forced by user. Growisofs will be called without further tests."), INFO ); + } + + else { + // ------------------------------- + // DVD Plus + // ------------------------------- + if( foundMedium & K3bDevice::MEDIA_DVD_PLUS_ALL ) { + if( m_doc->dummy() ) { + if( !questionYesNo( i18n("K3b does not support simulation with DVD+R(W) media. " + "Do you really want to continue? The media will be written " + "for real."), + i18n("No Simulation with DVD+R(W)") ) ) { + return false; + } + + m_doc->setDummy( false ); + emit newTask( i18n("Writing") ); + } + + if( m_doc->writingMode() != K3b::WRITING_MODE_AUTO && m_doc->writingMode() != K3b::WRITING_MODE_RES_OVWR ) + emit infoMessage( i18n("Writing mode ignored when writing DVD+R(W) media."), INFO ); + + if( foundMedium & K3bDevice::MEDIA_DVD_PLUS_RW ) { + if( usedMultiSessionMode() == K3bDataDoc::NONE || + usedMultiSessionMode() == K3bDataDoc::START ) + emit infoMessage( i18n("Writing DVD+RW."), INFO ); + else + emit infoMessage( i18n("Growing ISO9660 filesystem on DVD+RW."), INFO ); + } + else if( foundMedium & K3bDevice::MEDIA_DVD_PLUS_R_DL ) + emit infoMessage( i18n("Writing Double Layer DVD+R."), INFO ); + else + emit infoMessage( i18n("Writing DVD+R."), INFO ); + } + + // ------------------------------- + // DVD Minus + // ------------------------------- + else { + if( m_doc->dummy() && !m_doc->burner()->dvdMinusTestwrite() ) { + if( !questionYesNo( i18n("Your writer (%1 %2) does not support simulation with DVD-R(W) media. " + "Do you really want to continue? The media will be written " + "for real.") + .arg(m_doc->burner()->vendor()) + .arg(m_doc->burner()->description()), + i18n("No Simulation with DVD-R(W)") ) ) { + return false; + } + + m_doc->setDummy( false ); + } + + // RESTRICTED OVERWRITE + // -------------------- + if( foundMedium & K3bDevice::MEDIA_DVD_RW_OVWR ) { + if( usedMultiSessionMode() == K3bDataDoc::NONE || + usedMultiSessionMode() == K3bDataDoc::START ) + emit infoMessage( i18n("Writing DVD-RW in restricted overwrite mode."), INFO ); + else + emit infoMessage( i18n("Growing ISO9660 filesystem on DVD-RW in restricted overwrite mode."), INFO ); + } + + // NORMAL + // ------ + else { + + // FIXME: DVD-R DL jump and stuff + + if( m_doc->writingMode() == K3b::DAO ) + // || ( m_doc->writingMode() == K3b::WRITING_MODE_AUTO && +// usedMultiSessionMode() == K3bDataDoc::NONE ) ) + emit infoMessage( i18n("Writing %1 in DAO mode.").arg( K3bDevice::mediaTypeString(foundMedium, true) ), INFO ); + + else { + // check if the writer supports writing sequential and thus multisession (on -1 the burner cannot handle + // features and we simply ignore it and hope for the best) + if( m_doc->burner()->featureCurrent( K3bDevice::FEATURE_INCREMENTAL_STREAMING_WRITABLE ) == 0 ) { + if( !questionYesNo( i18n("Your writer (%1 %2) does not support Incremental Streaming with %3 " + "media. Multisession will not be possible. Continue anyway?") + .arg(m_doc->burner()->vendor()) + .arg(m_doc->burner()->description()) + .arg( K3bDevice::mediaTypeString(foundMedium, true) ), + i18n("No Incremental Streaming") ) ) { + return false; + } + else { + emit infoMessage( i18n("Writing %1 in DAO mode.").arg( K3bDevice::mediaTypeString(foundMedium, true) ), INFO ); + } + } + else { + if( !(foundMedium & (K3bDevice::MEDIA_DVD_RW|K3bDevice::MEDIA_DVD_RW_OVWR|K3bDevice::MEDIA_DVD_RW_SEQ)) && + m_doc->writingMode() == K3b::WRITING_MODE_RES_OVWR ) + emit infoMessage( i18n("Restricted Overwrite is not possible with DVD-R media."), INFO ); + + emit infoMessage( i18n("Writing %1 in incremental mode.").arg( K3bDevice::mediaTypeString(foundMedium, true) ), INFO ); + } + } + } + } + } + + return true; +} + + +QString K3bDvdJob::jobDescription() const +{ + if( m_doc->onlyCreateImages() ) { + return i18n("Creating Data Image File"); + } + else if( m_doc->multiSessionMode() == K3bDataDoc::NONE || + m_doc->multiSessionMode() == K3bDataDoc::AUTO ) { + return i18n("Writing Data DVD") + + ( m_doc->isoOptions().volumeID().isEmpty() + ? QString::null + : QString( " (%1)" ).arg(m_doc->isoOptions().volumeID()) ); + } + else { + return i18n("Writing Multisession DVD") + + ( m_doc->isoOptions().volumeID().isEmpty() + ? QString::null + : QString( " (%1)" ).arg(m_doc->isoOptions().volumeID()) ); + } +} + + +QString K3bDvdJob::jobDetails() const +{ + if( m_doc->copies() > 1 && + !m_doc->dummy() && + !(m_doc->multiSessionMode() == K3bDataDoc::CONTINUE || + m_doc->multiSessionMode() == K3bDataDoc::FINISH) ) + return i18n("ISO9660 Filesystem (Size: %1) - %n copy", + "ISO9660 Filesystem (Size: %1) - %n copies", + m_doc->copies()) + .arg(KIO::convertSize( m_doc->size() )); + else + return i18n("ISO9660 Filesystem (Size: %1)") + .arg(KIO::convertSize( m_doc->size() )); +} + +#include "k3bdvdjob.moc" diff --git a/libk3b/projects/datadvd/k3bdvdjob.h b/libk3b/projects/datadvd/k3bdvdjob.h new file mode 100644 index 0000000..381bc1d --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdjob.h @@ -0,0 +1,57 @@ +/* + * + * $Id: k3bdvdjob.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#ifndef _K3B_DVD_JOB_H_ +#define _K3B_DVD_JOB_H_ + +#include + +#include + +class K3bDataDoc; +class K3bGrowisofsWriter; + + +class K3bDvdJob : public K3bDataJob +{ + Q_OBJECT + + public: + /** + * To be more flexible we allow writing of any data doc + */ + K3bDvdJob( K3bDataDoc*, K3bJobHandler*, QObject* parent = 0 ); + virtual ~K3bDvdJob(); + + virtual QString jobDescription() const; + virtual QString jobDetails() const; + + protected: + void prepareData(); + virtual bool prepareWriterJob(); + void determineMultiSessionMode(); + K3bDataDoc::MultiSessionMode getMultiSessionMode( const K3bDevice::DiskInfo& ); + bool waitForMedium(); + int requestMedia( int state ); + + private: + K3bDataDoc* m_doc; + + class Private; + Private* d; +}; + +#endif diff --git a/libk3b/projects/datadvd/k3bdvdview.cpp b/libk3b/projects/datadvd/k3bdvdview.cpp new file mode 100644 index 0000000..512ec4b --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdview.cpp @@ -0,0 +1,48 @@ +/* + * + * $Id: k3bdvdview.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#include "k3bdvdview.h" +#include "k3bdvddoc.h" +#include "k3bdvdburndialog.h" +#include +#include + +#include + + +K3bDvdView::K3bDvdView( K3bDvdDoc* doc, QWidget *parent, const char *name ) + : K3bDataView( doc, parent, name ) +{ + m_doc = doc; + + fillStatusDisplay()->showDvdSizes(true); + + m_dataFileView->setNoItemText( i18n("Use drag'n'drop to add files and directories to the project.\n" + "To remove or rename files use the context menu.\n" + "After that press the burn button to write the DVD.") ); +} + + +K3bDvdView::~K3bDvdView() +{ +} + + +K3bProjectBurnDialog* K3bDvdView::newBurnDialog( QWidget* parent, const char* name ) +{ + return new K3bDvdBurnDialog( m_doc, parent, name, true ); +} + +#include "k3bdvdview.moc" diff --git a/libk3b/projects/datadvd/k3bdvdview.h b/libk3b/projects/datadvd/k3bdvdview.h new file mode 100644 index 0000000..d9f30f3 --- /dev/null +++ b/libk3b/projects/datadvd/k3bdvdview.h @@ -0,0 +1,40 @@ +/* + * + * $Id: k3bdvdview.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#ifndef _K3B_DVDVIEW_H_ +#define _K3B_DVDVIEW_H_ + +#include + +class K3bDvdDoc; + + +class K3bDvdView : public K3bDataView +{ + Q_OBJECT + + public: + K3bDvdView( K3bDvdDoc* doc, QWidget *parent = 0, const char *name = 0 ); + ~K3bDvdView(); + + protected: + virtual K3bProjectBurnDialog* newBurnDialog( QWidget* parent = 0, const char* name = 0 ); + + private: + K3bDvdDoc* m_doc; +}; + +#endif -- cgit v1.2.1