00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00052 static KoStore* createEncryptedStoreReader( const QString & filename, const QByteArray & appIdentification );
00064
00065 static KoStore* createEncryptedStoreReader( QIODevice *dev, const QByteArray & appIdentification );
00066
00078
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
00139
00140
00141
00142
00143 KUrl m_init_url;
00144
00145 QIODevice *m_init_dev;
00146
00147 bool m_init_deferred;
00148
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 };