00001
00002
00003
00004
00005 #ifndef __ARCHIVE_OPEN_CALLBACK_H
00006 #define __ARCHIVE_OPEN_CALLBACK_H
00007
00008 #include "String.h"
00009 #include "MyCom.h"
00010 #include "FileFind.h"
00011
00012 #ifndef _NO_CRYPTO
00013 #include "IPassword.h"
00014 #endif
00015 #include "IArchive.h"
00016
00017 struct IOpenCallbackUI
00018 {
00019 virtual HRESULT CheckBreak() = 0;
00020 virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0;
00021 virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0;
00022 #ifndef _NO_CRYPTO
00023 virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0;
00024 virtual HRESULT GetPasswordIfAny(UString &password) = 0;
00025 #endif
00026 };
00027
00028 class COpenCallbackImp:
00029 public IArchiveOpenCallback,
00030 public IArchiveOpenVolumeCallback,
00031 public IArchiveOpenSetSubArchiveName,
00032 #ifndef _NO_CRYPTO
00033 public ICryptoGetTextPassword,
00034 #endif
00035 public CMyUnknownImp
00036 {
00037 public:
00038 #ifndef _NO_CRYPTO
00039 MY_UNKNOWN_IMP3(
00040 IArchiveOpenVolumeCallback,
00041 ICryptoGetTextPassword,
00042 IArchiveOpenSetSubArchiveName
00043 )
00044 #else
00045 MY_UNKNOWN_IMP2(
00046 IArchiveOpenVolumeCallback,
00047 IArchiveOpenSetSubArchiveName
00048 )
00049 #endif
00050
00051 STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
00052 STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
00053
00054
00055 STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
00056 STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream);
00057
00058 #ifndef _NO_CRYPTO
00059
00060 STDMETHOD(CryptoGetTextPassword)(BSTR *password);
00061 #endif
00062
00063 STDMETHOD(SetSubArchiveName(const wchar_t *name))
00064 {
00065 _subArchiveMode = true;
00066 _subArchiveName = name;
00067 return S_OK;
00068 }
00069
00070 private:
00071 UString _folderPrefix;
00072 NWindows::NFile::NFind::CFileInfoW _fileInfo;
00073 bool _subArchiveMode;
00074 UString _subArchiveName;
00075 public:
00076 UStringVector FileNames;
00077 IOpenCallbackUI *Callback;
00078 void Init(const UString &folderPrefix, const UString &fileName)
00079 {
00080 _folderPrefix = folderPrefix;
00081 if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
00082 throw 1;
00083 FileNames.Clear();
00084 _subArchiveMode = false;
00085 }
00086 int FindName(const UString &name);
00087 };
00088
00089 #endif