phonebookengines/VirtualPhonebook/VPbkSimStore/inc/CFindView.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Sim store contact view implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VPBKSIMSTORE_CFINDVIEW_H
       
    20 #define VPBKSIMSTORE_CFINDVIEW_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "CFindViewBase.h"
       
    24 
       
    25 #include <MVPbkSimViewFindObserver.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CVPbkContactFindPolicy;
       
    29 class MVPbkSimStoreOperation;
       
    30 class RFs;
       
    31 
       
    32 namespace VPbkSimStore {
       
    33 
       
    34 class CContactView;
       
    35 
       
    36 NONSHARABLE_CLASS( CFindView ): public CFindViewBase,
       
    37                                 public MVPbkSimViewFindObserver                 
       
    38     {
       
    39     public: // Constructor and destructor
       
    40 
       
    41         /**
       
    42          * Creates a new instance of this class.
       
    43          *
       
    44          * @param aFindStrings              
       
    45          * @param aAllContactsView
       
    46          * @param aExternalViewObserver
       
    47          * @param aAlwaysIncludedContacts
       
    48          * @param aRFs
       
    49          * @return  A new instance of this class.
       
    50          */
       
    51         static CFindView* NewLC(    
       
    52                 const MDesCArray& aFindStrings,
       
    53                 CContactView& aAllContactsView,
       
    54                 MVPbkContactViewObserver& aExternalViewObserver,
       
    55                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts,
       
    56                 RFs& aRFs );
       
    57         /**
       
    58          * Destructor.
       
    59          */
       
    60         ~CFindView();    
       
    61     
       
    62     private: // From MVPbkContactViewObserver
       
    63         void ContactViewReady( MVPbkContactViewBase& aView );
       
    64         void ContactViewReadyForFiltering( 
       
    65                 MParentViewForFiltering& aView );
       
    66                 
       
    67     private: // From CFindViewBase
       
    68         void MatchL( RPointerArray<MVPbkSimContact>& aMatchedContacts );
       
    69         void DoContactAddedToViewL(
       
    70                 MVPbkContactViewBase& aView, 
       
    71                 TInt aIndex, 
       
    72                 const MVPbkContactLink& aContactLink,
       
    73                 RPointerArray<MVPbkSimContact>& aMatchedContacts );
       
    74         
       
    75     private: // From MVPbkSimViewFindObserver
       
    76         void ViewFindCompleted( MVPbkSimCntView& aSimCntView,
       
    77             const RVPbkStreamedIntArray& aSimIndexArray );
       
    78         void ViewFindError( MVPbkSimCntView& aSimCntView, TInt aError );
       
    79 
       
    80     private: // From MVPbkContactViewFiltering
       
    81         void UpdateFilterL( 
       
    82             const MDesCArray& aFindWords,
       
    83             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
    84         TBool IsNativeMatchingRequestActive();
       
    85             
       
    86     private: // From MAlwaysIncludedContacts    
       
    87         TBool IsContactAlwaysIncluded( const CViewContact& aContact ) const;
       
    88                                                         
       
    89     private: // Implementation
       
    90         CFindView( CContactView& aContactView );
       
    91         void ConstructL( const MDesCArray& aFindStrings,
       
    92                 MVPbkContactViewObserver& aExternalViewObserver,
       
    93                 const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts,
       
    94                 RFs& aRFs );
       
    95         void SetAlwaysIncludedContactsL( 
       
    96             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
       
    97         void ViewFindCompletedL( MVPbkSimCntView& aSimCntView,
       
    98                 const RVPbkStreamedIntArray& aSimIndexArray );
       
    99         void MatchContactL( const CViewContact& aViewContact,
       
   100             RPointerArray<MVPbkSimContact>& aMatchedContacts );
       
   101         void RemoveFromMatchArrayIfFound( const CViewContact& aViewContact );
       
   102         TBool IsSIMMatchL( const CViewContact& aContact,
       
   103             TInt& aMatchArrayIndex ) const;
       
   104         TInt FindFromMatchArray( const CViewContact& aContact ) const;
       
   105                             
       
   106     private: // Data
       
   107         /// Own: Contact matching operation
       
   108         MVPbkSimStoreOperation* iFindOperation;
       
   109         /// Own: the find policy
       
   110         CVPbkContactFindPolicy* iFindPolicy;
       
   111         /// Own: always included contacts
       
   112         RArray<TInt> iAlwaysIncluded;
       
   113         /// Own: match results (SIM indexes) from native view
       
   114         RArray<TInt> iSIMMatchedContacts;
       
   115     };
       
   116 
       
   117 // CleanupStack helpers for item owning RPointerArrays
       
   118 template <class T>
       
   119 class CleanupResetAndDestroy
       
   120     {
       
   121 public:
       
   122     inline static void PushL(T& aRef)
       
   123         { CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); }
       
   124 private:
       
   125     inline static void ResetAndDestroy(TAny *aPtr)
       
   126         { static_cast<T*>(aPtr)->ResetAndDestroy(); }
       
   127     };
       
   128 
       
   129 template <class T>
       
   130 inline void CleanupResetAndDestroyPushL(T& aRef)
       
   131     { CleanupResetAndDestroy<T>::PushL(aRef); }
       
   132     
       
   133 } // namespace VPbkSimStore    
       
   134 
       
   135 #endif // VPBKSIMSTORE_CFINDVIEW_H
       
   136 
       
   137 // End of File