xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/FileManager/UpdateCallback100.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // UpdateCallback100.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../../Windows/ErrorMsg.h"
6 
7 #include "../GUI/resource3.h"
8 
9 #include "LangUtils.h"
10 #include "UpdateCallback100.h"
11 
Z7_COM7F_IMF(CUpdateCallback100Imp::ScanProgress (UInt64,UInt64 numFiles,UInt64 totalSize,const wchar_t * path,Int32))12 Z7_COM7F_IMF(CUpdateCallback100Imp::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 /* isDir */))
13 {
14   return ProgressDialog->Sync.ScanProgress(numFiles, totalSize, us2fs(path));
15 }
16 
Z7_COM7F_IMF(CUpdateCallback100Imp::ScanError (const wchar_t * path,HRESULT errorCode))17 Z7_COM7F_IMF(CUpdateCallback100Imp::ScanError(const wchar_t *path, HRESULT errorCode))
18 {
19   ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
20   return S_OK;
21 }
22 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetNumFiles (UInt64 numFiles))23 Z7_COM7F_IMF(CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles))
24 {
25   return ProgressDialog->Sync.Set_NumFilesTotal(numFiles);
26 }
27 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal (UInt64 size))28 Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal(UInt64 size))
29 {
30   ProgressDialog->Sync.Set_NumBytesTotal(size);
31   return S_OK;
32 }
33 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted (const UInt64 * completed))34 Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted(const UInt64 *completed))
35 {
36   return ProgressDialog->Sync.Set_NumBytesCur(completed);
37 }
38 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetRatioInfo (const UInt64 * inSize,const UInt64 * outSize))39 Z7_COM7F_IMF(CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize))
40 {
41   ProgressDialog->Sync.Set_Ratio(inSize, outSize);
42   return S_OK;
43 }
44 
Z7_COM7F_IMF(CUpdateCallback100Imp::CompressOperation (const wchar_t * name))45 Z7_COM7F_IMF(CUpdateCallback100Imp::CompressOperation(const wchar_t *name))
46 {
47   return SetOperation_Base(NUpdateNotifyOp::kAdd, name, false);
48 }
49 
Z7_COM7F_IMF(CUpdateCallback100Imp::DeleteOperation (const wchar_t * name))50 Z7_COM7F_IMF(CUpdateCallback100Imp::DeleteOperation(const wchar_t *name))
51 {
52   return SetOperation_Base(NUpdateNotifyOp::kDelete, name, false);
53 }
54 
Z7_COM7F_IMF(CUpdateCallback100Imp::OperationResult (Int32))55 Z7_COM7F_IMF(CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */))
56 {
57   ProgressDialog->Sync.Set_NumFilesCur(++NumFiles);
58   return S_OK;
59 }
60 
61 void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s);
62 
Z7_COM7F_IMF(CUpdateCallback100Imp::ReportExtractResult (Int32 opRes,Int32 isEncrypted,const wchar_t * name))63 Z7_COM7F_IMF(CUpdateCallback100Imp::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name))
64 {
65   if (opRes != NArchive::NExtract::NOperationResult::kOK)
66   {
67     UString s;
68     SetExtractErrorMessage(opRes, isEncrypted, name, s);
69     ProgressDialog->Sync.AddError_Message(s);
70   }
71   return S_OK;
72 }
73 
Z7_COM7F_IMF(CUpdateCallback100Imp::ReportUpdateOperation (UInt32 notifyOp,const wchar_t * name,Int32 isDir))74 Z7_COM7F_IMF(CUpdateCallback100Imp::ReportUpdateOperation(UInt32 notifyOp, const wchar_t *name, Int32 isDir))
75 {
76   return SetOperation_Base(notifyOp, name, IntToBool(isDir));
77 }
78 
Z7_COM7F_IMF(CUpdateCallback100Imp::UpdateErrorMessage (const wchar_t * message))79 Z7_COM7F_IMF(CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message))
80 {
81   ProgressDialog->Sync.AddError_Message(message);
82   return S_OK;
83 }
84 
Z7_COM7F_IMF(CUpdateCallback100Imp::OpenFileError (const wchar_t * path,HRESULT errorCode))85 Z7_COM7F_IMF(CUpdateCallback100Imp::OpenFileError(const wchar_t *path, HRESULT errorCode))
86 {
87   ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
88   return S_OK;
89 }
90 
Z7_COM7F_IMF(CUpdateCallback100Imp::ReadingFileError (const wchar_t * path,HRESULT errorCode))91 Z7_COM7F_IMF(CUpdateCallback100Imp::ReadingFileError(const wchar_t *path, HRESULT errorCode))
92 {
93   ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
94   return S_OK;
95 }
96 
Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword2 (Int32 * passwordIsDefined,BSTR * password))97 Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password))
98 {
99   *password = NULL;
100   *passwordIsDefined = BoolToInt(PasswordIsDefined);
101   if (!PasswordIsDefined)
102     return S_OK;
103   return StringToBstr(Password, password);
104 }
105 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal (const UInt64 *,const UInt64 *))106 Z7_COM7F_IMF(CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */))
107 {
108   return S_OK;
109 }
110 
Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted (const UInt64 *,const UInt64 *))111 Z7_COM7F_IMF(CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */))
112 {
113   return ProgressDialog->Sync.CheckStop();
114 }
115 
116 
Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Start (const wchar_t * srcTempPath,const wchar_t * destFinalPath,UInt64 size,Int32 updateMode))117 Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Start(const wchar_t *srcTempPath, const wchar_t *destFinalPath, UInt64 size, Int32 updateMode))
118 {
119   return MoveArc_Start_Base(srcTempPath, destFinalPath, size, updateMode);
120 }
121 
Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Progress (UInt64 totalSize,UInt64 currentSize))122 Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Progress(UInt64 totalSize, UInt64 currentSize))
123 {
124   return MoveArc_Progress_Base(totalSize, currentSize);
125 }
126 
Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Finish ())127 Z7_COM7F_IMF(CUpdateCallback100Imp::MoveArc_Finish())
128 {
129   return MoveArc_Finish_Base();
130 }
131 
Z7_COM7F_IMF(CUpdateCallback100Imp::Before_ArcReopen ())132 Z7_COM7F_IMF(CUpdateCallback100Imp::Before_ArcReopen())
133 {
134   ProgressDialog->Sync.Clear_Stop_Status();
135   return S_OK;
136 }
137 
138 
Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword (BSTR * password))139 Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password))
140 {
141   *password = NULL;
142   if (!PasswordIsDefined)
143   {
144     RINOK(ShowAskPasswordDialog())
145   }
146   return StringToBstr(Password, password);
147 }
148