aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/Common/UpdateCallback.h
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/UI/Common/UpdateCallback.h')
-rw-r--r--CPP/7zip/UI/Common/UpdateCallback.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/CPP/7zip/UI/Common/UpdateCallback.h b/CPP/7zip/UI/Common/UpdateCallback.h
new file mode 100644
index 0000000..d27776e
--- /dev/null
+++ b/CPP/7zip/UI/Common/UpdateCallback.h
@@ -0,0 +1,165 @@
1// UpdateCallback.h
2
3#ifndef __UPDATE_CALLBACK_H
4#define __UPDATE_CALLBACK_H
5
6#include "../../../Common/MyCom.h"
7
8#include "../../Common/FileStreams.h"
9
10#include "../../IPassword.h"
11#include "../../ICoder.h"
12
13#include "../Common/UpdatePair.h"
14#include "../Common/UpdateProduce.h"
15
16#include "OpenArchive.h"
17
18struct CArcToDoStat
19{
20 CDirItemsStat2 NewData;
21 CDirItemsStat2 OldData;
22 CDirItemsStat2 DeleteData;
23
24 UInt64 Get_NumDataItems_Total() const
25 {
26 return NewData.Get_NumDataItems2() + OldData.Get_NumDataItems2();
27 }
28};
29
30#define INTERFACE_IUpdateCallbackUI(x) \
31 virtual HRESULT WriteSfx(const wchar_t *name, UInt64 size) x; \
32 virtual HRESULT SetTotal(UInt64 size) x; \
33 virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \
34 virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
35 virtual HRESULT CheckBreak() x; \
36 /* virtual HRESULT Finalize() x; */ \
37 virtual HRESULT SetNumItems(const CArcToDoStat &stat) x; \
38 virtual HRESULT GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode) x; \
39 virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \
40 virtual HRESULT ReadingFileError(const FString &path, DWORD systemError) x; \
41 virtual HRESULT SetOperationResult(Int32 opRes) x; \
42 virtual HRESULT ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name) x; \
43 virtual HRESULT ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir) x; \
44 /* virtual HRESULT SetPassword(const UString &password) x; */ \
45 virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
46 virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \
47 virtual HRESULT ShowDeleteFile(const wchar_t *name, bool isDir) x; \
48 /* virtual HRESULT CloseProgress() { return S_OK; } */
49
50struct IUpdateCallbackUI
51{
52 INTERFACE_IUpdateCallbackUI(=0)
53};
54
55struct CKeyKeyValPair
56{
57 UInt64 Key1;
58 UInt64 Key2;
59 unsigned Value;
60
61 int Compare(const CKeyKeyValPair &a) const
62 {
63 if (Key1 < a.Key1) return -1;
64 if (Key1 > a.Key1) return 1;
65 return MyCompare(Key2, a.Key2);
66 }
67};
68
69
70class CArchiveUpdateCallback:
71 public IArchiveUpdateCallback2,
72 public IArchiveUpdateCallbackFile,
73 public IArchiveExtractCallbackMessage,
74 public IArchiveGetRawProps,
75 public IArchiveGetRootProps,
76 public ICryptoGetTextPassword2,
77 public ICryptoGetTextPassword,
78 public ICompressProgressInfo,
79 public IInFileStream_Callback,
80 public CMyUnknownImp
81{
82 #if defined(_WIN32) && !defined(UNDER_CE)
83 bool _saclEnabled;
84 #endif
85 CRecordVector<CKeyKeyValPair> _map;
86
87 UInt32 _hardIndex_From;
88 UInt32 _hardIndex_To;
89
90 void UpdateProcessedItemStatus(unsigned dirIndex);
91
92public:
93 MY_QUERYINTERFACE_BEGIN2(IArchiveUpdateCallback2)
94 MY_QUERYINTERFACE_ENTRY(IArchiveUpdateCallbackFile)
95 MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage)
96 MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
97 MY_QUERYINTERFACE_ENTRY(IArchiveGetRootProps)
98 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword2)
99 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
100 MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo)
101 MY_QUERYINTERFACE_END
102 MY_ADDREF_RELEASE
103
104
105 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
106
107 INTERFACE_IArchiveUpdateCallback2(;)
108 INTERFACE_IArchiveUpdateCallbackFile(;)
109 INTERFACE_IArchiveExtractCallbackMessage(;)
110 INTERFACE_IArchiveGetRawProps(;)
111 INTERFACE_IArchiveGetRootProps(;)
112
113 STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
114 STDMETHOD(CryptoGetTextPassword)(BSTR *password);
115
116 CRecordVector<UInt32> _openFiles_Indexes;
117 FStringVector _openFiles_Paths;
118
119 bool AreAllFilesClosed() const { return _openFiles_Indexes.IsEmpty(); }
120 virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error);
121 virtual void InFileStream_On_Destroy(UINT_PTR val);
122
123 CRecordVector<UInt64> VolumesSizes;
124 FString VolName;
125 FString VolExt;
126 UString ArcFileName; // without path prefix
127
128 IUpdateCallbackUI *Callback;
129
130 const CDirItems *DirItems;
131 const CDirItem *ParentDirItem;
132
133 const CArc *Arc;
134 CMyComPtr<IInArchive> Archive;
135 const CObjectVector<CArcItem> *ArcItems;
136 const CRecordVector<CUpdatePair2> *UpdatePairs;
137 const UStringVector *NewNames;
138 int CommentIndex;
139 const UString *Comment;
140
141 bool PreserveATime;
142 bool ShareForWrite;
143 bool StopAfterOpenError;
144 bool StdInMode;
145
146 bool KeepOriginalItemNames;
147 bool StoreNtSecurity;
148 bool StoreHardLinks;
149 bool StoreSymLinks;
150
151 Byte *ProcessedItemsStatuses;
152
153 CArchiveUpdateCallback();
154
155 bool IsDir(const CUpdatePair2 &up) const
156 {
157 if (up.DirIndex >= 0)
158 return DirItems->Items[(unsigned)up.DirIndex].IsDir();
159 else if (up.ArcIndex >= 0)
160 return (*ArcItems)[(unsigned)up.ArcIndex].IsDir;
161 return false;
162 }
163};
164
165#endif