|
1 /* |
|
2 * Copyright (c) 2002-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <mdeobject.h> |
|
20 #include <mdeobjectquery.h> |
|
21 #include <mdeconstants.h> |
|
22 #include <StifParser.h> |
|
23 #include <StifTestInterface.h> |
|
24 #include "MdETestScripter.h" |
|
25 |
|
26 const TInt KRootCond = -1; |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CMdETestScripter::FindL |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 TInt CMdETestScripter::FindL( CStifItemParser& aItem ) |
|
33 { |
|
34 TInt maxCount; |
|
35 User::LeaveIfError( aItem.GetNextInt( maxCount ) ); |
|
36 TInt notifyCount; |
|
37 User::LeaveIfError( aItem.GetNextInt( notifyCount ) ); |
|
38 |
|
39 iQuery->FindL( maxCount, notifyCount ); |
|
40 return KErrNone; |
|
41 } |
|
42 |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CMdETestScripter::QueryObjectL |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TInt CMdETestScripter::QueryObjectL( CStifItemParser& aItem ) |
|
49 { |
|
50 TPtrC objectString; |
|
51 |
|
52 CMdENamespaceDef* space = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem ); |
|
53 |
|
54 User::LeaveIfError( aItem.GetNextString( objectString )); |
|
55 CMdEObjectDef& objdef = space->GetObjectDefL( objectString ); |
|
56 |
|
57 delete iQuery; |
|
58 iQuery = NULL; |
|
59 iQuery = iMdeSession->NewObjectQueryL( *space, objdef, this ); |
|
60 iQuery->SetResultMode( EQueryResultModeId ); |
|
61 iQuery->FindL(1); |
|
62 |
|
63 return KErrNone; |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CMdETestScripter::NewObjectQueryL |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TInt CMdETestScripter::NewObjectQueryL( CStifItemParser& aItem ) |
|
72 { |
|
73 TPtrC name; |
|
74 User::LeaveIfError( aItem.GetNextString( name )); |
|
75 CMdENamespaceDef* space = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem ); |
|
76 TPtrC modeString; |
|
77 User::LeaveIfError( aItem.GetNextString( modeString )); |
|
78 TQueryResultMode modeEnum = ResultModeL( modeString ); |
|
79 |
|
80 TPtrC objectString; |
|
81 User::LeaveIfError( aItem.GetNextString( objectString )); |
|
82 |
|
83 CMdEObjectDef& objdef = space->GetObjectDefL( objectString ); |
|
84 |
|
85 delete iQuery; |
|
86 iQuery = NULL; |
|
87 |
|
88 TPtrC type; |
|
89 User::LeaveIfError( aItem.GetNextString( type )); |
|
90 if ( type.Compare(_L("Object")) == 0 ) |
|
91 { |
|
92 iQuery = iMdeSession->NewObjectQueryL( *space, objdef, this ); |
|
93 } |
|
94 else if ( type.Compare(_L("LookupObject")) == 0 ) |
|
95 { |
|
96 RPointerArray<CMdEObjectDef> *objDefs = new (ELeave) RPointerArray<CMdEObjectDef>; |
|
97 TPtrC startMark; |
|
98 User::LeaveIfError( aItem.GetNextString( startMark )); |
|
99 if ( startMark.Compare(_L("{")) == 0) |
|
100 { |
|
101 TInt index; |
|
102 while( ETrue ) |
|
103 { |
|
104 index = GetObjectDefIndexL( aItem ); |
|
105 if ( index == KErrCompletion ) |
|
106 { |
|
107 break; |
|
108 } |
|
109 objDefs->Append( iObjectDefArray[ index ] ); |
|
110 } |
|
111 } |
|
112 iQuery = iMdeSession->NewObjectQueryL( objdef, objDefs, this ); |
|
113 } |
|
114 else |
|
115 { |
|
116 User::Leave( KErrArgument ); |
|
117 } |
|
118 |
|
119 |
|
120 iQuery->SetResultMode( modeEnum ); |
|
121 CMdELogicCondition* rootLogicCondition = &iQuery->Conditions(); |
|
122 iLogicConditionArray.Append( rootLogicCondition ); |
|
123 AppendNameL( iLogicConditionNameArray, name ); |
|
124 return KErrNone; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CMdETestScripter::NewRelationQueryL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CMdETestScripter::NewRelationQueryL( CStifItemParser& aItem ) |
|
132 { |
|
133 |
|
134 TPtrC name; |
|
135 User::LeaveIfError( aItem.GetNextString( name )); |
|
136 delete iQuery; |
|
137 iQuery = NULL; |
|
138 CMdENamespaceDef* space = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem ); |
|
139 TPtrC modeString; |
|
140 User::LeaveIfError( aItem.GetNextString( modeString )); |
|
141 TQueryResultMode modeEnum = ResultModeL( modeString ); |
|
142 |
|
143 iQuery = iMdeSession->NewRelationQueryL( *space, this ); |
|
144 iQuery->SetResultMode( modeEnum ); |
|
145 CMdELogicCondition* rootLogicCondition = &iQuery->Conditions(); |
|
146 iLogicConditionArray.Append( rootLogicCondition ); |
|
147 AppendNameL( iLogicConditionNameArray, name ); |
|
148 return KErrNone; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CMdETestScripter::NewEventQueryL |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TInt CMdETestScripter::NewEventQueryL( CStifItemParser& aItem ) |
|
156 { |
|
157 TPtrC name; |
|
158 User::LeaveIfError( aItem.GetNextString( name )); |
|
159 |
|
160 delete iQuery; |
|
161 iQuery = NULL; |
|
162 CMdENamespaceDef* space = SanitizeArrayIndexL( iNamespaceDefArray, *iNamespaceDefNameArray, aItem ); |
|
163 TPtrC modeString; |
|
164 User::LeaveIfError( aItem.GetNextString( modeString )); |
|
165 TQueryResultMode modeEnum = ResultModeL( modeString ); |
|
166 |
|
167 iQuery = iMdeSession->NewEventQueryL( *space, this ); |
|
168 iQuery->SetResultMode( modeEnum ); |
|
169 CMdELogicCondition* rootLogicCondition = &iQuery->Conditions(); |
|
170 iLogicConditionArray.Append( rootLogicCondition ); |
|
171 AppendNameL( iLogicConditionNameArray, name ); |
|
172 return KErrNone; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMdEObjectQuery::AddPropertyFilterL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CMdETestScripter::AddPropertyFilterL( CStifItemParser& aItem ) |
|
180 { |
|
181 CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem); |
|
182 ((CMdEObjectQuery *)iQuery)->AddPropertyFilterL( propertyDef ); |
|
183 return KErrNone; |
|
184 } |
|
185 |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CMdEObjectQuery::AppendOrderRuleL |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CMdETestScripter::AppendOrderRuleL( CStifItemParser& aItem ) |
|
192 { |
|
193 TInt ascending; |
|
194 User::LeaveIfError( aItem.GetNextInt( ascending ) ); |
|
195 TInt orderRule; |
|
196 User::LeaveIfError( aItem.GetNextInt( orderRule ) ); |
|
197 if ( orderRule == EOrderRuleTypeProperty ) |
|
198 { |
|
199 CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem); |
|
200 ((CMdEObjectQuery *)iQuery)->AppendOrderRuleL( TMdEOrderRule( *propertyDef, ascending )); |
|
201 } |
|
202 else |
|
203 { |
|
204 ((CMdEObjectQuery *)iQuery)->AppendOrderRuleL( TMdEOrderRule( (TOrderRuleType) orderRule, ascending )); |
|
205 } |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CMdETestScripter::HandleQueryNewResults |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CMdETestScripter::HandleQueryNewResults( CMdEQuery& /*aQuery*/, |
|
215 TInt /*aFirstNewItemIndex*/, TInt aNewItemCount ) |
|
216 { |
|
217 _LIT( KMessage, "Query new results count: " ); |
|
218 _LIT( KMessage2, " new count: " ); |
|
219 TBuf<128> buf( KMessage ); |
|
220 buf.Append( KMessage2 ); |
|
221 buf.AppendNum( aNewItemCount ); |
|
222 |
|
223 } |
|
224 |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CMdETestScripter::QueryRelationL |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 TInt CMdETestScripter::QueryRelationL( CStifItemParser& aItem ) |
|
231 { |
|
232 TPtrC relationString; |
|
233 User::LeaveIfError( aItem.GetNextString( relationString )); |
|
234 |
|
235 CMdERelationDef& reldef = iNamespaceDefArray[0]->GetRelationDefL( relationString ); |
|
236 |
|
237 delete iQuery; |
|
238 iQuery = NULL; |
|
239 iQuery = iMdeSession->NewRelationQueryL( *iNamespaceDefArray[0], this ); |
|
240 iQuery->SetResultMode( EQueryResultModeId ); |
|
241 iQueryRoot = &iQuery->Conditions(); |
|
242 iQueryRoot->AddRelationConditionL( reldef ); |
|
243 iQuery->FindL(1); |
|
244 |
|
245 return KErrNone; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CMdETestScripter::QueryEventL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TInt CMdETestScripter::QueryEventL( CStifItemParser& aItem ) |
|
253 { |
|
254 TPtrC eventString; |
|
255 User::LeaveIfError( aItem.GetNextString( eventString )); |
|
256 |
|
257 CMdEEventDef& evdef = iNamespaceDefArray[0]->GetEventDefL( eventString ); |
|
258 |
|
259 delete iQuery; |
|
260 iQuery = NULL; |
|
261 iQuery = iMdeSession->NewEventQueryL( *iNamespaceDefArray[0], this ); |
|
262 iQuery->SetResultMode( EQueryResultModeId ); |
|
263 iQueryRoot = &iQuery->Conditions(); |
|
264 iQueryRoot->AddEventConditionL( evdef ); |
|
265 iQuery->FindL(1); |
|
266 |
|
267 return KErrNone; |
|
268 } |
|
269 |
|
270 _LIT(KAND , "AND"); |
|
271 _LIT(KOR , "OR"); |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CMdETestScripter::NewLogicConditionL |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 TInt CMdETestScripter::NewLogicConditionL( CStifItemParser& aItem ) |
|
278 { |
|
279 TPtrC name; |
|
280 User::LeaveIfError( aItem.GetNextString( name )); |
|
281 TPtrC logicOperator; |
|
282 User::LeaveIfError( aItem.GetNextString( logicOperator )); |
|
283 TLogicConditionOperator logCondOperator = ELogicConditionOperatorAnd; |
|
284 if ( logicOperator.Compare( KAND ) == 0) |
|
285 { |
|
286 logCondOperator = ELogicConditionOperatorAnd; |
|
287 } |
|
288 else if ( logicOperator.Compare( KOR ) == 0) |
|
289 { |
|
290 logCondOperator = ELogicConditionOperatorOr; |
|
291 } |
|
292 else |
|
293 { |
|
294 User::Leave( KErrArgument ); |
|
295 } |
|
296 CMdELogicCondition* condition = CMdELogicCondition::NewL( logCondOperator ); |
|
297 iLogicConditionArray.Append( condition ); |
|
298 AppendNameL( iEventConditionNameArray, name ); |
|
299 return KErrNone; |
|
300 } |
|
301 |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CMdETestScripter::RightL |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CMdETestScripter::RightL( CStifItemParser& aItem ) |
|
308 { |
|
309 TPtrC name; |
|
310 User::LeaveIfError( aItem.GetNextString( name )); |
|
311 |
|
312 CMdERelationCondition* relationCond = SanitizeArrayIndexL( |
|
313 iRelationConditionArray, *iRelationConditionNameArray, aItem ); |
|
314 CMdELogicCondition* rightCond = &relationCond->RightL(); |
|
315 iLogicConditionArray.Append( rightCond ); |
|
316 AppendNameL( iLogicConditionNameArray, name ); |
|
317 return KErrNone; |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CMdETestScripter::LeftL |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CMdETestScripter::LeftL( CStifItemParser& aItem ) |
|
325 { |
|
326 TPtrC name; |
|
327 User::LeaveIfError( aItem.GetNextString( name )); |
|
328 |
|
329 CMdERelationCondition* relationCond = SanitizeArrayIndexL( |
|
330 iRelationConditionArray, *iRelationConditionNameArray, aItem ); |
|
331 CMdELogicCondition* leftCond = &relationCond->LeftL(); |
|
332 iLogicConditionArray.Append( leftCond ); |
|
333 AppendNameL( iLogicConditionNameArray, name ); |
|
334 return KErrNone; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CMdETestScripter::SetOperatorL |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 TInt CMdETestScripter::SetOperatorL( CStifItemParser& aItem ) |
|
342 { |
|
343 CMdELogicCondition* logicCondition = SanitizeArrayIndexL( iLogicConditionArray, *iLogicConditionNameArray, aItem ); |
|
344 TInt logicalOperator; |
|
345 User::LeaveIfError( aItem.GetNextInt( logicalOperator )); |
|
346 logicCondition->SetOperator( ( TLogicConditionOperator )logicalOperator ); |
|
347 return KErrNone; |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CMdETestScripter::SetNegateL |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 TInt CMdETestScripter::SetNegateL( CStifItemParser& aItem ) |
|
355 { |
|
356 CMdEPropertyCondition* condition = SanitizeArrayIndexL( iPropertyConditionArray, *iPropertyConditionNameArray, aItem ); |
|
357 TInt boolean; |
|
358 User::LeaveIfError( aItem.GetNextInt( boolean )); |
|
359 ((CMdECondition *)condition)->SetNegate( boolean ); |
|
360 return KErrNone; |
|
361 } |
|
362 |
|
363 |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CMdETestScripter::AddLogicConditionL |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 TInt CMdETestScripter::AddLogicConditionL( CStifItemParser& aItem ) |
|
370 { |
|
371 TPtrC name; |
|
372 User::LeaveIfError( aItem.GetNextString( name )); |
|
373 |
|
374 CMdELogicCondition* logicCondition = SanitizeArrayIndexL( iLogicConditionArray, *iLogicConditionNameArray, aItem ); |
|
375 |
|
376 TPtrC logicOperator; |
|
377 User::LeaveIfError( aItem.GetNextString( logicOperator )); |
|
378 TLogicConditionOperator logCondOperator = ELogicConditionOperatorAnd; |
|
379 if ( logicOperator.Compare( KAND ) == 0) |
|
380 { |
|
381 logCondOperator = ELogicConditionOperatorAnd; |
|
382 } |
|
383 else if ( logicOperator.Compare( KOR ) == 0) |
|
384 { |
|
385 logCondOperator = ELogicConditionOperatorOr; |
|
386 } |
|
387 else |
|
388 { |
|
389 User::Leave( KErrArgument ); |
|
390 } |
|
391 CMdELogicCondition* condition = &logicCondition->AddLogicConditionL( logCondOperator ); |
|
392 iLogicConditionArray.Append( condition ); |
|
393 AppendNameL( iLogicConditionNameArray, name ); |
|
394 return KErrNone; |
|
395 } |
|
396 |
|
397 |
|
398 _LIT(KRelationDef, "RelationDef"); |
|
399 _LIT(KRelationDefRange, "RelationDefRange"); |
|
400 |
|
401 _LIT(KAny, "Any"); |
|
402 _LIT(KEqual, "Equal"); |
|
403 _LIT(KNotEqual, "NotEqual"); |
|
404 _LIT(KLess, "Less"); |
|
405 _LIT(KLessOrEqual, "LessOrEqual"); |
|
406 _LIT(KGreater, "Greater"); |
|
407 _LIT(KGreaterOrEqual, "GreaterOrEqual"); |
|
408 _LIT(KBetween, "Between"); |
|
409 _LIT(KNotBetween, "NotBetween"); |
|
410 |
|
411 _LIT(KObject , "Object"); |
|
412 _LIT(KObjectDef , "ObjectDef"); |
|
413 _LIT(KGuid , "Guid"); |
|
414 |
|
415 _LIT(KNone , "None"); |
|
416 _LIT(KId , "Id"); |
|
417 _LIT(KIds , "Ids"); |
|
418 _LIT(KUri , "Uri"); |
|
419 _LIT(KUriBeginsWith , "UriBeginsWith"); |
|
420 _LIT(KFreeText , "FreeText"); |
|
421 _LIT(KFreeTextContains , "FreeTextContains"); |
|
422 _LIT(KFreeTextBeginsWith , "FreeTextBeginsWith"); |
|
423 _LIT(KFreeTextEndsWith , "FreeTextEndsWith"); |
|
424 _LIT(KFreeTextUsageCount , "FreeTextUsageCount"); |
|
425 |
|
426 |
|
427 _LIT(KCount , "Count"); |
|
428 _LIT(KItem , "Item"); |
|
429 _LIT(KDistinctValues , "DistinctValues"); |
|
430 _LIT(KObjectWithFreetexts , "ObjectWithFreetexts"); |
|
431 |
|
432 |
|
433 |
|
434 TQueryResultMode CMdETestScripter::ResultModeL(TDesC& aModeString) |
|
435 { |
|
436 TQueryResultMode modeEnum = EQueryResultModeId; |
|
437 if ( aModeString.Compare( KId ) == 0 ) |
|
438 { |
|
439 modeEnum = EQueryResultModeId; |
|
440 } |
|
441 else if ( aModeString.Compare( KItem ) == 0 ) |
|
442 { |
|
443 modeEnum = EQueryResultModeItem; |
|
444 } |
|
445 else if ( aModeString.Compare( KCount ) == 0 ) |
|
446 { |
|
447 modeEnum = EQueryResultModeCount; |
|
448 } |
|
449 else if ( aModeString.Compare( KDistinctValues ) == 0 ) |
|
450 { |
|
451 modeEnum = EQueryResultModeDistinctValues; |
|
452 } |
|
453 else if ( aModeString.Compare( KObjectWithFreetexts ) == 0 ) |
|
454 { |
|
455 modeEnum = EQueryResultModeObjectWithFreetexts; |
|
456 } |
|
457 else |
|
458 { |
|
459 User::Leave( KErrArgument ); |
|
460 } |
|
461 return modeEnum; |
|
462 } |
|
463 |
|
464 |
|
465 CMdERelationDef& CMdETestScripter::GetRelationDefStrL( CStifItemParser& aItem ) |
|
466 { |
|
467 TPtrC relationDefStr; |
|
468 User::LeaveIfError( aItem.GetNextString( relationDefStr )); |
|
469 TLex lex( relationDefStr ); |
|
470 TInt integer; |
|
471 TInt err = lex.Val( integer ); |
|
472 if ( err == KErrGeneral ) |
|
473 { |
|
474 return iNamespaceDefArray[0]->GetRelationDefL( relationDefStr ); |
|
475 } |
|
476 else |
|
477 { |
|
478 return *iRelationDefArray[ integer ]; |
|
479 } |
|
480 } |
|
481 |
|
482 TInt CMdETestScripter::GetObjectDefIndexL( CStifItemParser& aItem ) |
|
483 { |
|
484 TPtrC objectDefStr; |
|
485 User::LeaveIfError( aItem.GetNextString( objectDefStr )); |
|
486 TLex lex( objectDefStr ); |
|
487 TInt integer; |
|
488 TInt err = lex.Val( integer ); |
|
489 if ( err == KErrGeneral ) |
|
490 { |
|
491 if ( objectDefStr.Compare( _L("}")) == 0) |
|
492 { |
|
493 return KErrCompletion; // indictes end of list |
|
494 } |
|
495 for ( TInt i = 0; i < iObjectDefNameArray->Count(); i++) |
|
496 { |
|
497 if ( objectDefStr.Compare( (*iObjectDefNameArray)[i] ) == 0 ) |
|
498 { |
|
499 return i; |
|
500 } |
|
501 } |
|
502 return KErrNotFound; |
|
503 } |
|
504 else |
|
505 { |
|
506 return integer ; |
|
507 } |
|
508 } |
|
509 |
|
510 TInt CMdETestScripter::GetRelationDefIndexL( CStifItemParser& aItem ) |
|
511 { |
|
512 TPtrC relationDefStr; |
|
513 User::LeaveIfError( aItem.GetNextString( relationDefStr )); |
|
514 TLex lex( relationDefStr ); |
|
515 TInt integer; |
|
516 TInt err = lex.Val( integer ); |
|
517 if ( err == KErrGeneral ) |
|
518 { |
|
519 for ( TInt i = 0; i < iRelationDefNameArray->Count(); i++) |
|
520 { |
|
521 if ( relationDefStr.Compare( (*iRelationDefNameArray)[i] ) == 0 ) |
|
522 { |
|
523 return i; |
|
524 } |
|
525 } |
|
526 return KErrNotFound; |
|
527 } |
|
528 else |
|
529 { |
|
530 return integer ; |
|
531 } |
|
532 } |
|
533 |
|
534 TInt CMdETestScripter::GetEventDefIndexL( CStifItemParser& aItem ) |
|
535 { |
|
536 TPtrC eventDefStr; |
|
537 User::LeaveIfError( aItem.GetNextString( eventDefStr )); |
|
538 TLex lex( eventDefStr ); |
|
539 TInt integer; |
|
540 TInt err = lex.Val( integer ); |
|
541 if ( err == KErrGeneral ) |
|
542 { |
|
543 for ( TInt i = 0; i < iEventDefNameArray->Count(); i++) |
|
544 { |
|
545 if ( eventDefStr.Compare( (*iEventDefNameArray)[i] ) == 0 ) |
|
546 { |
|
547 return i; |
|
548 } |
|
549 } |
|
550 return KErrNotFound; |
|
551 } |
|
552 else |
|
553 { |
|
554 return integer ; |
|
555 } |
|
556 } |
|
557 |
|
558 TInt CMdETestScripter::GetObjectIndexL( CStifItemParser& aItem ) |
|
559 { |
|
560 TPtrC objectStr; |
|
561 User::LeaveIfError( aItem.GetNextString( objectStr )); |
|
562 TLex lex( objectStr ); |
|
563 TInt integer; |
|
564 TInt err = lex.Val( integer ); |
|
565 if ( err == KErrGeneral ) |
|
566 { |
|
567 if ( objectStr.Compare( _L("}")) == 0) |
|
568 { |
|
569 return KErrCompletion; // indictes end of list |
|
570 } |
|
571 for ( TInt i = 0; i < iObjectNameArray->Count(); i++) |
|
572 { |
|
573 if ( objectStr.Compare( (*iObjectNameArray)[i] ) == 0 ) |
|
574 { |
|
575 return i; |
|
576 } |
|
577 } |
|
578 return KErrNotFound; |
|
579 } |
|
580 else |
|
581 { |
|
582 return integer ; |
|
583 } |
|
584 } |
|
585 |
|
586 |
|
587 TInt CMdETestScripter::GetEventIndexL( CStifItemParser& aItem ) |
|
588 { |
|
589 TPtrC eventStr; |
|
590 User::LeaveIfError( aItem.GetNextString( eventStr )); |
|
591 TLex lex( eventStr ); |
|
592 TInt integer; |
|
593 TInt err = lex.Val( integer ); |
|
594 if ( err == KErrGeneral ) |
|
595 { |
|
596 if ( eventStr.Compare( _L("}")) == 0) |
|
597 { |
|
598 return KErrCompletion; // indictes end of list |
|
599 } |
|
600 for ( TInt i = 0; i < iEventNameArray->Count(); i++) |
|
601 { |
|
602 if ( eventStr.Compare( (*iEventNameArray)[i] ) == 0 ) |
|
603 { |
|
604 return i; |
|
605 } |
|
606 } |
|
607 return KErrNotFound; |
|
608 } |
|
609 else |
|
610 { |
|
611 return integer ; |
|
612 } |
|
613 } |
|
614 |
|
615 TInt CMdETestScripter::GetRelationIndexL( CStifItemParser& aItem ) |
|
616 { |
|
617 TPtrC relationStr; |
|
618 User::LeaveIfError( aItem.GetNextString( relationStr )); |
|
619 TLex lex( relationStr ); |
|
620 TInt integer; |
|
621 TInt err = lex.Val( integer ); |
|
622 if ( err == KErrGeneral ) |
|
623 { |
|
624 if ( relationStr.Compare( _L("}")) == 0) |
|
625 { |
|
626 return KErrCompletion; // indictes end of list |
|
627 } |
|
628 for ( TInt i = 0; i < iRelationNameArray->Count(); i++) |
|
629 { |
|
630 if ( relationStr.Compare( (*iRelationNameArray)[i] ) == 0 ) |
|
631 { |
|
632 return i; |
|
633 } |
|
634 } |
|
635 return KErrNotFound; |
|
636 } |
|
637 else |
|
638 { |
|
639 return integer ; |
|
640 } |
|
641 } |
|
642 |
|
643 TInt CMdETestScripter::GetLogicConditionIndexL( CStifItemParser& aItem ) |
|
644 { |
|
645 TPtrC logicConditionStr; |
|
646 User::LeaveIfError( aItem.GetNextString( logicConditionStr )); |
|
647 TLex lex( logicConditionStr ); |
|
648 TInt integer; |
|
649 TInt err = lex.Val( integer ); |
|
650 if ( err == KErrGeneral ) |
|
651 { |
|
652 for ( TInt i = 0; i < iLogicConditionNameArray->Count(); i++) |
|
653 { |
|
654 if ( logicConditionStr.Compare( (*iLogicConditionNameArray)[i] ) == 0 ) |
|
655 { |
|
656 return i; |
|
657 } |
|
658 } |
|
659 return KErrNotFound; |
|
660 } |
|
661 else |
|
662 { |
|
663 return integer ; |
|
664 } |
|
665 } |
|
666 |
|
667 |
|
668 TInt CMdETestScripter::GetRelationConditionIndexL( CStifItemParser& aItem ) |
|
669 { |
|
670 TPtrC relationConditionStr; |
|
671 User::LeaveIfError( aItem.GetNextString( relationConditionStr )); |
|
672 TLex lex( relationConditionStr ); |
|
673 TInt integer; |
|
674 TInt err = lex.Val( integer ); |
|
675 if ( err == KErrGeneral ) |
|
676 { |
|
677 for ( TInt i = 0; i < iRelationConditionNameArray->Count(); i++) |
|
678 { |
|
679 if ( relationConditionStr.Compare( (*iRelationConditionNameArray)[i] ) == 0 ) |
|
680 { |
|
681 return i; |
|
682 } |
|
683 } |
|
684 return KErrNotFound; |
|
685 } |
|
686 else |
|
687 { |
|
688 return integer ; |
|
689 } |
|
690 } |
|
691 |
|
692 |
|
693 |
|
694 TInt CMdETestScripter::GetPropertyDefIndexL( CStifItemParser& aItem ) |
|
695 { |
|
696 TPtrC propertyDefStr; |
|
697 User::LeaveIfError( aItem.GetNextString( propertyDefStr )); |
|
698 TLex lex( propertyDefStr ); |
|
699 TInt integer; |
|
700 TInt err = lex.Val( integer ); |
|
701 if ( err == KErrGeneral ) |
|
702 { |
|
703 if ( propertyDefStr.Compare( _L("}")) == 0) |
|
704 { |
|
705 return KErrCompletion; // indictes end of list |
|
706 } |
|
707 for ( TInt i = 0; i < iPropertyDefNameArray->Count(); i++) |
|
708 { |
|
709 if ( propertyDefStr.Compare( (*iPropertyDefNameArray)[i] ) == 0 ) |
|
710 { |
|
711 return i; |
|
712 } |
|
713 } |
|
714 return KErrNotFound; |
|
715 } |
|
716 else |
|
717 { |
|
718 return integer ; |
|
719 } |
|
720 } |
|
721 |
|
722 TInt CMdETestScripter::GetPropertyIndexL( CStifItemParser& aItem ) |
|
723 { |
|
724 TPtrC propertyStr; |
|
725 User::LeaveIfError( aItem.GetNextString( propertyStr )); |
|
726 TLex lex( propertyStr ); |
|
727 TInt integer; |
|
728 TInt err = lex.Val( integer ); |
|
729 if ( err == KErrGeneral ) |
|
730 { |
|
731 for ( TInt i = 0; i < iPropertyNameArray->Count(); i++) |
|
732 { |
|
733 if ( propertyStr.Compare( (*iPropertyNameArray)[i] ) == 0 ) |
|
734 { |
|
735 return i; |
|
736 } |
|
737 } |
|
738 return KErrNotFound; |
|
739 } |
|
740 else |
|
741 { |
|
742 return integer ; |
|
743 } |
|
744 } |
|
745 |
|
746 |
|
747 CMdEObjectDef& CMdETestScripter::GetObjectDefStrL( CStifItemParser& aItem ) |
|
748 { |
|
749 TPtrC objectDefStr; |
|
750 User::LeaveIfError( aItem.GetNextString( objectDefStr )); |
|
751 TLex lex( objectDefStr ); |
|
752 TInt integer; |
|
753 TInt err = lex.Val( integer ); |
|
754 if ( err == KErrGeneral ) |
|
755 { |
|
756 return iNamespaceDefArray[0]->GetObjectDefL( objectDefStr ); |
|
757 } |
|
758 else |
|
759 { |
|
760 return *iObjectDefArray[ integer ]; |
|
761 } |
|
762 } |
|
763 |
|
764 TObjectConditionCompareMethod CMdETestScripter::CompareMethodL(TDesC& aMethodString) |
|
765 { |
|
766 TObjectConditionCompareMethod methodEnum = EObjectConditionCompareNone; |
|
767 if ( aMethodString.Compare( KNone ) == 0 ) |
|
768 { |
|
769 methodEnum = EObjectConditionCompareNone; |
|
770 } |
|
771 else if ( aMethodString.Compare( KId ) == 0 ) |
|
772 { |
|
773 methodEnum = EObjectConditionCompareId; |
|
774 } |
|
775 else if ( aMethodString.Compare( KIds ) == 0 ) |
|
776 { |
|
777 methodEnum = EObjectConditionCompareIds; |
|
778 } |
|
779 else if ( aMethodString.Compare( KGuid ) == 0 ) |
|
780 { |
|
781 methodEnum = EObjectConditionCompareGuid; |
|
782 } |
|
783 else if ( aMethodString.Compare( KObjectDef ) == 0 ) |
|
784 { |
|
785 methodEnum = EObjectConditionCompareObjectDef; |
|
786 } |
|
787 else if ( aMethodString.Compare( KUri ) == 0 ) |
|
788 { |
|
789 methodEnum = EObjectConditionCompareUri; |
|
790 } |
|
791 else if ( aMethodString.Compare( KUriBeginsWith ) == 0 ) |
|
792 { |
|
793 methodEnum = EObjectConditionCompareUriBeginsWith; |
|
794 } |
|
795 else if ( aMethodString.Compare( KFreeText ) == 0 ) |
|
796 { |
|
797 methodEnum = EObjectConditionCompareFreeText; |
|
798 } |
|
799 else if ( aMethodString.Compare( KFreeTextContains ) == 0 ) |
|
800 { |
|
801 methodEnum = EObjectConditionCompareFreeTextContains; |
|
802 } |
|
803 else if ( aMethodString.Compare( KFreeTextBeginsWith ) == 0 ) |
|
804 { |
|
805 methodEnum = EObjectConditionCompareFreeTextBeginsWith; |
|
806 } |
|
807 else if ( aMethodString.Compare( KFreeTextEndsWith ) == 0 ) |
|
808 { |
|
809 methodEnum = EObjectConditionCompareFreeTextEndsWith; |
|
810 } |
|
811 else if ( aMethodString.Compare( KFreeTextUsageCount ) == 0 ) |
|
812 { |
|
813 methodEnum = EObjectConditionCompareUsageCount; |
|
814 } |
|
815 else |
|
816 { |
|
817 User::Leave( KErrArgument ); |
|
818 } |
|
819 return methodEnum; |
|
820 } |
|
821 |
|
822 |
|
823 TMdERangeType CMdETestScripter::RangeTypeL(TDesC& aTypeString) |
|
824 { |
|
825 TMdERangeType rangeType = EMdERangeTypeAny; |
|
826 if ( aTypeString.Compare( KAny ) == 0 ) |
|
827 { |
|
828 rangeType = EMdERangeTypeAny; |
|
829 } |
|
830 else if ( aTypeString.Compare( KEqual ) == 0 ) |
|
831 { |
|
832 rangeType = EMdERangeTypeEqual; |
|
833 } |
|
834 else if ( aTypeString.Compare( KNotEqual ) == 0 ) |
|
835 { |
|
836 rangeType = EMdERangeTypeNotEqual; |
|
837 } |
|
838 else if ( aTypeString.Compare( KLess ) == 0 ) |
|
839 { |
|
840 rangeType = EMdERangeTypeLess; |
|
841 } |
|
842 else if ( aTypeString.Compare( KLessOrEqual ) == 0 ) |
|
843 { |
|
844 rangeType = EMdERangeTypeLessOrEqual; |
|
845 } |
|
846 else if ( aTypeString.Compare( KGreater ) == 0 ) |
|
847 { |
|
848 rangeType = EMdERangeTypeGreater; |
|
849 } |
|
850 else if ( aTypeString.Compare( KGreaterOrEqual ) == 0 ) |
|
851 { |
|
852 rangeType = EMdERangeTypeGreaterOrEqual; |
|
853 } |
|
854 else if ( aTypeString.Compare( KBetween ) == 0 ) |
|
855 { |
|
856 rangeType = EMdERangeTypeBetween; |
|
857 } |
|
858 else if ( aTypeString.Compare( KNotBetween ) == 0 ) |
|
859 { |
|
860 rangeType = EMdERangeTypeNotBetween; |
|
861 } |
|
862 else |
|
863 { |
|
864 User::Leave( KErrArgument ); |
|
865 } |
|
866 return rangeType; |
|
867 } |
|
868 |
|
869 |
|
870 // ----------------------------------------------------------------------------- |
|
871 // CMdETestScripter::AddObjectConditionL |
|
872 // ----------------------------------------------------------------------------- |
|
873 // |
|
874 TInt CMdETestScripter::AddObjectConditionL( CStifItemParser& aItem ) |
|
875 { |
|
876 TPtrC name; |
|
877 User::LeaveIfError( aItem.GetNextString( name )); |
|
878 CMdEObjectCondition* newObjectCondition = NULL; |
|
879 |
|
880 |
|
881 CMdELogicCondition* logicCondition = SanitizeArrayIndexL( iLogicConditionArray, *iLogicConditionNameArray, aItem ); |
|
882 |
|
883 #if 0 |
|
884 logicConditionIndex = GetLogicConditionIndexL( aItem ); |
|
885 CMdELogicCondition* logicCondition; |
|
886 if ( logicConditionIndex >= 0 ) |
|
887 { |
|
888 logicCondition = iLogicConditionArray[ logicConditionIndex ]; |
|
889 } |
|
890 else if ( logicConditionIndex == KRootCond ) |
|
891 { |
|
892 logicCondition = &iQuery->Conditions(); |
|
893 } |
|
894 else |
|
895 { |
|
896 User::Leave( logicConditionIndex ); |
|
897 } |
|
898 |
|
899 #endif |
|
900 |
|
901 TPtrC type; |
|
902 User::LeaveIfError( aItem.GetNextString( type )); |
|
903 |
|
904 _LIT(KObjectConditionCompare , "ObjectConditionCompare"); |
|
905 |
|
906 _LIT(KRange , "Range"); |
|
907 |
|
908 if ( type.Compare( KObject ) == 0) |
|
909 { |
|
910 TInt firstIndex = GetObjectIndexL( aItem ); |
|
911 TInt objectCount; |
|
912 User::LeaveIfError( aItem.GetNextInt( objectCount )); |
|
913 if ( objectCount == 1 ) |
|
914 { |
|
915 newObjectCondition = &logicCondition->AddObjectConditionL( iObjectArray[ firstIndex ]->Id() ); |
|
916 } |
|
917 else |
|
918 { |
|
919 RArray<TItemId> objectIdArray; |
|
920 for ( TInt i = firstIndex ; i < firstIndex + objectCount ; i++ ) |
|
921 { |
|
922 objectIdArray.Append( iObjectArray[ i ]->Id() ); |
|
923 } |
|
924 newObjectCondition = &logicCondition->AddObjectConditionL( objectIdArray ); |
|
925 objectIdArray.Reset(); |
|
926 } |
|
927 } |
|
928 else if ( type.Compare( KObjectDef ) == 0 ) |
|
929 { |
|
930 newObjectCondition = &logicCondition->AddObjectConditionL( GetObjectDefStrL( aItem ) ); |
|
931 } |
|
932 else if ( type.Compare( KGuid ) == 0 ) |
|
933 { |
|
934 TInt guidHigh; |
|
935 TInt guidLow; |
|
936 TInt64 guidHigh64; |
|
937 TInt64 guidLow64; |
|
938 User::LeaveIfError( aItem.GetNextInt( guidHigh )); |
|
939 guidHigh64 = guidHigh; |
|
940 User::LeaveIfError( aItem.GetNextInt( guidLow )); |
|
941 guidLow64 = guidLow; |
|
942 newObjectCondition = &logicCondition->AddObjectConditionL( guidHigh64, guidLow64 ); |
|
943 } |
|
944 else if ( type.Compare( KObjectConditionCompare ) == 0 ) |
|
945 { |
|
946 TPtrC method; |
|
947 User::LeaveIfError( aItem.GetNextString( method )); |
|
948 TObjectConditionCompareMethod methodEnum = CompareMethodL( method ); |
|
949 |
|
950 TPtrC string; |
|
951 User::LeaveIfError( aItem.GetNextString( string )); |
|
952 if ( methodEnum == EObjectConditionCompareId ) |
|
953 { |
|
954 TLex lex( string ); |
|
955 TInt integer; |
|
956 TInt err = lex.Val( integer ); |
|
957 if ( err == KErrGeneral ) |
|
958 { // string is not a number so it should be a object name |
|
959 for ( TInt i = 0; i < iObjectNameArray->Count(); i++) |
|
960 { |
|
961 if ( string.Compare( (*iObjectNameArray)[i] ) == 0 ) |
|
962 { |
|
963 TBuf<20> objIdString; |
|
964 objIdString.Num(iObjectArray[i]->Id()); |
|
965 newObjectCondition = &logicCondition->AddObjectConditionL( |
|
966 EObjectConditionCompareId, |
|
967 objIdString ); |
|
968 break; |
|
969 } |
|
970 } |
|
971 } |
|
972 } |
|
973 else |
|
974 { |
|
975 newObjectCondition = &logicCondition->AddObjectConditionL( |
|
976 methodEnum, |
|
977 string); |
|
978 } |
|
979 } |
|
980 else if ( type.Compare( KRange ) == 0 ) |
|
981 { |
|
982 TPtrC type; |
|
983 User::LeaveIfError( aItem.GetNextString( type )); |
|
984 TMdERangeType rangeType = RangeTypeL( type ); |
|
985 |
|
986 TInt min; |
|
987 User::LeaveIfError( aItem.GetNextInt( min ) ); |
|
988 TInt max; |
|
989 User::LeaveIfError( aItem.GetNextInt( max ) ); |
|
990 newObjectCondition = &logicCondition->AddObjectConditionL( TMdEUintRange(min, max, rangeType)); |
|
991 } |
|
992 else |
|
993 { |
|
994 User::Leave( KErrArgument ); |
|
995 } |
|
996 iObjectConditionArray.Append( newObjectCondition ); |
|
997 AppendNameL( iObjectConditionNameArray, name ); |
|
998 |
|
999 return KErrNone; |
|
1000 } |
|
1001 |
|
1002 |
|
1003 _LIT(KTimeRange, "TimeRange"); |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // CMdETestScripter::AddPropertyConditionL |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 TInt CMdETestScripter::AddPropertyConditionL( CStifItemParser& aItem ) |
|
1010 { |
|
1011 |
|
1012 TPtrC name; |
|
1013 User::LeaveIfError( aItem.GetNextString( name )); |
|
1014 |
|
1015 CMdELogicCondition* logicCondition = SanitizeArrayIndexL( iLogicConditionArray, *iLogicConditionNameArray, aItem ); |
|
1016 |
|
1017 CMdEPropertyDef* propertyDef = SanitizeArrayIndexL( iPropertyDefArray, *iPropertyDefNameArray, aItem); |
|
1018 |
|
1019 TPtrC type; |
|
1020 User::LeaveIfError( aItem.GetNextString( type )); |
|
1021 _LIT(KPropCond, "PropCond"); |
|
1022 _LIT(KBool, "Bool"); |
|
1023 _LIT(KIntRange, "IntRange"); |
|
1024 _LIT(KInt64Range, "Int64Range"); |
|
1025 _LIT(KUintRange, "UintRange"); |
|
1026 _LIT(KRealRange, "RealRange"); |
|
1027 |
|
1028 _LIT(KTextCompare, "TextCompare"); |
|
1029 _LIT(KEquals, "Equals"); |
|
1030 _LIT(KContains, "Contains"); |
|
1031 _LIT(KBeginsWith, "BeginsWith"); |
|
1032 _LIT(KEndsWith, "EndsWith"); |
|
1033 |
|
1034 CMdEPropertyCondition* propertyCondition = NULL; |
|
1035 if (type.Compare( KPropCond ) == 0) |
|
1036 { |
|
1037 |
|
1038 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef ); |
|
1039 } |
|
1040 else if (type.Compare( KBool ) == 0) |
|
1041 { |
|
1042 TInt boolean; |
|
1043 User::LeaveIfError( aItem.GetNextInt( boolean ) ); |
|
1044 } |
|
1045 else if (type.Compare( KIntRange ) == 0) |
|
1046 { |
|
1047 TPtrC type; |
|
1048 User::LeaveIfError( aItem.GetNextString( type )); |
|
1049 TMdERangeType rangeType = RangeTypeL( type ); |
|
1050 |
|
1051 TInt min; |
|
1052 User::LeaveIfError( aItem.GetNextInt( min ) ); |
|
1053 TInt max; |
|
1054 User::LeaveIfError( aItem.GetNextInt( max ) ); |
|
1055 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef, TMdEIntRange( min, max, rangeType ) ); |
|
1056 } |
|
1057 else if (type.Compare( KInt64Range ) == 0) |
|
1058 { |
|
1059 TPtrC type; |
|
1060 User::LeaveIfError( aItem.GetNextString( type )); |
|
1061 TMdERangeType rangeType = RangeTypeL( type ); |
|
1062 |
|
1063 TInt min; |
|
1064 User::LeaveIfError( aItem.GetNextInt( min ) ); |
|
1065 TInt64 min64 = min ; |
|
1066 TInt max; |
|
1067 User::LeaveIfError( aItem.GetNextInt( max ) ); |
|
1068 TInt64 max64 = max ; |
|
1069 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef, TMdEInt64Range( min64, max64, rangeType ) ); |
|
1070 } |
|
1071 else if (type.Compare( KUintRange ) == 0) |
|
1072 { |
|
1073 TPtrC type; |
|
1074 User::LeaveIfError( aItem.GetNextString( type )); |
|
1075 TMdERangeType rangeType = RangeTypeL( type ); |
|
1076 |
|
1077 TUint min; |
|
1078 User::LeaveIfError( aItem.GetNextInt( min ) ); |
|
1079 TUint max; |
|
1080 User::LeaveIfError( aItem.GetNextInt( max ) ); |
|
1081 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef, TMdEUintRange( min, max, rangeType ) ); |
|
1082 } |
|
1083 else if (type.Compare( KRealRange ) == 0) |
|
1084 { |
|
1085 TPtrC type; |
|
1086 User::LeaveIfError( aItem.GetNextString( type )); |
|
1087 |
|
1088 TMdERangeType rangeType = RangeTypeL( type ); |
|
1089 |
|
1090 TReal min; |
|
1091 TPtrC minStr; |
|
1092 User::LeaveIfError( aItem.GetNextString( minStr ) ); |
|
1093 TLex lex( minStr ); |
|
1094 lex.Val( min ); |
|
1095 |
|
1096 TReal max; |
|
1097 TPtrC maxStr; |
|
1098 User::LeaveIfError( aItem.GetNextString( maxStr ) ); |
|
1099 lex.Assign( maxStr ); |
|
1100 lex.Val( max ); |
|
1101 |
|
1102 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef, TMdEIntRange( min, max, rangeType ) ); |
|
1103 } |
|
1104 else if (type.Compare( KTimeRange ) == 0) |
|
1105 { |
|
1106 TPtrC type; |
|
1107 User::LeaveIfError( aItem.GetNextString( type )); |
|
1108 |
|
1109 TMdERangeType rangeType = RangeTypeL( type ); |
|
1110 |
|
1111 TTime min; |
|
1112 TPtrC minStr; |
|
1113 User::LeaveIfError( aItem.GetNextString( minStr ) ); |
|
1114 min.Set( minStr ); |
|
1115 |
|
1116 TTime max; |
|
1117 TPtrC maxStr; |
|
1118 User::LeaveIfError( aItem.GetNextString( maxStr ) ); |
|
1119 max.Set( maxStr ); |
|
1120 |
|
1121 |
|
1122 propertyCondition = &logicCondition->AddPropertyConditionL( *propertyDef, TMdETimeRange( min, max, rangeType ) ); |
|
1123 } |
|
1124 else if (type.Compare( KTextCompare ) == 0) |
|
1125 { |
|
1126 TPtrC type; |
|
1127 User::LeaveIfError( aItem.GetNextString( type )); |
|
1128 TTextPropertyConditionCompareMethod compareMethod = ETextPropertyConditionCompareEquals; |
|
1129 if (type.Compare( KEquals ) == 0) |
|
1130 { |
|
1131 compareMethod = ETextPropertyConditionCompareEquals; |
|
1132 } |
|
1133 else if (type.Compare( KContains ) == 0) |
|
1134 { |
|
1135 compareMethod = ETextPropertyConditionCompareContains; |
|
1136 } |
|
1137 else if (type.Compare( KBeginsWith ) == 0) |
|
1138 { |
|
1139 compareMethod = ETextPropertyConditionCompareBeginsWith; |
|
1140 } |
|
1141 else if (type.Compare( KEndsWith ) == 0) |
|
1142 { |
|
1143 compareMethod = ETextPropertyConditionCompareEndsWith; |
|
1144 } |
|
1145 else |
|
1146 { |
|
1147 User::Leave( KErrArgument ); |
|
1148 } |
|
1149 TPtrC text; |
|
1150 User::LeaveIfError( aItem.GetNextString( text ) ); |
|
1151 propertyCondition = &logicCondition->AddPropertyConditionL( |
|
1152 *propertyDef, |
|
1153 compareMethod, |
|
1154 text); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 User::Leave( KErrArgument ); |
|
1159 } |
|
1160 |
|
1161 iPropertyConditionArray.Append( propertyCondition ); |
|
1162 |
|
1163 AppendNameL(iPropertyConditionNameArray, name ); |
|
1164 return KErrNone; |
|
1165 } |
|
1166 |
|
1167 |
|
1168 _LIT(KTimeAndEventCompare, "TimeAndEventCompare"); |
|
1169 |
|
1170 // ----------------------------------------------------------------------------- |
|
1171 // CMdETestScripter::AddRelationConditionL |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // |
|
1174 TInt CMdETestScripter::AddRelationConditionL( CStifItemParser& aItem ) |
|
1175 { |
|
1176 _LIT(KRelationId, "RelationId"); |
|
1177 _LIT(KLeft, "Left"); |
|
1178 _LIT(KRight, "Right"); |
|
1179 _LIT(KEither, "Either"); |
|
1180 TPtrC name; |
|
1181 User::LeaveIfError( aItem.GetNextString( name )); |
|
1182 |
|
1183 CMdELogicCondition* logicCondition = SanitizeArrayIndexL( iLogicConditionArray, *iLogicConditionNameArray, aItem ); |
|
1184 |
|
1185 #if 0 |
|
1186 TInt logicConditionIndex = GetLogicConditionIndexL( aItem ); |
|
1187 CMdELogicCondition* logicCondition; |
|
1188 if ( logicConditionIndex >= 0 ) |
|
1189 { |
|
1190 logicCondition = iLogicConditionArray[ logicConditionIndex ]; |
|
1191 } |
|
1192 else if ( logicConditionIndex == KRootCond ) |
|
1193 { |
|
1194 logicCondition = &iQuery->Conditions(); |
|
1195 } |
|
1196 else |
|
1197 { |
|
1198 User::Leave( logicConditionIndex ); |
|
1199 } |
|
1200 #endif |
|
1201 |
|
1202 CMdERelationCondition* newRelation = NULL; |
|
1203 |
|
1204 TPtrC side; |
|
1205 User::LeaveIfError( aItem.GetNextString( side )); |
|
1206 TRelationConditionSide condSide = ERelationConditionSideEither; |
|
1207 if (side.Compare( KLeft ) == 0) |
|
1208 { |
|
1209 condSide = ERelationConditionSideLeft; |
|
1210 } |
|
1211 else if (side.Compare( KRight ) == 0) |
|
1212 { |
|
1213 condSide = ERelationConditionSideRight; |
|
1214 } |
|
1215 else if (side.Compare( KEither ) == 0) |
|
1216 { |
|
1217 condSide = ERelationConditionSideEither; |
|
1218 } |
|
1219 else |
|
1220 { |
|
1221 User::Leave( KErrArgument ); |
|
1222 } |
|
1223 TPtrC type; |
|
1224 User::LeaveIfError( aItem.GetNextString( type )); |
|
1225 if (type.Compare( KRelationId ) == 0) |
|
1226 { |
|
1227 TInt id; |
|
1228 |
|
1229 TInt relationIdCount; |
|
1230 User::LeaveIfError( aItem.GetNextInt( relationIdCount )); |
|
1231 if ( relationIdCount == 1 ) |
|
1232 { |
|
1233 User::LeaveIfError( aItem.GetNextInt( id ) ); |
|
1234 newRelation = &logicCondition->AddRelationConditionL( TItemId ( id ) , condSide); |
|
1235 } |
|
1236 else |
|
1237 { |
|
1238 RArray<TItemId> relationIdArray; |
|
1239 for ( TInt i = 0 ; i < relationIdCount ; i++ ) |
|
1240 { |
|
1241 aItem.GetNextInt( id ); |
|
1242 relationIdArray.Append( TItemId ( id )); |
|
1243 } |
|
1244 newRelation = &logicCondition->AddRelationConditionL( TItemId ( id ), condSide ); |
|
1245 relationIdArray.Reset(); |
|
1246 } |
|
1247 |
|
1248 } |
|
1249 else if ( type.Compare( KRelationDef ) == 0) |
|
1250 { |
|
1251 CMdERelationDef& relationDef = GetRelationDefStrL( aItem ); |
|
1252 newRelation = &logicCondition->AddRelationConditionL( relationDef, condSide ); |
|
1253 } |
|
1254 else if (type.Compare( KRelationDefRange ) == 0) |
|
1255 { |
|
1256 CMdERelationDef& relationDef = GetRelationDefStrL( aItem ); |
|
1257 TPtrC type; |
|
1258 User::LeaveIfError( aItem.GetNextString( type )); |
|
1259 TMdERangeType rangeType = RangeTypeL( type ); |
|
1260 |
|
1261 TInt min; |
|
1262 User::LeaveIfError( aItem.GetNextInt( min ) ); |
|
1263 TInt max; |
|
1264 User::LeaveIfError( aItem.GetNextInt( max ) ); |
|
1265 |
|
1266 newRelation = &logicCondition->AddRelationConditionL( relationDef, |
|
1267 TMdEIntRange( min, max, rangeType ), condSide ); |
|
1268 } |
|
1269 else |
|
1270 { |
|
1271 User::Leave( KErrArgument ); |
|
1272 } |
|
1273 |
|
1274 iRelationConditionArray.Append( newRelation ); |
|
1275 AppendNameL( iRelationConditionNameArray, name ); |
|
1276 |
|
1277 return KErrNone; |
|
1278 } |
|
1279 |
|
1280 // ----------------------------------------------------------------------------- |
|
1281 // CMdETestScripter::AddEventConditionL |
|
1282 // ----------------------------------------------------------------------------- |
|
1283 // |
|
1284 TInt CMdETestScripter::AddEventConditionL( CStifItemParser& aItem ) |
|
1285 { |
|
1286 _LIT(KEventId, "EventId"); |
|
1287 _LIT(KNoParam, "NoParam"); |
|
1288 _LIT(KEventDef, "EventDef"); |
|
1289 _LIT(KEventCompare, "EventCompare"); |
|
1290 |
|
1291 TPtrC name; |
|
1292 User::LeaveIfError( aItem.GetNextString( name )); |
|
1293 CMdEEventCondition* newEvent = NULL; |
|
1294 |
|
1295 TInt logicConditionIndex = GetLogicConditionIndexL( aItem ); |
|
1296 CMdELogicCondition* logicCondition = NULL; |
|
1297 if ( logicConditionIndex >= 0 ) |
|
1298 { |
|
1299 logicCondition = iLogicConditionArray[ logicConditionIndex ]; |
|
1300 } |
|
1301 else if ( logicConditionIndex == KRootCond ) |
|
1302 { |
|
1303 logicCondition = &iQuery->Conditions(); |
|
1304 } |
|
1305 else |
|
1306 { |
|
1307 User::Leave( logicConditionIndex ); |
|
1308 } |
|
1309 |
|
1310 TPtrC type; |
|
1311 User::LeaveIfError( aItem.GetNextString( type )); |
|
1312 if (type.Compare( KNoParam ) == 0) |
|
1313 { |
|
1314 logicCondition->AddEventConditionL(); |
|
1315 } |
|
1316 else if (type.Compare( KEventId ) == 0) |
|
1317 { |
|
1318 TInt id; |
|
1319 User::LeaveIfError( aItem.GetNextInt( id ) ); |
|
1320 newEvent = &logicCondition->AddEventConditionL( TItemId(id) ); |
|
1321 } |
|
1322 else if (type.Compare( KEventDef ) == 0) |
|
1323 { |
|
1324 TPtrC eventString; |
|
1325 User::LeaveIfError( aItem.GetNextString( eventString )); |
|
1326 |
|
1327 CMdEEventDef& evdef = iNamespaceDefArray[0]->GetEventDefL( eventString ); |
|
1328 newEvent = &logicCondition->AddEventConditionL( evdef ); |
|
1329 } |
|
1330 else if (type.Compare( KTimeRange ) == 0) |
|
1331 { |
|
1332 TPtrC type; |
|
1333 User::LeaveIfError( aItem.GetNextString( type )); |
|
1334 |
|
1335 TMdERangeType rangeType = RangeTypeL( type ); |
|
1336 |
|
1337 TInt64 min; |
|
1338 TPtrC minStr; |
|
1339 User::LeaveIfError( aItem.GetNextString( minStr ) ); |
|
1340 TLex lex( minStr ); |
|
1341 lex.Val( min ); |
|
1342 |
|
1343 TInt64 max; |
|
1344 TPtrC maxStr; |
|
1345 User::LeaveIfError( aItem.GetNextString( maxStr ) ); |
|
1346 lex.Assign( maxStr ); |
|
1347 lex.Val( max ); |
|
1348 |
|
1349 newEvent = &logicCondition->AddEventConditionL( TMdETimeRange( min, max, rangeType ) ); |
|
1350 } |
|
1351 else if (type.Compare( KEventCompare ) == 0) |
|
1352 { |
|
1353 |
|
1354 |
|
1355 TPtrC type; |
|
1356 User::LeaveIfError( aItem.GetNextString( type )); |
|
1357 |
|
1358 _LIT( KNone, "None"); |
|
1359 _LIT( KSourceURI, "SourceURI"); |
|
1360 _LIT( KParticipantURI, "ParticipantURI"); |
|
1361 _LIT( KId, "Id"); |
|
1362 |
|
1363 TEventConditionCompareMethod compareMethod = EEventConditionCompareNone; |
|
1364 if (type.Compare( KNone ) == 0) |
|
1365 { |
|
1366 compareMethod = EEventConditionCompareNone; |
|
1367 } |
|
1368 else if (type.Compare( KSourceURI ) == 0) |
|
1369 { |
|
1370 compareMethod = EEventConditionCompareSourceURI; |
|
1371 } |
|
1372 else if (type.Compare( KParticipantURI ) == 0) |
|
1373 { |
|
1374 compareMethod = EEventConditionCompareParticipantURI; |
|
1375 } |
|
1376 else if (type.Compare( KId ) == 0) |
|
1377 { |
|
1378 compareMethod = EEventConditionCompareId; |
|
1379 } |
|
1380 else |
|
1381 { |
|
1382 User::Leave( KErrArgument ); |
|
1383 } |
|
1384 |
|
1385 TPtrC text; |
|
1386 User::LeaveIfError( aItem.GetNextString( text ) ); |
|
1387 newEvent = &logicCondition->AddEventConditionL( compareMethod, text ); |
|
1388 } |
|
1389 else if (type.Compare( KTimeAndEventCompare ) == 0) |
|
1390 { |
|
1391 |
|
1392 _LIT( KNone, "None"); |
|
1393 _LIT( KSourceURI, "SourceURI"); |
|
1394 _LIT( KParticipantURI, "ParticipantURI"); |
|
1395 _LIT( KId, "Id"); |
|
1396 |
|
1397 TPtrC type; |
|
1398 User::LeaveIfError( aItem.GetNextString( type )); |
|
1399 |
|
1400 TMdERangeType rangeType = RangeTypeL( type ); |
|
1401 |
|
1402 TInt64 min; |
|
1403 TPtrC minStr; |
|
1404 User::LeaveIfError( aItem.GetNextString( minStr ) ); |
|
1405 TLex lex( minStr ); |
|
1406 lex.Val( min ); |
|
1407 |
|
1408 TInt64 max; |
|
1409 TPtrC maxStr; |
|
1410 User::LeaveIfError( aItem.GetNextString( maxStr ) ); |
|
1411 lex.Assign( maxStr ); |
|
1412 lex.Val( max ); |
|
1413 |
|
1414 TEventConditionCompareMethod compareMethod = EEventConditionCompareNone; |
|
1415 if (type.Compare( KNone ) == 0) |
|
1416 { |
|
1417 compareMethod = EEventConditionCompareNone; |
|
1418 } |
|
1419 else if (type.Compare( KSourceURI ) == 0) |
|
1420 { |
|
1421 compareMethod = EEventConditionCompareSourceURI; |
|
1422 } |
|
1423 else if (type.Compare( KParticipantURI ) == 0) |
|
1424 { |
|
1425 compareMethod = EEventConditionCompareParticipantURI; |
|
1426 } |
|
1427 else if (type.Compare( KId ) == 0) |
|
1428 { |
|
1429 compareMethod = EEventConditionCompareId; |
|
1430 } |
|
1431 else |
|
1432 { |
|
1433 User::Leave( KErrArgument ); |
|
1434 } |
|
1435 |
|
1436 TPtrC text; |
|
1437 User::LeaveIfError( aItem.GetNextString( text ) ); |
|
1438 newEvent = &logicCondition->AddEventConditionL( TMdETimeRange( min, max, rangeType ), |
|
1439 compareMethod, text ); |
|
1440 } |
|
1441 |
|
1442 AppendNameL( iEventConditionNameArray , name ); |
|
1443 iEventConditionArray.AppendL( newEvent ); |
|
1444 return KErrNone; |
|
1445 } |
|
1446 |
|
1447 // ----------------------------------------------------------------------------- |
|
1448 // CMdETestScripter::ObjectConditionsL |
|
1449 // ----------------------------------------------------------------------------- |
|
1450 // |
|
1451 TInt CMdETestScripter::ObjectConditionsL( CStifItemParser& aItem ) |
|
1452 { |
|
1453 TPtrC name; |
|
1454 User::LeaveIfError( aItem.GetNextString( name )); |
|
1455 CMdEEventCondition* eventCondition = SanitizeArrayIndexL( iEventConditionArray, *iEventConditionNameArray, aItem ); |
|
1456 CMdELogicCondition& objectConditions = eventCondition->ObjectConditionsL(); |
|
1457 AppendNameL( iLogicConditionNameArray , name ); |
|
1458 iLogicConditionArray.AppendL( &objectConditions ); |
|
1459 return KErrNone; |
|
1460 } |
|
1461 |
|
1462 #if 0 |
|
1463 |
|
1464 void CMdETestScripter::HandleQueryCompleted(CMdEQuery& aQuery, TInt aError) |
|
1465 { |
|
1466 TBuf<128> buf; |
|
1467 |
|
1468 Signal(); |
|
1469 |
|
1470 if (aQuery.Type() == EQueryTypeObject) |
|
1471 { |
|
1472 iLog->Log(_L("Object query completed notification: Error=%d"), aError); |
|
1473 |
|
1474 TQueryResultMode mode = aQuery.ResultMode(); |
|
1475 if ( mode == EQueryResultModeItem ) |
|
1476 { |
|
1477 TInt cou = aQuery.Count(); |
|
1478 |
|
1479 buf.Format(_L(" EModeItem, results=%d"), cou); |
|
1480 iLog->Log(buf); |
|
1481 |
|
1482 for( TInt i = 0; i < cou; i++ ) |
|
1483 { |
|
1484 const TInt64 rid = (TInt64)aQuery.ResultItem( i ).Id(); |
|
1485 buf.Format(_L(" Id %d = %Ld"), i, rid); |
|
1486 iLog->Log(buf); |
|
1487 } |
|
1488 } |
|
1489 else if ( mode == EQueryResultModeId ) |
|
1490 { |
|
1491 TInt cou = aQuery.Count(); |
|
1492 |
|
1493 buf.Format(_L(" EModeId, results=%d"), cou); |
|
1494 iLog->Log(buf); |
|
1495 TInt i; |
|
1496 TInt64 rid; |
|
1497 RArray<TInt64> ridArray; |
|
1498 for( i = 0; i < cou; i++ ) |
|
1499 { |
|
1500 rid = (TInt64)aQuery.ResultId( i ); |
|
1501 ridArray.Append( rid ); |
|
1502 } |
|
1503 |
|
1504 for( i = cou; --i >= 0; ) |
|
1505 { |
|
1506 for( TInt j = iResultIndices.Count(); --j >= 0 ; ) |
|
1507 { |
|
1508 if ( iObjectArray[ iResultIndices[j]]->Id() == ridArray[i] ) |
|
1509 { // matching result |
|
1510 iResultIndices.Remove( j ); |
|
1511 ridArray.Remove( i ); |
|
1512 } |
|
1513 } |
|
1514 } |
|
1515 |
|
1516 if ( iResultIndices.Count() != 0 || iObjectArray.Count() != 0 ) |
|
1517 { |
|
1518 _LIT( KTestMessage1, "Not expected object query result" ); |
|
1519 iLog->Log( KTestMessage1 ); |
|
1520 return; |
|
1521 } |
|
1522 } |
|
1523 else if ( mode == EQueryResultModeCount ) |
|
1524 { |
|
1525 TInt cou = aQuery.Count(); |
|
1526 buf.Format(_L(" EModeCount, results=%d"), cou); |
|
1527 iLog->Log(buf); |
|
1528 } |
|
1529 } |
|
1530 else if (aQuery.Type() == EQueryTypeRelation) |
|
1531 { |
|
1532 iLog->Log(_L("Relation query completed notification: Error=%d"), aError); |
|
1533 |
|
1534 TInt cou = aQuery.Count(); |
|
1535 |
|
1536 buf.Format(_L(" results=%d"), cou); |
|
1537 iLog->Log(buf); |
|
1538 } |
|
1539 else if (aQuery.Type() == EQueryTypeEvent) |
|
1540 { |
|
1541 iLog->Log(_L("Event query completed notification: Error=%d"), aError); |
|
1542 |
|
1543 TInt cou = aQuery.Count(); |
|
1544 |
|
1545 buf.Format(_L(" results=%d"), cou); |
|
1546 iLog->Log(buf); |
|
1547 } |
|
1548 else |
|
1549 { |
|
1550 _LIT( KTestMessage2, "Query completed notification of unknown query" ); |
|
1551 iLog->Log( KTestMessage2 ); |
|
1552 } |
|
1553 } |
|
1554 |
|
1555 #else |
|
1556 |
|
1557 void CMdETestScripter::HandleQueryCompleted(CMdEQuery& aQuery, TInt /* aError */ ) |
|
1558 { |
|
1559 TBuf<128> buf; |
|
1560 |
|
1561 Signal(); |
|
1562 |
|
1563 RArray<TInt64> expectedIdArray; |
|
1564 RArray<TInt64> resultIdArray; |
|
1565 |
|
1566 if (aQuery.Type() == EQueryTypeObject) |
|
1567 { |
|
1568 for( TInt j = iResultIndices.Count(); --j >= 0 ; ) |
|
1569 { |
|
1570 expectedIdArray.Append( iObjectArray[ iResultIndices[j]]->Id() ); |
|
1571 } |
|
1572 } |
|
1573 else if (aQuery.Type() == EQueryTypeRelation) |
|
1574 { |
|
1575 for( TInt j = iResultIndices.Count(); --j >= 0 ; ) |
|
1576 { |
|
1577 expectedIdArray.Append( iRelationArray[ iResultIndices[j]]->Id() ); |
|
1578 } |
|
1579 } |
|
1580 else if (aQuery.Type() == EQueryTypeEvent) |
|
1581 { |
|
1582 for( TInt j = iResultIndices.Count(); --j >= 0 ; ) |
|
1583 { |
|
1584 expectedIdArray.Append( iEventArray[ iResultIndices[j]]->Id() ); |
|
1585 } |
|
1586 } |
|
1587 else |
|
1588 { |
|
1589 _LIT( KTestMessage3, "Query completed notification of unknown query" ); |
|
1590 iLog->Log( KTestMessage3 ); |
|
1591 } |
|
1592 |
|
1593 TQueryResultMode mode = aQuery.ResultMode(); |
|
1594 if ( mode == EQueryResultModeCount ) |
|
1595 { |
|
1596 if (aQuery.Count() != iResultIndices.Count()) |
|
1597 { |
|
1598 _LIT( KTestMessage4, "Not expected query result count" ); |
|
1599 iLog->Log( KTestMessage4 ); |
|
1600 expectedIdArray.Reset(); |
|
1601 return; |
|
1602 } |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 for (TInt i = 0; i < aQuery.Count(); i++) |
|
1607 { |
|
1608 if (aQuery.ResultMode() == EQueryResultModeId) |
|
1609 { |
|
1610 _LIT(KFormat3,"ID: %Ld"); |
|
1611 const TInt64 id = (TInt64)aQuery.ResultId(i); |
|
1612 resultIdArray.Append( id ); |
|
1613 iLog->Log(KFormat3, id); |
|
1614 } |
|
1615 else if (aQuery.ResultMode() == EQueryResultModeItem |
|
1616 || aQuery.ResultMode() == EQueryResultModeObjectWithFreetexts) |
|
1617 { |
|
1618 switch( aQuery.Type() ) |
|
1619 { |
|
1620 case EQueryTypeObject: |
|
1621 { |
|
1622 _LIT(KFormat5o,"Object ID: %Ld URI: '%S' Def: '%S' Properties: %d Freetexts: %d UsageCount: %d"); |
|
1623 |
|
1624 CMdEObject& obj = (CMdEObject&)aQuery.ResultItem(i); |
|
1625 const TInt64 objId = (TInt64)obj.Id(); |
|
1626 resultIdArray.Append( objId ); |
|
1627 iLog->Log(KFormat5o, objId, &obj.Uri(), &obj.Def().Name(), obj.PropertyCount(), obj.FreeTextCount(), obj.UsageCount()); |
|
1628 } |
|
1629 break; |
|
1630 case EQueryTypeRelation: |
|
1631 { |
|
1632 _LIT(KFormat4r,"Relation ID: %Ld Def: '%S' Left ID: %Ld Right ID: %Ld Param: %d"); |
|
1633 |
|
1634 CMdERelation& rel = (CMdERelation&)aQuery.ResultItem(i); |
|
1635 const TInt64 relId = (TInt64)rel.Id(); |
|
1636 resultIdArray.Append( relId ); |
|
1637 const TInt64 relLId = (TInt64)rel.LeftObjectId(); |
|
1638 const TInt64 relRId = (TInt64)rel.RightObjectId(); |
|
1639 iLog->Log(KFormat4r, relId, &rel.Def().Name(), relLId, relRId, rel.Parameter()); |
|
1640 } |
|
1641 break; |
|
1642 case EQueryTypeEvent: |
|
1643 { |
|
1644 _LIT(KFormat4e,"Event ID: %Ld Def: '%S' Object ID: %Ld"); |
|
1645 |
|
1646 CMdEEvent& eve = (CMdEEvent&)aQuery.ResultItem(i); |
|
1647 const TInt64 eveId = (TInt64)eve.Id(); |
|
1648 resultIdArray.Append( eveId ); |
|
1649 const TInt64 eveOId = (TInt64)eve.ObjectId(); |
|
1650 iLog->Log(KFormat4e, eveId, &eve.Def().Name(), eveOId); |
|
1651 } |
|
1652 break; |
|
1653 } |
|
1654 } |
|
1655 else if (aQuery.ResultMode() == EQueryResultModeDistinctValues) |
|
1656 { |
|
1657 _LIT(KFormat5,"Found with text: "); |
|
1658 |
|
1659 buf = KFormat5; |
|
1660 buf.Append( aQuery.ResultDistinctValue(i) ); |
|
1661 iLog->Log( buf ); |
|
1662 } |
|
1663 } |
|
1664 |
|
1665 |
|
1666 if (aQuery.ResultMode() == EQueryResultModeId || aQuery.ResultMode() == EQueryResultModeItem |
|
1667 || aQuery.ResultMode() == EQueryResultModeObjectWithFreetexts ) |
|
1668 { |
|
1669 for(TInt i = resultIdArray.Count(); --i >= 0; ) |
|
1670 { |
|
1671 for( TInt j = expectedIdArray.Count(); --j >= 0 ; ) |
|
1672 { |
|
1673 if ( expectedIdArray[j] == resultIdArray[i] ) |
|
1674 { // matching result |
|
1675 expectedIdArray.Remove( j ); |
|
1676 resultIdArray.Remove( i ); |
|
1677 break; |
|
1678 } |
|
1679 } |
|
1680 } |
|
1681 |
|
1682 if ( expectedIdArray.Count() != 0 || resultIdArray.Count() != 0 ) |
|
1683 { |
|
1684 expectedIdArray.Reset(); |
|
1685 resultIdArray.Reset(); |
|
1686 _LIT( KTestMessage5, "Not expected object query result" ); |
|
1687 iLog->Log( KTestMessage5 ); |
|
1688 return; |
|
1689 } |
|
1690 } |
|
1691 } |
|
1692 } |
|
1693 |
|
1694 #endif |
|
1695 |
|
1696 |
|
1697 |
|
1698 TInt CMdETestScripter::SetEventQueryResultL( CStifItemParser& aItem ) |
|
1699 { |
|
1700 iResultIndices.Reset(); |
|
1701 TPtrC startMark; |
|
1702 User::LeaveIfError( aItem.GetNextString( startMark )); |
|
1703 TLex lex; |
|
1704 TPtrC indexStr; |
|
1705 TInt index; |
|
1706 |
|
1707 if ( startMark.Compare(_L("{")) == 0) |
|
1708 { |
|
1709 while( ETrue ) |
|
1710 { |
|
1711 index = GetEventIndexL( aItem ); |
|
1712 if ( index == KErrCompletion ) |
|
1713 { |
|
1714 break; |
|
1715 } |
|
1716 iResultIndices.Append( index ); |
|
1717 } |
|
1718 } |
|
1719 return KErrNone; |
|
1720 } |
|
1721 |
|
1722 TInt CMdETestScripter::SetRelationQueryResultL( CStifItemParser& aItem ) |
|
1723 { |
|
1724 iResultIndices.Reset(); |
|
1725 TPtrC startMark; |
|
1726 User::LeaveIfError( aItem.GetNextString( startMark )); |
|
1727 TLex lex; |
|
1728 TPtrC indexStr; |
|
1729 TInt index; |
|
1730 |
|
1731 if ( startMark.Compare(_L("{")) == 0) |
|
1732 { |
|
1733 while( ETrue ) |
|
1734 { |
|
1735 index = GetRelationIndexL( aItem ); |
|
1736 if ( index == KErrCompletion ) |
|
1737 { |
|
1738 break; |
|
1739 } |
|
1740 iResultIndices.Append( index ); |
|
1741 } |
|
1742 } |
|
1743 return KErrNone; |
|
1744 } |
|
1745 |
|
1746 |
|
1747 TInt CMdETestScripter::SetObjectQueryResultL( CStifItemParser& aItem ) |
|
1748 { |
|
1749 iResultIndices.Reset(); |
|
1750 TPtrC startMark; |
|
1751 User::LeaveIfError( aItem.GetNextString( startMark )); |
|
1752 TLex lex; |
|
1753 TPtrC indexStr; |
|
1754 TInt index; |
|
1755 |
|
1756 if ( startMark.Compare(_L("{")) == 0) |
|
1757 { |
|
1758 while( ETrue ) |
|
1759 { |
|
1760 index = GetObjectIndexL( aItem ); |
|
1761 if ( index == KErrCompletion ) |
|
1762 { |
|
1763 break; |
|
1764 } |
|
1765 iResultIndices.Append( index ); |
|
1766 } |
|
1767 } |
|
1768 return KErrNone; |
|
1769 } |
|
1770 |
|
1771 |
|
1772 // ----------------------------------------------------------------------------- |
|
1773 // CMdETestScripter::TestPopulateDbL |
|
1774 // ----------------------------------------------------------------------------- |
|
1775 // |
|
1776 TInt CMdETestScripter::TestPopulateDbL( CStifItemParser& /*aItem*/ ) |
|
1777 { |
|
1778 CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL(); |
|
1779 CMdEObjectDef& objectDef = namespaceDef.GetObjectDefL( MdeConstants::Album::KAlbumObject ); |
|
1780 CMdEObject* albumObject = iMdeSession->NewObjectL( |
|
1781 objectDef, MdeConstants::Object::KAutomaticUri ); |
|
1782 CMdEPropertyDef& creationDatePropertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); |
|
1783 TTime time( 0 ); |
|
1784 albumObject->AddTimePropertyL( creationDatePropertyDef, time ); |
|
1785 |
|
1786 CMdEPropertyDef& lastModifiedDatePropertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
|
1787 |
|
1788 albumObject->AddTimePropertyL( lastModifiedDatePropertyDef, time ); |
|
1789 iMdeSession->AddObjectL( *albumObject ); |
|
1790 |
|
1791 CMdEObjectDef& audioObjectDef = namespaceDef.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
1792 CMdEObject* audioObject = iMdeSession->NewObjectL( |
|
1793 audioObjectDef, MdeConstants::Object::KAutomaticUri ); |
|
1794 |
|
1795 audioObject->AddTimePropertyL( creationDatePropertyDef, time ); |
|
1796 |
|
1797 audioObject->AddTimePropertyL( lastModifiedDatePropertyDef, time ); |
|
1798 iMdeSession->AddObjectL( *audioObject ); |
|
1799 CMdERelationDef& relationDef = namespaceDef.GetRelationDefL( MdeConstants::Relations::KContains ); |
|
1800 |
|
1801 CMdERelation* relation = iMdeSession->NewRelationL( relationDef, albumObject->Id(), audioObject->Id(), 0 ); |
|
1802 iMdeSession->AddRelationL( *relation ); |
|
1803 |
|
1804 CMdEObjectDef& objDef = namespaceDef.GetObjectDefL( MdeConstants::Object::KBaseObject ); |
|
1805 |
|
1806 delete iQuery; |
|
1807 iQuery = NULL; |
|
1808 iQuery = iMdeSession->NewObjectQueryL( namespaceDef, objDef, this ); |
|
1809 |
|
1810 CMdELogicCondition& rootCond = iQuery->Conditions(); |
|
1811 |
|
1812 CMdERelationDef& containsRelDef = namespaceDef.GetRelationDefL( |
|
1813 MdeConstants::Relations::KContains ); |
|
1814 |
|
1815 CMdERelationCondition& relCond = rootCond.AddRelationConditionL( |
|
1816 containsRelDef, ERelationConditionSideRight ); |
|
1817 CMdELogicCondition& leftRelCond = relCond.LeftL(); |
|
1818 |
|
1819 leftRelCond.AddObjectConditionL( albumObject->Id() ); |
|
1820 |
|
1821 iQuery->SetResultMode( EQueryResultModeId ); |
|
1822 |
|
1823 iQuery->FindL(); |
|
1824 return KErrNone; |
|
1825 } |
|
1826 |