1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module contains implementation of CSettingServer |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <e32svr.h> |
|
22 |
|
23 #include "SettingServerClient.h" |
|
24 #include "SettingServer.h" |
|
25 |
|
26 #include <StifParser.h> |
|
27 #include "STIFTestFrameworkSettings.h" |
|
28 |
|
29 #include "Logging.h" |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 |
|
47 // ==================== LOCAL FUNCTIONS ======================================= |
|
48 |
|
49 // None |
|
50 |
|
51 #undef LOGGER |
|
52 #define LOGGER iSettingServer->Logger() |
|
53 |
|
54 // ================= MEMBER FUNCTIONS ========================================= |
|
55 |
|
56 /* |
|
57 ------------------------------------------------------------------------------- |
|
58 |
|
59 Class: CLoggerSetting |
|
60 |
|
61 Method: NewL |
|
62 |
|
63 Description: Create new CLoggerSetting (Setting server session) |
|
64 |
|
65 Parameters: RThread& aClient: in: Handle to thread client |
|
66 CSettingServer* aServer: in: Pointer to CSettingServer |
|
67 |
|
68 Return Values: CLoggerSetting* Pointer to new CLoggerSetting |
|
69 |
|
70 Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. |
|
71 |
|
72 Status: Proposal |
|
73 |
|
74 ------------------------------------------------------------------------------- |
|
75 */ |
|
76 CLoggerSetting* CLoggerSetting::NewL( CSettingServer* aServer ) |
|
77 { |
|
78 CLoggerSetting* self=new( ELeave ) CLoggerSetting(); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL( aServer ); |
|
81 CleanupStack::Pop(); |
|
82 return self; |
|
83 |
|
84 } |
|
85 |
|
86 /* |
|
87 ------------------------------------------------------------------------------- |
|
88 |
|
89 Class: CLoggerSetting |
|
90 |
|
91 Method: CLoggerSetting |
|
92 |
|
93 Description: Constructor. Initialise base class. |
|
94 |
|
95 Parameters: RThread& aClient: in: Handle to client |
|
96 |
|
97 Return Values: None |
|
98 |
|
99 Errors/Exceptions: None |
|
100 |
|
101 Status: Proposal |
|
102 |
|
103 ------------------------------------------------------------------------------- |
|
104 */ |
|
105 CLoggerSetting::CLoggerSetting() : |
|
106 CSession2() |
|
107 { |
|
108 |
|
109 } |
|
110 |
|
111 /* |
|
112 ------------------------------------------------------------------------------- |
|
113 |
|
114 Class: CLoggerSetting |
|
115 |
|
116 Method: ~CLoggerSetting |
|
117 |
|
118 Description: Destructor. |
|
119 |
|
120 Parameters: None |
|
121 |
|
122 Return Values: None |
|
123 |
|
124 Errors/Exceptions: None |
|
125 |
|
126 Status: Proposal |
|
127 |
|
128 ------------------------------------------------------------------------------- |
|
129 */ |
|
130 CLoggerSetting::~CLoggerSetting() |
|
131 { |
|
132 |
|
133 } |
|
134 |
|
135 /* |
|
136 ------------------------------------------------------------------------------- |
|
137 |
|
138 Class: CLoggerSetting |
|
139 |
|
140 Method: ConstructL |
|
141 |
|
142 Description: Second level constructor. |
|
143 |
|
144 Parameters: CSettingServer* aServer: in: Server |
|
145 |
|
146 Return Values: None |
|
147 |
|
148 Errors/Exceptions: Leaves if base class CreateL leaves |
|
149 |
|
150 Status: Proposal |
|
151 |
|
152 ------------------------------------------------------------------------------- |
|
153 */ |
|
154 void CLoggerSetting::ConstructL( CSettingServer* aServer ) |
|
155 { |
|
156 // @spe __TRACE( KInit,( _L( "CLoggerSetting::ConstructL - constructing server session" ) ) ); |
|
157 iSettingServer = aServer; |
|
158 |
|
159 // second-phase construct base class |
|
160 //CSession2::CreateL(); |
|
161 |
|
162 // iSettingServer = aServer; |
|
163 |
|
164 // Inform server class that session is opening. |
|
165 iSettingServer->OpenSession(); |
|
166 |
|
167 __TRACE( KInit,( _L( "CLoggerSetting::ConstructL - constructing server session done" ) ) ); |
|
168 |
|
169 } |
|
170 |
|
171 /* |
|
172 ------------------------------------------------------------------------------- |
|
173 |
|
174 Class: CLoggerSetting |
|
175 |
|
176 Method: PanicClient |
|
177 |
|
178 Description: Panic clients. |
|
179 |
|
180 Parameters: TInt aPanic: in: Panic code |
|
181 |
|
182 Return Values: None |
|
183 |
|
184 Errors/Exceptions: None |
|
185 |
|
186 Status: Proposal |
|
187 |
|
188 ------------------------------------------------------------------------------- |
|
189 */ |
|
190 void CLoggerSetting::PanicClient( const TInt aPanic, const RMessage2& aMessage ) const |
|
191 { |
|
192 __TRACE( KError,( _L( "CLoggerSetting::PanicClient code = %d" ), aPanic ) ); |
|
193 |
|
194 _LIT( KTxtModule,"CLoggerSetting" ); |
|
195 |
|
196 aMessage.Panic( KTxtModule,aPanic ); |
|
197 } |
|
198 |
|
199 /* |
|
200 ------------------------------------------------------------------------------- |
|
201 |
|
202 Class: CLoggerSetting |
|
203 |
|
204 Method: CloseSession |
|
205 |
|
206 Description: Close session |
|
207 |
|
208 Parameters: const RMessage&: out: Message to be completed. |
|
209 |
|
210 Return Values: TInt: Always KErrNone |
|
211 |
|
212 Errors/Exceptions: None |
|
213 |
|
214 Status: Proposal |
|
215 |
|
216 ------------------------------------------------------------------------------- |
|
217 */ |
|
218 TInt CLoggerSetting::CloseSession( /*const RMessage& aMessage*/ ) |
|
219 { |
|
220 __TRACE( KVerbose,( _L( "CLoggerSetting::CloseSession in" ) ) ); |
|
221 |
|
222 // Close session from server (and stop it if required) |
|
223 iSettingServer->CloseSession(); |
|
224 |
|
225 // NOTE: This complete will make after DispatchMessageL in ServiceL method. |
|
226 // Complete message. This must be done after possible closing |
|
227 // of the server to make sure that server is first closed before |
|
228 // client can send new messages. |
|
229 // aMessage.Complete( KErrNone ); |
|
230 |
|
231 __TRACE( KVerbose,( _L( "CLoggerSetting::CloseSession out" ) ) ); |
|
232 |
|
233 return KErrNone; |
|
234 |
|
235 } |
|
236 |
|
237 /* |
|
238 ------------------------------------------------------------------------------- |
|
239 |
|
240 Class: CLoggerSetting |
|
241 |
|
242 Method: ServiceL |
|
243 |
|
244 Description: Trap harness for dispatcher |
|
245 |
|
246 Parameters: const RMessage& aMessage: inout: Message |
|
247 |
|
248 Return Values: None |
|
249 |
|
250 Errors/Exceptions: None |
|
251 |
|
252 Status: Proposal |
|
253 |
|
254 ------------------------------------------------------------------------------- |
|
255 */ |
|
256 void CLoggerSetting::ServiceL( const RMessage2& aMessage ) |
|
257 { |
|
258 __TRACE( KVerbose,( _L( "CLoggerSetting::ServiceL in" ) ) ); |
|
259 |
|
260 TInt r( KErrNone ); |
|
261 TBool isMessageSync( EFalse ); |
|
262 |
|
263 TRAPD( ret, r = DispatchMessageL( aMessage, isMessageSync ) ); |
|
264 |
|
265 if( ret != KErrNone ) |
|
266 { |
|
267 // Complete message on leaving cases with leave code allways. |
|
268 __TRACE( KError,( _L( "CLoggerSetting::DispatchMessageL leaved" ) ) ); |
|
269 aMessage.Complete( ret ); |
|
270 } |
|
271 else if( isMessageSync ) |
|
272 { |
|
273 // Message is syncronous, Complete message with error code |
|
274 // originating from message handling |
|
275 __TRACE( KVerbose,( _L( "CLoggerSetting::DispatchMessageL completed with: %d" ), r ) ); |
|
276 aMessage.Complete( r ); |
|
277 } |
|
278 __TRACE( KVerbose,( _L( "CLoggerSetting::ServiceL out" ) ) ); |
|
279 |
|
280 } |
|
281 |
|
282 /* |
|
283 ------------------------------------------------------------------------------- |
|
284 |
|
285 Class: CLoggerSetting |
|
286 |
|
287 Method: DispatchMessageL |
|
288 |
|
289 Description: Dispatch message, calls corresponding function to do it. |
|
290 |
|
291 Parameters: const RMessage& aMessage: inout: Message to be handled |
|
292 TBool& aIsMessageSync: inout: Indication of the message type |
|
293 |
|
294 Return Values: TInt: Error code |
|
295 |
|
296 Errors/Exceptions: Leaves if operation handling function leaves |
|
297 |
|
298 Status: Proposal |
|
299 |
|
300 ------------------------------------------------------------------------------- |
|
301 */ |
|
302 TInt CLoggerSetting::DispatchMessageL( const RMessage2& aMessage, |
|
303 TBool& aIsMessageSync ) |
|
304 { |
|
305 __TRACE( KInit ,( _L( "CLoggerSetting::DispatchMessageL in" ) ) ); |
|
306 switch( aMessage.Function() ) |
|
307 { |
|
308 case ESettingServerCloseSession: |
|
309 { |
|
310 __TRACE( KInit ,( _L( "Closing Setting server session" ) ) ); |
|
311 aIsMessageSync = ETrue; |
|
312 return CloseSession( /*aMessage*/ ); |
|
313 } |
|
314 case ESetIniFileInformation: |
|
315 { |
|
316 __TRACE( KInit ,( _L( "Set initialization file setting" ) ) ); |
|
317 aIsMessageSync = ETrue; |
|
318 return SetIniFileSettings( aMessage ); |
|
319 } |
|
320 case EReadLoggerSettingsFromIniFile: |
|
321 { |
|
322 __TRACE( KInit ,( _L( "Read Logger setting(s) from initialization file" ) ) ); |
|
323 aIsMessageSync = ETrue; |
|
324 return ReadLoggerSettingsFromIniFile( aMessage ); |
|
325 } |
|
326 case EGetLoggerSettings: |
|
327 { |
|
328 __TRACE( KInit ,( _L( "Get Logger setting(s)" ) ) ); |
|
329 aIsMessageSync = ETrue; |
|
330 return GetLoggerSettings( aMessage ); |
|
331 } |
|
332 case ESetNewIniFileSetting: |
|
333 { |
|
334 __TRACE( KInit ,( _L( "Set new initialization file setting" ) ) ); |
|
335 aIsMessageSync = ETrue; |
|
336 return SetNewIniFileSetting( aMessage ); |
|
337 } |
|
338 case EGetEngineSettings: |
|
339 { |
|
340 __TRACE(KInit, (_L("Get Engine settings"))); |
|
341 aIsMessageSync = ETrue; |
|
342 return GetEngineSettings(aMessage); |
|
343 } |
|
344 case EStoreEngineSettings: |
|
345 { |
|
346 __TRACE(KInit, (_L("Store Engine settings"))); |
|
347 aIsMessageSync = ETrue; |
|
348 return StoreEngineSettings(aMessage); |
|
349 } |
|
350 // Invalid request |
|
351 default: |
|
352 { |
|
353 PanicClient( EBadRequest, aMessage ); |
|
354 return KErrNotSupported; |
|
355 } |
|
356 } |
|
357 |
|
358 } |
|
359 |
|
360 /* |
|
361 ------------------------------------------------------------------------------- |
|
362 |
|
363 Class: CSettingServer |
|
364 |
|
365 Method: SetIniFileSettings |
|
366 |
|
367 Description: Set initialization filename and path settings to Setting |
|
368 server. |
|
369 |
|
370 Parameters: const RMessage& aMessage: inout: Message to be handled |
|
371 |
|
372 Return Values: TInt: Symbian error code |
|
373 |
|
374 Errors/Exceptions: None |
|
375 |
|
376 Status: Proposal |
|
377 |
|
378 ------------------------------------------------------------------------------- |
|
379 */ |
|
380 TInt CLoggerSetting::SetIniFileSettings( const RMessage2& aMessage ) |
|
381 { |
|
382 __TRACE( KInit, ( _L( "CLoggerSetting::SetIniFileSettings" ) ) ); |
|
383 |
|
384 // Get data from message |
|
385 TFileName iniFile; |
|
386 |
|
387 // Get length from message param 1 |
|
388 // Read data from client descriptor (param 0) |
|
389 TRAPD( ret, aMessage.ReadL( 0, iniFile ) ); |
|
390 |
|
391 if ( ret != KErrNone ) |
|
392 { |
|
393 PanicClient( EBadDescriptor, aMessage ); |
|
394 return KErrBadDescriptor; |
|
395 } |
|
396 |
|
397 // Inifile name and path information |
|
398 iSettingServer->iIniFile = iniFile; |
|
399 |
|
400 __TRACE( KInit, ( _L( "New initialization file: [%S]" ), &iSettingServer->iIniFile ) ); |
|
401 |
|
402 return KErrNone; |
|
403 |
|
404 } |
|
405 |
|
406 /* |
|
407 ------------------------------------------------------------------------------- |
|
408 |
|
409 Class: CSettingServer |
|
410 |
|
411 Method: ReadLoggerSettingsFromIniFile |
|
412 |
|
413 Description: Read Logger setting from initialization file. Mainly use from |
|
414 TestEngine side. |
|
415 |
|
416 Parameters: const RMessage& aMessage: inout: Message to be handled |
|
417 |
|
418 Return Values: TInt: Symbian error code |
|
419 |
|
420 Errors/Exceptions: None |
|
421 |
|
422 Status: Proposal |
|
423 |
|
424 ------------------------------------------------------------------------------- |
|
425 */ |
|
426 TInt CLoggerSetting::ReadLoggerSettingsFromIniFile( const RMessage2& aMessage ) |
|
427 { |
|
428 __TRACE( KInit, ( _L( "CLoggerSetting::ReadLoggerSettingsFromIniFile" ) ) ); |
|
429 |
|
430 TInt ret = ReadLoggerDefaults(); |
|
431 if( ret != KErrNone ) |
|
432 { |
|
433 return ret; |
|
434 } |
|
435 |
|
436 // Copies logger settings to the package |
|
437 TPckg<TLoggerSettings> loggerSettingsPckg( iSettingServer->iLoggerSettings ); |
|
438 |
|
439 // Writes a packege that includes the logger overwrite settings to aMessage |
|
440 TRAPD( err, aMessage.WriteL( 0, loggerSettingsPckg ) ); |
|
441 |
|
442 if ( err != KErrNone ) |
|
443 { |
|
444 PanicClient( EBadDescriptor, aMessage ); |
|
445 } |
|
446 |
|
447 return KErrNone; |
|
448 |
|
449 } |
|
450 |
|
451 /* |
|
452 ------------------------------------------------------------------------------- |
|
453 |
|
454 Class: CLoggerSetting |
|
455 |
|
456 Method: ReadLoggerDefaults |
|
457 |
|
458 Description: Parse Logger defaults from STIF initialization |
|
459 file. |
|
460 |
|
461 Parameters: None |
|
462 |
|
463 Return Values: TInt: Return Symbian error code |
|
464 |
|
465 Errors/Exceptions: None |
|
466 |
|
467 Status: Proposal |
|
468 |
|
469 ------------------------------------------------------------------------------- |
|
470 */ |
|
471 TInt CLoggerSetting::ReadLoggerDefaults() |
|
472 { |
|
473 __TRACE( KInit,( _L( "" ) ) ); |
|
474 __TRACE( KInit,( _L( "CLoggerSetting::ReadLoggerDefaults" ) ) ); |
|
475 __TRACE( KInit,( _L( "Start reading and parsing Logger defaults" ) ) ); |
|
476 |
|
477 TInt ret = KErrNone; |
|
478 |
|
479 // Create parser for parsing ini file |
|
480 CStifParser* parser = NULL; |
|
481 TRAPD( r, parser = CStifParser::NewL( _L(""), iSettingServer->iIniFile ) ); |
|
482 if ( r != KErrNone ) |
|
483 { |
|
484 __TRACE( KError,( CStifLogger::ERed, _L( "Can't open ini-file [%S], code %d" ), &iSettingServer->iIniFile, r ) ); |
|
485 return r; |
|
486 } |
|
487 |
|
488 CSTIFTestFrameworkSettings* settings = NULL; |
|
489 TRAPD( settings_ret, settings = CSTIFTestFrameworkSettings::NewL() ); |
|
490 if ( settings_ret != KErrNone ) |
|
491 { |
|
492 __TRACE( KError,( CStifLogger::ERed, _L( "CSTIFTestFrameworkSettings class object creation fails") ) ); |
|
493 return settings_ret; |
|
494 } |
|
495 |
|
496 TInt get_ret( KErrNone ); |
|
497 |
|
498 CStifSectionParser* sectionParser = NULL; |
|
499 // Parse Logger's overwrite values |
|
500 _LIT( KDefaultsStart, "[Logger_Defaults]" ); |
|
501 _LIT( KDefaultsEnd, "[End_Logger_Defaults]" ); |
|
502 __TRACE( KInit,( _L( "Starting to search sections" ) ) ); |
|
503 |
|
504 TRAP( r, |
|
505 sectionParser = parser->SectionL( KDefaultsStart, KDefaultsEnd ); |
|
506 ); |
|
507 // Get directory settings |
|
508 if ( ( r == KErrNone ) && sectionParser ) |
|
509 { |
|
510 __TRACE( KInit,( _L( "Found '%S' and '%S' sections" ), &KDefaultsStart, &KDefaultsEnd ) ); |
|
511 |
|
512 __TRACE( KInit,( _L( "Parsing Logger directory indicator" ) ) ); |
|
513 TBool createDir( EFalse ); |
|
514 TRAP( get_ret, |
|
515 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
516 _L( "CreateLogDirectories=" ), createDir ); |
|
517 ); |
|
518 if ( get_ret == KErrNone ) |
|
519 { |
|
520 __TRACE( KInit,( _L( "Logger directory indicator: %d"), createDir ) ); |
|
521 iSettingServer->iLoggerSettings.iCreateLogDirectories = createDir; |
|
522 iSettingServer->iLoggerSettings.iIsDefined.iCreateLogDir = ETrue; |
|
523 } |
|
524 else |
|
525 { |
|
526 __TRACE( KInit,( _L( "Indicator not found or not given" ) ) ); |
|
527 } |
|
528 |
|
529 // Get Logger path settings |
|
530 __TRACE( KInit,( _L( "Parsing Logger path setting (Emulator)" ) ) ); |
|
531 TPtrC emulatorPath; |
|
532 get_ret = settings->GetFileSetting( sectionParser, |
|
533 _L( "EmulatorBasePath=" ), |
|
534 emulatorPath ); |
|
535 if ( get_ret == KErrNone ) |
|
536 { |
|
537 __TRACE( KInit,( _L( "Logger base path setting: %S"), &emulatorPath ) ); |
|
538 iSettingServer->iLoggerSettings.iEmulatorPath = emulatorPath; |
|
539 iSettingServer->iLoggerSettings.iIsDefined.iPath = ETrue; |
|
540 } |
|
541 else |
|
542 { |
|
543 __TRACE( KInit,( _L( "Path not found or not given (Emulator)" ) ) ); |
|
544 } |
|
545 |
|
546 // Get Logger format settings |
|
547 __TRACE( KInit,( _L( "Parsing Logger file type setting (Emulator)" ) ) ); |
|
548 CStifLogger::TLoggerType emulatorType = CStifLogger::ETxt; |
|
549 TRAP( get_ret, |
|
550 get_ret = settings->GetFormatL( sectionParser, |
|
551 _L( "EmulatorFormat=" ), emulatorType ); |
|
552 ); |
|
553 if ( get_ret == KErrNone ) |
|
554 { |
|
555 __TRACE( KInit,( _L( "File type setting: %d"), emulatorType ) ); |
|
556 iSettingServer->iLoggerSettings.iEmulatorFormat = emulatorType; |
|
557 iSettingServer->iLoggerSettings.iIsDefined.iFormat = ETrue; |
|
558 } |
|
559 else |
|
560 { |
|
561 __TRACE( KInit,( _L( "File type not found or not given (Emulator)" ) ) ); |
|
562 } |
|
563 |
|
564 // Get Logger output settings |
|
565 __TRACE( KInit,( _L( "Parsing Logger output setting (Emulator)" ) ) ); |
|
566 CStifLogger::TOutput emulatorOutput = CStifLogger::EFile; |
|
567 TRAP( get_ret, |
|
568 get_ret = settings->GetOutputL( sectionParser, |
|
569 _L( "EmulatorOutput=" ), emulatorOutput ); |
|
570 ); |
|
571 if ( get_ret == KErrNone ) |
|
572 { |
|
573 __TRACE( KInit,( _L( "Output setting: %d"), emulatorOutput ) ); |
|
574 iSettingServer->iLoggerSettings.iEmulatorOutput = emulatorOutput; |
|
575 iSettingServer->iLoggerSettings.iIsDefined.iOutput = ETrue; |
|
576 } |
|
577 else |
|
578 { |
|
579 __TRACE( KInit,( _L( "Output not found or not given (Emulator)" ) ) ); |
|
580 } |
|
581 |
|
582 // Get Logger HW path settings |
|
583 __TRACE( KInit,( _L( "Parsing Logger path setting (Hardware)" ) ) ); |
|
584 TPtrC hwPath; |
|
585 get_ret = settings->GetFileSetting( sectionParser, |
|
586 _L( "HardwareBasePath=" ), |
|
587 hwPath ); |
|
588 if ( get_ret == KErrNone ) |
|
589 { |
|
590 __TRACE( KInit,( _L( "Base path setting: %S"), &hwPath ) ); |
|
591 iSettingServer->iLoggerSettings.iHardwarePath = hwPath; |
|
592 iSettingServer->iLoggerSettings.iIsDefined.iHwPath = ETrue; |
|
593 } |
|
594 else |
|
595 { |
|
596 __TRACE( KInit,( _L( "Path not found or not given (Hardware)" ) ) ); |
|
597 } |
|
598 |
|
599 // Get Logger HW format settings |
|
600 __TRACE( KInit,( _L( "Parsing Logger file type setting (Hardware)" ) ) ); |
|
601 CStifLogger::TLoggerType hwType = CStifLogger::ETxt; |
|
602 TRAP( get_ret, |
|
603 get_ret = settings->GetFormatL( sectionParser, |
|
604 _L( "HardwareFormat=" ), hwType ); |
|
605 ); |
|
606 if ( get_ret == KErrNone ) |
|
607 { |
|
608 __TRACE( KInit,( _L( "File type setting: %d"), hwType ) ); |
|
609 iSettingServer->iLoggerSettings.iHardwareFormat = hwType; |
|
610 iSettingServer->iLoggerSettings.iIsDefined.iHwFormat = ETrue; |
|
611 } |
|
612 else |
|
613 { |
|
614 __TRACE( KInit,( _L( "File type not found or not given (Hardware)" ) ) ); |
|
615 } |
|
616 |
|
617 // Get Logger HW output settings |
|
618 __TRACE( KInit,( _L( "Parsing Logger output setting (Hardware)" ) ) ); |
|
619 CStifLogger::TOutput hwOutput = CStifLogger::EFile; |
|
620 TRAP( get_ret, |
|
621 get_ret = settings->GetOutputL( sectionParser, |
|
622 _L( "HardwareOutput=" ), hwOutput ); |
|
623 ); |
|
624 if ( get_ret == KErrNone ) |
|
625 { |
|
626 __TRACE( KInit,( _L( "Output setting: %d"), hwOutput ) ); |
|
627 iSettingServer->iLoggerSettings.iHardwareOutput = hwOutput; |
|
628 iSettingServer->iLoggerSettings.iIsDefined.iHwOutput = ETrue; |
|
629 } |
|
630 else |
|
631 { |
|
632 __TRACE( KInit,( _L( "Output not found or not given (Hardware)" ) ) ); |
|
633 } |
|
634 |
|
635 // Get Logger file creation mode (overwrite settings) |
|
636 __TRACE( KInit,( _L( "Parsing file creation setting" ) ) ); |
|
637 TBool overwrite( ETrue ); |
|
638 TRAP( get_ret, |
|
639 get_ret = settings->GetOverwriteL( sectionParser, |
|
640 _L( "FileCreationMode=" ), overwrite ); |
|
641 ); |
|
642 if ( get_ret == KErrNone ) |
|
643 { |
|
644 __TRACE( KInit,( _L( "File creation mode setting: %d"), overwrite ) ); |
|
645 iSettingServer->iLoggerSettings.iOverwrite = overwrite; |
|
646 iSettingServer->iLoggerSettings.iIsDefined.iOverwrite = ETrue; |
|
647 } |
|
648 else |
|
649 { |
|
650 __TRACE( KInit,( _L( "File creation not found or not given" ) ) ); |
|
651 } |
|
652 |
|
653 // Get Time stamp settings |
|
654 __TRACE( KInit,( _L( "Parsing time stamp setting" ) ) ); |
|
655 TBool timeStamp( ETrue ); |
|
656 TRAP( get_ret, |
|
657 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
658 _L( "WithTimeStamp=" ), timeStamp ); |
|
659 ); |
|
660 if ( get_ret == KErrNone ) |
|
661 { |
|
662 __TRACE( KInit,( _L( "Time stamp setting: %d"), timeStamp ) ); |
|
663 iSettingServer->iLoggerSettings.iTimeStamp = timeStamp; |
|
664 iSettingServer->iLoggerSettings.iIsDefined.iTimeStamp = ETrue; |
|
665 } |
|
666 else |
|
667 { |
|
668 __TRACE( KInit,( _L( "Time stamp not found or not given" ) ) ); |
|
669 } |
|
670 |
|
671 // Get Test report line break settings |
|
672 __TRACE( KInit,( _L( "Parsing line break setting" ) ) ); |
|
673 TBool lineBreak( ETrue ); |
|
674 TRAP( get_ret, |
|
675 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
676 _L( "WithLineBreak=" ), lineBreak ); |
|
677 ); |
|
678 if ( get_ret == KErrNone ) |
|
679 { |
|
680 __TRACE( KInit,( _L( "Line break setting: %d"), lineBreak ) ); |
|
681 iSettingServer->iLoggerSettings.iLineBreak = lineBreak; |
|
682 iSettingServer->iLoggerSettings.iIsDefined.iLineBreak = ETrue; |
|
683 } |
|
684 else |
|
685 { |
|
686 __TRACE( KInit,( _L( "Line break not found or not given" ) ) ); |
|
687 } |
|
688 |
|
689 // Get Test report event ranking settings |
|
690 __TRACE( KInit,( _L( "Parsing event ranking setting" ) ) ); |
|
691 TBool eventRanking( EFalse ); |
|
692 TRAP( get_ret, |
|
693 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
694 _L( "WithEventRanking=" ), eventRanking ); |
|
695 ); |
|
696 if ( get_ret == KErrNone ) |
|
697 { |
|
698 __TRACE( KInit,( _L( "Event ranking setting: %d"), eventRanking ) ); |
|
699 iSettingServer->iLoggerSettings.iEventRanking = eventRanking; |
|
700 iSettingServer->iLoggerSettings.iIsDefined.iEventRanking = ETrue; |
|
701 } |
|
702 else |
|
703 { |
|
704 __TRACE( KInit,( _L( "Event ranking not found or not given" ) ) ); |
|
705 } |
|
706 |
|
707 // Get Test report thread id settings |
|
708 __TRACE( KInit,( _L( "Parsing thread id setting" ) ) ); |
|
709 TBool threadId( EFalse ); |
|
710 TRAP( get_ret, |
|
711 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
712 _L( "ThreadIdToLogFile=" ), threadId ); |
|
713 ); |
|
714 if ( get_ret == KErrNone ) |
|
715 { |
|
716 __TRACE( KInit,( _L( "Thread id setting: %d"), threadId ) ); |
|
717 iSettingServer->iLoggerSettings.iThreadId = threadId; |
|
718 iSettingServer->iLoggerSettings.iIsDefined.iThreadId = ETrue; |
|
719 } |
|
720 else |
|
721 { |
|
722 __TRACE( KInit,( _L( "Thread id not found or not given" ) ) ); |
|
723 } |
|
724 // Get unicode setting |
|
725 __TRACE( KInit,( _L( "Parsing unicode setting" ) ) ); |
|
726 TBool unicode(EFalse); |
|
727 TRAP( get_ret, |
|
728 get_ret = settings->GetBooleanSettingsL( sectionParser, |
|
729 _L( "FileUnicode=" ), unicode ); |
|
730 ); |
|
731 if ( get_ret == KErrNone ) |
|
732 { |
|
733 __TRACE( KInit,( _L( "Unicode setting: %d"), unicode ) ); |
|
734 iSettingServer->iLoggerSettings.iUnicode = unicode; |
|
735 iSettingServer->iLoggerSettings.iIsDefined.iUnicode = ETrue; |
|
736 } |
|
737 else |
|
738 { |
|
739 __TRACE( KInit,( _L( "Unicode setting not found or not given" ) ) ); |
|
740 } |
|
741 |
|
742 // Check if test case title should be added to log file name |
|
743 __TRACE( KInit,( _L( "Parsing AddTestCaseTitle setting" ) ) ); |
|
744 TBool addTestCaseTitle(EFalse); |
|
745 TRAP(get_ret, |
|
746 get_ret = settings->GetBooleanSettingsL(sectionParser, |
|
747 _L( "AddTestCaseTitle=" ), addTestCaseTitle); |
|
748 ); |
|
749 if(get_ret == KErrNone) |
|
750 { |
|
751 __TRACE( KInit,( _L( "AddTestCaseTitle setting: %d"), addTestCaseTitle)); |
|
752 iSettingServer->iLoggerSettings.iAddTestCaseTitle = addTestCaseTitle; |
|
753 iSettingServer->iLoggerSettings.iIsDefined.iAddTestCaseTitle = ETrue; |
|
754 } |
|
755 else |
|
756 { |
|
757 __TRACE(KInit, (_L("AddTestCaseTitle setting not found or not given"))); |
|
758 } |
|
759 } |
|
760 else |
|
761 { |
|
762 __TRACE( KInit,( _L( "Not found '%S' and '%S' sections" ), &KDefaultsStart, &KDefaultsEnd ) ); |
|
763 ret = KErrNotFound; |
|
764 } |
|
765 __TRACE( KInit,( _L( "End reading and parsing Logger defaults" ) ) ); |
|
766 __TRACE( KInit,( _L( "" ) ) ); |
|
767 delete sectionParser; |
|
768 delete settings; |
|
769 delete parser; |
|
770 |
|
771 return ret; |
|
772 |
|
773 } |
|
774 |
|
775 /* |
|
776 ------------------------------------------------------------------------------- |
|
777 |
|
778 Class: CSettingServer |
|
779 |
|
780 Method: GetLoggerSettings |
|
781 |
|
782 Description: Get Logger settings. Mainly use from Logger side. |
|
783 |
|
784 If there are not any active sessions, then stop active scheduler and |
|
785 close whole server. |
|
786 |
|
787 Parameters: None |
|
788 |
|
789 Return Values: TInt: Symbian error code |
|
790 |
|
791 Errors/Exceptions: None |
|
792 |
|
793 Status: Proposal |
|
794 |
|
795 ------------------------------------------------------------------------------- |
|
796 */ |
|
797 TInt CLoggerSetting::GetLoggerSettings( const RMessage2& aMessage ) |
|
798 { |
|
799 __TRACE( KInit, ( _L( "CLoggerSetting::GetLoggerSettings in" ) ) ); |
|
800 |
|
801 // Copies logger settings to the package |
|
802 TPckg<TLoggerSettings> loggerSettingsPckg( iSettingServer->iLoggerSettings ); |
|
803 |
|
804 // Writes a packege that includes the logger overwrite settings to aMessage |
|
805 TRAPD( err, aMessage.WriteL( 0, loggerSettingsPckg ) ); |
|
806 |
|
807 if ( err != KErrNone ) |
|
808 { |
|
809 PanicClient( EBadDescriptor, aMessage ); |
|
810 } |
|
811 |
|
812 __TRACE( KInit, ( _L( "CLoggerSetting::GetLoggerSettings out" ) ) ); |
|
813 |
|
814 return KErrNone; |
|
815 |
|
816 } |
|
817 |
|
818 /* |
|
819 ------------------------------------------------------------------------------- |
|
820 |
|
821 Class: CSettingServer |
|
822 |
|
823 Method: SetNewIniFileSetting |
|
824 |
|
825 Description: Set new initialization file settings to WINS and HW platforms. |
|
826 |
|
827 Parameters: None |
|
828 |
|
829 Return Values: TInt: Symbian error code |
|
830 |
|
831 Errors/Exceptions: None |
|
832 |
|
833 Status: Proposal |
|
834 |
|
835 ------------------------------------------------------------------------------- |
|
836 */ |
|
837 TInt CLoggerSetting::SetNewIniFileSetting( const RMessage2& aMessage ) |
|
838 { |
|
839 __TRACE( KInit, ( _L( "CLoggerSetting::SetNewIniFileSetting" ) ) ); |
|
840 |
|
841 TInt ret( 0 ); |
|
842 |
|
843 TName newIniFileSetting; |
|
844 // Get data from message |
|
845 // NOTE! If message length is over TName, ReadL will cut the message |
|
846 // to allowed size and won't return any error code or leave code. |
|
847 TRAP( ret, aMessage.ReadL( 0, newIniFileSetting ) ); |
|
848 |
|
849 if ( ret != KErrNone ) |
|
850 { |
|
851 PanicClient( EBadDescriptor, aMessage ); |
|
852 return KErrBadDescriptor; |
|
853 } |
|
854 |
|
855 iSettingServer->iLoggerSettings.iEmulatorPath = newIniFileSetting; |
|
856 iSettingServer->iLoggerSettings.iIsDefined.iPath = ETrue; |
|
857 iSettingServer->iLoggerSettings.iHardwarePath = newIniFileSetting; |
|
858 iSettingServer->iLoggerSettings.iIsDefined.iHwPath = ETrue; |
|
859 |
|
860 __TRACE( KInit, ( _L( "New emulator and hardware path: [%S]" ), &newIniFileSetting ) ); |
|
861 |
|
862 return KErrNone; |
|
863 |
|
864 } |
|
865 |
|
866 /* |
|
867 ------------------------------------------------------------------------------- |
|
868 |
|
869 Class: CSettingServer |
|
870 |
|
871 Method: GetEngineSettings |
|
872 |
|
873 Description: Get TestEngine settings. |
|
874 |
|
875 If there are not any active sessions, then stop active scheduler and |
|
876 close whole server. |
|
877 |
|
878 Parameters: None |
|
879 |
|
880 Return Values: TInt: Symbian error code |
|
881 |
|
882 Errors/Exceptions: None |
|
883 |
|
884 Status: Proposal |
|
885 |
|
886 ------------------------------------------------------------------------------- |
|
887 */ |
|
888 TInt CLoggerSetting::GetEngineSettings(const RMessage2& aMessage) |
|
889 { |
|
890 __TRACE(KInit, (_L("CLoggerSetting::GetEngineSettings in"))); |
|
891 |
|
892 // Copies logger settings to the package |
|
893 TPckg<TEngineSettings> engineSettingsPckg(iSettingServer->iEngineSettings); |
|
894 |
|
895 // Writes a packege that includes the logger overwrite settings to aMessage |
|
896 TRAPD(err, aMessage.WriteL(0, engineSettingsPckg)); |
|
897 |
|
898 if(err != KErrNone) |
|
899 { |
|
900 PanicClient(EBadDescriptor, aMessage); |
|
901 } |
|
902 |
|
903 __TRACE(KInit, (_L("CLoggerSetting::GetEngineSettings out"))); |
|
904 |
|
905 return KErrNone; |
|
906 } |
|
907 |
|
908 /* |
|
909 ------------------------------------------------------------------------------- |
|
910 |
|
911 Class: CSettingServer |
|
912 |
|
913 Method: StoreEngineSettings |
|
914 |
|
915 Description: Store TestEngine settings. |
|
916 |
|
917 If there are not any active sessions, then stop active scheduler and |
|
918 close whole server. |
|
919 |
|
920 Parameters: None |
|
921 |
|
922 Return Values: TInt: Symbian error code |
|
923 |
|
924 Errors/Exceptions: None |
|
925 |
|
926 Status: Proposal |
|
927 |
|
928 ------------------------------------------------------------------------------- |
|
929 */ |
|
930 TInt CLoggerSetting::StoreEngineSettings(const RMessage2& aMessage) |
|
931 { |
|
932 __TRACE(KInit, (_L("CLoggerSetting::StoreEngineSettings in"))); |
|
933 |
|
934 // Copies logger settings to the package |
|
935 TPckg<TEngineSettings> engineSettingsPckg(iSettingServer->iEngineSettings); |
|
936 |
|
937 // Reads a packege that includes the engine settings |
|
938 TRAPD(err, aMessage.ReadL(0, engineSettingsPckg)); |
|
939 |
|
940 if(err != KErrNone) |
|
941 { |
|
942 PanicClient(EBadDescriptor, aMessage); |
|
943 } |
|
944 |
|
945 __TRACE(KInit, (_L("CLoggerSetting::StoreEngineSettings out"))); |
|
946 |
|
947 return KErrNone; |
|
948 } |
|
949 |
|
950 // End of File |
|