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 #define INTERFACE_IUpdateCallbackUI(x) \ 19 virtual HRESULT WriteSfx(const wchar_t *name, UInt64 size) x; \ 20 virtual HRESULT SetTotal(UInt64 size) x; \ 21 virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \ 22 virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \ 23 virtual HRESULT CheckBreak() x; \ 24 /* virtual HRESULT Finalize() x; */ \ 25 virtual HRESULT SetNumItems(UInt64 numItems) x; \ 26 virtual HRESULT GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode) x; \ 27 virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \ 28 virtual HRESULT ReadingFileError(const FString &path, DWORD systemError) x; \ 29 virtual HRESULT SetOperationResult(Int32 opRes) x; \ 30 virtual HRESULT ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name) x; \ 31 virtual HRESULT ReportUpdateOpeartion(UInt32 op, const wchar_t *name, bool isDir) x; \ 32 /* virtual HRESULT SetPassword(const UString &password) x; */ \ 33 virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \ 34 virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \ 35 virtual HRESULT ShowDeleteFile(const wchar_t *name, bool isDir) x; \ 36 /* virtual HRESULT CloseProgress() { return S_OK; } */ 37 38 struct IUpdateCallbackUI 39 { 40 INTERFACE_IUpdateCallbackUI(=0) 41 }; 42 43 struct CKeyKeyValPair 44 { 45 UInt64 Key1; 46 UInt64 Key2; 47 unsigned Value; 48 CompareCKeyKeyValPair49 int Compare(const CKeyKeyValPair &a) const 50 { 51 if (Key1 < a.Key1) return -1; 52 if (Key1 > a.Key1) return 1; 53 return MyCompare(Key2, a.Key2); 54 } 55 }; 56 57 58 class CArchiveUpdateCallback: 59 public IArchiveUpdateCallback2, 60 public IArchiveUpdateCallbackFile, 61 public IArchiveExtractCallbackMessage, 62 public IArchiveGetRawProps, 63 public IArchiveGetRootProps, 64 public ICryptoGetTextPassword2, 65 public ICryptoGetTextPassword, 66 public ICompressProgressInfo, 67 public IInFileStream_Callback, 68 public CMyUnknownImp 69 { 70 #if defined(_WIN32) && !defined(UNDER_CE) 71 bool _saclEnabled; 72 #endif 73 CRecordVector<CKeyKeyValPair> _map; 74 75 UInt32 _hardIndex_From; 76 UInt32 _hardIndex_To; 77 78 public: 79 MY_QUERYINTERFACE_BEGIN2(IArchiveUpdateCallback2) 80 MY_QUERYINTERFACE_ENTRY(IArchiveUpdateCallbackFile) 81 MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage) 82 MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) 83 MY_QUERYINTERFACE_ENTRY(IArchiveGetRootProps) 84 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword2) 85 MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword) 86 MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo) 87 MY_QUERYINTERFACE_END 88 MY_ADDREF_RELEASE 89 90 91 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 92 93 INTERFACE_IArchiveUpdateCallback2(;) 94 INTERFACE_IArchiveUpdateCallbackFile(;) 95 INTERFACE_IArchiveExtractCallbackMessage(;) 96 INTERFACE_IArchiveGetRawProps(;) 97 INTERFACE_IArchiveGetRootProps(;) 98 99 STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); 100 STDMETHOD(CryptoGetTextPassword)(BSTR *password); 101 102 CRecordVector<UInt32> _openFiles_Indexes; 103 FStringVector _openFiles_Paths; 104 AreAllFilesClosed()105 bool AreAllFilesClosed() const { return _openFiles_Indexes.IsEmpty(); } 106 virtual HRESULT InFileStream_On_Error(UINT_PTR val, DWORD error); 107 virtual void InFileStream_On_Destroy(UINT_PTR val); 108 109 CRecordVector<UInt64> VolumesSizes; 110 FString VolName; 111 FString VolExt; 112 113 IUpdateCallbackUI *Callback; 114 115 const CDirItems *DirItems; 116 const CDirItem *ParentDirItem; 117 118 const CArc *Arc; 119 CMyComPtr<IInArchive> Archive; 120 const CObjectVector<CArcItem> *ArcItems; 121 const CRecordVector<CUpdatePair2> *UpdatePairs; 122 const UStringVector *NewNames; 123 124 bool ShareForWrite; 125 bool StdInMode; 126 127 bool KeepOriginalItemNames; 128 bool StoreNtSecurity; 129 bool StoreHardLinks; 130 bool StoreSymLinks; 131 132 Byte *ProcessedItemsStatuses; 133 134 135 CArchiveUpdateCallback(); 136 IsDir(const CUpdatePair2 & up)137 bool IsDir(const CUpdatePair2 &up) const 138 { 139 if (up.DirIndex >= 0) 140 return DirItems->Items[up.DirIndex].IsDir(); 141 else if (up.ArcIndex >= 0) 142 return (*ArcItems)[up.ArcIndex].IsDir; 143 return false; 144 } 145 }; 146 147 #endif 148