• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword (BSTR * password))116 Z7_COM7F_IMF(CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password))
117 {
118   *password = NULL;
119   if (!PasswordIsDefined)
120   {
121     RINOK(ShowAskPasswordDialog())
122   }
123   return StringToBstr(Password, password);
124 }
125