|
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: Comparator algorithms for notifier* |
|
15 */ |
|
16 |
|
17 #include "mdsnotifycomparator.h" |
|
18 |
|
19 #include "mdcresult.h" |
|
20 #include "mdcitem.h" |
|
21 #include "mdccommon.pan" |
|
22 #include "mdcserializationbuffer.h" |
|
23 #include "mderange.h" |
|
24 #include "mdscommoninternal.h" |
|
25 #include "mdcquery.h" |
|
26 #include "mdccommon.h" |
|
27 #include "mdeinternalerror.h" |
|
28 |
|
29 CMdSNotifyComparator* CMdSNotifyComparator::NewL() |
|
30 { |
|
31 CMdSNotifyComparator* that = CMdSNotifyComparator::NewLC(); |
|
32 CleanupStack::Pop( that ); |
|
33 return that; |
|
34 } |
|
35 |
|
36 CMdSNotifyComparator* CMdSNotifyComparator::NewLC() |
|
37 { |
|
38 CMdSNotifyComparator* that = new(ELeave) CMdSNotifyComparator(); |
|
39 CleanupStack::PushL( that ); |
|
40 that->ConstructL(); |
|
41 return that; |
|
42 } |
|
43 |
|
44 |
|
45 CMdSNotifyComparator::~CMdSNotifyComparator() |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 CMdSNotifyComparator::CMdSNotifyComparator() |
|
51 { |
|
52 |
|
53 } |
|
54 |
|
55 void CMdSNotifyComparator::ConstructL() |
|
56 { |
|
57 } |
|
58 |
|
59 TBool CMdSNotifyComparator::MatchL( |
|
60 TDefId aNamespaceDefId, TUint32 aType, |
|
61 CMdCSerializationBuffer& aSerializedCondition, |
|
62 CMdCSerializationBuffer& aSerializedItems, |
|
63 CMdCSerializationBuffer& aSerializedItemIds, |
|
64 RArray<TItemId>& aMatchingItemIdArray, |
|
65 TBool aAllowConfidential) |
|
66 { |
|
67 const TMdCItems& items = TMdCItems::GetFromBufferL( aSerializedItems ); |
|
68 |
|
69 const TMdCItemIds& itemIds = TMdCItemIds::GetFromBufferL( aSerializedItemIds ); |
|
70 |
|
71 // check if some namespace definitions are not the same |
|
72 if( itemIds.iNamespaceDefId != aNamespaceDefId ) |
|
73 { |
|
74 return EFalse; |
|
75 } |
|
76 |
|
77 if( ( items.iObjects.iPtr.iCount > 0 ) && |
|
78 ( itemIds.iObjectIds.iPtr.iCount > 0 ) && |
|
79 ( aType & ( EObjectNotifyAdd | EObjectNotifyModify ) ) ) |
|
80 { |
|
81 // object ID count and object item count should match |
|
82 __ASSERT_DEBUG( items.iObjects.iPtr.iCount == itemIds.iObjectIds.iPtr.iCount, MMdCCommon::Panic( KErrCorrupt ) ); |
|
83 |
|
84 aSerializedItemIds.PositionL( itemIds.iObjectIds.iPtr.iOffset ); |
|
85 for( TUint32 i = 0; i < itemIds.iObjectIds.iPtr.iCount; i++ ) |
|
86 { |
|
87 TItemId objectId; |
|
88 aSerializedItemIds.ReceiveL( objectId ); |
|
89 |
|
90 if( aSerializedCondition.Size() > 0 ) |
|
91 { |
|
92 TBool results( EFalse ); |
|
93 TBool succeed( EFalse ); |
|
94 |
|
95 // move condition buffer's position beginnig of the buffer |
|
96 aSerializedCondition.PositionL( KNoOffset ); |
|
97 |
|
98 const TMdCLogicCondition& logicCondition = |
|
99 TMdCLogicCondition::GetFromBufferL( aSerializedCondition ); |
|
100 |
|
101 for ( TUint32 j = 0; j < logicCondition.iChildConditions.iPtr.iCount; j++ ) |
|
102 { |
|
103 // set correct position to item buffer |
|
104 aSerializedItems.PositionL( items.iObjects.iPtr.iOffset + |
|
105 i * sizeof(TMdCObject) ); |
|
106 |
|
107 // set correct positin to condition buffer |
|
108 aSerializedCondition.PositionL( |
|
109 logicCondition.iChildConditions.iPtr.iOffset + |
|
110 j * CMdCSerializationBuffer::KRequiredSizeForTUint32 ); |
|
111 TUint32 conditionOffset; |
|
112 aSerializedCondition.ReceiveL( conditionOffset ); |
|
113 aSerializedCondition.PositionL( conditionOffset ); |
|
114 |
|
115 results = MatchObjectL( aSerializedCondition, |
|
116 aSerializedItems, objectId, aAllowConfidential ); |
|
117 |
|
118 succeed = results; |
|
119 if ( logicCondition.iOperator == ELogicConditionOperatorAnd ) |
|
120 { |
|
121 if( !results ) |
|
122 { |
|
123 break; |
|
124 } |
|
125 } |
|
126 |
|
127 if ( logicCondition.iOperator == ELogicConditionOperatorOr ) |
|
128 { |
|
129 if( results ) |
|
130 { |
|
131 break; |
|
132 } |
|
133 } |
|
134 } |
|
135 |
|
136 if ( logicCondition.iNegated ) |
|
137 { |
|
138 succeed = !( succeed ); |
|
139 } |
|
140 |
|
141 if ( succeed ) |
|
142 { |
|
143 aMatchingItemIdArray.AppendL( objectId ); |
|
144 } |
|
145 } |
|
146 else |
|
147 { |
|
148 aMatchingItemIdArray.AppendL( objectId ); |
|
149 } |
|
150 } |
|
151 } |
|
152 else if( ( items.iEvents.iPtr.iCount > 0 ) && |
|
153 ( itemIds.iEventIds.iPtr.iCount > 0 ) && |
|
154 ( aType & ( EEventNotifyAdd /*| EEventNotifyRemove*/ ) ) ) |
|
155 { |
|
156 // event ID count and event item count should match |
|
157 __ASSERT_DEBUG( items.iEvents.iPtr.iCount == itemIds.iEventIds.iPtr.iCount, MMdCCommon::Panic( KErrCorrupt ) ); |
|
158 |
|
159 aSerializedItemIds.PositionL( itemIds.iEventIds.iPtr.iOffset ); |
|
160 for( TUint32 i = 0; i < itemIds.iEventIds.iPtr.iCount; i++ ) |
|
161 { |
|
162 TItemId eventId; |
|
163 aSerializedItemIds.ReceiveL( eventId ); |
|
164 |
|
165 if( aSerializedCondition.Size() > 0 ) |
|
166 { |
|
167 // set correct position to item buffer |
|
168 aSerializedItems.PositionL( items.iEvents.iPtr.iOffset + i * sizeof(TMdCEvent) ); |
|
169 |
|
170 // move condition buffer's position to the begin of the buffer |
|
171 aSerializedCondition.PositionL( KNoOffset ); |
|
172 |
|
173 if( MatchEventL( aSerializedCondition, aSerializedItems, eventId ) ) |
|
174 { |
|
175 aMatchingItemIdArray.AppendL( eventId ); |
|
176 } |
|
177 } |
|
178 else |
|
179 { |
|
180 aMatchingItemIdArray.AppendL( eventId ); |
|
181 } |
|
182 } |
|
183 } |
|
184 else if( ( items.iRelations.iPtr.iCount > 0 ) && |
|
185 ( itemIds.iRelationIds.iPtr.iCount > 0 ) && |
|
186 ( aType & ( ERelationNotifyAdd | ERelationNotifyModify /*| ERelationNotifyRemove*/ ) ) ) |
|
187 { |
|
188 // relation ID count and relation item count should match |
|
189 __ASSERT_DEBUG( items.iRelations.iPtr.iCount == itemIds.iRelationIds.iPtr.iCount, MMdCCommon::Panic( KErrCorrupt ) ); |
|
190 |
|
191 aSerializedItemIds.PositionL( itemIds.iRelationIds.iPtr.iOffset ); |
|
192 for( TUint32 i = 0; i < itemIds.iRelationIds.iPtr.iCount; i++ ) |
|
193 { |
|
194 TItemId relationId; |
|
195 aSerializedItemIds.ReceiveL( relationId ); |
|
196 |
|
197 if( aSerializedCondition.Size() > 0 ) |
|
198 { |
|
199 // set correct position to item buffer |
|
200 aSerializedItems.PositionL( items.iRelations.iPtr.iOffset |
|
201 + i * sizeof(TMdCRelation) ); |
|
202 |
|
203 // move condition buffer's position to the begin of the buffer |
|
204 aSerializedCondition.PositionL( KNoOffset ); |
|
205 |
|
206 if( MatchRelationL( aSerializedCondition, aSerializedItems, relationId ) ) |
|
207 { |
|
208 aMatchingItemIdArray.AppendL( relationId ); |
|
209 } |
|
210 } |
|
211 else |
|
212 { |
|
213 aMatchingItemIdArray.AppendL( relationId ); |
|
214 } |
|
215 } |
|
216 } |
|
217 |
|
218 if( aMatchingItemIdArray.Count() > 0 ) |
|
219 { |
|
220 return ETrue; |
|
221 } |
|
222 else |
|
223 { |
|
224 return EFalse; |
|
225 } |
|
226 } |
|
227 |
|
228 TBool CMdSNotifyComparator::MatchObjectL( |
|
229 CMdCSerializationBuffer& aSerializedCondition, |
|
230 CMdCSerializationBuffer& aSerializedItem, TItemId aObjectId, |
|
231 TBool aAllowConfidential ) |
|
232 { |
|
233 // check if object is failed |
|
234 if( aObjectId == KNoId ) |
|
235 { |
|
236 return EFalse; |
|
237 } |
|
238 |
|
239 // Check type |
|
240 const TMdCCondition& condition = |
|
241 TMdCCondition::GetFromBufferL( aSerializedCondition ); |
|
242 |
|
243 switch( condition.iConditionType ) |
|
244 { |
|
245 case EConditionTypeObject: |
|
246 { |
|
247 return ( CheckObjectL( aSerializedCondition, aSerializedItem, |
|
248 aAllowConfidential ) ); |
|
249 } |
|
250 case EConditionTypeProperty: |
|
251 case EConditionTypePropertyIntRange: |
|
252 case EConditionTypePropertyInt64Range: |
|
253 case EConditionTypePropertyUintRange: |
|
254 case EConditionTypePropertyRealRange: |
|
255 case EConditionTypePropertyTimeRange: |
|
256 case EConditionTypePropertyText: |
|
257 case EConditionTypePropertyBool: |
|
258 { |
|
259 return ( CheckPropertyL( aSerializedCondition, aSerializedItem ) ); |
|
260 } |
|
261 default: |
|
262 #ifdef _DEBUG |
|
263 User::Panic( _L("MdSNCMaO") , KErrMdEUnknownConditionType ); |
|
264 #endif |
|
265 break; |
|
266 } |
|
267 |
|
268 return EFalse; |
|
269 } |
|
270 |
|
271 TBool CMdSNotifyComparator::CheckPropertyL( |
|
272 CMdCSerializationBuffer& aSerializedCondition, |
|
273 CMdCSerializationBuffer& aSerializedItem ) |
|
274 { |
|
275 const TMdCObject& object = TMdCObject::GetFromBufferL( aSerializedItem ); |
|
276 |
|
277 const TMdCPropertyCondition& propertyCondition = |
|
278 TMdCPropertyCondition::GetFromBufferL( aSerializedCondition ); |
|
279 |
|
280 for( TUint32 i=0; i < object.iProperties.iPtr.iCount; i++ ) |
|
281 { |
|
282 aSerializedItem.PositionL( object.iProperties.iPtr.iOffset |
|
283 + i * sizeof(TMdCProperty) ); |
|
284 const TMdCProperty& property = TMdCProperty::GetFromBufferL( aSerializedItem ); |
|
285 |
|
286 // check propertyDefId doesn't match -> skip it |
|
287 if( property.iPropertyDefId == propertyCondition.iPropertyDefId ) |
|
288 { |
|
289 // move condition buffer to begin of the condition |
|
290 aSerializedCondition.PositionL( propertyCondition.iCondition ); |
|
291 |
|
292 switch( propertyCondition.iConditionType ) |
|
293 { |
|
294 case EConditionTypeProperty: |
|
295 { |
|
296 // check only if existing condition is negated |
|
297 if( propertyCondition.iNegated ) |
|
298 { |
|
299 return EFalse; |
|
300 } |
|
301 else |
|
302 { |
|
303 return ETrue; |
|
304 } |
|
305 } |
|
306 |
|
307 case EConditionTypePropertyIntRange: |
|
308 { |
|
309 TInt32 rangeType32( 0 ); |
|
310 aSerializedCondition.ReceiveL( rangeType32 ); |
|
311 const TMdERangeType rangeType = ( TMdERangeType )rangeType32; |
|
312 |
|
313 TMdCValueUnion minValue; |
|
314 aSerializedCondition.ReceiveL( minValue ); |
|
315 TMdCValueUnion maxValue; |
|
316 aSerializedCondition.ReceiveL( maxValue ); |
|
317 |
|
318 // init range for next test |
|
319 TMdEIntRange range( minValue.iInt32, maxValue.iInt32, |
|
320 rangeType ); |
|
321 |
|
322 if( range.InRange( property.iValue.iInt32 ) == propertyCondition.iNegated ) |
|
323 { |
|
324 return EFalse; |
|
325 } |
|
326 break; |
|
327 } |
|
328 case EConditionTypePropertyInt64Range: |
|
329 { |
|
330 TInt32 rangeType32( 0 ); |
|
331 aSerializedCondition.ReceiveL( rangeType32 ); |
|
332 const TMdERangeType rangeType = ( TMdERangeType )rangeType32; |
|
333 |
|
334 TMdCValueUnion minValue; |
|
335 aSerializedCondition.ReceiveL( minValue ); |
|
336 TMdCValueUnion maxValue; |
|
337 aSerializedCondition.ReceiveL( maxValue ); |
|
338 |
|
339 // init range for next test |
|
340 TMdEInt64Range range( minValue.iInt64, maxValue.iInt64, |
|
341 rangeType ); |
|
342 |
|
343 // test if valueType is in the range |
|
344 if( range.InRange( property.iValue.iInt64 ) == propertyCondition.iNegated ) |
|
345 { |
|
346 return EFalse; |
|
347 } |
|
348 break; |
|
349 } |
|
350 case EConditionTypePropertyUintRange: |
|
351 { |
|
352 TInt32 rangeType32( 0 ); |
|
353 aSerializedCondition.ReceiveL( rangeType32 ); |
|
354 const TMdERangeType rangeType = ( TMdERangeType )rangeType32; |
|
355 |
|
356 TMdCValueUnion minValue; |
|
357 aSerializedCondition.ReceiveL( minValue ); |
|
358 TMdCValueUnion maxValue; |
|
359 aSerializedCondition.ReceiveL( maxValue ); |
|
360 |
|
361 // init range for next test |
|
362 TMdEUintRange range( minValue.iUint32, maxValue.iUint32, |
|
363 rangeType ); |
|
364 |
|
365 if( range.InRange( property.iValue.iUint32 ) == propertyCondition.iNegated ) |
|
366 { |
|
367 return EFalse; |
|
368 } |
|
369 break; |
|
370 } |
|
371 case EConditionTypePropertyRealRange: |
|
372 { |
|
373 TInt32 rangeType32( 0 ); |
|
374 aSerializedCondition.ReceiveL( rangeType32 ); |
|
375 const TMdERangeType rangeType = ( TMdERangeType )rangeType32; |
|
376 |
|
377 TMdCValueUnion minValue; |
|
378 aSerializedCondition.ReceiveL( minValue ); |
|
379 TMdCValueUnion maxValue; |
|
380 aSerializedCondition.ReceiveL( maxValue ); |
|
381 |
|
382 // init range for next test |
|
383 TMdERealRange range( minValue.iReal, maxValue.iReal, rangeType ); |
|
384 |
|
385 // test if valueType is in the range |
|
386 if( range.InRange( property.iValue.iReal ) == propertyCondition.iNegated ) |
|
387 { |
|
388 return EFalse; |
|
389 } |
|
390 break; |
|
391 } |
|
392 case EConditionTypePropertyTimeRange: |
|
393 { |
|
394 TInt32 rangeType32( 0 ); |
|
395 aSerializedCondition.ReceiveL( rangeType32 ); |
|
396 TMdERangeType rangeType = ( TMdERangeType )rangeType32; |
|
397 |
|
398 TMdCValueUnion minValue; |
|
399 aSerializedCondition.ReceiveL( minValue ); |
|
400 TMdCValueUnion maxValue; |
|
401 aSerializedCondition.ReceiveL( maxValue ); |
|
402 |
|
403 // init range for next test |
|
404 TMdETimeRange range( minValue.iInt64, maxValue.iInt64, |
|
405 rangeType ); |
|
406 |
|
407 TTime value( property.iValue.iInt64 ); |
|
408 // test if valueType is in the range |
|
409 if( range.InRange( property.iValue.iInt64 ) == propertyCondition.iNegated ) |
|
410 { |
|
411 return EFalse; |
|
412 } |
|
413 break; |
|
414 } |
|
415 case EConditionTypePropertyText: |
|
416 { |
|
417 // SerializedItem |
|
418 aSerializedItem.PositionL( property.iValue.iPtr.iOffset ); |
|
419 TPtrC16 value = aSerializedItem.ReceivePtr16L(); |
|
420 |
|
421 // ConditionItem |
|
422 TUint32 condCompareMethod( 0 ); |
|
423 aSerializedCondition.ReceiveL( condCompareMethod ); |
|
424 TPtrC16 condValue = aSerializedCondition.ReceivePtr16L(); |
|
425 |
|
426 //Check, that compare method is in range |
|
427 #ifdef _DEBUG |
|
428 if( condCompareMethod <= ETextPropertyConditionCompareFirst || condCompareMethod >= ETextPropertyConditionCompareLast ) |
|
429 { |
|
430 User::Panic( _L("MdSNCCP1") , KErrMdEUnknownConditionCompareMethod ); |
|
431 } |
|
432 #endif |
|
433 TBool compareResult( EFalse ); |
|
434 |
|
435 switch( condCompareMethod ) |
|
436 { |
|
437 case ETextPropertyConditionCompareEquals: |
|
438 { |
|
439 if( (value == condValue ) ) |
|
440 { |
|
441 compareResult = EFalse; |
|
442 } |
|
443 break; |
|
444 } |
|
445 case ETextPropertyConditionCompareContains: |
|
446 { |
|
447 compareResult = FindDes( value, condValue ); |
|
448 break; |
|
449 } |
|
450 case ETextPropertyConditionCompareBeginsWith: |
|
451 { |
|
452 compareResult = CompareDesBeginsWith( value, condValue ); |
|
453 break; |
|
454 } |
|
455 case ETextPropertyConditionCompareEndsWith: |
|
456 { |
|
457 compareResult = CompareDesEndsWith( value, condValue ); |
|
458 break; |
|
459 } |
|
460 default: |
|
461 { |
|
462 #ifdef _DEBUG |
|
463 User::Panic( _L("MdSNCCP2") , KErrMdEUnknownConditionCompareMethod ); |
|
464 #endif |
|
465 } |
|
466 } |
|
467 |
|
468 if( compareResult == propertyCondition.iNegated ) |
|
469 { |
|
470 return EFalse; |
|
471 } |
|
472 break; |
|
473 } |
|
474 case EConditionTypePropertyBool: |
|
475 { |
|
476 const TBool value( property.iValue.iInt32 ); |
|
477 |
|
478 TBool condValue( EFalse ); |
|
479 aSerializedCondition.ReceiveL( condValue ); |
|
480 |
|
481 if( ( value == condValue ) == propertyCondition.iNegated ) |
|
482 { |
|
483 return EFalse; |
|
484 } |
|
485 break; |
|
486 } |
|
487 default: |
|
488 { |
|
489 #ifdef _DEBUG |
|
490 User::Panic( _L("MdSNCCP3") , KErrMdEUnknownConditionType ); |
|
491 #endif |
|
492 User::Leave( KErrMdEUnknownConditionType ); |
|
493 } |
|
494 } // switch |
|
495 |
|
496 return ETrue; |
|
497 |
|
498 } // if |
|
499 |
|
500 } // for |
|
501 |
|
502 return EFalse; |
|
503 } |
|
504 |
|
505 TBool CMdSNotifyComparator::CheckObjectL( CMdCSerializationBuffer& aSerializedCondition, |
|
506 CMdCSerializationBuffer& aSerializedItem, |
|
507 TBool aAllowConfidential ) |
|
508 { |
|
509 const TMdCObject& object = TMdCObject::GetFromBufferL( aSerializedItem ); |
|
510 |
|
511 const TBool confidential = object.iFlags & EMdEObjectFlagConfidential; |
|
512 |
|
513 // check if object is confidential and confidentials are not allowed |
|
514 if( confidential && ( aAllowConfidential == EFalse ) ) |
|
515 { |
|
516 return EFalse; |
|
517 } |
|
518 |
|
519 // check if no condition defined |
|
520 if( aSerializedCondition.Size() <= 0 ) |
|
521 { |
|
522 // pass all successful objects |
|
523 return ETrue; |
|
524 } |
|
525 |
|
526 const TMdCObjectCondition& condition = |
|
527 TMdCObjectCondition::GetFromBufferL( aSerializedCondition ); |
|
528 |
|
529 switch( condition.iConfidentialityLevel ) |
|
530 { |
|
531 case EObjectConditionLevelNormal: |
|
532 if( confidential ) |
|
533 { |
|
534 return EFalse; |
|
535 } |
|
536 break; |
|
537 case EObjectConditionLevelConfidential: |
|
538 if( confidential == EFalse ) |
|
539 { |
|
540 return EFalse; |
|
541 } |
|
542 break; |
|
543 |
|
544 default: |
|
545 { |
|
546 #ifdef _DEBUG |
|
547 User::Panic( _L("MdSNCCO1") , KErrMdEUnknownConfidentialityLevel ); |
|
548 #endif |
|
549 User::Leave( KErrMdEUnknownConfidentialityLevel ); |
|
550 } |
|
551 } |
|
552 |
|
553 if( ( condition.iFlags & EMdEObjectFlagPlaceholder ) && |
|
554 ( object.iFlags & EMdEObjectFlagPlaceholder ) ) |
|
555 { |
|
556 return EFalse; |
|
557 } |
|
558 |
|
559 // move position to begin of sub condition |
|
560 aSerializedCondition.PositionL( condition.iCondition ); |
|
561 |
|
562 switch( condition.iCompareMethod ) |
|
563 { |
|
564 case EObjectConditionCompareNone: |
|
565 break; |
|
566 |
|
567 case EObjectConditionCompareId: |
|
568 { |
|
569 TItemId conditionObjectId; |
|
570 aSerializedCondition.ReceiveL( conditionObjectId ); |
|
571 |
|
572 if( ( conditionObjectId == object.iId ) == condition.iNegated ) |
|
573 { |
|
574 return EFalse; |
|
575 } |
|
576 } |
|
577 break; |
|
578 |
|
579 case EObjectConditionCompareUsageCount: |
|
580 { |
|
581 TInt32 rangeType32; |
|
582 aSerializedCondition.ReceiveL( rangeType32 ); |
|
583 const TMdERangeType rangeType = (TMdERangeType)rangeType32; |
|
584 |
|
585 TMdCValueUnion minValue; |
|
586 aSerializedCondition.ReceiveL( minValue ); |
|
587 TMdCValueUnion maxValue; |
|
588 aSerializedCondition.ReceiveL( maxValue ); |
|
589 |
|
590 // init range for next test |
|
591 TMdEUintRange range( minValue.iUint32, maxValue.iUint32, |
|
592 rangeType ); |
|
593 |
|
594 // test if event's creation time is in the range |
|
595 if( BoolEqual( range.InRange( object.iUsageCount ), condition.iNegated ) ) |
|
596 { |
|
597 return EFalse; |
|
598 } |
|
599 } |
|
600 break; |
|
601 |
|
602 case EObjectConditionCompareGuid: |
|
603 { |
|
604 TInt64 conditionGuidHigh; |
|
605 aSerializedCondition.ReceiveL( conditionGuidHigh ); |
|
606 TInt64 conditionGuidLow; |
|
607 aSerializedCondition.ReceiveL( conditionGuidLow ); |
|
608 |
|
609 if( ( ( conditionGuidHigh == object.iGuidHigh ) && |
|
610 ( conditionGuidLow == object.iGuidLow ) ) == |
|
611 condition.iNegated ) |
|
612 { |
|
613 return EFalse; |
|
614 } |
|
615 } |
|
616 break; |
|
617 |
|
618 case EObjectConditionCompareObjectDef: |
|
619 { |
|
620 TDefId conditionObjectDefId; |
|
621 aSerializedCondition.ReceiveL( conditionObjectDefId ); |
|
622 |
|
623 if( ( conditionObjectDefId == object.iDefId ) == condition.iNegated ) |
|
624 { |
|
625 return EFalse; |
|
626 } |
|
627 } |
|
628 break; |
|
629 |
|
630 case EObjectConditionCompareUri: |
|
631 { |
|
632 aSerializedItem.PositionL( object.iUri.iPtr.iOffset ); |
|
633 TPtrC16 uri = aSerializedItem.ReceivePtr16L(); |
|
634 |
|
635 TPtrC16 conditionUri = aSerializedCondition.ReceivePtr16L(); |
|
636 |
|
637 if( ( conditionUri.Compare( uri ) == 0 ) == condition.iNegated ) |
|
638 { |
|
639 return EFalse; |
|
640 } |
|
641 } |
|
642 break; |
|
643 |
|
644 case EObjectConditionCompareUriBeginsWith: |
|
645 { |
|
646 aSerializedItem.PositionL( object.iUri.iPtr.iOffset ); |
|
647 TPtrC16 uri = aSerializedItem.ReceivePtr16L(); |
|
648 |
|
649 TPtrC16 conditionUri = aSerializedCondition.ReceivePtr16L(); |
|
650 |
|
651 if( CompareDesBeginsWith( uri, conditionUri ) == condition.iNegated ) |
|
652 { |
|
653 return EFalse; |
|
654 } |
|
655 } |
|
656 break; |
|
657 |
|
658 default: |
|
659 { |
|
660 #ifdef _DEBUG |
|
661 User::Panic( _L("MdSNCCO2") , KErrMdEUnknownConditionCompareMethod ); |
|
662 #endif |
|
663 User::Leave( KErrMdEUnknownConditionCompareMethod ); |
|
664 } |
|
665 } |
|
666 |
|
667 return ETrue; |
|
668 } |
|
669 |
|
670 |
|
671 TBool CMdSNotifyComparator::MatchEventL(CMdCSerializationBuffer& aSerializedCondition, |
|
672 CMdCSerializationBuffer& aSerializedItem, |
|
673 TItemId aEventId) |
|
674 { |
|
675 const TMdCEvent& event = TMdCEvent::GetFromBufferL( aSerializedItem ); |
|
676 |
|
677 // check if event is failed |
|
678 if( aEventId == 0 ) |
|
679 { |
|
680 return EFalse; |
|
681 } |
|
682 |
|
683 // check if no condition defined |
|
684 if( aSerializedCondition.Size() <= 0 ) |
|
685 { |
|
686 // pass all successful events |
|
687 return ETrue; |
|
688 } |
|
689 |
|
690 const TMdCEventCondition& eventCondition = |
|
691 TMdCEventCondition::GetFromBufferL( aSerializedCondition ); |
|
692 |
|
693 // check if event condition contains event ID comparsion |
|
694 if( eventCondition.iEventId != KNoId ) |
|
695 { |
|
696 if( ( eventCondition.iEventId == event.iId ) == eventCondition.iNegated ) |
|
697 { |
|
698 return EFalse; |
|
699 } |
|
700 } |
|
701 |
|
702 // check if event condition contains event def ID comparsion |
|
703 if( eventCondition.iEventDefId != KNoDefId ) |
|
704 { |
|
705 if( ( eventCondition.iEventDefId == event.iDefId ) == eventCondition.iNegated ) |
|
706 { |
|
707 return EFalse; |
|
708 } |
|
709 } |
|
710 |
|
711 // check event condition contains event creation time range comparision |
|
712 if( eventCondition.iCreationTimeRange != KNoOffset ) |
|
713 { |
|
714 aSerializedCondition.PositionL( eventCondition.iCreationTimeRange ); |
|
715 |
|
716 TInt32 rangeType32; |
|
717 aSerializedCondition.ReceiveL( rangeType32 ); |
|
718 const TMdERangeType rangeType = (TMdERangeType)rangeType32; |
|
719 |
|
720 TMdCValueUnion minValue; |
|
721 aSerializedCondition.ReceiveL( minValue ); |
|
722 TMdCValueUnion maxValue; |
|
723 aSerializedCondition.ReceiveL( maxValue ); |
|
724 |
|
725 // init range for next test |
|
726 TMdEInt64Range range( minValue.iInt64, maxValue.iInt64, rangeType ); |
|
727 |
|
728 // test if event's creation time is in the range |
|
729 if( range.InRange( event.iTime.Int64() ) == eventCondition.iNegated ) |
|
730 { |
|
731 return EFalse; |
|
732 } |
|
733 } |
|
734 |
|
735 // check object condition |
|
736 // (only accept OR-logic condition which contains object ID condition(s)) |
|
737 if( eventCondition.iObjectCondition != KNoOffset ) |
|
738 { |
|
739 aSerializedCondition.PositionL( eventCondition.iObjectCondition ); |
|
740 |
|
741 if( MatchObjectIdToObjectIdConditionsL( aSerializedCondition, |
|
742 event.iObjectId ) == eventCondition.iNegated ) |
|
743 { |
|
744 return EFalse; |
|
745 } |
|
746 } |
|
747 |
|
748 // check event condition contains source or participant comparsion |
|
749 if( ( EEventConditionCompareSourceURI == eventCondition.iCompareMethod ) || |
|
750 ( EEventConditionCompareParticipantURI == eventCondition.iCompareMethod ) ) |
|
751 { |
|
752 aSerializedCondition.PositionL( eventCondition.iUriCondition ); |
|
753 |
|
754 TPtrC16 eventConditionUri = aSerializedCondition.ReceivePtr16L(); |
|
755 |
|
756 // source comparsion |
|
757 if( EEventConditionCompareSourceURI == eventCondition.iCompareMethod ) |
|
758 { |
|
759 TPtrC16 eventSource( KNullDesC ); |
|
760 if ( event.iSourceText.iPtr.iCount > 0 ) |
|
761 { |
|
762 aSerializedItem.PositionL( event.iSourceText.iPtr.iOffset ); |
|
763 eventSource.Set( aSerializedItem.ReceivePtr16L() ); |
|
764 } |
|
765 |
|
766 if( ( eventConditionUri.Compare( eventSource ) == 0 ) == eventCondition.iNegated ) |
|
767 { |
|
768 return EFalse; |
|
769 } |
|
770 } |
|
771 // participant comparsion |
|
772 else |
|
773 { |
|
774 TPtrC16 eventParticipant( KNullDesC ); |
|
775 if (event.iParticipantText.iPtr.iCount > 0) |
|
776 { |
|
777 aSerializedItem.PositionL( event.iParticipantText.iPtr.iOffset ); |
|
778 eventParticipant.Set( aSerializedItem.ReceivePtr16L() ); |
|
779 } |
|
780 |
|
781 if( ( eventConditionUri.Compare( eventParticipant ) == 0 ) == eventCondition.iNegated ) |
|
782 { |
|
783 return EFalse; |
|
784 } |
|
785 } |
|
786 } |
|
787 |
|
788 return ETrue; |
|
789 } |
|
790 |
|
791 TBool CMdSNotifyComparator::MatchRelationL(CMdCSerializationBuffer& aSerializedCondition, |
|
792 CMdCSerializationBuffer& aSerializedItem, |
|
793 TItemId aRelationId) |
|
794 { |
|
795 const TMdCRelation& relation = |
|
796 TMdCRelation::GetFromBufferL( aSerializedItem ); |
|
797 |
|
798 // check if event is failed |
|
799 if( aRelationId == 0 ) |
|
800 { |
|
801 return EFalse; |
|
802 } |
|
803 |
|
804 // check if no condition defined |
|
805 if( aSerializedCondition.Size() <= 0 ) |
|
806 { |
|
807 // pass all successful events |
|
808 return ETrue; |
|
809 } |
|
810 |
|
811 const TMdCRelationCondition& relationCondition = |
|
812 TMdCRelationCondition::GetFromBufferL( aSerializedCondition ); |
|
813 |
|
814 // check if relation condition contains relation def ID comparsion |
|
815 if( relationCondition.iRelationDefId != KNoDefId && |
|
816 BoolEqual( relationCondition.iRelationDefId == relation.iDefId, |
|
817 relationCondition.iNegated ) ) |
|
818 { |
|
819 return EFalse; |
|
820 } |
|
821 |
|
822 if ( relationCondition.iRelationId != KNoId && |
|
823 BoolEqual( relationCondition.iRelationId == aRelationId, |
|
824 relationCondition.iNegated ) ) |
|
825 { |
|
826 return EFalse; |
|
827 } |
|
828 |
|
829 if ( relationCondition.iRelationIds.iPtr.iOffset != KNoOffset && |
|
830 BoolEqual( MatchRelationIdsL( relationCondition, |
|
831 aSerializedCondition, aRelationId ), |
|
832 relationCondition.iNegated ) ) |
|
833 { |
|
834 return EFalse; |
|
835 } |
|
836 |
|
837 if( relationCondition.iGuid != KNoOffset ) |
|
838 { |
|
839 TInt64 conditionGuidHigh; |
|
840 aSerializedCondition.ReceiveL( conditionGuidHigh ); |
|
841 TInt64 conditionGuidLow; |
|
842 aSerializedCondition.ReceiveL( conditionGuidLow ); |
|
843 |
|
844 if ( conditionGuidHigh != 0 && conditionGuidLow != 0 && |
|
845 ( BoolEqual( conditionGuidHigh == relation.iGuidHigh, |
|
846 relationCondition.iNegated ) || |
|
847 BoolEqual( conditionGuidHigh == relation.iGuidLow, |
|
848 relationCondition.iNegated ) ) ) |
|
849 { |
|
850 return EFalse; |
|
851 } |
|
852 } |
|
853 |
|
854 // check relation condition contains relation parameter range comparision |
|
855 if( relation.iParameter != KNoOffset ) |
|
856 { |
|
857 aSerializedCondition.PositionL( relation.iParameter ); |
|
858 |
|
859 TInt32 rangeType32; |
|
860 aSerializedCondition.ReceiveL( rangeType32 ); |
|
861 const TMdERangeType rangeType = (TMdERangeType)rangeType32; |
|
862 |
|
863 TMdCValueUnion minValue; |
|
864 aSerializedCondition.ReceiveL( minValue ); |
|
865 TMdCValueUnion maxValue; |
|
866 aSerializedCondition.ReceiveL( maxValue ); |
|
867 |
|
868 // init range for next test |
|
869 TMdEIntRange range( minValue.iInt32, maxValue.iInt32, rangeType ); |
|
870 |
|
871 // test if event's creation time is in the range |
|
872 if( BoolEqual( range.InRange( relation.iParameter ), |
|
873 relationCondition.iNegated ) ) |
|
874 { |
|
875 return EFalse; |
|
876 } |
|
877 } |
|
878 |
|
879 if( relationCondition.iLeftObjectCondition != KNoOffset && |
|
880 ERelationConditionSideLeft == relationCondition.iObjectSide ) |
|
881 { |
|
882 aSerializedCondition.PositionL( relationCondition.iLeftObjectCondition ); |
|
883 |
|
884 if( BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
885 aSerializedCondition, relation.iLeftObjectId ), |
|
886 relationCondition.iNegated ) ) |
|
887 { |
|
888 return EFalse; |
|
889 } |
|
890 } |
|
891 |
|
892 if( relationCondition.iRightObjectCondition != KNoOffset && |
|
893 ERelationConditionSideRight == relationCondition.iObjectSide ) |
|
894 { |
|
895 aSerializedCondition.PositionL( |
|
896 relationCondition.iRightObjectCondition ); |
|
897 |
|
898 if( BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
899 aSerializedCondition, relation.iRightObjectId ), |
|
900 relationCondition.iNegated ) ) |
|
901 { |
|
902 return EFalse; |
|
903 } |
|
904 } |
|
905 |
|
906 if ( ( relationCondition.iLeftObjectCondition != KNoOffset || |
|
907 relationCondition.iRightObjectCondition != KNoOffset ) && |
|
908 ERelationConditionSideEither == relationCondition.iObjectSide ) |
|
909 { |
|
910 TBool eitherMatches = EFalse; |
|
911 |
|
912 if ( relationCondition.iLeftObjectCondition != KNoOffset ) |
|
913 { |
|
914 aSerializedCondition.PositionL( |
|
915 relationCondition.iLeftObjectCondition ); |
|
916 |
|
917 if( !BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
918 aSerializedCondition, relation.iLeftObjectId ), |
|
919 relationCondition.iNegated ) ) |
|
920 { |
|
921 eitherMatches = ETrue; |
|
922 } |
|
923 } |
|
924 |
|
925 if ( relationCondition.iRightObjectCondition != KNoOffset ) |
|
926 { |
|
927 aSerializedCondition.PositionL( |
|
928 relationCondition.iRightObjectCondition ); |
|
929 |
|
930 if( !BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
931 aSerializedCondition, relation.iRightObjectId ), |
|
932 relationCondition.iNegated ) ) |
|
933 { |
|
934 eitherMatches = ETrue; |
|
935 } |
|
936 } |
|
937 |
|
938 // left and right condition didn't match |
|
939 if( !eitherMatches ) |
|
940 { |
|
941 return EFalse; |
|
942 } |
|
943 } |
|
944 |
|
945 if ( relationCondition.iLastModifiedDateRange != KNoOffset ) |
|
946 { |
|
947 aSerializedCondition.PositionL( |
|
948 relationCondition.iLastModifiedDateRange ); |
|
949 |
|
950 TInt32 rangeRule; |
|
951 aSerializedCondition.ReceiveL( rangeRule ); |
|
952 const TMdERangeType rangeType = (TMdERangeType)rangeRule; |
|
953 |
|
954 TMdCValueUnion minValue; |
|
955 aSerializedCondition.ReceiveL( minValue ); |
|
956 TMdCValueUnion maxValue; |
|
957 aSerializedCondition.ReceiveL( maxValue ); |
|
958 |
|
959 // init range for next test |
|
960 TMdEInt64Range range( minValue.iInt64, maxValue.iInt64, rangeType ); |
|
961 |
|
962 // test if event's creation time is in the range |
|
963 if( BoolEqual( range.InRange( relation.iLastModifiedDate.Int64() ), |
|
964 relationCondition.iNegated ) ) |
|
965 { |
|
966 return EFalse; |
|
967 } |
|
968 } |
|
969 |
|
970 return ETrue; |
|
971 } |
|
972 |
|
973 TBool CMdSNotifyComparator::MatchObjectIdsL( |
|
974 CMdCSerializationBuffer& aSerializedCondition, |
|
975 const RArray<TItemId>& aItemIdArray, |
|
976 RArray<TItemId>& aMatchingItemIdArray |
|
977 ) |
|
978 { |
|
979 // check if condition buffer contains condition |
|
980 if( aSerializedCondition.Size() > 0 ) |
|
981 { |
|
982 aSerializedCondition.PositionL( KNoOffset ); |
|
983 |
|
984 const TMdCLogicCondition& logicCondition = |
|
985 TMdCLogicCondition::GetFromBufferL( aSerializedCondition ); |
|
986 |
|
987 for( TUint32 i = 0; i < logicCondition.iChildConditions.iPtr.iCount; i++ ) |
|
988 { |
|
989 aSerializedCondition.PositionL( |
|
990 logicCondition.iChildConditions.iPtr.iOffset + |
|
991 i * CMdCSerializationBuffer::KRequiredSizeForTUint32 ); |
|
992 |
|
993 TUint32 childOffset; |
|
994 aSerializedCondition.ReceiveL( childOffset ); |
|
995 aSerializedCondition.PositionL( childOffset ); |
|
996 |
|
997 const TMdCCondition& condition = TMdCCondition::GetFromBufferL( |
|
998 aSerializedCondition ); |
|
999 |
|
1000 if( EConditionTypeObject == condition.iConditionType ) |
|
1001 { |
|
1002 const TMdCObjectCondition& objectCondition = |
|
1003 TMdCObjectCondition::GetFromBufferL( aSerializedCondition ); |
|
1004 |
|
1005 if ( EObjectConditionCompareNone == objectCondition.iCompareMethod ) |
|
1006 { |
|
1007 // all matches |
|
1008 return ETrue; |
|
1009 } |
|
1010 |
|
1011 // only ID conditions are checked |
|
1012 if( EObjectConditionCompareId == objectCondition.iCompareMethod ) |
|
1013 { |
|
1014 aSerializedCondition.PositionL( objectCondition.iCondition ); |
|
1015 |
|
1016 // get object condition's object ID |
|
1017 TItemId conditionObjectId; |
|
1018 aSerializedCondition.ReceiveL( conditionObjectId ); |
|
1019 |
|
1020 const TInt objectIdCount = aItemIdArray.Count(); |
|
1021 for( TInt i = 0; i < objectIdCount; i++ ) |
|
1022 { |
|
1023 const TItemId objectId = aItemIdArray[i]; |
|
1024 |
|
1025 if( ( objectId == conditionObjectId ) != objectCondition.iNegated ) |
|
1026 { |
|
1027 aMatchingItemIdArray.AppendL( objectId ); |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 if( aMatchingItemIdArray.Count() < aItemIdArray.Count() ) |
|
1032 { |
|
1033 // none or some matches |
|
1034 return EFalse; |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 // all matches |
|
1039 return ETrue; |
|
1040 } |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 // if condition is something else than ID, return true so that client receives |
|
1045 // needed notification even though also extra notifications will be received |
|
1046 return ETrue; |
|
1047 } |
|
1048 } |
|
1049 } |
|
1050 } |
|
1051 return ETrue; |
|
1052 } |
|
1053 |
|
1054 TBool CMdSNotifyComparator::FindDes( TDesC16& aDes, TDesC16& aFindDes ) |
|
1055 { |
|
1056 if( aDes.Find( aFindDes ) != KErrNotFound ) |
|
1057 { |
|
1058 return ETrue; |
|
1059 } |
|
1060 return EFalse; |
|
1061 } |
|
1062 |
|
1063 TBool CMdSNotifyComparator::CompareDesEndsWith( TDesC16& aDes, TDesC16& aCompareDes ) |
|
1064 { |
|
1065 if( aDes.Length() < aCompareDes.Length() ) |
|
1066 { |
|
1067 return EFalse; |
|
1068 } |
|
1069 |
|
1070 return ( aDes.Right( aCompareDes.Length() ).Compare( aCompareDes ) == 0 ); |
|
1071 } |
|
1072 |
|
1073 TBool CMdSNotifyComparator::CompareDesBeginsWith( TDesC16& aDes, TDesC16& aCompareDes ) |
|
1074 { |
|
1075 if( aDes.Length() < aCompareDes.Length() ) |
|
1076 { |
|
1077 return EFalse; |
|
1078 } |
|
1079 |
|
1080 return ( aDes.Left( aCompareDes.Length() ).Compare( aCompareDes ) == 0 ); |
|
1081 } |
|
1082 |
|
1083 TBool CMdSNotifyComparator::MatchObjectIdToObjectIdConditionsL( |
|
1084 CMdCSerializationBuffer& aSerializedCondition, TItemId aObjectId) |
|
1085 { |
|
1086 const TMdCLogicCondition& logicCondition = |
|
1087 TMdCLogicCondition::GetFromBufferL( aSerializedCondition ); |
|
1088 |
|
1089 TBool matchingId = EFalse; |
|
1090 |
|
1091 for( TUint32 i = 0; i < logicCondition.iChildConditions.iPtr.iCount; i++ ) |
|
1092 { |
|
1093 aSerializedCondition.PositionL( |
|
1094 logicCondition.iChildConditions.iPtr.iOffset + |
|
1095 i * CMdCSerializationBuffer::KRequiredSizeForTUint32 ); |
|
1096 |
|
1097 TUint32 childOffset; |
|
1098 aSerializedCondition.ReceiveL( childOffset ); |
|
1099 aSerializedCondition.PositionL( childOffset ); |
|
1100 |
|
1101 const TMdCCondition& condition = TMdCCondition::GetFromBufferL( |
|
1102 aSerializedCondition ); |
|
1103 |
|
1104 if( EConditionTypeObject == condition.iConditionType ) |
|
1105 { |
|
1106 const TMdCObjectCondition& objectCondition = |
|
1107 TMdCObjectCondition::GetFromBufferL( aSerializedCondition ); |
|
1108 |
|
1109 if( EObjectConditionCompareId == objectCondition.iCompareMethod ) |
|
1110 { |
|
1111 aSerializedCondition.PositionL( objectCondition.iCondition ); |
|
1112 |
|
1113 TItemId conditionObjectId; |
|
1114 aSerializedCondition.ReceiveL( conditionObjectId ); |
|
1115 |
|
1116 TBool currentMatch = ( conditionObjectId == aObjectId ) != objectCondition.iNegated; |
|
1117 |
|
1118 if( currentMatch ) |
|
1119 { |
|
1120 matchingId = ETrue; |
|
1121 break; |
|
1122 } |
|
1123 } |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 return matchingId != logicCondition.iNegated; |
|
1128 } |
|
1129 |
|
1130 TBool CMdSNotifyComparator::MatchRelationIdsL( |
|
1131 const TMdCRelationCondition& aRelationCondition, |
|
1132 CMdCSerializationBuffer& aSerializedCondition, TItemId aRelationId) |
|
1133 { |
|
1134 if( aRelationCondition.iRelationIds.iPtr.iCount > 0 && |
|
1135 aRelationCondition.iRelationIds.iPtr.iOffset != KNoOffset ) |
|
1136 { |
|
1137 aSerializedCondition.PositionL( aRelationCondition.iRelationIds.iPtr.iOffset ); |
|
1138 |
|
1139 for (TInt i = 0; i < aRelationCondition.iRelationIds.iPtr.iCount; ++i) |
|
1140 { |
|
1141 TItemId relationId; |
|
1142 aSerializedCondition.ReceiveL( relationId ); |
|
1143 if ( relationId == aRelationId ) |
|
1144 { |
|
1145 return ETrue; |
|
1146 } |
|
1147 } |
|
1148 } |
|
1149 |
|
1150 return EFalse; |
|
1151 } |
|
1152 |
|
1153 TBool CMdSNotifyComparator::MatchRelationItemsL( |
|
1154 CMdCSerializationBuffer& aSerializedCondition, |
|
1155 CMdCSerializationBuffer& aSerializedItems, |
|
1156 RArray<TItemId>& aMatchingItemIdArray) |
|
1157 { |
|
1158 aSerializedItems.PositionL( KNoOffset ); |
|
1159 |
|
1160 const TMdCItems& items = TMdCItems::GetFromBufferL( aSerializedItems ); |
|
1161 |
|
1162 if( items.iRelations.iPtr.iCount == 0 ) |
|
1163 { |
|
1164 return EFalse; |
|
1165 } |
|
1166 |
|
1167 for( TUint32 i = 0; i < items.iRelations.iPtr.iCount; i++ ) |
|
1168 { |
|
1169 aSerializedItems.PositionL( items.iRelations.iPtr.iOffset + |
|
1170 + i * sizeof(TMdCRelation) ); |
|
1171 const TMdCRelation& relation = TMdCRelation::GetFromBufferL( aSerializedItems ); |
|
1172 |
|
1173 if( aSerializedCondition.Size() > 0 ) |
|
1174 { |
|
1175 // move condition buffer's position to the begin of the buffer |
|
1176 aSerializedCondition.PositionL( KNoOffset ); |
|
1177 |
|
1178 if( MatchRelationItemL( aSerializedCondition, relation ) ) |
|
1179 { |
|
1180 aMatchingItemIdArray.AppendL( relation.iId ); |
|
1181 } |
|
1182 } |
|
1183 else |
|
1184 { |
|
1185 aMatchingItemIdArray.AppendL( relation.iId ); |
|
1186 } |
|
1187 } |
|
1188 |
|
1189 if( aMatchingItemIdArray.Count() > 0 ) |
|
1190 { |
|
1191 return ETrue; |
|
1192 } |
|
1193 else |
|
1194 { |
|
1195 return EFalse; |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 TBool CMdSNotifyComparator::MatchRelationItemL(CMdCSerializationBuffer& aSerializedCondition, |
|
1200 const TMdCRelation& aRelation) |
|
1201 { |
|
1202 // check if event is failed |
|
1203 if( aRelation.iId == 0 ) |
|
1204 { |
|
1205 return EFalse; |
|
1206 } |
|
1207 |
|
1208 const TMdCRelationCondition& relationCondition = |
|
1209 TMdCRelationCondition::GetFromBufferL( aSerializedCondition ); |
|
1210 |
|
1211 // check if relation condition contains relation def ID comparsion |
|
1212 if( relationCondition.iRelationDefId != KNoDefId && |
|
1213 BoolEqual( relationCondition.iRelationDefId == aRelation.iDefId, |
|
1214 relationCondition.iNegated ) ) |
|
1215 { |
|
1216 return EFalse; |
|
1217 } |
|
1218 |
|
1219 // check if relation condition contains relation ID comparsion |
|
1220 if ( relationCondition.iRelationId != KNoId && |
|
1221 BoolEqual( relationCondition.iRelationId == aRelation.iId, |
|
1222 relationCondition.iNegated ) ) |
|
1223 { |
|
1224 return EFalse; |
|
1225 } |
|
1226 |
|
1227 // check if relation condition contains relation IDs comparsion |
|
1228 if ( relationCondition.iRelationIds.iPtr.iOffset != KNoOffset && |
|
1229 BoolEqual( MatchRelationIdsL( relationCondition, |
|
1230 aSerializedCondition, aRelation.iId ), |
|
1231 relationCondition.iNegated ) ) |
|
1232 { |
|
1233 return EFalse; |
|
1234 } |
|
1235 |
|
1236 // check relation condition contains left and/or right object condition comparisions |
|
1237 if ( ( relationCondition.iLeftObjectCondition != KNoOffset || |
|
1238 relationCondition.iRightObjectCondition != KNoOffset ) && |
|
1239 ERelationConditionSideEither == relationCondition.iObjectSide ) |
|
1240 { |
|
1241 TBool eitherMatches = EFalse; |
|
1242 |
|
1243 if ( relationCondition.iLeftObjectCondition != KNoOffset ) |
|
1244 { |
|
1245 aSerializedCondition.PositionL( |
|
1246 relationCondition.iLeftObjectCondition ); |
|
1247 |
|
1248 if( !BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
1249 aSerializedCondition, aRelation.iLeftObjectId ), |
|
1250 relationCondition.iNegated ) ) |
|
1251 { |
|
1252 eitherMatches = ETrue; |
|
1253 } |
|
1254 } |
|
1255 |
|
1256 if ( relationCondition.iRightObjectCondition != KNoOffset ) |
|
1257 { |
|
1258 aSerializedCondition.PositionL( |
|
1259 relationCondition.iRightObjectCondition ); |
|
1260 |
|
1261 if( !BoolEqual( MatchObjectIdToObjectIdConditionsL( |
|
1262 aSerializedCondition, aRelation.iRightObjectId ), |
|
1263 relationCondition.iNegated ) ) |
|
1264 { |
|
1265 eitherMatches = ETrue; |
|
1266 } |
|
1267 } |
|
1268 |
|
1269 // left and right condition didn't match |
|
1270 if( !eitherMatches ) |
|
1271 { |
|
1272 return EFalse; |
|
1273 } |
|
1274 } |
|
1275 |
|
1276 return ETrue; |
|
1277 } |