phonebookui/Phonebook2/ServerApplication/src/CPbk2ServerAppStoreManager.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 5 81f8547efd4f
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    40 #include <MVPbkContactViewBase.h>
    40 #include <MVPbkContactViewBase.h>
    41 #include <MVPbkContactLink.h>
    41 #include <MVPbkContactLink.h>
    42 #include <MVPbkContactLinkArray.h>
    42 #include <MVPbkContactLinkArray.h>
    43 #include <CVPbkSortOrderAcquirer.h>
    43 #include <CVPbkSortOrderAcquirer.h>
    44 #include <VPbkSortOrderAcquirerUid.h>
    44 #include <VPbkSortOrderAcquirerUid.h>
       
    45 #include <MVPbkBaseContact.h>
       
    46 #include <MVPbkContactSelector.h>
    45 
    47 
    46 // Debugging headers
    48 // Debugging headers
    47 #include <Pbk2Debug.h>
    49 #include <Pbk2Debug.h>
       
    50 
       
    51 #include <featmgr.h>
       
    52 
    48 
    53 
    49 /// Unnamed namespace for local definitions
    54 /// Unnamed namespace for local definitions
    50 namespace {
    55 namespace {
    51 
    56 
    52 _LIT( KGroupSortOrderDisplayName, "AllGroups" );
    57 _LIT( KGroupSortOrderDisplayName, "AllGroups" );
    63         static_cast<RImplInfoPtrArray*>( aObj )->ResetAndDestroy();
    68         static_cast<RImplInfoPtrArray*>( aObj )->ResetAndDestroy();
    64         }
    69         }
    65     }
    70     }
    66 
    71 
    67 } /// namespace
    72 } /// namespace
       
    73 
       
    74 /**
       
    75  * Helper class to filter mycard from phonebooks views
       
    76  */
       
    77 class CPbk2MyCardFilter : public CBase, 
       
    78                           public MVPbkContactSelector
       
    79     {
       
    80 public:
       
    81     CPbk2MyCardFilter();
       
    82     ~CPbk2MyCardFilter();
       
    83 protected:  // From MVPbkContactSelector
       
    84     TBool IsContactIncluded(
       
    85                 const MVPbkBaseContact& aContact );
       
    86     };
       
    87 
       
    88 CPbk2MyCardFilter::CPbk2MyCardFilter()
       
    89     {
       
    90     }
       
    91 
       
    92 CPbk2MyCardFilter::~CPbk2MyCardFilter()
       
    93     {
       
    94     }
       
    95 
       
    96 TBool CPbk2MyCardFilter::IsContactIncluded(
       
    97                 const MVPbkBaseContact& aContact )
       
    98     {
       
    99     TBool isContactIncluded( ETrue );
       
   100     // this is temporary solution to hide own contact from phonebook contacts list,
       
   101     // TODO remove this code when we can hide own contact with contact model
       
   102 
       
   103     MVPbkBaseContact& contact = const_cast<MVPbkBaseContact&>( aContact );
       
   104     TAny* extension = contact.BaseContactExtension( 
       
   105                 KVPbkBaseContactExtension2Uid );
       
   106 
       
   107     if( extension )
       
   108         {
       
   109         MVPbkBaseContact2* baseContactExtension =
       
   110                 static_cast<MVPbkBaseContact2*>( extension );
       
   111         TInt error( KErrNone );
       
   112         isContactIncluded =
       
   113                 ( !baseContactExtension->IsOwnContact( error ) );
       
   114         }
       
   115     
       
   116     return isContactIncluded;
       
   117     }
    68 
   118 
    69 // --------------------------------------------------------------------------
   119 // --------------------------------------------------------------------------
    70 // CPbk2ServerAppStoreManager::CPbk2ServerAppStoreManager
   120 // CPbk2ServerAppStoreManager::CPbk2ServerAppStoreManager
    71 // --------------------------------------------------------------------------
   121 // --------------------------------------------------------------------------
    72 //
   122 //
   167     MVPbkContactViewBase* result = NULL;
   217     MVPbkContactViewBase* result = NULL;
   168      
   218      
   169     CPbk2ContactViewBuilder* viewBuilder = CPbk2ContactViewBuilder::NewLC
   219     CPbk2ContactViewBuilder* viewBuilder = CPbk2ContactViewBuilder::NewLC
   170         ( iContactManager, aStoreProperties );
   220         ( iContactManager, aStoreProperties );
   171 
   221 
       
   222     if( !iMyCardFilter )
       
   223         {
       
   224         FeatureManager::InitializeLibL();
       
   225         if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) )
       
   226             {
       
   227             iMyCardFilter = new (ELeave) CPbk2MyCardFilter();
       
   228             }
       
   229         FeatureManager::UnInitializeLib();    
       
   230         }
       
   231 
       
   232     
   172     if ( aViewType == EVPbkContactsView )
   233     if ( aViewType == EVPbkContactsView )
   173         {
   234         {
   174         result = viewBuilder->CreateContactViewForStoresLC
   235         result = viewBuilder->CreateContactViewForStoresLC
   175             ( aStoreUris, *this, aSortOrderManager.SortOrder(),
   236             ( aStoreUris, *this, aSortOrderManager.SortOrder(),
   176               aViewFilter, aFlags );
   237               aViewFilter, aFlags, iMyCardFilter );
   177         CleanupStack::Pop(); // result
   238         CleanupStack::Pop(); // result
   178         }
   239         }
   179     else if ( aViewType == EVPbkGroupsView )
   240     else if ( aViewType == EVPbkGroupsView )
   180         {
   241         {
   181         const MVPbkFieldTypeList* sortOrder = NULL;
   242         const MVPbkFieldTypeList* sortOrder = NULL;
   209                 found = ETrue;
   270                 found = ETrue;
   210                 }
   271                 }
   211 
   272 
   212             }
   273             }
   213         CleanupStack::PopAndDestroy(); // implementations
   274         CleanupStack::PopAndDestroy(); // implementations
   214         
   275                 
   215         result = viewBuilder->CreateGroupViewForStoresLC
   276         result = viewBuilder->CreateGroupViewForStoresLC
   216             ( aStoreUris, *this, *sortOrder,
   277             ( aStoreUris, *this, *sortOrder,
   217               aViewFilter, aFlags );
   278               aViewFilter, aFlags );
       
   279         
   218         CleanupStack::Pop(); // result
   280         CleanupStack::Pop(); // result
   219         }
   281         }
   220 
   282 
   221     CleanupStack::PopAndDestroy(); // viewBuilder
   283     CleanupStack::PopAndDestroy(); // viewBuilder
   222 
   284