phoneengine/PhoneCntFinder/ContactService/inc/cphcntcontactmatchstrategy.h
branchRCL_3
changeset 62 5266b1f337bd
child 81 c26cc2a7c548
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Contact matching strategy
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPHCNTCONTACTMATCHSTRATEGY_H
       
    20 #define CPHCNTCONTACTMATCHSTRATEGY_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <CVPbkPhoneNumberMatchStrategy.h>
       
    24 
       
    25 #include "mphcntcontactmatchstrategy.h"
       
    26 #include "mphcntcontactstoreeventobserver.h"
       
    27 
       
    28 class CVPbkContactManager;
       
    29 class MVPbkContactFindObserver;
       
    30 class CVPbkPhoneNumberMatchStrategy;
       
    31 class CVPbkContactStoreUriArray;
       
    32 class CPhCntContactStoreUris;
       
    33 class CCntRawPhoneNumberExtractor;
       
    34 
       
    35 /**
       
    36  *  Strategy for matcing CS contacts.
       
    37  *
       
    38  *  @lib PhoneCntFinder.lib
       
    39  *  @since S60 v3.1
       
    40  */
       
    41 NONSHARABLE_CLASS( CPhCntContactMatchStrategy ) :
       
    42     public CBase,
       
    43     public MPhCntContactMatchStrategy,
       
    44     private MPhCntContactStoreEventObserver
       
    45     {
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Static contstructor.
       
    50      *
       
    51      * @since S60 v3.1
       
    52      * @param aContactManager Contact manager.
       
    53      * @param aUriArray Array of contact store URI's used.
       
    54      * @param aObserver Observer for finding contacts.
       
    55      * @param aMatchFlags A bitset of flags for matching strategy. Has zero or
       
    56      * more CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags flags set.
       
    57      */
       
    58     static CPhCntContactMatchStrategy* NewL(
       
    59         CVPbkContactManager& aContactManager,
       
    60         CPhCntContactStoreUris& aContactStoreUris,
       
    61         MVPbkContactFindObserver& aObserver,
       
    62         TUint32 aMatchFlags );
       
    63 
       
    64     /**
       
    65      * Destructor.
       
    66      *
       
    67      * @since S60 v3.1
       
    68      */
       
    69     virtual ~CPhCntContactMatchStrategy();
       
    70 
       
    71 // from base class MPhCntContactMatchStrategy
       
    72 
       
    73     /**
       
    74      * From MPhCntContactMatchStrategy
       
    75      *
       
    76      * @since S60 v3.1
       
    77      * @see MPhCntContactMatchStrategy
       
    78      */
       
    79     void FindMatchesL( const TDesC& aPhoneNumber );
       
    80 
       
    81 private:
       
    82 
       
    83     /**
       
    84      * Creates contact match strategy with given numbers
       
    85      * of digits.
       
    86      *
       
    87      * @since S60 v3.1
       
    88      * @return Error code.
       
    89      */
       
    90     TInt CreateContactMatchStrategy();
       
    91 
       
    92 // From base class MCenRepNotifyHandlerCallback
       
    93 
       
    94     /**
       
    95      * From base class MCenRepNotifyHandlerCallback
       
    96      * This callback method is used to notify the client about
       
    97      * changes for string value keys, i.e. key type is EStringKey.
       
    98      *
       
    99      * @param aId Id of the key that has changed.
       
   100      * @param aNewValue The new value of the key.
       
   101      */
       
   102     void HandleNotifyString( TUint32 aId, const TDesC16& aNewValue );
       
   103 
       
   104 
       
   105 // From base class MPhCntContactStoreEventObserver
       
   106 
       
   107     /**
       
   108      * From MPhCntContactStoreEventObserver
       
   109      *
       
   110      * @since S60 v3.2
       
   111      * @see MPhCntContactStoreEventObserver.
       
   112      */
       
   113     void ContactStoreAvailabilityChanged();
       
   114 
       
   115     /**
       
   116      * Method to ease unit testing. Creates the actual instance of iMatchStrategy.
       
   117      */
       
   118     virtual TInt DoCreateMatchStrategy();
       
   119     
       
   120     /**
       
   121      * Makes the actual matching request using number
       
   122      * Declared virtual to ease unit testing.
       
   123      */
       
   124     virtual void DoMatchL( const TDesC& aNumber );
       
   125 
       
   126 protected:
       
   127 
       
   128     CPhCntContactMatchStrategy(
       
   129         CVPbkContactManager& aContactManager,
       
   130         CPhCntContactStoreUris& aContactStoreUris,
       
   131         MVPbkContactFindObserver& aObserver,
       
   132         TUint32 aMatchFlags );
       
   133 
       
   134     void ConstructL();
       
   135 
       
   136 private: // data
       
   137 
       
   138     /**
       
   139      * Match strategy.
       
   140      * Own.
       
   141      */
       
   142     CVPbkPhoneNumberMatchStrategy* iMatchStrategy;
       
   143 
       
   144      /**
       
   145       * Contact manager is needed with match strategy.
       
   146       * Not own.
       
   147       */
       
   148     CVPbkContactManager& iContactManager;
       
   149 
       
   150     /**
       
   151      * Gives active contact store uris.
       
   152      * Not own.
       
   153      */
       
   154     CPhCntContactStoreUris& iContactStoreUris;
       
   155 
       
   156      /**
       
   157      * Observer of matching.
       
   158      * Now own.
       
   159      */
       
   160     MVPbkContactFindObserver& iObserver;
       
   161 
       
   162      /**
       
   163       * URI's of the active contact stores, where contacts are
       
   164       * looked from.
       
   165       * Own.
       
   166       */
       
   167     CVPbkContactStoreUriArray* iUriArray;
       
   168 
       
   169     /**
       
   170      * Number extractor.
       
   171      * Own.
       
   172      */
       
   173     CCntRawPhoneNumberExtractor* iNumberExtractor;
       
   174 
       
   175 protected:  // data
       
   176 
       
   177     /**
       
   178      * A bitset of matching strategy flags. Changed from
       
   179      * CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags enum to TUint32
       
   180      * in order to support multiple flags, as in
       
   181      * CVPbkPhoneNumberMatchStrategy::TConfig.
       
   182 	 * 
       
   183 	 * Protected because a unit test class derives from this class.
       
   184      */
       
   185     TUint32 iMatchFlags;
       
   186 
       
   187     };
       
   188 
       
   189 
       
   190 #endif // CPHCNTCONTACTMATCHSTRATEGY_H