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