1370b324cSopenharmony_ci// OpenCallbackConsole.cpp 2370b324cSopenharmony_ci 3370b324cSopenharmony_ci#include "StdAfx.h" 4370b324cSopenharmony_ci 5370b324cSopenharmony_ci#include "OpenCallbackConsole.h" 6370b324cSopenharmony_ci 7370b324cSopenharmony_ci#include "ConsoleClose.h" 8370b324cSopenharmony_ci#include "UserInputUtils.h" 9370b324cSopenharmony_ci 10370b324cSopenharmony_cistatic HRESULT CheckBreak2() 11370b324cSopenharmony_ci{ 12370b324cSopenharmony_ci return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK; 13370b324cSopenharmony_ci} 14370b324cSopenharmony_ci 15370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_CheckBreak() 16370b324cSopenharmony_ci{ 17370b324cSopenharmony_ci return CheckBreak2(); 18370b324cSopenharmony_ci} 19370b324cSopenharmony_ci 20370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *files, const UInt64 *bytes) 21370b324cSopenharmony_ci{ 22370b324cSopenharmony_ci if (!MultiArcMode && NeedPercents()) 23370b324cSopenharmony_ci { 24370b324cSopenharmony_ci if (files) 25370b324cSopenharmony_ci { 26370b324cSopenharmony_ci _totalFilesDefined = true; 27370b324cSopenharmony_ci // _totalFiles = *files; 28370b324cSopenharmony_ci _percent.Total = *files; 29370b324cSopenharmony_ci } 30370b324cSopenharmony_ci else 31370b324cSopenharmony_ci _totalFilesDefined = false; 32370b324cSopenharmony_ci 33370b324cSopenharmony_ci if (bytes) 34370b324cSopenharmony_ci { 35370b324cSopenharmony_ci // _totalBytesDefined = true; 36370b324cSopenharmony_ci _totalBytes = *bytes; 37370b324cSopenharmony_ci if (!files) 38370b324cSopenharmony_ci _percent.Total = *bytes; 39370b324cSopenharmony_ci } 40370b324cSopenharmony_ci else 41370b324cSopenharmony_ci { 42370b324cSopenharmony_ci // _totalBytesDefined = false; 43370b324cSopenharmony_ci if (!files) 44370b324cSopenharmony_ci _percent.Total = _totalBytes; 45370b324cSopenharmony_ci } 46370b324cSopenharmony_ci } 47370b324cSopenharmony_ci 48370b324cSopenharmony_ci return CheckBreak2(); 49370b324cSopenharmony_ci} 50370b324cSopenharmony_ci 51370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) 52370b324cSopenharmony_ci{ 53370b324cSopenharmony_ci if (!MultiArcMode && NeedPercents()) 54370b324cSopenharmony_ci { 55370b324cSopenharmony_ci if (files) 56370b324cSopenharmony_ci { 57370b324cSopenharmony_ci _percent.Files = *files; 58370b324cSopenharmony_ci if (_totalFilesDefined) 59370b324cSopenharmony_ci _percent.Completed = *files; 60370b324cSopenharmony_ci } 61370b324cSopenharmony_ci 62370b324cSopenharmony_ci if (bytes) 63370b324cSopenharmony_ci { 64370b324cSopenharmony_ci if (!_totalFilesDefined) 65370b324cSopenharmony_ci _percent.Completed = *bytes; 66370b324cSopenharmony_ci } 67370b324cSopenharmony_ci _percent.Print(); 68370b324cSopenharmony_ci } 69370b324cSopenharmony_ci 70370b324cSopenharmony_ci return CheckBreak2(); 71370b324cSopenharmony_ci} 72370b324cSopenharmony_ci 73370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_Finished() 74370b324cSopenharmony_ci{ 75370b324cSopenharmony_ci ClosePercents(); 76370b324cSopenharmony_ci return S_OK; 77370b324cSopenharmony_ci} 78370b324cSopenharmony_ci 79370b324cSopenharmony_ci 80370b324cSopenharmony_ci#ifndef Z7_NO_CRYPTO 81370b324cSopenharmony_ci 82370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password) 83370b324cSopenharmony_ci{ 84370b324cSopenharmony_ci *password = NULL; 85370b324cSopenharmony_ci RINOK(CheckBreak2()) 86370b324cSopenharmony_ci 87370b324cSopenharmony_ci if (!PasswordIsDefined) 88370b324cSopenharmony_ci { 89370b324cSopenharmony_ci ClosePercents(); 90370b324cSopenharmony_ci RINOK(GetPassword_HRESULT(_so, Password)) 91370b324cSopenharmony_ci PasswordIsDefined = true; 92370b324cSopenharmony_ci } 93370b324cSopenharmony_ci return StringToBstr(Password, password); 94370b324cSopenharmony_ci} 95370b324cSopenharmony_ci 96370b324cSopenharmony_ci/* 97370b324cSopenharmony_ciHRESULT COpenCallbackConsole::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password) 98370b324cSopenharmony_ci{ 99370b324cSopenharmony_ci passwordIsDefined = PasswordIsDefined; 100370b324cSopenharmony_ci password = Password; 101370b324cSopenharmony_ci return S_OK; 102370b324cSopenharmony_ci} 103370b324cSopenharmony_ci 104370b324cSopenharmony_cibool COpenCallbackConsole::Open_WasPasswordAsked() 105370b324cSopenharmony_ci{ 106370b324cSopenharmony_ci return PasswordWasAsked; 107370b324cSopenharmony_ci} 108370b324cSopenharmony_ci 109370b324cSopenharmony_civoid COpenCallbackConsole::Open_Clear_PasswordWasAsked_Flag () 110370b324cSopenharmony_ci{ 111370b324cSopenharmony_ci PasswordWasAsked = false; 112370b324cSopenharmony_ci} 113370b324cSopenharmony_ci*/ 114370b324cSopenharmony_ci 115370b324cSopenharmony_ci#endif 116