Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / UI / FileManager / UpdateCallback100.cpp
1 // UpdateCallback100.cpp\r
2 \r
3 #include "StdAfx.h"\r
4 \r
5 #include "PasswordDialog.h"\r
6 #include "UpdateCallback100.h"\r
7 \r
8 STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)\r
9 {\r
10   ProgressDialog->Sync.SetNumFilesTotal(numFiles);\r
11   return S_OK;\r
12 }\r
13 \r
14 STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)\r
15 {\r
16   ProgressDialog->Sync.SetProgress(size, 0);\r
17   return S_OK;\r
18 }\r
19 \r
20 STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)\r
21 {\r
22   RINOK(ProgressDialog->Sync.ProcessStopAndPause());\r
23   if (completeValue != NULL)\r
24     ProgressDialog->Sync.SetPos(*completeValue);\r
25   return S_OK;\r
26 }\r
27 \r
28 STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)\r
29 {\r
30   ProgressDialog->Sync.SetRatioInfo(inSize, outSize);\r
31   return S_OK;\r
32 }\r
33 \r
34 STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name)\r
35 {\r
36   ProgressDialog->Sync.SetCurrentFileName(name);\r
37   return S_OK;\r
38 }\r
39 \r
40 STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name)\r
41 {\r
42   ProgressDialog->Sync.SetCurrentFileName(name);\r
43   return S_OK;\r
44 }\r
45 \r
46 STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */)\r
47 {\r
48   ProgressDialog->Sync.SetNumFilesCur(++_numFiles);\r
49   return S_OK;\r
50 }\r
51 \r
52 STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)\r
53 {\r
54   ProgressDialog->Sync.AddErrorMessage(message);\r
55   return S_OK;\r
56 }\r
57 \r
58 STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)\r
59 {\r
60   *password = NULL;\r
61   *passwordIsDefined = BoolToInt(_passwordIsDefined);\r
62   if (!_passwordIsDefined)\r
63     return S_OK;\r
64   return StringToBstr(_password, password);\r
65 }\r
66 \r
67 STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)\r
68 {\r
69   return S_OK;\r
70 }\r
71 \r
72 STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)\r
73 {\r
74   return ProgressDialog->Sync.ProcessStopAndPause();\r
75 }\r
76 \r
77 STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)\r
78 {\r
79   *password = NULL;\r
80   if (!_passwordIsDefined)\r
81   {\r
82     CPasswordDialog dialog;\r
83     ProgressDialog->WaitCreating();\r
84     if (dialog.Create(*ProgressDialog) == IDCANCEL)\r
85       return E_ABORT;\r
86     _password = dialog.Password;\r
87     _passwordIsDefined = true;\r
88   }\r
89   return StringToBstr(_password, password);\r
90 }\r