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
ScanProgress(UInt64,UInt64 numFiles,UInt64 totalSize,const wchar_t * path,Int32)12 STDMETHODIMP 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
ScanError(const wchar_t * path,HRESULT errorCode)17 STDMETHODIMP CUpdateCallback100Imp::ScanError(const wchar_t *path, HRESULT errorCode)
18 {
19 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
20 return S_OK;
21 }
22
SetNumFiles(UInt64 numFiles)23 STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)
24 {
25 return ProgressDialog->Sync.Set_NumFilesTotal(numFiles);
26 }
27
SetTotal(UInt64 size)28 STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
29 {
30 ProgressDialog->Sync.Set_NumBytesTotal(size);
31 return S_OK;
32 }
33
SetCompleted(const UInt64 * completed)34 STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completed)
35 {
36 return ProgressDialog->Sync.Set_NumBytesCur(completed);
37 }
38
SetRatioInfo(const UInt64 * inSize,const UInt64 * outSize)39 STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
40 {
41 ProgressDialog->Sync.Set_Ratio(inSize, outSize);
42 return S_OK;
43 }
44
CompressOperation(const wchar_t * name)45 STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name)
46 {
47 return SetOperation_Base(NUpdateNotifyOp::kAdd, name, false);
48 }
49
DeleteOperation(const wchar_t * name)50 STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name)
51 {
52 return SetOperation_Base(NUpdateNotifyOp::kDelete, name, false);
53 }
54
OperationResult(Int32)55 STDMETHODIMP 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
ReportExtractResult(Int32 opRes,Int32 isEncrypted,const wchar_t * name)63 HRESULT 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
ReportUpdateOperation(UInt32 notifyOp,const wchar_t * name,Int32 isDir)74 HRESULT CUpdateCallback100Imp::ReportUpdateOperation(UInt32 notifyOp, const wchar_t *name, Int32 isDir)
75 {
76 return SetOperation_Base(notifyOp, name, IntToBool(isDir));
77 }
78
UpdateErrorMessage(const wchar_t * message)79 STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
80 {
81 ProgressDialog->Sync.AddError_Message(message);
82 return S_OK;
83 }
84
OpenFileError(const wchar_t * path,HRESULT errorCode)85 HRESULT CUpdateCallback100Imp::OpenFileError(const wchar_t *path, HRESULT errorCode)
86 {
87 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
88 return S_OK;
89 }
90
ReadingFileError(const wchar_t * path,HRESULT errorCode)91 STDMETHODIMP CUpdateCallback100Imp::ReadingFileError(const wchar_t *path, HRESULT errorCode)
92 {
93 ProgressDialog->Sync.AddError_Code_Name(errorCode, path);
94 return S_OK;
95 }
96
CryptoGetTextPassword2(Int32 * passwordIsDefined,BSTR * password)97 STDMETHODIMP 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
SetTotal(const UInt64 *,const UInt64 *)106 STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
107 {
108 return S_OK;
109 }
110
SetCompleted(const UInt64 *,const UInt64 *)111 STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
112 {
113 return ProgressDialog->Sync.CheckStop();
114 }
115
CryptoGetTextPassword(BSTR * password)116 STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
117 {
118 *password = NULL;
119 if (!PasswordIsDefined)
120 {
121 RINOK(ShowAskPasswordDialog())
122 }
123 return StringToBstr(Password, password);
124 }
125