• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

ark

internaljobs.cpp

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 #include "internaljobs.h"
00027 #include <kdebug.h>
00028 
00029 
00030 namespace Kerfuffle
00031 {
00032     InternalJob::InternalJob( QObject *parent )
00033         : ThreadWeaver::Job( parent ), m_success( false )
00034     {
00035     }
00036 
00037     InternalJob::~InternalJob()
00038     {
00039     }
00040 
00041     InternalListingJob::InternalListingJob( ReadOnlyArchiveInterface *archive, QObject *parent )
00042         : InternalJob( parent ), m_helper( 0 ), m_archive( archive )
00043     {
00044     }
00045 
00046     InternalListingJob::~InternalListingJob()
00047     {
00048         delete m_helper;
00049         m_helper = 0;
00050     }
00051 
00052     void InternalListingJob::run()
00053     {
00054         m_helper = new ArchiveJobHelper( m_archive );
00055         connect( m_helper, SIGNAL( entry( const ArchiveEntry & ) ),
00056              this, SIGNAL( entry( const ArchiveEntry & ) ) );
00057         connect( m_helper, SIGNAL( progress( double ) ),
00058              this, SIGNAL( progress( double ) ) );
00059         connect( m_helper, SIGNAL( error( const QString&, const QString& ) ),
00060              this, SIGNAL( error( const QString&, const QString& ) ) );
00061         setSuccess( m_helper->getTheListing() );
00062     }
00063 
00064     InternalExtractJob::InternalExtractJob( ReadOnlyArchiveInterface *archive, const QList<QVariant> & files, const QString & destinationDirectory, bool preservePaths, QObject *parent )
00065         : InternalJob( parent ), m_archive( archive ), m_files( files ), m_destinationDirectory( destinationDirectory ),
00066           m_helper( 0 ), m_preservePaths( preservePaths )
00067     {
00068 
00069     }
00070 
00071     InternalExtractJob::~InternalExtractJob()
00072     {
00073         delete m_helper;
00074         m_helper = 0;
00075     }
00076 
00077     void InternalExtractJob::run()
00078     {
00079         m_helper = new ArchiveJobHelper( m_archive );
00080         connect( m_helper, SIGNAL( progress( double ) ),
00081              this, SIGNAL( progress( double ) ) );
00082         connect( m_helper, SIGNAL( error( const QString&, const QString& ) ),
00083              this, SIGNAL( error( const QString&, const QString& ) ) );
00084         m_archive->registerObserver( m_helper );
00085         setSuccess( m_archive->copyFiles( m_files, m_destinationDirectory, m_preservePaths ) );
00086         m_archive->removeObserver( m_helper );
00087     }
00088 
00089     InternalAddJob::InternalAddJob( ReadWriteArchiveInterface *archive, const QStringList & files, QObject *parent )
00090         : InternalJob( parent ), m_files( files ), m_archive( archive ), m_helper( 0 )
00091     {
00092     }
00093 
00094     InternalAddJob::~InternalAddJob()
00095     {
00096         delete m_helper;
00097         m_helper = 0;
00098     }
00099 
00100     void InternalAddJob::run()
00101     {
00102         m_helper = new ArchiveJobHelper( m_archive );
00103 
00104         connect( m_helper, SIGNAL( entry( const ArchiveEntry & ) ),
00105              this, SIGNAL( entry( const ArchiveEntry & ) ) );
00106         connect( m_helper, SIGNAL( progress( double ) ),
00107              this, SIGNAL( progress( double ) ) );
00108         connect( m_helper, SIGNAL( error( const QString&, const QString& ) ),
00109              this, SIGNAL( error( const QString&, const QString& ) ) );
00110 
00111         m_archive->registerObserver( m_helper );
00112         setSuccess( m_archive->addFiles( m_files ) );
00113         m_archive->removeObserver( m_helper );
00114     }
00115 
00116     InternalDeleteJob::InternalDeleteJob( ReadWriteArchiveInterface *archive, const QList<QVariant> & entries, QObject *parent )
00117         : InternalJob( parent ), m_entries( entries ), m_archive( archive ), m_helper( 0 )
00118     {
00119     }
00120 
00121     InternalDeleteJob::~InternalDeleteJob()
00122     {
00123         delete m_helper;
00124         m_helper = 0;
00125     }
00126 
00127     void InternalDeleteJob::run()
00128     {
00129         m_helper = new ArchiveJobHelper( m_archive );
00130 
00131         // TODO: Connect the signals
00132         connect( m_helper, SIGNAL( entryRemoved( const QString& ) ),
00133                  this, SIGNAL( entryRemoved( const QString& ) ) );
00134         connect( m_helper, SIGNAL( progress( double ) ),
00135              this, SIGNAL( progress( double ) ) );
00136         connect( m_helper, SIGNAL( error( const QString&, const QString& ) ),
00137              this, SIGNAL( error( const QString&, const QString& ) ) );
00138 
00139         m_archive->registerObserver( m_helper );
00140         setSuccess( m_archive->deleteFiles( m_entries ) );
00141         m_archive->removeObserver( m_helper );
00142     }
00143 
00144     ArchiveJobHelper::ArchiveJobHelper( ReadOnlyArchiveInterface *archive, QObject *parent )
00145         : QObject( parent ), m_archive( archive )
00146     {
00147     }
00148 
00149     ArchiveJobHelper::~ArchiveJobHelper()
00150     {
00151     }
00152 
00153     bool ArchiveJobHelper::getTheListing()
00154     {
00155         m_archive->registerObserver( this );
00156         bool result = m_archive->list();
00157         m_archive->removeObserver( this );
00158         return result;
00159     }
00160 
00161     void ArchiveJobHelper::onError( const QString & message, const QString & details )
00162     {
00163         emit error( message, details );
00164     }
00165 
00166     void ArchiveJobHelper::onEntry( const ArchiveEntry & archiveEntry )
00167     {
00168         emit entry( archiveEntry );
00169     }
00170 
00171     void ArchiveJobHelper::onProgress( double d )
00172     {
00173         emit progress( d );
00174     }
00175 
00176     void ArchiveJobHelper::onEntryRemoved( const QString & path )
00177     {
00178         emit entryRemoved( path );
00179     }
00180 
00181 
00182 } // namespace Kerfuffle
00183 
00184 #include "internaljobs.moc"

ark

Skip menu "ark"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal