diff -r e686773b3f54 -r 04ab22b956c2 phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppStoreManager.cpp --- a/phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppStoreManager.cpp Tue Feb 02 10:12:17 2010 +0200 +++ b/phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppStoreManager.cpp Fri Feb 19 22:40:27 2010 +0200 @@ -42,10 +42,15 @@ #include #include #include +#include +#include // Debugging headers #include +#include + + /// Unnamed namespace for local definitions namespace { @@ -66,6 +71,51 @@ } /// namespace +/** + * Helper class to filter mycard from phonebooks views + */ +class CPbk2MyCardFilter : public CBase, + public MVPbkContactSelector + { +public: + CPbk2MyCardFilter(); + ~CPbk2MyCardFilter(); +protected: // From MVPbkContactSelector + TBool IsContactIncluded( + const MVPbkBaseContact& aContact ); + }; + +CPbk2MyCardFilter::CPbk2MyCardFilter() + { + } + +CPbk2MyCardFilter::~CPbk2MyCardFilter() + { + } + +TBool CPbk2MyCardFilter::IsContactIncluded( + const MVPbkBaseContact& aContact ) + { + TBool isContactIncluded( ETrue ); + // this is temporary solution to hide own contact from phonebook contacts list, + // TODO remove this code when we can hide own contact with contact model + + MVPbkBaseContact& contact = const_cast( aContact ); + TAny* extension = contact.BaseContactExtension( + KVPbkBaseContactExtension2Uid ); + + if( extension ) + { + MVPbkBaseContact2* baseContactExtension = + static_cast( extension ); + TInt error( KErrNone ); + isContactIncluded = + ( !baseContactExtension->IsOwnContact( error ) ); + } + + return isContactIncluded; + } + // -------------------------------------------------------------------------- // CPbk2ServerAppStoreManager::CPbk2ServerAppStoreManager // -------------------------------------------------------------------------- @@ -169,11 +219,22 @@ CPbk2ContactViewBuilder* viewBuilder = CPbk2ContactViewBuilder::NewLC ( iContactManager, aStoreProperties ); + if( !iMyCardFilter ) + { + FeatureManager::InitializeLibL(); + if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) ) + { + iMyCardFilter = new (ELeave) CPbk2MyCardFilter(); + } + FeatureManager::UnInitializeLib(); + } + + if ( aViewType == EVPbkContactsView ) { result = viewBuilder->CreateContactViewForStoresLC ( aStoreUris, *this, aSortOrderManager.SortOrder(), - aViewFilter, aFlags ); + aViewFilter, aFlags, iMyCardFilter ); CleanupStack::Pop(); // result } else if ( aViewType == EVPbkGroupsView ) @@ -211,10 +272,11 @@ } CleanupStack::PopAndDestroy(); // implementations - + result = viewBuilder->CreateGroupViewForStoresLC ( aStoreUris, *this, *sortOrder, aViewFilter, aFlags ); + CleanupStack::Pop(); // result }