ark
archiveinterface.h
Go to the documentation of this file.00001 /* 00002 * Copyright (c) 2007 Henrique Pinto <henrique.pinto@kdemail.net> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #ifndef ARCHIVEINTERFACE_H 00027 #define ARCHIVEINTERFACE_H 00028 00029 #include <QObject> 00030 #include <QStringList> 00031 #include <QString> 00032 00033 #include "archive.h" 00034 #include "kerfuffle_export.h" 00035 00036 namespace Kerfuffle 00037 { 00038 class ArchiveObserver; 00039 00040 class KERFUFFLE_EXPORT ReadOnlyArchiveInterface: public QObject 00041 { 00042 Q_OBJECT 00043 public: 00044 explicit ReadOnlyArchiveInterface( const QString & filename, QObject *parent = 0 ); 00045 virtual ~ReadOnlyArchiveInterface(); 00046 00047 QString filename() const { return m_filename; } 00048 virtual bool isReadOnly() const { return true; } 00049 00050 void KDE_NO_EXPORT registerObserver( ArchiveObserver *observer ); 00051 void KDE_NO_EXPORT removeObserver( ArchiveObserver *observer ); 00052 00053 virtual bool open() { return true; } 00054 virtual bool list() = 0; 00055 virtual bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory, bool preservePaths ) = 0; 00056 00057 protected: 00058 void error( const QString & message, const QString & details = QString() ); 00059 void entry( const ArchiveEntry & archiveEntry ); 00060 void progress( double ); 00061 void entryRemoved( const QString& path ); 00062 00063 private: 00064 QList<ArchiveObserver*> m_observers; 00065 QString m_filename; 00066 }; 00067 00068 class KERFUFFLE_EXPORT ReadWriteArchiveInterface: public ReadOnlyArchiveInterface 00069 { 00070 Q_OBJECT 00071 public: 00072 explicit ReadWriteArchiveInterface( const QString & filename, QObject *parent = 0 ); 00073 virtual ~ReadWriteArchiveInterface(); 00074 00075 virtual bool isReadOnly() const; 00076 00077 virtual bool addFiles( const QStringList & files ) = 0; 00078 virtual bool deleteFiles( const QList<QVariant> & files ) = 0; 00079 }; 00080 00081 } // namespace Kerfuffle 00082 00083 #endif // ARCHIVEINTERFACE_H
KDE 4.0 API Reference