1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// ArchiveOpenCallback.h 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef __ARCHIVE_OPEN_CALLBACK_H 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define __ARCHIVE_OPEN_CALLBACK_H 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Common/MyCom.h" 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Common/MyString.h" 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "Windows/FileFind.h" 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef _NO_CRYPTO 12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../IPassword.h" 13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../../Archive/IArchive.h" 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifdef _NO_CRYPTO 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define INTERFACE_IOpenCallbackUI_Crypto(x) 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#else 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define INTERFACE_IOpenCallbackUI_Crypto(x) \ 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x; \ 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT Open_GetPasswordIfAny(UString &password) x; \ 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual bool Open_WasPasswordAsked() x; \ 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual void Open_ClearPasswordWasAskedFlag() x; \ 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define INTERFACE_IOpenCallbackUI(x) \ 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT Open_CheckBreak() x; \ 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x; \ 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x; \ 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync INTERFACE_IOpenCallbackUI_Crypto(x) 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 36baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct IOpenCallbackUI 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync INTERFACE_IOpenCallbackUI(=0) 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 41baa3858d3f5d128a5c8466b700098109edcad5f2repo syncclass COpenCallbackImp: 42baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public IArchiveOpenCallback, 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public IArchiveOpenVolumeCallback, 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public IArchiveOpenSetSubArchiveName, 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _NO_CRYPTO 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public ICryptoGetTextPassword, 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync public CMyUnknownImp 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 50baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _NO_CRYPTO 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync MY_UNKNOWN_IMP3( 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IArchiveOpenVolumeCallback, 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ICryptoGetTextPassword, 55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IArchiveOpenSetSubArchiveName 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ) 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #else 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync MY_UNKNOWN_IMP2( 59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IArchiveOpenVolumeCallback, 60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IArchiveOpenSetSubArchiveName 61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ) 62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync INTERFACE_IArchiveOpenCallback(;) 65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync INTERFACE_IArchiveOpenVolumeCallback(;) 66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _NO_CRYPTO 68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync STDMETHOD(CryptoGetTextPassword)(BSTR *password); 69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync STDMETHOD(SetSubArchiveName(const wchar_t *name)) 72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 73baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _subArchiveMode = true; 74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _subArchiveName = name; 75baa3858d3f5d128a5c8466b700098109edcad5f2repo sync TotalSize = 0; 76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return S_OK; 77baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 79baa3858d3f5d128a5c8466b700098109edcad5f2repo syncprivate: 80baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString _folderPrefix; 81baa3858d3f5d128a5c8466b700098109edcad5f2repo sync NWindows::NFile::NFind::CFileInfoW _fileInfo; 82baa3858d3f5d128a5c8466b700098109edcad5f2repo sync bool _subArchiveMode; 83baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UString _subArchiveName; 84baa3858d3f5d128a5c8466b700098109edcad5f2repo syncpublic: 85baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UStringVector FileNames; 86baa3858d3f5d128a5c8466b700098109edcad5f2repo sync IOpenCallbackUI *Callback; 87baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CMyComPtr<IArchiveOpenCallback> ReOpenCallback; 88baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt64 TotalSize; 89baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 90baa3858d3f5d128a5c8466b700098109edcad5f2repo sync COpenCallbackImp(): Callback(NULL) {} 91baa3858d3f5d128a5c8466b700098109edcad5f2repo sync void Init(const UString &folderPrefix, const UString &fileName) 92baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 93baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _folderPrefix = folderPrefix; 94baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (!_fileInfo.Find(_folderPrefix + fileName)) 95baa3858d3f5d128a5c8466b700098109edcad5f2repo sync throw 1; 96baa3858d3f5d128a5c8466b700098109edcad5f2repo sync FileNames.Clear(); 97baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _subArchiveMode = false; 98baa3858d3f5d128a5c8466b700098109edcad5f2repo sync TotalSize = 0; 99baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 100baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int FindName(const UString &name); 101baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 102baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 103baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 104