|
1 // tefcons.cpp |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <e32std.h> |
|
14 #include <e32cons.h> |
|
15 #include <e32keys.h> |
|
16 #include <test/testexecutelogger.h> |
|
17 #include <fshell/consoleextensions.h> |
|
18 |
|
19 NONSHARABLE_CLASS(CTefConsole) : public CConsoleBase |
|
20 { |
|
21 public: |
|
22 CTefConsole(); |
|
23 virtual ~CTefConsole(); |
|
24 virtual TInt Create(const TDesC &aTitle,TSize aSize); |
|
25 virtual void Read(TRequestStatus &aStatus); |
|
26 virtual void ReadCancel(); |
|
27 virtual void Write(const TDesC &aDes); |
|
28 virtual TPoint CursorPos() const; |
|
29 virtual void SetCursorPosAbs(const TPoint &aPoint); |
|
30 virtual void SetCursorPosRel(const TPoint &aPoint); |
|
31 virtual void SetCursorHeight(TInt aPercentage); |
|
32 virtual void SetTitle(const TDesC &aTitle); |
|
33 virtual void ClearScreen(); |
|
34 virtual void ClearToEndOfLine(); |
|
35 virtual TSize ScreenSize() const; |
|
36 virtual TKeyCode KeyCode() const; |
|
37 virtual TUint KeyModifiers() const; |
|
38 virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
39 |
|
40 void WriteStdErr(const TDesC &aDes); |
|
41 |
|
42 private: |
|
43 CTestExecuteLogger* iLogger; |
|
44 }; |
|
45 |
|
46 CTefConsole::CTefConsole() |
|
47 { |
|
48 } |
|
49 |
|
50 TInt CTefConsole::Create(const TDesC& aTitle, TSize /*aSize*/) |
|
51 { |
|
52 iLogger = new CTestExecuteLogger(); |
|
53 if (!iLogger) return KErrNoMemory; |
|
54 TInt logMode = TLoggerOptions(ELogHTMLOnly); |
|
55 TInt logLevel = RFileFlogger::TLogSeverity(ESevrAll); |
|
56 iLogger->SetLoggerOptions(logMode); |
|
57 TInt err = iLogger->Connect(); |
|
58 if (err) return err; |
|
59 const TDesC& logFilePath(aTitle); |
|
60 err = iLogger->HtmlLogger().CreateLog(logFilePath, RTestExecuteLogServ::ELogModeAppend); |
|
61 if (err) return err; |
|
62 iLogger->HtmlLogger().SetLogLevel(TLogSeverity(logLevel)); |
|
63 |
|
64 iLogger->HtmlLogger().Write(_L("<pre>\r\n")); // horrible horrible tef logging - the client is responsible for writing markup! |
|
65 return KErrNone; |
|
66 } |
|
67 |
|
68 |
|
69 CTefConsole::~CTefConsole() |
|
70 { |
|
71 if (iLogger) |
|
72 { |
|
73 iLogger->HtmlLogger().Write(_L("</pre>\r\n")); // horrible horrible tef logging - the client is responsible for writing markup! |
|
74 iLogger->Close(); |
|
75 delete iLogger; |
|
76 } |
|
77 } |
|
78 |
|
79 void CTefConsole::Read(TRequestStatus &aStatus) |
|
80 { |
|
81 TRequestStatus *pS=(&aStatus); |
|
82 User::RequestComplete(pS, KErrNotSupported); |
|
83 } |
|
84 |
|
85 void CTefConsole::ReadCancel() |
|
86 { |
|
87 } |
|
88 |
|
89 void CTefConsole::Write(const TDesC& aDes) |
|
90 { |
|
91 //TODO sort out the file and line |
|
92 //iLogger->LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, aDes); |
|
93 iLogger->HtmlLogger().Write(aDes); |
|
94 } |
|
95 |
|
96 void CTefConsole::WriteStdErr(const TDesC &aDes) |
|
97 { |
|
98 //iLogger->LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, aDes); |
|
99 iLogger->HtmlLogger().Write(aDes); |
|
100 } |
|
101 |
|
102 TPoint CTefConsole::CursorPos() const |
|
103 { |
|
104 return TPoint(0,0); |
|
105 } |
|
106 |
|
107 void CTefConsole::SetCursorPosAbs(const TPoint& /*aPoint*/) |
|
108 { |
|
109 } |
|
110 |
|
111 void CTefConsole::SetCursorPosRel(const TPoint& /*aPoint*/) |
|
112 { |
|
113 } |
|
114 |
|
115 void CTefConsole::SetCursorHeight(TInt /*aPercentage*/) |
|
116 { |
|
117 } |
|
118 |
|
119 void CTefConsole::SetTitle(const TDesC& /*aTitle*/) |
|
120 { |
|
121 } |
|
122 |
|
123 void CTefConsole::ClearScreen() |
|
124 { |
|
125 } |
|
126 |
|
127 void CTefConsole::ClearToEndOfLine() |
|
128 { |
|
129 } |
|
130 |
|
131 TSize CTefConsole::ScreenSize() const |
|
132 { |
|
133 return TSize(10,10); |
|
134 } |
|
135 |
|
136 TKeyCode CTefConsole::KeyCode() const |
|
137 { |
|
138 return EKeyNull; |
|
139 } |
|
140 |
|
141 TUint CTefConsole::KeyModifiers() const |
|
142 { |
|
143 return 0; |
|
144 } |
|
145 |
|
146 extern "C" EXPORT_C TAny *NewConsole() |
|
147 { |
|
148 return(new CTefConsole); |
|
149 } |
|
150 |
|
151 TInt CTefConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1) |
|
152 { |
|
153 if (aExtensionId == ConsoleStdErr::KWriteStdErrConsoleExtension) |
|
154 { |
|
155 TDesC* des = (TDesC*)a1; |
|
156 WriteStdErr(*des); |
|
157 return KErrNone; |
|
158 } |
|
159 else |
|
160 { |
|
161 return CConsoleBase::Extension_(aExtensionId, a0, a1); |
|
162 } |
|
163 |
|
164 } |