1 // ArchiveOpenCallback.h |
|
2 |
|
3 #ifndef __ARCHIVE_OPEN_CALLBACK_H |
|
4 #define __ARCHIVE_OPEN_CALLBACK_H |
|
5 |
|
6 #include "Common/MyString.h" |
|
7 #include "Common/MyCom.h" |
|
8 #include "Windows/FileFind.h" |
|
9 |
|
10 #ifndef _NO_CRYPTO |
|
11 #include "../../IPassword.h" |
|
12 #endif |
|
13 #include "../../Archive/IArchive.h" |
|
14 |
|
15 struct IOpenCallbackUI |
|
16 { |
|
17 virtual HRESULT CheckBreak() = 0; |
|
18 virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0; |
|
19 virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0; |
|
20 #ifndef _NO_CRYPTO |
|
21 virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0; |
|
22 virtual HRESULT GetPasswordIfAny(UString &password) = 0; |
|
23 virtual bool WasPasswordAsked() = 0; |
|
24 virtual void ClearPasswordWasAskedFlag() = 0; |
|
25 #endif |
|
26 }; |
|
27 |
|
28 class COpenCallbackImp: |
|
29 public IArchiveOpenCallback, |
|
30 public IArchiveOpenVolumeCallback, |
|
31 public IArchiveOpenSetSubArchiveName, |
|
32 #ifndef _NO_CRYPTO |
|
33 public ICryptoGetTextPassword, |
|
34 #endif |
|
35 public CMyUnknownImp |
|
36 { |
|
37 public: |
|
38 #ifndef _NO_CRYPTO |
|
39 MY_UNKNOWN_IMP3( |
|
40 IArchiveOpenVolumeCallback, |
|
41 ICryptoGetTextPassword, |
|
42 IArchiveOpenSetSubArchiveName |
|
43 ) |
|
44 #else |
|
45 MY_UNKNOWN_IMP2( |
|
46 IArchiveOpenVolumeCallback, |
|
47 IArchiveOpenSetSubArchiveName |
|
48 ) |
|
49 #endif |
|
50 |
|
51 STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes); |
|
52 STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes); |
|
53 |
|
54 // IArchiveOpenVolumeCallback |
|
55 STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value); |
|
56 STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream); |
|
57 |
|
58 #ifndef _NO_CRYPTO |
|
59 // ICryptoGetTextPassword |
|
60 STDMETHOD(CryptoGetTextPassword)(BSTR *password); |
|
61 #endif |
|
62 |
|
63 STDMETHOD(SetSubArchiveName(const wchar_t *name)) |
|
64 { |
|
65 _subArchiveMode = true; |
|
66 _subArchiveName = name; |
|
67 return S_OK; |
|
68 } |
|
69 |
|
70 private: |
|
71 UString _folderPrefix; |
|
72 NWindows::NFile::NFind::CFileInfoW _fileInfo; |
|
73 bool _subArchiveMode; |
|
74 UString _subArchiveName; |
|
75 public: |
|
76 UStringVector FileNames; |
|
77 IOpenCallbackUI *Callback; |
|
78 UInt64 TotalSize; |
|
79 |
|
80 COpenCallbackImp(): Callback(NULL) {} |
|
81 void Init(const UString &folderPrefix, const UString &fileName) |
|
82 { |
|
83 _folderPrefix = folderPrefix; |
|
84 if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo)) |
|
85 throw 1; |
|
86 FileNames.Clear(); |
|
87 _subArchiveMode = false; |
|
88 TotalSize = 0; |
|
89 } |
|
90 int FindName(const UString &name); |
|
91 }; |
|
92 |
|
93 #endif |
|