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 18 struct CArcToDoStat 19 { 20 CDirItemsStat2 NewData; 21 CDirItemsStat2 OldData; 22 CDirItemsStat2 DeleteData; 23 Get_NumDataItems_TotalCArcToDoStat24 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 ReportUpdateOpeartion(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 50 struct IUpdateCallbackUI 51 { 52 INTERFACE_IUpdateCallbackUI(=0) 53 }; 54 55 struct CKeyKeyValPair 56 { 57 UInt64 Key1; 58 UInt64 Key2; 59 unsigned Value; 60 CompareCKeyKeyValPair61 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 70 class 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 public: 91 MY_QUERYINTERFACE_BEGIN2(IArchiveUpdateCallback2) 92 MY_QUERYINTERFACE_ENTRY(IArchiveUpdateCallbackFile) 93 MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage) 94 MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) 95 MY_QUERYINTERFACE_ENTRY(IArchiveGetRootProps) 96 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword2) 97 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) 98 MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo) 99 MY_QUERYINTERFACE_END 100 MY_ADDREF_RELEASE 101 102 103 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 104 105 INTERFACE_IArchiveUpdateCallback2(;) 106 INTERFACE_IArchiveUpdateCallbackFile(;) 107 INTERFACE_IArchiveExtractCallbackMessage(;) 108 INTERFACE_IArchiveGetRawProps(;) 109 INTERFACE_IArchiveGetRootProps(;) 110 111 STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); 112 STDMETHOD(CryptoGetTextPassword)(BSTR *password); 113 114 CRecordVector<UInt32> _openFiles_Indexes; 115 FStringVector _openFiles_Paths; 116 AreAllFilesClosed()117 bool AreAllFilesClosed() const { return _openFiles_Indexes.IsEmpty(); } 118 virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error); 119 virtual void InFileStream_On_Destroy(UINT_PTR val); 120 121 CRecordVector<UInt64> VolumesSizes; 122 FString VolName; 123 FString VolExt; 124 125 IUpdateCallbackUI *Callback; 126 127 const CDirItems *DirItems; 128 const CDirItem *ParentDirItem; 129 130 const CArc *Arc; 131 CMyComPtr<IInArchive> Archive; 132 const CObjectVector<CArcItem> *ArcItems; 133 const CRecordVector<CUpdatePair2> *UpdatePairs; 134 const UStringVector *NewNames; 135 int CommentIndex; 136 const UString *Comment; 137 138 bool ShareForWrite; 139 bool StopAfterOpenError; 140 bool StdInMode; 141 142 bool KeepOriginalItemNames; 143 bool StoreNtSecurity; 144 bool StoreHardLinks; 145 bool StoreSymLinks; 146 147 Byte *ProcessedItemsStatuses; 148 149 150 CArchiveUpdateCallback(); 151 IsDir(const CUpdatePair2 & up)152 bool IsDir(const CUpdatePair2 &up) const 153 { 154 if (up.DirIndex >= 0) 155 return DirItems->Items[up.DirIndex].IsDir(); 156 else if (up.ArcIndex >= 0) 157 return (*ArcItems)[up.ArcIndex].IsDir; 158 return false; 159 } 160 }; 161 162 #endif 163