summaryrefslogtreecommitdiffstats
path: root/libk3b/plugin/k3baudioencoder.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
commit50b48aec6ddd451a6d1709c0942477b503457663 (patch)
treea9ece53ec06fd0a2819de7a2a6de997193566626 /libk3b/plugin/k3baudioencoder.cpp
downloadk3b-50b48aec6ddd451a6d1709c0942477b503457663.tar.gz
k3b-50b48aec6ddd451a6d1709c0942477b503457663.zip
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
Diffstat (limited to 'libk3b/plugin/k3baudioencoder.cpp')
-rw-r--r--libk3b/plugin/k3baudioencoder.cpp175
1 files changed, 175 insertions, 0 deletions
diff --git a/libk3b/plugin/k3baudioencoder.cpp b/libk3b/plugin/k3baudioencoder.cpp
new file mode 100644
index 0000000..3b1309a
--- /dev/null
+++ b/libk3b/plugin/k3baudioencoder.cpp
@@ -0,0 +1,175 @@
+/*
+ *
+ * $Id: k3baudioencoder.cpp 619556 2007-01-03 17:38:12Z trueg $
+ * Copyright (C) 2003 Sebastian Trueg <[email protected]>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <[email protected]>
+ *
+ * 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 "k3baudioencoder.h"
+
+#include <qfile.h>
+
+#include <kdebug.h>
+
+
+class K3bAudioEncoder::Private
+{
+public:
+ Private()
+ : outputFile(0) {
+ }
+
+ QFile* outputFile;
+ QString outputFilename;
+
+ QString lastErrorString;
+};
+
+
+K3bAudioEncoder::K3bAudioEncoder( QObject* parent, const char* name )
+ : K3bPlugin( parent, name )
+{
+ d = new Private();
+}
+
+
+K3bAudioEncoder::~K3bAudioEncoder()
+{
+ closeFile();
+ delete d;
+}
+
+
+bool K3bAudioEncoder::openFile( const QString& ext, const QString& filename, const K3b::Msf& length )
+{
+ closeFile();
+
+ d->outputFile = new QFile( filename );
+ if( d->outputFile->open( IO_WriteOnly ) ) {
+ return initEncoder( ext, length );
+ }
+ else {
+ kdDebug() << "(K3bAudioEncoder) unable to open file " << filename << endl;
+ closeFile();
+ return false;
+ }
+}
+
+
+bool K3bAudioEncoder::isOpen() const
+{
+ if( d->outputFile )
+ return d->outputFile->isOpen();
+ else
+ return false;
+}
+
+
+void K3bAudioEncoder::closeFile()
+{
+ if( d->outputFile ) {
+ finishEncoder();
+ if( d->outputFile->isOpen() )
+ d->outputFile->close();
+ delete d->outputFile;
+ d->outputFile = 0;
+ d->outputFilename = QString::null;
+ }
+}
+
+
+const QString& K3bAudioEncoder::filename() const
+{
+ if( d->outputFile )
+ return d->outputFilename;
+ else
+ return QString::null;
+}
+
+
+
+void K3bAudioEncoder::setMetaData( K3bAudioEncoder::MetaDataField f, const QString& data )
+{
+ if( !data.isEmpty() )
+ return setMetaDataInternal( f, data );
+}
+
+
+long K3bAudioEncoder::encode( const char* data, Q_ULONG len )
+{
+ return encodeInternal( data, len );
+}
+
+
+bool K3bAudioEncoder::initEncoder( const QString& ext, const K3b::Msf& length )
+{
+ if( !isOpen() ) {
+ kdDebug() << "(K3bAudioEncoder) call to initEncoder without openFile!" << endl;
+ return false;
+ }
+
+ return initEncoderInternal( ext, length );
+}
+
+
+Q_LONG K3bAudioEncoder::writeData( const char* data, Q_ULONG len )
+{
+ if( d->outputFile ) {
+ return d->outputFile->writeBlock( data, len );
+ }
+ else {
+ kdDebug() << "(K3bAudioEncoder) call to writeData without opening a file first." << endl;
+ return -1;
+ }
+}
+
+
+bool K3bAudioEncoder::initEncoderInternal( const QString&, const K3b::Msf& )
+{
+ // do nothing
+ return true;
+}
+
+
+void K3bAudioEncoder::setMetaDataInternal( K3bAudioEncoder::MetaDataField, const QString& )
+{
+ // do nothing
+}
+
+
+void K3bAudioEncoder::finishEncoder()
+{
+ if( isOpen() )
+ finishEncoderInternal();
+}
+
+
+void K3bAudioEncoder::finishEncoderInternal()
+{
+ // do nothing
+}
+
+
+void K3bAudioEncoder::setLastError( const QString& e )
+{
+ d->lastErrorString = e;
+}
+
+
+QString K3bAudioEncoder::lastErrorString() const
+{
+ if( d->lastErrorString.isEmpty() )
+ return i18n("An unknown error occurred.");
+ else
+ return d->lastErrorString;
+}
+
+#include "k3baudioencoder.moc"