|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Implementation of customization components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "TestParams.h" |
|
23 |
|
24 //#include <e32svr.h> |
|
25 |
|
26 #include <StifLogger.h> |
|
27 #include <StifItemParser.h> |
|
28 //#include <Stiftestinterface.h> |
|
29 |
|
30 //#include "ThemesTest.h" |
|
31 #include "TestDmCallback.h" |
|
32 #include "TestDmDDFObject.h" |
|
33 #include "FileCoderB64.h" |
|
34 |
|
35 #include "nsmldmuri.h" |
|
36 |
|
37 |
|
38 // EXTERNAL DATA STRUCTURES |
|
39 //extern ?external_data; |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 //extern ?external_function( ?arg_type,?arg_type ); |
|
43 |
|
44 // CONSTANTS |
|
45 //const ?type ?constant_var = ?constant; |
|
46 |
|
47 // MACROS |
|
48 //#define ?macro ?macro_def |
|
49 |
|
50 // LOCAL CONSTANTS AND MACROS |
|
51 //const ?type ?constant_var = ?constant; |
|
52 //#define ?macro_name ?macro_def |
|
53 |
|
54 // MODULE DATA STRUCTURES |
|
55 //enum ?declaration |
|
56 //typedef ?declaration |
|
57 |
|
58 // LOCAL FUNCTION PROTOTYPES |
|
59 //?type ?function_name( ?arg_type, ?arg_type ); |
|
60 |
|
61 // FORWARD DECLARATIONS |
|
62 //class ?FORWARD_CLASSNAME; |
|
63 |
|
64 // ============================= LOCAL FUNCTIONS =============================== |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =============================== |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CTestParams::CTestParams |
|
73 // C++ default constructor can NOT contain any code, that |
|
74 // might leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CTestParams::CTestParams( CStifLogger *aLog ) |
|
78 : iLog( aLog ) |
|
79 // , iStr( 0 ) |
|
80 , iUri( 0 ) |
|
81 , iData( 0 ) |
|
82 , iDataType( 0 ) |
|
83 , iOutputFile( 0 ) |
|
84 , iExpectedStatus( -1 ) |
|
85 , iExpectedData( 0 ) |
|
86 , iExpectedType( 0 ) |
|
87 , iStatusRef( -1 ) |
|
88 , iResultsRef( -1 ) |
|
89 { |
|
90 /**/ |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CTestParams::ConstructL |
|
95 // Symbian 2nd phase constructor can leave. |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CTestParams::ConstructL( CStifItemParser& aItem ) |
|
99 { |
|
100 // Parse parameters |
|
101 TPtrC str; |
|
102 TInt ret = aItem.Remainder( str ); |
|
103 |
|
104 TBuf8<200> buf; |
|
105 buf.Copy( str ) ; |
|
106 |
|
107 iLog->Log( _L("CmdParams: '%S'"), &str ); |
|
108 |
|
109 |
|
110 // TInt i = 0; |
|
111 // while (aItem.GetNextString( str ) == KErrNone ) |
|
112 // { |
|
113 // iLog->Log( _L("Par[%d]: '%S'"), i, &str ); |
|
114 // } |
|
115 |
|
116 // iLog->Log( _L("Version is")) ; |
|
117 // iLog->Log( version->Ptr(0) ) ; |
|
118 // |
|
119 // iLog->Log( _L("Add Test Adding Policy data failed! %d" ), iStatus ); |
|
120 |
|
121 TTestParamVar var( buf ); |
|
122 while (var.Next()) |
|
123 { |
|
124 TPtrC8 key = var.Name(); |
|
125 TPtrC8 value = var.Value(); |
|
126 TBool exist = var.ValueExist(); |
|
127 iLog->Log(_L8("key: '%S', value: '%S', exist: %d"), &key, &value, exist); |
|
128 |
|
129 /* |
|
130 Syntax: |
|
131 ------- |
|
132 |
|
133 URI= |
|
134 |
|
135 File= |
|
136 Text= |
|
137 |
|
138 IT= Input (text) |
|
139 IF= Input File (filename) |
|
140 OF= Output File |
|
141 |
|
142 ET= Expected result (text) |
|
143 EF= Expected file (filename) |
|
144 |
|
145 */ |
|
146 _LIT8( KURI, "URI" ); // = value |
|
147 |
|
148 _LIT8( KText, "Text" ); // = "Text input" |
|
149 _LIT8( KFile, "File" ); // = Filename (and path) |
|
150 _LIT8( KType, "Type" ); // = MimeType (of data) |
|
151 |
|
152 _LIT8( KInputText, "IT" ); // = "Input Text" |
|
153 _LIT8( KInputFile, "IF" ); // = InputFileName (and path) |
|
154 _LIT8( KInputFile2, "IF2" ); // = InputFileName (and path) |
|
155 _LIT8( KInputType, "IM" ); // = Input MimeType (of data) |
|
156 _LIT8( KOutputFile, "OF" ); // = OutputFileName (and path) (where result data is saved) |
|
157 |
|
158 _LIT8( KExpectedStatus, "ES" ); // = <Expected Status Code> |
|
159 _LIT8( KExpectedText, "ET" ); // = "Expected Result Text" |
|
160 _LIT8( KExpectedFile, "EF" ); // = ExpectedResultFile (and path) |
|
161 _LIT8( KExpectedFile2, "EF2" ); // = ExpectedResultFile (and path) |
|
162 _LIT8( KExpectedType, "EM" ); // = Expected MimeType (of return data) |
|
163 |
|
164 // , iUri( 0 ) |
|
165 // , iData( 0 ) |
|
166 // , iDataType( 0 ) |
|
167 |
|
168 if ( key.CompareF( KURI ) == 0 ) |
|
169 { |
|
170 if (iUri == 0) |
|
171 { |
|
172 delete iUri; |
|
173 iUri = 0; |
|
174 iUri = value.AllocL(); |
|
175 } |
|
176 else |
|
177 { |
|
178 iLog->Log(_L8("Warning: URI already given, not resetting to: '%S'"), &value ); |
|
179 } |
|
180 } |
|
181 else if ( key.CompareF( KInputText ) == 0 || key.CompareF( KText ) == 0 ) |
|
182 { |
|
183 delete iData; |
|
184 iData = 0; |
|
185 iData = value.AllocL(); |
|
186 } |
|
187 else if ( key.CompareF( KInputFile ) == 0 || key.CompareF( KFile ) == 0 ) |
|
188 { |
|
189 delete iData; |
|
190 iData = 0; |
|
191 |
|
192 TFileCoderB64 coder; |
|
193 User::LeaveIfError( coder.EncodeL( value, iData ) ); |
|
194 } |
|
195 else if ( key.CompareF( KInputFile2) == 0 ) |
|
196 { |
|
197 delete iData; |
|
198 iData = 0; |
|
199 |
|
200 RFs fs; fs.Connect(); |
|
201 TFileName fn; fn.Copy(value); |
|
202 RFile f; f.Open(fs, fn, EFileShareExclusive|EFileRead); |
|
203 |
|
204 TInt size; f.Size( size ); |
|
205 iData = HBufC8::NewL( size ); |
|
206 TPtr8 ptr( iData->Des() ); |
|
207 f.Read( ptr ); |
|
208 |
|
209 f.Close(); |
|
210 fs.Close(); |
|
211 } |
|
212 else if ( key.CompareF( KInputType ) == 0 || key.CompareF( KType ) == 0 ) |
|
213 { |
|
214 delete iDataType; |
|
215 iDataType = 0; |
|
216 iDataType = value.AllocL(); |
|
217 } |
|
218 else if (key.CompareF( KOutputFile ) == 0 ) |
|
219 { |
|
220 delete iOutputFile; |
|
221 iOutputFile = 0; |
|
222 iOutputFile = value.AllocL(); |
|
223 } |
|
224 else if (key.CompareF( KExpectedStatus ) == 0 ) |
|
225 { |
|
226 TLex8 lex( value ); |
|
227 User::LeaveIfError( lex.Val( iExpectedStatus ) ); |
|
228 } |
|
229 else if (key.CompareF( KExpectedText ) == 0 ) |
|
230 { |
|
231 delete iExpectedData; |
|
232 iExpectedData = 0; |
|
233 iExpectedData = value.AllocL(); |
|
234 } |
|
235 else if (key.CompareF( KExpectedFile ) == 0 ) |
|
236 { |
|
237 delete iExpectedData; |
|
238 iExpectedData = 0; |
|
239 |
|
240 TFileCoderB64 coder; |
|
241 User::LeaveIfError( coder.EncodeL( value, iExpectedData ) ); |
|
242 } |
|
243 else if (key.CompareF( KExpectedFile2 ) == 0 ) |
|
244 { |
|
245 delete iExpectedData; |
|
246 iExpectedData = 0; |
|
247 |
|
248 RFs fs; fs.Connect(); |
|
249 TFileName fn; fn.Copy(value); |
|
250 RFile f; f.Open(fs, fn, EFileShareExclusive|EFileRead); |
|
251 |
|
252 TInt size; f.Size( size ); |
|
253 iExpectedData = HBufC8::NewL( size ); |
|
254 TPtr8 ptr( iExpectedData->Des() ); |
|
255 f.Read( ptr ); |
|
256 |
|
257 f.Close(); |
|
258 fs.Close(); |
|
259 } |
|
260 else if (key.CompareF( KExpectedType ) == 0 ) |
|
261 { |
|
262 delete iExpectedType; |
|
263 iExpectedType = 0; |
|
264 iExpectedType = value.AllocL(); |
|
265 } |
|
266 else |
|
267 { |
|
268 // Unknown parameter |
|
269 iLog->Log(_L8("Warning: Unknown parameter: key: '%S', value: '%S', exist: %d"), &key, &value, exist); |
|
270 } |
|
271 |
|
272 } |
|
273 // Cleanup |
|
274 } |
|
275 |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CTestParams::NewL |
|
279 // Two-phased constructor. |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 CTestParams* CTestParams::NewL( CStifLogger *aLog, CStifItemParser& aItem ) |
|
283 { |
|
284 CTestParams* self = NewLC( aLog, aItem ); |
|
285 CleanupStack::Pop( self ); |
|
286 |
|
287 return self; |
|
288 } |
|
289 CTestParams* CTestParams::NewLC( CStifLogger *aLog, CStifItemParser& aItem ) |
|
290 { |
|
291 CTestParams* self = new (ELeave) CTestParams( aLog ); |
|
292 |
|
293 CleanupStack::PushL( self ); |
|
294 self->ConstructL( aItem ); |
|
295 |
|
296 return self; |
|
297 } |
|
298 |
|
299 |
|
300 // Destructor |
|
301 CTestParams::~CTestParams() |
|
302 { |
|
303 /**/ |
|
304 delete iUri; |
|
305 delete iData; |
|
306 delete iDataType; |
|
307 delete iOutputFile; |
|
308 delete iExpectedData; |
|
309 delete iExpectedType; |
|
310 } |
|
311 |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CTestParams::?member_function |
|
315 // ?implementation_description |
|
316 // (other items were commented in a header). |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 /*?type CTestParams::?member_function( |
|
320 ?arg_type arg, |
|
321 ?arg_type arg ) |
|
322 { |
|
323 |
|
324 ?code |
|
325 |
|
326 } |
|
327 */ |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 /* |
|
334 void CTestParams::SetL( CStifItemParser& aItem ) |
|
335 { |
|
336 // iString = aItem. |
|
337 TPtrC str; |
|
338 TInt ret = aItem.Remainder( str ); |
|
339 } |
|
340 */ |
|
341 const TDesC8& CTestParams::Uri() |
|
342 { |
|
343 if (iUri != 0) |
|
344 { |
|
345 return *iUri; |
|
346 } |
|
347 else |
|
348 { |
|
349 return KNullDesC8; |
|
350 } |
|
351 } |
|
352 const TDesC8& CTestParams::Data() |
|
353 { |
|
354 if (iData != 0) |
|
355 { |
|
356 return *iData; |
|
357 } |
|
358 else |
|
359 { |
|
360 return KNullDesC8; |
|
361 } |
|
362 } |
|
363 const TDesC8& CTestParams::DataType() |
|
364 { |
|
365 if (iDataType != 0) |
|
366 { |
|
367 return *iDataType; |
|
368 } |
|
369 else |
|
370 { |
|
371 return KNullDesC8; |
|
372 } |
|
373 } |
|
374 //sf-void CTestParams::SetCallback( CTestDmCallback* aCallback ) |
|
375 //sf- { |
|
376 //sf- iCallback = aCallback; |
|
377 //sf- } |
|
378 void CTestParams::SetResultsRef( TInt aResultsRef ) |
|
379 { |
|
380 iResultsRef = aResultsRef; |
|
381 } |
|
382 void CTestParams::SetStatusRef( TInt aStatusRef ) |
|
383 { |
|
384 iStatusRef = aStatusRef; |
|
385 } |
|
386 |
|
387 |
|
388 //sf-TInt CTestParams::CheckStatusL( MSmlDmAdapter::TError aStatus ) |
|
389 TInt CTestParams::CheckStatusL( TInt aStatus ) |
|
390 { |
|
391 TInt ret = KErrNone; |
|
392 |
|
393 if (iExpectedStatus >= 0 && iExpectedStatus != aStatus) |
|
394 { |
|
395 iLog->Log( _L8("Error: CTestParams::CheckStatusL: expected=%d, status=%d"), iExpectedStatus, aStatus ); |
|
396 ret = KErrGeneral; |
|
397 } |
|
398 |
|
399 return ret; |
|
400 } |
|
401 |
|
402 TInt CTestParams::CheckDataL( CBufFlat& aObject ) |
|
403 { |
|
404 TPtrC8 ptr = aObject.Ptr(0); |
|
405 TInt ret = CheckDataL( ptr ); |
|
406 return ret; |
|
407 /* |
|
408 TInt ret = KErrNone; |
|
409 |
|
410 if (iExpectedData) |
|
411 { |
|
412 TPtrC8 ptr = aObject.Ptr(0); |
|
413 if (iExpectedData->Compare( ptr ) != 0) |
|
414 { |
|
415 iLog->Log( _L8("Error: CTestParams::CheckDataL") ); |
|
416 ret = KErrGeneral; |
|
417 } |
|
418 } |
|
419 |
|
420 return ret; |
|
421 */ |
|
422 } |
|
423 |
|
424 TInt CTestParams::CheckDataL( const TDesC8& aObject ) |
|
425 { |
|
426 TInt ret = KErrNone; |
|
427 |
|
428 if (iExpectedData) |
|
429 { |
|
430 TInt len1 = iExpectedData->Length(); |
|
431 TInt len2 = aObject.Length(); |
|
432 if (iExpectedData->Compare( aObject ) != 0) |
|
433 { |
|
434 TPtrC8 expt = iExpectedData->Left( 80 ); |
|
435 TPtrC8 real = aObject.Left( 80 ); |
|
436 //sf- iLog->Log( _L8("Error: CTestParams::CheckDataL") ); |
|
437 iLog->Log( _L8("Error: CTestParams::CheckDataL: expected='%S', real='%S'"), &expt, &real ); |
|
438 ret = KErrGeneral; |
|
439 } |
|
440 } |
|
441 |
|
442 return ret; |
|
443 } |
|
444 |
|
445 TInt CTestParams::CheckTypeL( const TDesC8 &aType ) |
|
446 { |
|
447 TInt ret = KErrNone; |
|
448 |
|
449 if (iExpectedType) |
|
450 { |
|
451 if (iExpectedType->CompareF( aType ) != 0) |
|
452 { |
|
453 iLog->Log( _L8("Error: CTestParams::CheckTypeL: exp='%S', typ='%S'"), iExpectedType, &aType ); |
|
454 ret = KErrGeneral; |
|
455 } |
|
456 } |
|
457 |
|
458 return ret; |
|
459 } |
|
460 |
|
461 TInt CTestParams::CheckL( CTestDmCallback* aCallback ) |
|
462 { |
|
463 TInt ret = KErrNone; |
|
464 // MSmlDmAdapter::TError status = EOk; |
|
465 // const CBufBase& GetResultsObjectL( TInt aResultsRef ); |
|
466 // const TDesC8& GetResultsTypeL( TInt aResultsRef ); |
|
467 |
|
468 if (iStatusRef >= 0) |
|
469 { |
|
470 MSmlDmAdapter::TError status = aCallback->GetStatusL( iStatusRef ); |
|
471 TInt ret1 = CheckStatusL( status ); |
|
472 |
|
473 ret = (ret != KErrNone) ? ret : ret1; |
|
474 } |
|
475 else |
|
476 { |
|
477 // iLog->"Error: StatusRef not set" |
|
478 } |
|
479 |
|
480 if (iResultsRef >= 0) |
|
481 { |
|
482 const CBufBase& tmpObject = aCallback->GetResultsObjectL( iResultsRef ); |
|
483 TInt ret1 = CheckDataL( *(CBufFlat*) &tmpObject ); |
|
484 |
|
485 TPtrC8 tmpType = aCallback->GetResultsTypeL( iResultsRef ); |
|
486 TInt ret2 = CheckTypeL( tmpType ); |
|
487 |
|
488 // choose first error code |
|
489 ret = (ret != KErrNone) ? ret : ret1; |
|
490 ret = (ret != KErrNone) ? ret : ret2; |
|
491 } |
|
492 else |
|
493 { |
|
494 // iLog->"Note: ResultsRef not set" |
|
495 } |
|
496 |
|
497 return ret; |
|
498 } |
|
499 |
|
500 TInt CTestParams::CheckStatusRefL( TInt aStatusRef ) |
|
501 { |
|
502 TInt ret = KErrNone; |
|
503 |
|
504 if (iExpectedStatus) |
|
505 { |
|
506 |
|
507 } |
|
508 |
|
509 return ret; |
|
510 } |
|
511 TInt CTestParams::CheckResultsRefL( TInt aResultsRef ) |
|
512 { |
|
513 TInt ret = KErrNone; |
|
514 |
|
515 if (iExpectedStatus) |
|
516 { |
|
517 |
|
518 } |
|
519 |
|
520 return ret; |
|
521 } |
|
522 |
|
523 |
|
524 //****************************************************************************** |
|
525 // |
|
526 // |
|
527 // |
|
528 //****************************************************************************** |
|
529 |
|
530 // ============================ MEMBER FUNCTIONS =============================== |
|
531 |
|
532 // ----------------------------------------------------------------------------- |
|
533 // CDDFTestParams::CDDFTestParams |
|
534 // C++ default constructor can NOT contain any code, that |
|
535 // might leave. |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 CDDFTestParams::CDDFTestParams( CStifLogger *aLog ) |
|
539 : iLog( aLog ) |
|
540 , iUri( 0 ) |
|
541 |
|
542 // , iAccessTypes |
|
543 , iDefaultValue( 0 ) |
|
544 , iDescription( 0 ) |
|
545 // , iFormat( 0 ) |
|
546 // , iOccurence( 0 ) |
|
547 // , iScope( 0 ) |
|
548 , iTitle( 0 ) |
|
549 , iMimeType( 0 ) |
|
550 , iObjectGroup( 0 ) |
|
551 { |
|
552 /**/ |
|
553 } |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CDDFTestParams::ConstructL |
|
557 // Symbian 2nd phase constructor can leave. |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 void CDDFTestParams::ConstructL( CStifItemParser& aItem ) |
|
561 { |
|
562 // Parse parameters |
|
563 TPtrC str; |
|
564 TInt ret = aItem.Remainder( str ); |
|
565 |
|
566 HBufC8* ptr = HBufC8::NewLC( str.Length() ); |
|
567 ptr->Des().Copy( str ); |
|
568 |
|
569 //sf- TBuf8<400> buf; |
|
570 //sf- buf.Copy( str ) ; |
|
571 |
|
572 iLog->Log( _L("CmdParams: '%S'"), &str ); |
|
573 |
|
574 /* |
|
575 Syntax: |
|
576 ------- |
|
577 //same as uri Name= |
|
578 AccessTypes= |
|
579 DefaultValue= |
|
580 Description= |
|
581 Format= |
|
582 Occurence= |
|
583 Scope= |
|
584 Title= |
|
585 MimeType= |
|
586 ObjectGroup= |
|
587 */ |
|
588 /* Keywords */ |
|
589 _LIT8( KURI, "URI" ); // = uri |
|
590 _LIT8( KAccessTypes, "AccessTypes" ); // = |
|
591 _LIT8( KDefaultValue, "DefaultValue" ); // = |
|
592 _LIT8( KDescription, "Description" ); // = |
|
593 _LIT8( KFormat, "Format" ); // = |
|
594 _LIT8( KOccurence, "Occurence" ); // = |
|
595 _LIT8( KScope, "Scope" ); // = |
|
596 _LIT8( KTitle, "Title" ); // = |
|
597 _LIT8( KMimeType, "MimeType" ); // = |
|
598 _LIT8( KObjectGroup, "ObjectGroup" ); // = |
|
599 |
|
600 /* AccessTypes */ |
|
601 const TChar KAccessType_Add = 'A'; |
|
602 const TChar KAccessType_Copy = 'C'; |
|
603 const TChar KAccessType_Delete = 'D'; |
|
604 const TChar KAccessType_Exec = 'E'; |
|
605 const TChar KAccessType_Get = 'G'; |
|
606 const TChar KAccessType_Replace = 'R'; |
|
607 |
|
608 /* Format */ |
|
609 _LIT8( KFormat_B64, "B64" ); |
|
610 _LIT8( KFormat_Bool, "Bool" ); |
|
611 _LIT8( KFormat_Chr, "Chr" ); |
|
612 _LIT8( KFormat_Int, "Int" ); |
|
613 _LIT8( KFormat_Node, "Node" ); |
|
614 _LIT8( KFormat_Null, "Null" ); |
|
615 _LIT8( KFormat_Xml, "Xml" ); |
|
616 _LIT8( KFormat_Bin, "Bin" ); |
|
617 |
|
618 /* Occurrence */ |
|
619 _LIT8( KOccurence_One, "One" ); |
|
620 _LIT8( KOccurence_ZeroOrOne, "ZeroOrOne" ); |
|
621 _LIT8( KOccurence_ZeroOrMore, "ZeroOrMore" ); |
|
622 _LIT8( KOccurence_OneOrMore, "OneOrMore" ); |
|
623 _LIT8( KOccurence_ZeroOrN, "ZeroOrN" ); |
|
624 _LIT8( KOccurence_OneOrN, "OneOrN" ); |
|
625 |
|
626 /* Scope */ |
|
627 _LIT8( KScope_Permanent, "Permanent" ); |
|
628 _LIT8( KScope_Dynamic, "Dynamic" ); |
|
629 |
|
630 |
|
631 TTestParamVar var( *ptr ); |
|
632 //sf- TTestParamVar var( buf ); |
|
633 while (var.Next()) |
|
634 { |
|
635 TPtrC8 key = var.Name(); |
|
636 TPtrC8 value = var.Value(); |
|
637 TBool exist = var.ValueExist(); |
|
638 iLog->Log(_L8("key: '%S', value: '%S', exist: %d"), &key, &value, exist); |
|
639 |
|
640 if ( key.CompareF( KURI ) == 0 ) |
|
641 { |
|
642 delete iUri; |
|
643 iUri = 0; |
|
644 iUri = value.AllocL(); |
|
645 } |
|
646 else if ( key.CompareF( KAccessTypes ) == 0) |
|
647 { |
|
648 //sf- SetAccessTypes( value ); |
|
649 for (TInt i = 0 ; i < value.Length() ; i++) |
|
650 { |
|
651 if ( value[i] == KAccessType_Add ) |
|
652 { |
|
653 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Add; |
|
654 iAccessTypes.SetAdd(); |
|
655 } |
|
656 else if ( value[i] == KAccessType_Copy ) |
|
657 { |
|
658 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Copy; |
|
659 iAccessTypes.SetCopy(); |
|
660 } |
|
661 else if ( value[i] == KAccessType_Delete ) |
|
662 { |
|
663 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Delete; |
|
664 iAccessTypes.SetDelete(); |
|
665 } |
|
666 else if ( value[i] == KAccessType_Exec ) |
|
667 { |
|
668 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Exec; |
|
669 iAccessTypes.SetExec(); |
|
670 } |
|
671 else if ( value[i] == KAccessType_Get ) |
|
672 { |
|
673 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Get; |
|
674 iAccessTypes.SetGet(); |
|
675 } |
|
676 else if ( value[i] == KAccessType_Replace ) |
|
677 { |
|
678 //sf- iAccessTypes |= TSmlDmAccessTypes::EAccessType_Replace; |
|
679 iAccessTypes.SetReplace(); |
|
680 } |
|
681 else |
|
682 { |
|
683 iLog->Log(_L8("Warning: Unknown AccessType: '%S'"), &value ); |
|
684 } |
|
685 } |
|
686 } |
|
687 else if ( key.CompareF( KDefaultValue ) == 0 ) |
|
688 { |
|
689 delete iDefaultValue; |
|
690 iDefaultValue = 0; |
|
691 iDefaultValue = value.AllocL(); |
|
692 } |
|
693 else if ( key.CompareF( KDescription ) == 0 ) |
|
694 { |
|
695 delete iDescription; |
|
696 iDescription = 0; |
|
697 iDescription = value.AllocL(); |
|
698 } |
|
699 else if ( key.CompareF( KFormat ) == 0 ) |
|
700 { |
|
701 //sf- SetFormat( value ); |
|
702 if (value.CompareF( KFormat_B64 ) == 0 ) |
|
703 { |
|
704 iFormat = MSmlDmDDFObject::EB64; |
|
705 } |
|
706 else if (value.CompareF( KFormat_Bool ) == 0 ) |
|
707 { |
|
708 iFormat = MSmlDmDDFObject::EBool; |
|
709 } |
|
710 else if (value.CompareF( KFormat_Chr ) == 0 ) |
|
711 { |
|
712 iFormat = MSmlDmDDFObject::EChr; |
|
713 } |
|
714 else if (value.CompareF( KFormat_Int ) == 0 ) |
|
715 { |
|
716 iFormat = MSmlDmDDFObject::EInt; |
|
717 } |
|
718 else if (value.CompareF( KFormat_Node ) == 0 ) |
|
719 { |
|
720 iFormat = MSmlDmDDFObject::ENode; |
|
721 } |
|
722 else if (value.CompareF( KFormat_Null ) == 0 ) |
|
723 { |
|
724 iFormat = MSmlDmDDFObject::ENull; |
|
725 } |
|
726 else if (value.CompareF( KFormat_Xml ) == 0 ) |
|
727 { |
|
728 iFormat = MSmlDmDDFObject::EXml; |
|
729 } |
|
730 else if (value.CompareF( KFormat_Bin ) == 0 ) |
|
731 { |
|
732 iFormat = MSmlDmDDFObject::EBin; |
|
733 } |
|
734 else |
|
735 { |
|
736 iLog->Log(_L8("Warning: Unknown Format: '%S'"), &value ); |
|
737 } |
|
738 } |
|
739 else if ( key.CompareF( KOccurence ) == 0 ) |
|
740 { |
|
741 if (value.CompareF( KOccurence_One ) == 0 ) |
|
742 { |
|
743 iOccurence = MSmlDmDDFObject::EOne; |
|
744 } |
|
745 else if (value.CompareF( KOccurence_ZeroOrOne ) == 0 ) |
|
746 { |
|
747 iOccurence = MSmlDmDDFObject::EZeroOrOne; |
|
748 } |
|
749 else if (value.CompareF( KOccurence_ZeroOrMore ) == 0 ) |
|
750 { |
|
751 iOccurence = MSmlDmDDFObject::EZeroOrMore; |
|
752 } |
|
753 else if (value.CompareF( KOccurence_OneOrMore ) == 0 ) |
|
754 { |
|
755 iOccurence = MSmlDmDDFObject::EOneOrMore; |
|
756 } |
|
757 else if (value.CompareF( KOccurence_ZeroOrN ) == 0 ) |
|
758 { |
|
759 iOccurence = MSmlDmDDFObject::EZeroOrN; |
|
760 } |
|
761 else if (value.CompareF( KOccurence_OneOrN ) == 0 ) |
|
762 { |
|
763 iOccurence = MSmlDmDDFObject::EOneOrN; |
|
764 } |
|
765 else |
|
766 { |
|
767 iLog->Log(_L8("Warning: Unknown Occurrence: '%S'"), &value ); |
|
768 } |
|
769 } |
|
770 else if ( key.CompareF( KScope ) == 0 ) |
|
771 { |
|
772 if (value.CompareF( KScope_Permanent ) == 0 ) |
|
773 { |
|
774 iScope = MSmlDmDDFObject::EPermanent; |
|
775 } |
|
776 else if (value.CompareF( KScope_Dynamic ) == 0 ) |
|
777 { |
|
778 iScope = MSmlDmDDFObject::EDynamic; |
|
779 } |
|
780 else |
|
781 { |
|
782 iLog->Log(_L8("Warning: Unknown Scope: '%S'"), &value ); |
|
783 } |
|
784 } |
|
785 else if ( key.CompareF( KTitle ) == 0 ) |
|
786 { |
|
787 delete iTitle; |
|
788 iTitle = 0; |
|
789 iTitle = value.AllocL(); |
|
790 } |
|
791 else if ( key.CompareF( KMimeType ) == 0 ) |
|
792 { |
|
793 delete iMimeType; |
|
794 iMimeType = 0; |
|
795 iMimeType = value.AllocL(); |
|
796 } |
|
797 else if ( key.CompareF( KObjectGroup ) == 0 ) |
|
798 { |
|
799 TLex8 lex( value ); |
|
800 lex.Val( iObjectGroup ); |
|
801 } |
|
802 else |
|
803 { |
|
804 // Unknown parameter |
|
805 iLog->Log(_L8("Warning: Unknown parameter: key: '%S', value: '%S', exist: %d"), &key, &value, exist); |
|
806 } |
|
807 |
|
808 } |
|
809 |
|
810 // Cleanup |
|
811 CleanupStack::PopAndDestroy( ptr ); |
|
812 } |
|
813 |
|
814 |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CDDFTestParams::NewL |
|
817 // Two-phased constructor. |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 CDDFTestParams* CDDFTestParams::NewL( CStifLogger *aLog, CStifItemParser& aItem ) |
|
821 { |
|
822 CDDFTestParams* self = NewLC( aLog, aItem ); |
|
823 CleanupStack::Pop( self ); |
|
824 |
|
825 return self; |
|
826 } |
|
827 CDDFTestParams* CDDFTestParams::NewLC( CStifLogger *aLog, CStifItemParser& aItem ) |
|
828 { |
|
829 CDDFTestParams* self = new (ELeave) CDDFTestParams( aLog ); |
|
830 |
|
831 CleanupStack::PushL( self ); |
|
832 self->ConstructL( aItem ); |
|
833 |
|
834 return self; |
|
835 } |
|
836 |
|
837 |
|
838 // Destructor |
|
839 CDDFTestParams::~CDDFTestParams() |
|
840 { |
|
841 /**/ |
|
842 delete iUri; |
|
843 delete iDefaultValue; |
|
844 delete iDescription; |
|
845 delete iTitle; |
|
846 delete iMimeType; |
|
847 } |
|
848 |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // CTestParams::?member_function |
|
852 // ?implementation_description |
|
853 // (other items were commented in a header). |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 /*?type CTestParams::?member_function( |
|
857 ?arg_type arg, |
|
858 ?arg_type arg ) |
|
859 { |
|
860 |
|
861 ?code |
|
862 |
|
863 } |
|
864 */ |
|
865 |
|
866 const TDesC8& CDDFTestParams::Uri() |
|
867 { |
|
868 if (iUri != 0) |
|
869 { |
|
870 return *iUri; |
|
871 } |
|
872 else |
|
873 { |
|
874 return KNullDesC8; |
|
875 } |
|
876 } |
|
877 |
|
878 TInt CDDFTestParams::CheckL( CTestDmDDFObject* aDdfRoot ) |
|
879 { |
|
880 TInt ret = KErrNone; |
|
881 |
|
882 // Find correct node |
|
883 CTestDmDDFObject* curNode = aDdfRoot; |
|
884 TInt num = NSmlDmURI::NumOfURISegs( *iUri ); |
|
885 |
|
886 for (TInt i = 0 ; i < num && curNode != 0 ; i++) |
|
887 { |
|
888 TPtrC8 nodeName = NSmlDmURI::URISeg( *iUri, i ); |
|
889 if ( nodeName.CompareF( _L8("<X>") ) == 0 ) |
|
890 { |
|
891 nodeName.Set( KNullDesC8 ); |
|
892 } |
|
893 curNode = curNode->FindChildObject( nodeName ); |
|
894 } |
|
895 |
|
896 // Check node data |
|
897 iLog->Log(_L8("Checking node: URI='%S'"), iUri ); |
|
898 |
|
899 if (curNode != 0) |
|
900 { |
|
901 /* |
|
902 if ( iUri && iUri->Compare( curNode->Uri() ) != 0 ) |
|
903 { |
|
904 TPtrC8 expt = *iUri; |
|
905 TPtrC8 real = curNode->Uri(); |
|
906 iLog->Log(_L8("Error: Uri: expected='%S' real='%S'"), &expt, &real ); |
|
907 ret = KErrGeneral; |
|
908 } |
|
909 */ |
|
910 if ( iAccessTypes.GetACL() != curNode->AccessTypes().GetACL() ) |
|
911 { |
|
912 TUint8 expt = iAccessTypes.GetACL(); |
|
913 TUint8 real = curNode->AccessTypes().GetACL(); |
|
914 iLog->Log(_L8("Error: AccessTypes: expected=%d real=%d"), expt, real ); |
|
915 ret = KErrGeneral; |
|
916 } |
|
917 if ( iDefaultValue && iDefaultValue->Compare( curNode->DefaultValue() ) != 0 ) |
|
918 { |
|
919 TPtrC8 expt = *iDefaultValue; |
|
920 TPtrC8 real = curNode->DefaultValue(); |
|
921 iLog->Log(_L8("Error: DefaultValue: expected='%S' real='%S'"), &expt, &real ); |
|
922 ret = KErrGeneral; |
|
923 } |
|
924 if ( iDescription && iDescription->Compare( curNode->Description() ) != 0 ) |
|
925 { |
|
926 TPtrC8 expt = *iDescription; |
|
927 TPtrC8 real = curNode->Description(); |
|
928 iLog->Log(_L8("Error: DefaultValue: expected='%S' real='%S'"), &expt, &real ); |
|
929 ret = KErrGeneral; |
|
930 } |
|
931 if ( iFormat != curNode->DFFormat() ) |
|
932 { |
|
933 TInt expt = iFormat; |
|
934 TInt real = curNode->DFFormat(); |
|
935 iLog->Log(_L8("Error: Format: expected=%d real=%d"), expt, real ); |
|
936 ret = KErrGeneral; |
|
937 } |
|
938 if ( iOccurence != curNode->Occurence() ) |
|
939 { |
|
940 TInt expt = iOccurence; |
|
941 TInt real = curNode->Occurence(); |
|
942 iLog->Log(_L8("Error: Occurence: expected=%d real=%d"), expt, real ); |
|
943 ret = KErrGeneral; |
|
944 } |
|
945 if ( iScope != curNode->Scope() ) |
|
946 { |
|
947 TInt expt = iScope; |
|
948 TInt real = curNode->Scope(); |
|
949 iLog->Log(_L8("Error: Scope: expected=%d real=%d"), expt, real ); |
|
950 ret = KErrGeneral; |
|
951 } |
|
952 if ( iTitle && iTitle->Compare( curNode->DFTitle() ) != 0 ) |
|
953 { |
|
954 TPtrC8 expt = *iTitle; |
|
955 TPtrC8 real = curNode->DFTitle(); |
|
956 iLog->Log(_L8("Error: Title: expected='%S' real='%S'"), &expt, &real ); |
|
957 ret = KErrGeneral; |
|
958 } |
|
959 if ( iMimeType && iMimeType->Compare( curNode->DFTypeMimeType() ) != 0 ) |
|
960 { |
|
961 TPtrC8 expt = *iMimeType; |
|
962 TPtrC8 real = curNode->DFTypeMimeType(); |
|
963 iLog->Log(_L8("Error: MimeType: expected='%S' real='%S'"), &expt, &real ); |
|
964 ret = KErrGeneral; |
|
965 } |
|
966 if ( iObjectGroup != curNode->ObjectGroup() ) |
|
967 { |
|
968 TInt expt = iObjectGroup; |
|
969 TInt real = curNode->ObjectGroup(); |
|
970 iLog->Log(_L8("Error: ObjectGroup: expected=%d real=%d"), expt, real ); |
|
971 ret = KErrGeneral; |
|
972 } |
|
973 } |
|
974 else |
|
975 { |
|
976 iLog->Log(_L8("Error: Node not found") ); |
|
977 ret = KErrGeneral; |
|
978 } |
|
979 |
|
980 return ret; |
|
981 } |
|
982 |
|
983 //****************************************************************************** |
|
984 // |
|
985 // |
|
986 // |
|
987 //****************************************************************************** |
|
988 |
|
989 |
|
990 TTestParamVar::TTestParamVar( const TDesC8 &aStr ) |
|
991 : iLog( 0 ) |
|
992 , iLex( aStr ) |
|
993 //sf- : iStr( aStr ) |
|
994 //sf- , iPos( 0 ) |
|
995 , iName( KNullDesC8 ) |
|
996 , iValue( KNullDesC8 ) |
|
997 , iValueExist( EFalse ) |
|
998 { |
|
999 } |
|
1000 |
|
1001 TBool TTestParamVar::Next() |
|
1002 { |
|
1003 TBool ok = ETrue; |
|
1004 |
|
1005 iName.Set( KNullDesC8 ); |
|
1006 iValue.Set( KNullDesC8 ); |
|
1007 iValueExist = EFalse; |
|
1008 |
|
1009 ok = !iLex.Eos(); |
|
1010 |
|
1011 if (ok) |
|
1012 { |
|
1013 iName.Set( GetWord() ); |
|
1014 if (iName.Length() == 0) |
|
1015 { |
|
1016 ok = EFalse; |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 TChar chr = GetChar(); |
|
1021 if (chr == '=') |
|
1022 { |
|
1023 iValue.Set( GetWord() ); |
|
1024 /* |
|
1025 TInt i, j, k = iValue.Length(); |
|
1026 for( i=j=0; i<k; i++,j++ ) |
|
1027 { |
|
1028 if( iValue[i] == TChar('\"') && iValue[i+1] == TChar('\"') ) |
|
1029 { |
|
1030 i++; |
|
1031 } |
|
1032 iValue[j] = iValue[i]; |
|
1033 } |
|
1034 iValue.SetLength(j); |
|
1035 */ |
|
1036 /* |
|
1037 while( iValue.Find( _L("\"\"") != KErrNotFound ) |
|
1038 { |
|
1039 iValue.Replace( iValue.Find( _L("\"\""), 2, _L("\"") ); |
|
1040 } |
|
1041 */ |
|
1042 |
|
1043 iValueExist = ETrue; |
|
1044 } |
|
1045 else if (!chr.Eos()) |
|
1046 { |
|
1047 UnGetChar(); |
|
1048 } |
|
1049 |
|
1050 if (ok && iLog) |
|
1051 { |
|
1052 iLog->Log( _L8("name: '%S', value: '%S', exist: %d"), &iName, &iValue, iValueExist ); |
|
1053 } |
|
1054 |
|
1055 return ok; |
|
1056 } |
|
1057 |
|
1058 const TDesC8& TTestParamVar::Name() |
|
1059 { |
|
1060 return iName; |
|
1061 } |
|
1062 |
|
1063 const TDesC8& TTestParamVar::Value() |
|
1064 { |
|
1065 return iValue; |
|
1066 } |
|
1067 |
|
1068 TBool TTestParamVar::ValueExist() |
|
1069 { |
|
1070 return iValueExist; |
|
1071 } |
|
1072 |
|
1073 TChar TTestParamVar::GetChar() |
|
1074 { |
|
1075 iLex.SkipSpace(); |
|
1076 return iLex.Get(); |
|
1077 } |
|
1078 |
|
1079 void TTestParamVar::UnGetChar() |
|
1080 { |
|
1081 iLex.UnGet(); |
|
1082 } |
|
1083 |
|
1084 TPtrC8 TTestParamVar::GetWord() |
|
1085 { |
|
1086 TBool quoted = EFalse; |
|
1087 |
|
1088 iLex.SkipSpace(); |
|
1089 |
|
1090 // Check if word is quoted |
|
1091 if (iLex.Peek() == '\"') |
|
1092 { |
|
1093 iLex.Get(); |
|
1094 quoted = ETrue; |
|
1095 } |
|
1096 |
|
1097 // Mark start position of word |
|
1098 iLex.Mark(); |
|
1099 |
|
1100 // Seek end of word and extract it |
|
1101 TBool ready = EFalse; |
|
1102 while (!ready && !iLex.Eos()) |
|
1103 { |
|
1104 TChar chr = iLex.Get(); |
|
1105 |
|
1106 //sf- if (chr == '\"' || (!quoted && (chr.IsSpace() || chr == '='))) |
|
1107 if (quoted) |
|
1108 { |
|
1109 if (chr == '\"') |
|
1110 { |
|
1111 if((iLex.Eos()) || (iLex.Peek() == ' ')) |
|
1112 { |
|
1113 iLex.UnGet(); |
|
1114 ready = ETrue; |
|
1115 } |
|
1116 } |
|
1117 } |
|
1118 else if (chr.IsSpace() || chr == '=' || chr == '\"') |
|
1119 { |
|
1120 iLex.UnGet(); |
|
1121 ready = ETrue; |
|
1122 } |
|
1123 } |
|
1124 |
|
1125 // Extract word |
|
1126 TPtrC8 word = iLex.MarkedToken(); |
|
1127 if (quoted) |
|
1128 { |
|
1129 iLex.Get(); |
|
1130 } |
|
1131 |
|
1132 // return |
|
1133 return word; |
|
1134 } |
|
1135 |
|
1136 |
|
1137 /* |
|
1138 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1139 |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 // ?function_name implements... |
|
1142 // ?implementation_description. |
|
1143 // Returns: ?value_1: ?description |
|
1144 // ?value_n: ?description |
|
1145 // ?description |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 ?type ?function_name( |
|
1149 ?arg_type arg, // ?description |
|
1150 ?arg_type arg ) // ?description |
|
1151 { |
|
1152 |
|
1153 ?code |
|
1154 |
|
1155 } |
|
1156 */ |
|
1157 // End of File |