85 { R_CNTMODEL_NATIVE_FILTER_RINGING_TONE, |
85 { R_CNTMODEL_NATIVE_FILTER_RINGING_TONE, |
86 CContactDatabase::ERingTone }, |
86 CContactDatabase::ERingTone }, |
87 |
87 |
88 { R_CNTMODEL_NATIVE_FILTER_ASSISTANT_PHONE_NUMBER, |
88 { R_CNTMODEL_NATIVE_FILTER_ASSISTANT_PHONE_NUMBER, |
89 CContactDatabase::EPhonable }, |
89 CContactDatabase::EPhonable }, |
90 |
90 |
91 { R_CNTMODEL_NATIVE_FILTER_TOP_CONTACT, |
91 { R_CNTMODEL_NATIVE_FILTER_TOP_CONTACT, |
92 CContactDatabase::ECustomFilter2 }, |
92 CContactDatabase::ECustomFilter2 }, |
93 |
93 |
94 /// This has to be the last |
94 /// This has to be the last |
95 { KLastElement, |
95 { KLastElement, |
96 CContactDatabase::EUnfiltered } |
96 CContactDatabase::EUnfiltered } |
97 }; |
97 }; |
98 |
98 |
145 for ( TInt matchPriority = 0; |
145 for ( TInt matchPriority = 0; |
146 matchPriority <= maxMatchPriority; ++matchPriority ) |
146 matchPriority <= maxMatchPriority; ++matchPriority ) |
147 { |
147 { |
148 TBool versitIsMatched = matchingProperty->Matches( |
148 TBool versitIsMatched = matchingProperty->Matches( |
149 aFilterType->VersitProperties()[matchPriority]); |
149 aFilterType->VersitProperties()[matchPriority]); |
150 TBool excludedParmaterIsMatched = |
150 TBool excludedParmaterIsMatched = |
151 aFilterType->ExcludedParameters(). |
151 aFilterType->ExcludedParameters(). |
152 ContainsAll(aFieldType.ExcludedParameters()); |
152 ContainsAll(aFieldType.ExcludedParameters()); |
153 // if the FilterType is matched the Versit Property and |
153 // if the FilterType is matched the Versit Property and |
154 // the excludeParameter of FiledType, it needn't custom filter. |
154 // the excludeParameter of FiledType, it needn't custom filter. |
155 if ( versitIsMatched && excludedParmaterIsMatched ) |
155 if ( versitIsMatched && excludedParmaterIsMatched ) |
156 { |
156 { |
157 ret = EFalse; |
157 ret = EFalse; |
158 break; |
158 break; |
312 iView = NULL; |
312 iView = NULL; |
313 |
313 |
314 if ( iFilteredView ) |
314 if ( iFilteredView ) |
315 { |
315 { |
316 //after iFilteredView->Close( *iNativeObserver ) |
316 //after iFilteredView->Close( *iNativeObserver ) |
317 //both iFilteredView and iBaseView are deleted |
317 //both iFilteredView and iBaseView are deleted |
318 iFilteredView->Close( *iNativeObserver ); |
318 iFilteredView->Close( *iNativeObserver ); |
319 } |
319 } |
320 else if ( iBaseView ) |
320 else if ( iBaseView ) |
321 { |
321 { |
322 //but iBaseView's pointer is still not NULL |
322 //but iBaseView's pointer is still not NULL |
323 //make sure iBaseView is unable to call its member function |
323 //make sure iBaseView is unable to call its member function |
324 iBaseView->Close( *iNativeObserver ); |
324 iBaseView->Close( *iNativeObserver ); |
325 } |
325 } |
326 } |
326 } |
327 |
327 |
328 // -------------------------------------------------------------------------- |
328 // -------------------------------------------------------------------------- |
376 if ( aViewDefinition.FieldTypeFilter() ) |
376 if ( aViewDefinition.FieldTypeFilter() ) |
377 { |
377 { |
378 const CFieldFactory& fieldFactory = Store().FieldFactory(); |
378 const CFieldFactory& fieldFactory = Store().FieldFactory(); |
379 |
379 |
380 // Copy construct the filter |
380 // Copy construct the filter |
381 iFilter = CVPbkFieldTypeSelector::NewL( |
381 iFilter = CVPbkFieldTypeSelector::NewL( |
382 *aViewDefinition.FieldTypeFilter() ); |
382 *aViewDefinition.FieldTypeFilter() ); |
383 |
383 |
384 iNativeFilter = ConvertFieldTypeFilterL |
384 iNativeFilter = ConvertFieldTypeFilterL |
385 ( *iFilter, fieldFactory, iFs, iCustomFilteringNeeded ); |
385 ( *iFilter, fieldFactory, iFs, iCustomFilteringNeeded ); |
386 } |
386 } |
392 } |
392 } |
393 if ( iCustomFilteringNeeded ) |
393 if ( iCustomFilteringNeeded ) |
394 { |
394 { |
395 // Stop observing the base view, the custom view |
395 // Stop observing the base view, the custom view |
396 // will observe it and report back |
396 // will observe it and report back |
397 // Construction of the iCustomFilteredView should be done in two |
397 // Construction of the iCustomFilteredView should be done in two |
398 // phases. Due to that there is dependencies between views in this |
398 // phases. Due to that there is dependencies between views in this |
399 // and iCustomFilteredView class. |
399 // and iCustomFilteredView class. |
400 iCustomFilteredView = |
400 iCustomFilteredView = |
401 new (ELeave) CCustomFilteredContactView( Store(), iFilter, |
401 new (ELeave) CCustomFilteredContactView( Store(), iFilter, |
402 *this, aViewDefinition.ContactSelector() ); |
402 *this, aViewDefinition.ContactSelector() ); |
403 ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView, |
403 ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView, |
404 aViewSortOrder ); |
404 aViewSortOrder ); |
405 |
405 |
406 if ( iFilteredView ) |
406 if ( iFilteredView ) |
407 { |
407 { |
408 iBaseView->Close( *iCustomFilteredView ); |
408 iBaseView->Close( *iCustomFilteredView ); |
409 } |
409 } |
410 |
410 |
411 iCustomFilteredView->ConstructL |
411 iCustomFilteredView->ConstructL |
412 ( aViewDefinition, *this, *iSortOrder, *iView ); |
412 ( aViewDefinition, *this, *iSortOrder, *iView ); |
413 |
413 |
414 iView = &iCustomFilteredView->ContactViewBase(); |
414 iView = &iCustomFilteredView->ContactViewBase(); |
415 } |
415 } |
438 |
438 |
439 // -------------------------------------------------------------------------- |
439 // -------------------------------------------------------------------------- |
440 // CFilteredContactView::DoChangeSortOrderL |
440 // CFilteredContactView::DoChangeSortOrderL |
441 // -------------------------------------------------------------------------- |
441 // -------------------------------------------------------------------------- |
442 // |
442 // |
443 TBool CFilteredContactView::DoChangeSortOrderL( |
443 TBool CFilteredContactView::DoChangeSortOrderL( |
444 const CVPbkContactViewDefinition& aViewDefinition, |
444 const CVPbkContactViewDefinition& aViewDefinition, |
445 RContactViewSortOrder& aSortOrder ) |
445 RContactViewSortOrder& aSortOrder ) |
446 { |
446 { |
447 TBool canBeChanged = ETrue; |
447 TBool canBeChanged = ETrue; |
448 if ( iRemoteView ) |
448 if ( iRemoteView ) |
449 { |
449 { |
450 if ( RemoteViewName( aViewDefinition ).Compare( |
450 if ( RemoteViewName( aViewDefinition ).Compare( |
451 KVPbkAllContactsViewName ) == 0 ) |
451 KVPbkAllContactsViewName ) == 0 ) |
452 { |
452 { |
453 // Set Contacts Model default view setting only if client |
453 // Set Contacts Model default view setting only if client |
454 // is using KVPbkAllContactsViewName shared view. |
454 // is using KVPbkAllContactsViewName shared view. |
455 NamedRemoteViewViewDefinitionStoreUtility:: |
455 NamedRemoteViewViewDefinitionStoreUtility:: |
456 SetNamedRemoteViewViewDefinitionL( |
456 SetNamedRemoteViewViewDefinitionL( |
457 KVPbkAllContactsViewName, aSortOrder, |
457 KVPbkAllContactsViewName, aSortOrder, |
458 KVPbkDefaultContactViewPrefs); |
458 KVPbkDefaultContactViewPrefs); |
459 } |
459 } |
460 iRemoteView->ChangeSortOrderL( aSortOrder ); |
460 iRemoteView->ChangeSortOrderL( aSortOrder ); |
461 } |
461 } |
462 else |
462 else |
463 { |
463 { |
464 // CContactLocalView doesn't support ChangeSortOrderL |
464 // CContactLocalView doesn't support ChangeSortOrderL |
465 canBeChanged = EFalse; |
465 canBeChanged = EFalse; |
466 } |
466 } |
467 |
467 |
468 return canBeChanged; |
468 return canBeChanged; |
469 } |
469 } |
470 |
470 |
471 // -------------------------------------------------------------------------- |
471 // -------------------------------------------------------------------------- |
472 // CFilteredContactView::ContactViewReady |
472 // CFilteredContactView::ContactViewReady |
475 void CFilteredContactView::ContactViewReady( |
475 void CFilteredContactView::ContactViewReady( |
476 MVPbkContactViewBase& aView ) |
476 MVPbkContactViewBase& aView ) |
477 { |
477 { |
478 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
478 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
479 ("CFilteredContactView::ContactViewReady(0x%x)"), &aView); |
479 ("CFilteredContactView::ContactViewReady(0x%x)"), &aView); |
480 |
480 |
481 /* when custom filtering view is used, MVPbkContactViewObserver doesn't support |
481 /* when custom filtering view is used, MVPbkContactViewObserver doesn't support |
482 * sortOrder changed notification, CViewBase will send viewReady instead, |
482 * sortOrder changed notification, CViewBase will send viewReady instead, |
483 * use it to keep sort order up to date */ |
483 * use it to keep sort order up to date */ |
484 if ( iCustomFilteringNeeded ) |
484 if ( iCustomFilteringNeeded ) |
485 { |
485 { |
527 TInt aIndex, const MVPbkContactLink& aContactLink ) |
527 TInt aIndex, const MVPbkContactLink& aContactLink ) |
528 { |
528 { |
529 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
529 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
530 ("CFilteredContactView::ContactAddedToView(0x%x)"), &aView); |
530 ("CFilteredContactView::ContactAddedToView(0x%x)"), &aView); |
531 |
531 |
532 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
532 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
533 iObservers, |
533 iObservers, |
534 &MVPbkContactViewObserver::ContactAddedToView, |
534 &MVPbkContactViewObserver::ContactAddedToView, |
535 &MVPbkContactViewObserver::ContactViewError ); |
535 &MVPbkContactViewObserver::ContactViewError ); |
536 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
536 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
537 iFilteringObservers, |
537 iFilteringObservers, |
538 &MVPbkContactViewObserver::ContactAddedToView, |
538 &MVPbkContactViewObserver::ContactAddedToView, |
539 &MVPbkContactViewObserver::ContactViewError ); |
539 &MVPbkContactViewObserver::ContactViewError ); |
540 } |
540 } |
541 |
541 |
548 TInt aIndex, const MVPbkContactLink& aContactLink ) |
548 TInt aIndex, const MVPbkContactLink& aContactLink ) |
549 { |
549 { |
550 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
550 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
551 ("CFilteredContactView::ContactRemovedFromView(0x%x)"), &aView); |
551 ("CFilteredContactView::ContactRemovedFromView(0x%x)"), &aView); |
552 |
552 |
553 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
553 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
554 iObservers, |
554 iObservers, |
555 &MVPbkContactViewObserver::ContactRemovedFromView, |
555 &MVPbkContactViewObserver::ContactRemovedFromView, |
556 &MVPbkContactViewObserver::ContactViewError ); |
556 &MVPbkContactViewObserver::ContactViewError ); |
557 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
557 VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
558 iFilteringObservers, |
558 iFilteringObservers, |
559 &MVPbkContactViewObserver::ContactRemovedFromView, |
559 &MVPbkContactViewObserver::ContactRemovedFromView, |
560 &MVPbkContactViewObserver::ContactViewError ); |
560 &MVPbkContactViewObserver::ContactViewError ); |
561 } |
561 } |
562 |
562 |
571 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
571 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
572 ("CFilteredContactView::ContactViewError(0x%x)"), &aView); |
572 ("CFilteredContactView::ContactViewError(0x%x)"), &aView); |
573 |
573 |
574 VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, iObservers, |
574 VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, iObservers, |
575 &MVPbkContactViewObserver::ContactViewError ); |
575 &MVPbkContactViewObserver::ContactViewError ); |
576 VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, |
576 VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, |
577 iFilteringObservers, &MVPbkContactViewObserver::ContactViewError ); |
577 iFilteringObservers, &MVPbkContactViewObserver::ContactViewError ); |
|
578 } |
|
579 |
|
580 // -------------------------------------------------------------------------- |
|
581 // CFilteredContactView::ContactViewObserverExtension |
|
582 // -------------------------------------------------------------------------- |
|
583 // |
|
584 TAny* CFilteredContactView::ContactViewObserverExtension( TUid aExtensionUid ) |
|
585 { |
|
586 if( aExtensionUid == KVPbkContactViewObserverExtension2Uid ) |
|
587 { |
|
588 return static_cast<MVPbkContactViewObserverExtension*>( this ); |
|
589 } |
|
590 return NULL; |
|
591 } |
|
592 |
|
593 // -------------------------------------------------------------------------- |
|
594 // CFilteredContactView::FilteredContactRemovedFromView |
|
595 // -------------------------------------------------------------------------- |
|
596 // |
|
597 void CFilteredContactView::FilteredContactRemovedFromView( |
|
598 MVPbkContactViewBase& aView ) |
|
599 { |
|
600 const TInt count = iObservers.Count(); |
|
601 |
|
602 for( TInt i = 0; i < count; i++ ) |
|
603 { |
|
604 MVPbkContactViewObserver* observer = iObservers[i]; |
|
605 |
|
606 TAny* extension = observer->ContactViewObserverExtension( |
|
607 KVPbkContactViewObserverExtension2Uid ); |
|
608 |
|
609 if( extension ) |
|
610 { |
|
611 MVPbkContactViewObserverExtension* contactViewExtension = |
|
612 static_cast<MVPbkContactViewObserverExtension*>( extension ); |
|
613 |
|
614 if( contactViewExtension ) |
|
615 { |
|
616 contactViewExtension->FilteredContactRemovedFromView( aView ); |
|
617 } |
|
618 } |
|
619 } |
578 } |
620 } |
579 |
621 |
580 // -------------------------------------------------------------------------- |
622 // -------------------------------------------------------------------------- |
581 // CFilteredContactView::ConstructBaseViewsL |
623 // CFilteredContactView::ConstructBaseViewsL |
582 // -------------------------------------------------------------------------- |
624 // -------------------------------------------------------------------------- |
589 iNativeObserver = &aObserver; |
631 iNativeObserver = &aObserver; |
590 |
632 |
591 // Construct the all contacts view first |
633 // Construct the all contacts view first |
592 if ( RemoteViewDefinition( aViewDefinition ) ) |
634 if ( RemoteViewDefinition( aViewDefinition ) ) |
593 { |
635 { |
594 iRemoteView = CContactNamedRemoteView::NewL( |
636 iRemoteView = CContactNamedRemoteView::NewL( |
595 *iNativeObserver, RemoteViewName( aViewDefinition ), |
637 *iNativeObserver, RemoteViewName( aViewDefinition ), |
596 Store().NativeDatabase(), aViewSortOrder, |
638 Store().NativeDatabase(), aViewSortOrder, |
597 KVPbkDefaultContactViewPrefs ); |
639 KVPbkDefaultContactViewPrefs ); |
598 |
640 |
599 iBaseView = iRemoteView; |
641 iBaseView = iRemoteView; |
600 } |
642 } |
601 else |
643 else |
602 { |
644 { |
603 iBaseView = CContactLocalView::NewL( *iNativeObserver, |
645 iBaseView = CContactLocalView::NewL( *iNativeObserver, |
604 Store().NativeDatabase(), aViewSortOrder, |
646 Store().NativeDatabase(), aViewSortOrder, |
605 KVPbkDefaultContactViewPrefs ); |
647 KVPbkDefaultContactViewPrefs ); |
606 } |
648 } |
607 |
649 |
608 // Set base class view pointer |
650 // Set base class view pointer |
609 iView = iBaseView; |
651 iView = iBaseView; |
610 |
652 |
611 // If there is a native filter, construct a native filtered view |
653 // If there is a native filter, construct a native filtered view |
612 if ( iNativeFilter > 0 ) |
654 if ( iNativeFilter > 0 ) |
613 { |
655 { |
614 iFilteredView = CContactFilteredView::NewL |
656 iFilteredView = CContactFilteredView::NewL |
615 ( *iNativeObserver, Store().NativeDatabase(), |
657 ( *iNativeObserver, Store().NativeDatabase(), |