F:/KPlato/koffice/libs/store/KoEncryptedStore.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Thomas Schaap <thomas.schaap@kdemail.net>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoStoreBase.h"
00021 #include <QHash>
00022 #include <QtCrypto>
00023 
00024 class QString;
00025 class QByteArray;
00026 class QIODevice;
00027 class QWidget;
00028 class KUrl;
00029 class KoZipStore;
00030 struct KoEncryptedStore_EncryptionData;
00031 
00032 class KoEncryptedStore : public KoStoreBase
00033 {
00034 public:
00035     KoEncryptedStore( const QString & filename, Mode mode, const QByteArray & appIdentification );
00036     KoEncryptedStore( QIODevice *dev, Mode mode, const QByteArray & appIdentification );
00037     KoEncryptedStore( QWidget* window, const KUrl& url, const QString & filename, Mode _mode, const QByteArray & appIdentification );
00038     ~KoEncryptedStore();
00039 
00051     // Creating a KoEncryptedStore will give more overhead and a KoZipStore can't decrypt encrypted files
00052     static KoStore* createEncryptedStoreReader( const QString & filename, const QByteArray & appIdentification );
00064     // Creating a KoEncryptedStore will give more overhead and a KoZipStore can't decrypt encrypted files
00065     static KoStore* createEncryptedStoreReader( QIODevice *dev, const QByteArray & appIdentification );
00066 
00078     // Creating a KoEncryptedStore will give more overhead and a KoZipStore can't decrypt encrypted files
00079     static KoStore* createEncryptedStoreReader( QWidget* window, const KUrl& url, const QString & filename, const QByteArray & appIdentification );
00080 
00091     bool setPassword( const QString& password );
00092 
00093 protected:
00094     virtual bool init( Mode mode, const QByteArray& appIdentification );
00095     virtual bool openWrite( const QString& name );
00096     virtual bool openRead( const QString& name );
00097     virtual bool closeWrite();
00098     virtual bool closeRead();
00099     virtual bool enterRelativeDirectory( const QString& dirName );
00100     virtual bool enterAbsoluteDirectory( const QString& path );
00101     virtual bool fileExists( const QString& absPath ) const;
00102 
00109     bool isEncrypted( );
00110 
00119     KoZipStore *ripZipStore( );
00120 
00125     void findPasswordInKWallet( );
00126 
00131     void savePasswordInKWallet( );
00132 
00133 private:
00134     QSecureArray decryptFile( QSecureArray & encryptedFile, KoEncryptedStore_EncryptionData & encData, QSecureArray & password );
00135     QString normalizedFullPath( const QString& fullpath );
00136     QString filenameOnly( const QString& fullpath );
00137     bool initBackend( );
00138     /* Deferred loading is used to prevent dataloss because the backend store would have opened the file,
00139      * but the user won't provide a password. The backend store is not loaded until a password is provided,
00140      * so files are not overwritten until they *can* be overwritten.
00141      */
00142     // Temporary store for a possible url, used for deferred loading of the backend store
00143     KUrl m_init_url;
00144     // Temporary store for a possible device, used for deferred loading of the backend store
00145     QIODevice *m_init_dev;
00146     // A flag used for deferred loading of the backend store
00147     bool m_init_deferred;
00148     // Temporary store for the application identification, used for deferred loading of the backend store
00149     QByteArray m_init_appIdentification;
00150 
00151 protected:
00152     QCA::Initializer m_qcaInit;
00153     QHash<QString, KoEncryptedStore_EncryptionData> m_encryptionData;
00154     KoZipStore *m_store;
00155     QSecureArray m_password;
00156     QWidget *m_window;
00157     QString m_filename;
00158     QByteArray m_manifestBuffer;
00159 };

Généré le Wed Nov 22 23:41:14 2006 pour KPlato par  doxygen 1.5.1-p1