1// UpdateCallback.h
2
3#ifndef __UPDATE_CALLBACK_H
4#define __UPDATE_CALLBACK_H
5
6#include "../../../Common/MyCom.h"
7
8#include "../../IPassword.h"
9#include "../../ICoder.h"
10
11#include "../Common/UpdatePair.h"
12#include "../Common/UpdateProduce.h"
13
14#define INTERFACE_IUpdateCallbackUI(x) \
15  virtual HRESULT SetTotal(UInt64 size) x; \
16  virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \
17  virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
18  virtual HRESULT CheckBreak() x; \
19  virtual HRESULT Finilize() x; \
20  virtual HRESULT SetNumFiles(UInt64 numFiles) x; \
21  virtual HRESULT GetStream(const wchar_t *name, bool isAnti) x; \
22  virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError) x; \
23  virtual HRESULT SetOperationResult(Int32 operationResult) x; \
24  virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
25  virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \
26  /* virtual HRESULT ShowDeleteFile(const wchar_t *name) x; */ \
27  /* virtual HRESULT CloseProgress() { return S_OK; }; */
28
29struct IUpdateCallbackUI
30{
31  INTERFACE_IUpdateCallbackUI(=0)
32};
33
34struct CKeyKeyValPair
35{
36  UInt64 Key1;
37  UInt64 Key2;
38  unsigned Value;
39
40  int Compare(const CKeyKeyValPair &a) const
41  {
42    if (Key1 < a.Key1) return -1;
43    if (Key1 > a.Key1) return 1;
44    return MyCompare(Key2, a.Key2);
45  }
46};
47
48
49class CArchiveUpdateCallback:
50  public IArchiveUpdateCallback2,
51  public IArchiveGetRawProps,
52  public IArchiveGetRootProps,
53  public ICryptoGetTextPassword2,
54  public ICryptoGetTextPassword,
55  public ICompressProgressInfo,
56  public CMyUnknownImp
57{
58  #if defined(_WIN32) && !defined(UNDER_CE)
59  bool _saclEnabled;
60  #endif
61  CRecordVector<CKeyKeyValPair> _map;
62
63  UInt32 _hardIndex_From;
64  UInt32 _hardIndex_To;
65
66public:
67  MY_UNKNOWN_IMP6(
68      IArchiveUpdateCallback2,
69      IArchiveGetRawProps,
70      IArchiveGetRootProps,
71      ICryptoGetTextPassword2,
72      ICryptoGetTextPassword,
73      ICompressProgressInfo)
74
75  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
76
77  INTERFACE_IArchiveUpdateCallback2(;)
78  INTERFACE_IArchiveGetRawProps(;)
79  INTERFACE_IArchiveGetRootProps(;)
80
81  STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
82  STDMETHOD(CryptoGetTextPassword)(BSTR *password);
83
84  CRecordVector<UInt64> VolumesSizes;
85  FString VolName;
86  FString VolExt;
87
88  IUpdateCallbackUI *Callback;
89
90  bool ShareForWrite;
91  bool StdInMode;
92
93  const CDirItems *DirItems;
94  const CDirItem *ParentDirItem;
95
96  const CObjectVector<CArcItem> *ArcItems;
97  const CRecordVector<CUpdatePair2> *UpdatePairs;
98  const UStringVector *NewNames;
99  CMyComPtr<IInArchive> Archive;
100  CMyComPtr<IArchiveGetRawProps> GetRawProps;
101  CMyComPtr<IArchiveGetRootProps> GetRootProps;
102
103  bool KeepOriginalItemNames;
104  bool StoreNtSecurity;
105  bool StoreHardLinks;
106  bool StoreSymLinks;
107
108  Byte *ProcessedItemsStatuses;
109
110  CArchiveUpdateCallback();
111
112  bool IsDir(const CUpdatePair2 &up) const
113  {
114    if (up.DirIndex >= 0)
115      return DirItems->Items[up.DirIndex].IsDir();
116    else if (up.ArcIndex >= 0)
117      return (*ArcItems)[up.ArcIndex].IsDir;
118    return false;
119  }
120};
121
122#endif
123