1 // UpdateCallbackGUI.cpp
\r
5 #include "Common/IntToString.h"
\r
6 #include "Common/StringConvert.h"
\r
8 #include "Windows/Error.h"
\r
9 #include "Windows/PropVariant.h"
\r
11 #include "../FileManager/PasswordDialog.h"
\r
13 #include "UpdateCallbackGUI.h"
\r
15 using namespace NWindows;
\r
17 CUpdateCallbackGUI::~CUpdateCallbackGUI() {}
\r
19 void CUpdateCallbackGUI::Init()
\r
21 FailedFiles.Clear();
\r
25 void CUpdateCallbackGUI::AddErrorMessage(LPCWSTR message)
\r
27 ProgressDialog->Sync.AddErrorMessage(message);
\r
30 void CUpdateCallbackGUI::AddErrorMessage(const wchar_t *name, DWORD systemError)
\r
33 UString(L"WARNING: ") +
\r
34 NError::MyFormatMessageW(systemError) +
\r
39 HRESULT CUpdateCallbackGUI::OpenResult(const wchar_t *name, HRESULT result)
\r
43 AddErrorMessage (UString(L"Error: ") + name + UString(L" is not supported archive"));
\r
48 HRESULT CUpdateCallbackGUI::StartScanning()
\r
53 HRESULT CUpdateCallbackGUI::CanNotFindError(const wchar_t *name, DWORD systemError)
\r
55 FailedFiles.Add(name);
\r
56 AddErrorMessage(name, systemError);
\r
60 HRESULT CUpdateCallbackGUI::FinishScanning()
\r
65 HRESULT CUpdateCallbackGUI::StartArchive(const wchar_t *name, bool /* updating */)
\r
67 ProgressDialog->Sync.SetTitleFileName(name);
\r
71 HRESULT CUpdateCallbackGUI::FinishArchive()
\r
76 HRESULT CUpdateCallbackGUI::CheckBreak()
\r
78 return ProgressDialog->Sync.ProcessStopAndPause();
\r
81 HRESULT CUpdateCallbackGUI::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, const wchar_t *path)
\r
83 ProgressDialog->Sync.SetCurrentFileName(path);
\r
84 ProgressDialog->Sync.SetNumFilesTotal(numFiles);
\r
85 return ProgressDialog->Sync.ProcessStopAndPause();
\r
88 HRESULT CUpdateCallbackGUI::Finilize()
\r
93 HRESULT CUpdateCallbackGUI::SetNumFiles(UInt64 numFiles)
\r
95 ProgressDialog->Sync.SetNumFilesTotal(numFiles);
\r
99 HRESULT CUpdateCallbackGUI::SetTotal(UInt64 total)
\r
101 ProgressDialog->Sync.SetProgress(total, 0);
\r
105 HRESULT CUpdateCallbackGUI::SetCompleted(const UInt64 *completeValue)
\r
107 RINOK(CheckBreak());
\r
108 if (completeValue != NULL)
\r
109 ProgressDialog->Sync.SetPos(*completeValue);
\r
113 HRESULT CUpdateCallbackGUI::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
\r
115 RINOK(CheckBreak());
\r
116 ProgressDialog->Sync.SetRatioInfo(inSize, outSize);
\r
120 HRESULT CUpdateCallbackGUI::GetStream(const wchar_t *name, bool /* isAnti */)
\r
122 ProgressDialog->Sync.SetCurrentFileName(name);
\r
126 HRESULT CUpdateCallbackGUI::OpenFileError(const wchar_t *name, DWORD systemError)
\r
128 FailedFiles.Add(name);
\r
129 // if (systemError == ERROR_SHARING_VIOLATION)
\r
131 AddErrorMessage(name, systemError);
\r
134 // return systemError;
\r
137 HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */)
\r
140 ProgressDialog->Sync.SetNumFilesCur(NumFiles);
\r
144 HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
\r
147 if (!PasswordIsDefined)
\r
149 if (passwordIsDefined == 0 || AskPassword)
\r
151 CPasswordDialog dialog;
\r
152 ProgressDialog->WaitCreating();
\r
153 if (dialog.Create(*ProgressDialog) == IDCANCEL)
\r
155 Password = dialog.Password;
\r
156 PasswordIsDefined = true;
\r
159 if (passwordIsDefined != 0)
\r
160 *passwordIsDefined = BoolToInt(PasswordIsDefined);
\r
161 return StringToBstr(Password, password);
\r
164 HRESULT CUpdateCallbackGUI::CryptoGetTextPassword(BSTR *password)
\r
166 return CryptoGetTextPassword2(NULL, password);
\r
170 It doesn't work, since main stream waits Dialog
\r
171 HRESULT CUpdateCallbackGUI::CloseProgress()
\r
173 ProgressDialog->MyClose();
\r
179 HRESULT CUpdateCallbackGUI::Open_CheckBreak()
\r
181 return ProgressDialog->Sync.ProcessStopAndPause();
\r
184 HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
\r
186 // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles);
\r
190 HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
\r
192 return ProgressDialog->Sync.ProcessStopAndPause();
\r
197 HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password)
\r
199 PasswordWasAsked = true;
\r
200 return CryptoGetTextPassword2(NULL, password);
\r
203 HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password)
\r
205 if (PasswordIsDefined)
\r
206 password = Password;
\r
210 bool CUpdateCallbackGUI::Open_WasPasswordAsked()
\r
212 return PasswordWasAsked;
\r
215 void CUpdateCallbackGUI::Open_ClearPasswordWasAskedFlag()
\r
217 PasswordWasAsked = false;
\r
221 HRESULT CUpdateCallbackGUI::ShowDeleteFile(const wchar_t *name)
\r
223 ProgressDialog->Sync.SetCurrentFileName(name);
\r