Commit 10d49b6f authored by Henrique Pinto's avatar Henrique Pinto
Browse files

* Rename LibArchiveHandler to ArchiveBase and move it to its own file,

   as it is actually generic, not tied to libarchive at all.

svn path=/branches/work/libarchive-based-ark/ark/; revision=686058
parent c403142b
......@@ -39,6 +39,7 @@ set(arkpart_PART_SRCS ${libark_common_SRCS}
archiveinterface.cpp
libarchivehandler.cpp
jobs.cpp
archivebase.cpp
#tar.cpp
#zip.cpp
#lha.cpp
......
......@@ -26,9 +26,8 @@
// ark includes
#include "arch.h"
#include "arkwidget.h"
#include "archivebase.h"
#include "arkutils.h"
#include "filelistview.h"
// C includes
#include <stdlib.h>
......@@ -70,6 +69,6 @@ Arch *Arch::archFactory( ArchType /*aType*/,
const QString &filename,
const QString &/*openAsMimeType*/ )
{
return new LibArchiveHandler( filename );
return new ArchiveBase( new LibArchiveInterface( filename ) );
}
#include "arch.moc"
/*
* Copyright (c) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "archivebase.h"
#include "jobs.h"
#include "settings.h"
#include <kdebug.h>
#include <ThreadWeaver/Job>
#include <ThreadWeaver/Weaver>
#include <QFile>
#include <QDir>
#include <QList>
#include <QStringList>
#include <QDateTime>
ArchiveBase::ArchiveBase( ReadOnlyArchiveInterface *archive )
: Arch( archive? archive->filename() : QString() ), m_iface( archive )
{
}
ArchiveBase::~ArchiveBase()
{
delete m_iface;
m_iface = 0;
}
void ArchiveBase::open()
{
ListingJob *job = new ListingJob( m_iface, this );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
this, SLOT( listingDone( ThreadWeaver::Job * ) ) );
connect( job, SIGNAL( entry( const ArchiveEntry & ) ),
this, SIGNAL( newEntry( const ArchiveEntry & ) ) );
ThreadWeaver::Weaver::instance()->enqueue( job );
}
void ArchiveBase::listingDone( ThreadWeaver::Job *job )
{
emit opened( job->success() );
delete job;
}
void ArchiveBase::create()
{
}
void ArchiveBase::addFile( const QStringList & )
{
}
void ArchiveBase::addDir( const QString & )
{
}
void ArchiveBase::remove( const QStringList & )
{
}
void ArchiveBase::extractFiles( const QList<QVariant> & files, const QString& destinationDir )
{
ExtractionJob *job = new ExtractionJob( m_iface, files, destinationDir, this );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
this, SLOT( extractionDone( ThreadWeaver::Job * ) ) );
ThreadWeaver::Weaver::instance()->enqueue( job );
}
void ArchiveBase::extractionDone( ThreadWeaver::Job *job )
{
emit sigExtract( job->success() );
delete job;
}
#include "archivebase.moc"
/*
* Copyright (c) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARCHIVEBASE_H
#define ARCHIVEBASE_H
#include "arch.h"
#include "archiveinterface.h"
namespace ThreadWeaver
{
class Job;
} // namespace ThreadWeaver
class ArchiveBase: public Arch
{
Q_OBJECT
public:
/*
* Creates an Arch to operate on the given interface.
* This takes ownership of the interface, which is deleted
* on the destructor.
*/
ArchiveBase( ReadOnlyArchiveInterface *archive );
virtual ~ArchiveBase();
virtual void open();
virtual void create();
virtual void addFile( const QStringList & );
virtual void addDir( const QString & );
virtual void remove( const QStringList & );
virtual void extractFiles( const QList<QVariant> & files, const QString& destinationDir );
private slots:
void listingDone( ThreadWeaver::Job* );
void extractionDone( ThreadWeaver::Job* );
private:
ReadOnlyArchiveInterface *m_iface;
};
#endif // ARCHIVEBASE_H
......@@ -40,63 +40,6 @@
#include <QStringList>
#include <QDateTime>
LibArchiveHandler::LibArchiveHandler( const QString &filename )
: Arch( filename )
{
kDebug( 1601 ) << "libarchive api version = " << archive_api_version() << endl;
}
LibArchiveHandler::~LibArchiveHandler()
{
}
void LibArchiveHandler::open()
{
ListingJob *job = new ListingJob( new LibArchiveInterface( fileName(), this ) );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
this, SLOT( listingDone( ThreadWeaver::Job * ) ) );
connect( job, SIGNAL( entry( const ArchiveEntry & ) ),
this, SIGNAL( newEntry( const ArchiveEntry & ) ) );
ThreadWeaver::Weaver::instance()->enqueue( job );
}
void LibArchiveHandler::listingDone( ThreadWeaver::Job *job )
{
emit opened( job->success() );
delete job;
}
void LibArchiveHandler::create()
{
}
void LibArchiveHandler::addFile( const QStringList & )
{
}
void LibArchiveHandler::addDir( const QString & )
{
}
void LibArchiveHandler::remove( const QStringList & )
{
}
void LibArchiveHandler::extractFiles( const QList<QVariant> & files, const QString& destinationDir )
{
ExtractionJob *job = new ExtractionJob( new LibArchiveInterface( fileName(), this ), files, destinationDir, this );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
this, SLOT( extractionDone( ThreadWeaver::Job * ) ) );
ThreadWeaver::Weaver::instance()->enqueue( job );
}
void LibArchiveHandler::extractionDone( ThreadWeaver::Job *job )
{
emit sigExtract( job->success() );
delete job;
}
LibArchiveInterface::LibArchiveInterface( const QString & filename, QObject *parent )
: ReadOnlyArchiveInterface( filename, parent )
{
......
......@@ -49,24 +49,4 @@ class LibArchiveInterface: public ReadOnlyArchiveInterface
void copyData( struct archive *source, struct archive *dest );
};
class LibArchiveHandler: public Arch
{
Q_OBJECT
public:
LibArchiveHandler( const QString &filename );
virtual ~LibArchiveHandler();
virtual void open();
virtual void create();
virtual void addFile( const QStringList & );
virtual void addDir( const QString & );
virtual void remove( const QStringList & );
virtual void extractFiles( const QList<QVariant> & files, const QString& destinationDir );
private slots:
void listingDone( ThreadWeaver::Job* );
void extractionDone( ThreadWeaver::Job* );
};
#endif // LIBARCHIVEHANDLER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment