78 */ |
82 */ |
79 void CServerConsole::ConstructL(const TDesC& aName) |
83 void CServerConsole::ConstructL(const TDesC& aName) |
80 { |
84 { |
81 iWindowName = aName.AllocL(); |
85 iWindowName = aName.AllocL(); |
82 iConsole = Console::NewL(*iWindowName, TSize(KConsFullScreen,KConsFullScreen)); |
86 iConsole = Console::NewL(*iWindowName, TSize(KConsFullScreen,KConsFullScreen)); |
|
87 iConsoleReader = CConsoleReader::NewL(*iConsole); |
83 } |
88 } |
84 |
89 |
85 /** |
90 /** |
86 * |
91 * |
87 * Accessor for base console. |
92 * Accessor for base console. |
117 iInstructions = aInstructions.AllocL(); |
122 iInstructions = aInstructions.AllocL(); |
118 iConsole->ClearScreen(); |
123 iConsole->ClearScreen(); |
119 iConsole->Write(*iInstructions); |
124 iConsole->Write(*iInstructions); |
120 } |
125 } |
121 |
126 |
|
127 /** |
|
128 * |
|
129 * Starts the console reader listening for input. |
|
130 * |
|
131 * @param "MConsoleReader& aReader" |
|
132 * The console reader. |
|
133 * |
|
134 * @xxxx |
|
135 * |
|
136 */ |
|
137 void CServerConsole::Read(MConsoleReader& aReader) |
|
138 { |
|
139 iConsoleReader->DoRead(aReader); |
|
140 } |
|
141 |
|
142 /** |
|
143 * |
|
144 * Stops the console reader listening for input. |
|
145 * |
|
146 * |
|
147 * @xxxx |
|
148 * |
|
149 */ |
|
150 void CServerConsole::ReadCancel() |
|
151 { |
|
152 iConsoleReader->Cancel(); |
|
153 } |
|
154 |
|
155 /** |
|
156 * |
|
157 * RunL method for active object CServerConsole. |
|
158 * |
|
159 * @xxxx |
|
160 * |
|
161 */ |
|
162 void CServerConsole::RunL() |
|
163 { |
|
164 User::LeaveIfError(iStatus.Int()); |
|
165 TBool reading = iConsoleReader->IsActive(); |
|
166 iConsoleReader->Cancel(); |
|
167 |
|
168 //listen for key input if we were before... |
|
169 if (reading) |
|
170 iConsoleReader->DoRead(); |
|
171 } |
|
172 |
|
173 /** |
|
174 * |
|
175 * DoCancel method for active object CServerConsole. |
|
176 * |
|
177 * @xxxx |
|
178 * |
|
179 */ |
|
180 void CServerConsole::DoCancel() |
|
181 { |
|
182 ReadCancel(); |
|
183 } |
|
184 |
|
185 /** |
|
186 * |
|
187 * Error handler for active object CServerConsole. |
|
188 * (Currently a stub) |
|
189 * |
|
190 * @param "TInt aError" |
|
191 * The error code |
|
192 * |
|
193 * @return "TInt" |
|
194 * The error code |
|
195 * |
|
196 * @xxxx |
|
197 * |
|
198 */ |
|
199 TInt CServerConsole::RunError(TInt aError) |
|
200 { |
|
201 return aError; |
|
202 } |
|
203 |
|
204 |
|
205 |
|
206 /** |
|
207 * |
|
208 * Static constructor for CConsoleReader. |
|
209 * |
|
210 * @param "CConsoleBase& aConsole" |
|
211 * The console we are to read |
|
212 * |
|
213 * @return "CConsoleReader*" |
|
214 * The constructed CConsoleReader |
|
215 * |
|
216 * @xxxx |
|
217 * |
|
218 */ |
|
219 CConsoleReader* CConsoleReader::NewL(CConsoleBase& aConsole) |
|
220 { |
|
221 CConsoleReader* s = new(ELeave) CConsoleReader(aConsole); |
|
222 return s; |
|
223 } |
|
224 |
|
225 /** |
|
226 * |
|
227 * First-phase constructor for CConsoleReader. |
|
228 * Adds itself to the Active Scheduler. |
|
229 * |
|
230 * @param "CConsoleBase& aConsole" |
|
231 * console to read from |
|
232 * |
|
233 * @xxxx |
|
234 * |
|
235 */ |
|
236 CConsoleReader::CConsoleReader(CConsoleBase& aConsole) : |
|
237 CActive(EPriorityUserInput), |
|
238 iConsole(aConsole) |
|
239 { |
|
240 CActiveScheduler::Add(this); |
|
241 } |
|
242 |
|
243 /** |
|
244 * |
|
245 * Destructor for CConsoleReader. |
|
246 * |
|
247 * @xxxx |
|
248 * |
|
249 */ |
|
250 CConsoleReader::~CConsoleReader() |
|
251 { |
|
252 Cancel(); |
|
253 } |
|
254 |
|
255 /** |
|
256 * |
|
257 * DoRead method for active object CConsoleReader; |
|
258 * sets client and starts reading |
|
259 * |
|
260 * @param "MConsoleReader& aClient" |
|
261 * client MConsoleReader (which will process the input) |
|
262 * |
|
263 * @xxxx |
|
264 * |
|
265 */ |
|
266 void CConsoleReader::DoRead(MConsoleReader& aClient) |
|
267 { |
|
268 iClient = &aClient; |
|
269 DoRead(); |
|
270 } |
|
271 |
|
272 /** |
|
273 * |
|
274 * DoRead method for active object CConsoleReader; |
|
275 * starts reading from current client |
|
276 * |
|
277 * @xxxx |
|
278 * |
|
279 */ |
|
280 void CConsoleReader::DoRead() |
|
281 { |
|
282 iConsole.Read(iStatus); |
|
283 SetActive(); |
|
284 } |
|
285 |
|
286 /** |
|
287 * |
|
288 * RunL method for active object CConsoleReader; |
|
289 * fetches a keystroke and sends it to its client for processing. |
|
290 * |
|
291 * @xxxx |
|
292 * |
|
293 */ |
|
294 void CConsoleReader::RunL() |
|
295 { |
|
296 iKeyStroke = iConsole.KeyCode(); |
|
297 if (iStatus.Int()) |
|
298 iClient->Error(iStatus.Int()); |
|
299 else |
|
300 iClient->InputReceived(iKeyStroke); |
|
301 } |
|
302 |
|
303 /** |
|
304 * |
|
305 * DoCancel method for active object CConsoleReader |
|
306 * |
|
307 * @xxxx |
|
308 * |
|
309 */ |
|
310 void CConsoleReader::DoCancel() |
|
311 { |
|
312 iConsole.ReadCancel(); |
|
313 } |