1 // UpdateCallbackConsole.h 2 3 #ifndef __UPDATE_CALLBACK_CONSOLE_H 4 #define __UPDATE_CALLBACK_CONSOLE_H 5 6 #include "../../../Common/StdOutStream.h" 7 8 #include "../Common/Update.h" 9 10 #include "PercentPrinter.h" 11 12 struct CErrorPathCodes 13 { 14 FStringVector Paths; 15 CRecordVector<DWORD> Codes; 16 AddErrorCErrorPathCodes17 void AddError(const FString &path, DWORD systemError) 18 { 19 Paths.Add(path); 20 Codes.Add(systemError); 21 } ClearCErrorPathCodes22 void Clear() 23 { 24 Paths.Clear(); 25 Codes.Clear(); 26 } 27 }; 28 29 class CCallbackConsoleBase 30 { 31 protected: 32 CPercentPrinter _percent; 33 34 CStdOutStream *_so; 35 CStdOutStream *_se; 36 37 void CommonError(const FString &path, DWORD systemError, bool isWarning); 38 39 HRESULT ScanError_Base(const FString &path, DWORD systemError); 40 HRESULT OpenFileError_Base(const FString &name, DWORD systemError); 41 HRESULT ReadingFileError_Base(const FString &name, DWORD systemError); 42 43 public: NeedPercents()44 bool NeedPercents() const { return _percent._so != NULL; }; 45 46 bool StdOutMode; 47 48 bool NeedFlush; 49 unsigned PercentsNameLevel; 50 unsigned LogLevel; 51 52 AString _tempA; 53 UString _tempU; 54 CCallbackConsoleBase()55 CCallbackConsoleBase(): 56 StdOutMode(false), 57 NeedFlush(false), 58 PercentsNameLevel(1), 59 LogLevel(0) 60 {} 61 SetWindowWidth(unsigned width)62 void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; } 63 Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream)64 void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream) 65 { 66 FailedFiles.Clear(); 67 68 _so = outStream; 69 _se = errorStream; 70 _percent._so = percentStream; 71 } 72 ClosePercents2()73 void ClosePercents2() 74 { 75 if (NeedPercents()) 76 _percent.ClosePrint(true); 77 } 78 ClosePercents_for_so()79 void ClosePercents_for_so() 80 { 81 if (NeedPercents() && _so == _percent._so) 82 _percent.ClosePrint(false); 83 } 84 85 86 CErrorPathCodes FailedFiles; 87 CErrorPathCodes ScanErrors; 88 89 HRESULT PrintProgress(const wchar_t *name, const char *command, bool showInLog); 90 91 }; 92 93 class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase 94 { 95 // void PrintPropPair(const char *name, const wchar_t *val); 96 97 public: 98 #ifndef _NO_CRYPTO 99 bool PasswordIsDefined; 100 UString Password; 101 bool AskPassword; 102 #endif 103 104 bool DeleteMessageWasShown; 105 CUpdateCallbackConsole()106 CUpdateCallbackConsole() 107 : DeleteMessageWasShown(false) 108 #ifndef _NO_CRYPTO 109 , PasswordIsDefined(false) 110 , AskPassword(false) 111 #endif 112 {} 113 114 /* 115 void Init(CStdOutStream *outStream) 116 { 117 CCallbackConsoleBase::Init(outStream); 118 } 119 */ 120 // ~CUpdateCallbackConsole() { if (NeedPercents()) _percent.ClosePrint(); } 121 INTERFACE_IUpdateCallbackUI2(;) 122 }; 123 124 #endif 125