1 // UpdateCallbackConsole.h 2 3 #ifndef ZIP7_INC_UPDATE_CALLBACK_CONSOLE_H 4 #define ZIP7_INC_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 30 class CCallbackConsoleBase 31 { 32 protected: 33 CPercentPrinter _percent; 34 35 CStdOutStream *_so; 36 CStdOutStream *_se; 37 38 void CommonError(const FString &path, DWORD systemError, bool isWarning); 39 // void CommonError(const char *message); 40 41 HRESULT ScanError_Base(const FString &path, DWORD systemError); 42 HRESULT OpenFileError_Base(const FString &name, DWORD systemError); 43 HRESULT ReadingFileError_Base(const FString &name, DWORD systemError); 44 45 public: NeedPercents()46 bool NeedPercents() const { return _percent._so != NULL; } 47 48 bool StdOutMode; 49 50 bool NeedFlush; 51 unsigned PercentsNameLevel; 52 unsigned LogLevel; 53 54 AString _tempA; 55 UString _tempU; 56 CCallbackConsoleBase()57 CCallbackConsoleBase(): 58 StdOutMode(false), 59 NeedFlush(false), 60 PercentsNameLevel(1), 61 LogLevel(0), 62 NumNonOpenFiles(0) 63 {} 64 SetWindowWidth(unsigned width)65 void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; } 66 Init(CStdOutStream * outStream,CStdOutStream * errorStream,CStdOutStream * percentStream)67 void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream) 68 { 69 FailedFiles.Clear(); 70 71 _so = outStream; 72 _se = errorStream; 73 _percent._so = percentStream; 74 } 75 ClosePercents2()76 void ClosePercents2() 77 { 78 if (NeedPercents()) 79 _percent.ClosePrint(true); 80 } 81 ClosePercents_for_so()82 void ClosePercents_for_so() 83 { 84 if (NeedPercents() && _so == _percent._so) 85 _percent.ClosePrint(false); 86 } 87 88 CErrorPathCodes FailedFiles; 89 CErrorPathCodes ScanErrors; 90 UInt64 NumNonOpenFiles; 91 92 HRESULT PrintProgress(const wchar_t *name, bool isDir, const char *command, bool showInLog); 93 94 // void PrintInfoLine(const UString &s); 95 // void PrintPropInfo(UString &s, PROPID propID, const PROPVARIANT *value); 96 }; 97 98 99 class CUpdateCallbackConsole Z7_final: 100 public IUpdateCallbackUI2, 101 public CCallbackConsoleBase 102 { 103 // void PrintPropPair(const char *name, const wchar_t *val); 104 Z7_IFACE_IMP(IUpdateCallbackUI) 105 Z7_IFACE_IMP(IDirItemsCallback) 106 Z7_IFACE_IMP(IUpdateCallbackUI2) 107 public: 108 bool DeleteMessageWasShown; 109 110 #ifndef Z7_NO_CRYPTO 111 bool PasswordIsDefined; 112 bool AskPassword; 113 UString Password; 114 #endif 115 CUpdateCallbackConsole()116 CUpdateCallbackConsole(): 117 DeleteMessageWasShown(false) 118 #ifndef Z7_NO_CRYPTO 119 , PasswordIsDefined(false) 120 , AskPassword(false) 121 #endif 122 {} 123 124 /* 125 void Init(CStdOutStream *outStream) 126 { 127 CCallbackConsoleBase::Init(outStream); 128 } 129 */ 130 // ~CUpdateCallbackConsole() { if (NeedPercents()) _percent.ClosePrint(); } 131 }; 132 133 #endif 134