phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppStoreManager.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 5 81f8547efd4f
--- 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 <MVPbkContactLinkArray.h>
 #include <CVPbkSortOrderAcquirer.h>
 #include <VPbkSortOrderAcquirerUid.h>
+#include <MVPbkBaseContact.h>
+#include <MVPbkContactSelector.h>
 
 // Debugging headers
 #include <Pbk2Debug.h>
 
+#include <featmgr.h>
+
+
 /// 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<MVPbkBaseContact&>( aContact );
+    TAny* extension = contact.BaseContactExtension( 
+                KVPbkBaseContactExtension2Uid );
+
+    if( extension )
+        {
+        MVPbkBaseContact2* baseContactExtension =
+                static_cast<MVPbkBaseContact2*>( 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
         }