OLD | NEW |
| (Empty) |
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 #ifdef _NO_CRYPTO | |
16 | |
17 #define INTERFACE_IOpenCallbackUI_Crypto(x) | |
18 | |
19 #else | |
20 | |
21 #define INTERFACE_IOpenCallbackUI_Crypto(x) \ | |
22 virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x; \ | |
23 virtual HRESULT Open_GetPasswordIfAny(UString &password) x; \ | |
24 virtual bool Open_WasPasswordAsked() x; \ | |
25 virtual void Open_ClearPasswordWasAskedFlag() x; \ | |
26 | |
27 #endif | |
28 | |
29 #define INTERFACE_IOpenCallbackUI(x) \ | |
30 virtual HRESULT Open_CheckBreak() x; \ | |
31 virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x; \ | |
32 virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x;
\ | |
33 INTERFACE_IOpenCallbackUI_Crypto(x) | |
34 | |
35 struct IOpenCallbackUI | |
36 { | |
37 INTERFACE_IOpenCallbackUI(=0) | |
38 }; | |
39 | |
40 class COpenCallbackImp: | |
41 public IArchiveOpenCallback, | |
42 public IArchiveOpenVolumeCallback, | |
43 public IArchiveOpenSetSubArchiveName, | |
44 #ifndef _NO_CRYPTO | |
45 public ICryptoGetTextPassword, | |
46 #endif | |
47 public CMyUnknownImp | |
48 { | |
49 public: | |
50 #ifndef _NO_CRYPTO | |
51 MY_UNKNOWN_IMP3( | |
52 IArchiveOpenVolumeCallback, | |
53 ICryptoGetTextPassword, | |
54 IArchiveOpenSetSubArchiveName | |
55 ) | |
56 #else | |
57 MY_UNKNOWN_IMP2( | |
58 IArchiveOpenVolumeCallback, | |
59 IArchiveOpenSetSubArchiveName | |
60 ) | |
61 #endif | |
62 | |
63 INTERFACE_IArchiveOpenCallback(;) | |
64 INTERFACE_IArchiveOpenVolumeCallback(;) | |
65 | |
66 #ifndef _NO_CRYPTO | |
67 STDMETHOD(CryptoGetTextPassword)(BSTR *password); | |
68 #endif | |
69 | |
70 STDMETHOD(SetSubArchiveName(const wchar_t *name)) | |
71 { | |
72 _subArchiveMode = true; | |
73 _subArchiveName = name; | |
74 return S_OK; | |
75 } | |
76 | |
77 private: | |
78 UString _folderPrefix; | |
79 NWindows::NFile::NFind::CFileInfoW _fileInfo; | |
80 bool _subArchiveMode; | |
81 UString _subArchiveName; | |
82 public: | |
83 UStringVector FileNames; | |
84 IOpenCallbackUI *Callback; | |
85 CMyComPtr<IArchiveOpenCallback> ReOpenCallback; | |
86 UInt64 TotalSize; | |
87 | |
88 COpenCallbackImp(): Callback(NULL) {} | |
89 void Init(const UString &folderPrefix, const UString &fileName) | |
90 { | |
91 _folderPrefix = folderPrefix; | |
92 if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo)) | |
93 throw 1; | |
94 FileNames.Clear(); | |
95 _subArchiveMode = false; | |
96 TotalSize = 0; | |
97 } | |
98 int FindName(const UString &name); | |
99 }; | |
100 | |
101 #endif | |
OLD | NEW |