phoneengine/PhoneCntFinder/ContactService/inc/cphcntcontactmatchstrategy.h
branchRCL_3
changeset 81 c26cc2a7c548
parent 62 5266b1f337bd
equal deleted inserted replaced
73:e30d4a1b8bad 81:c26cc2a7c548
    18 
    18 
    19 #ifndef CPHCNTCONTACTMATCHSTRATEGY_H
    19 #ifndef CPHCNTCONTACTMATCHSTRATEGY_H
    20 #define CPHCNTCONTACTMATCHSTRATEGY_H
    20 #define CPHCNTCONTACTMATCHSTRATEGY_H
    21 
    21 
    22 #include <e32base.h>
    22 #include <e32base.h>
       
    23 #include <cenrepnotifyhandler.h>
    23 #include <CVPbkPhoneNumberMatchStrategy.h>
    24 #include <CVPbkPhoneNumberMatchStrategy.h>
       
    25 #include <cntdb.h>  // KBestMatchingPhoneNumbers
    24 
    26 
    25 #include "mphcntcontactmatchstrategy.h"
    27 #include "mphcntcontactmatchstrategy.h"
    26 #include "mphcntcontactstoreeventobserver.h"
    28 #include "mphcntcontactstoreeventobserver.h"
    27 
    29 
       
    30 #include "MPhCntContactManager.h"
       
    31 
    28 class CVPbkContactManager;
    32 class CVPbkContactManager;
    29 class MVPbkContactFindObserver;
    33 class MVPbkContactFindObserver;
    30 class CVPbkPhoneNumberMatchStrategy;
    34 class CVPbkPhoneNumberMatchStrategy;
       
    35 class CRepository;
    31 class CVPbkContactStoreUriArray;
    36 class CVPbkContactStoreUriArray;
    32 class CPhCntContactStoreUris;
    37 class CPhCntContactStoreUris;
    33 class CCntRawPhoneNumberExtractor;
    38 class CCntRawPhoneNumberExtractor;
       
    39 
       
    40 // Digit count used to match CS number.
       
    41 const TInt KPhCntMatchMin = 7;
       
    42 const TInt KPhCntMatchMax = 11;
       
    43 const TInt KPhCntMatchDefault = KBestMatchingPhoneNumbers;
    34 
    44 
    35 /**
    45 /**
    36  *  Strategy for matcing CS contacts.
    46  *  Strategy for matcing CS contacts.
    37  *
    47  *
    38  *  @lib PhoneCntFinder.lib
    48  *  @lib PhoneCntFinder.lib
    39  *  @since S60 v3.1
    49  *  @since S60 v3.1
    40  */
    50  */
    41 NONSHARABLE_CLASS( CPhCntContactMatchStrategy ) :
    51 NONSHARABLE_CLASS( CPhCntContactMatchStrategy ) :
    42     public CBase,
    52     public CBase,
    43     public MPhCntContactMatchStrategy,
    53     public MPhCntContactMatchStrategy,    
    44     private MPhCntContactStoreEventObserver
    54     private MPhCntContactStoreEventObserver
    45     {
    55     {
    46 public:
    56 public:
    47 
    57 
    48     /**
    58     /**
    50      *
    60      *
    51      * @since S60 v3.1
    61      * @since S60 v3.1
    52      * @param aContactManager Contact manager.
    62      * @param aContactManager Contact manager.
    53      * @param aUriArray Array of contact store URI's used.
    63      * @param aUriArray Array of contact store URI's used.
    54      * @param aObserver Observer for finding contacts.
    64      * @param aObserver Observer for finding contacts.
    55      * @param aMatchFlags A bitset of flags for matching strategy. Has zero or
    65      * @param aRemoveDuplicatesStrategy Contact dupe removal strategy
    56      * more CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags flags set.
       
    57      */
    66      */
    58     static CPhCntContactMatchStrategy* NewL(
    67     static CPhCntContactMatchStrategy* NewL(
    59         CVPbkContactManager& aContactManager,
    68         CVPbkContactManager& aContactManager,
    60         CPhCntContactStoreUris& aContactStoreUris,
    69         CPhCntContactStoreUris& aContactStoreUris,
    61         MVPbkContactFindObserver& aObserver,
    70         MVPbkContactFindObserver& aObserver,
    62         TUint32 aMatchFlags );
    71         MPhCntContactManager::TDuplicateRemovalStrategy aRemoveDuplicatesStrategy );
    63 
    72 
    64     /**
    73     /**
    65      * Destructor.
    74      * Destructor.
    66      *
    75      *
    67      * @since S60 v3.1
    76      * @since S60 v3.1
    76      * @since S60 v3.1
    85      * @since S60 v3.1
    77      * @see MPhCntContactMatchStrategy
    86      * @see MPhCntContactMatchStrategy
    78      */
    87      */
    79     void FindMatchesL( const TDesC& aPhoneNumber );
    88     void FindMatchesL( const TDesC& aPhoneNumber );
    80 
    89 
    81 private:
    90 private:    
    82 
    91     
    83     /**
    92     /**
    84      * Creates contact match strategy with given numbers
    93      * Creates contact match strategy with given numbers
    85      * of digits.
    94      * of digits.
    86      *
    95      *
    87      * @since S60 v3.1
    96      * @since S60 v3.1
    88      * @return Error code.
    97      * @return Error code.
    89      */
    98      */
    90     TInt CreateContactMatchStrategy();
    99     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 
   100 
   105 // From base class MPhCntContactStoreEventObserver
   101 // From base class MPhCntContactStoreEventObserver
   106 
   102 
   107     /**
   103     /**
   108      * From MPhCntContactStoreEventObserver
   104      * From MPhCntContactStoreEventObserver
   114 
   110 
   115     /**
   111     /**
   116      * Method to ease unit testing. Creates the actual instance of iMatchStrategy.
   112      * Method to ease unit testing. Creates the actual instance of iMatchStrategy.
   117      */
   113      */
   118     virtual TInt DoCreateMatchStrategy();
   114     virtual TInt DoCreateMatchStrategy();
   119     
   115         
   120     /**
   116     /**
   121      * Makes the actual matching request using number
   117      * Removes postfix from aNumber    
   122      * Declared virtual to ease unit testing.
       
   123      */
   118      */
   124     virtual void DoMatchL( const TDesC& aNumber );
   119     TDesC* RemoveExtraCharactersLC( const TDesC& aNumber );
   125 
   120 
   126 protected:
   121 protected:
   127 
   122 
   128     CPhCntContactMatchStrategy(
   123     CPhCntContactMatchStrategy(
   129         CVPbkContactManager& aContactManager,
   124         CVPbkContactManager& aContactManager,
   130         CPhCntContactStoreUris& aContactStoreUris,
   125         CPhCntContactStoreUris& aContactStoreUris,
   131         MVPbkContactFindObserver& aObserver,
   126         MVPbkContactFindObserver& aObserver,
   132         TUint32 aMatchFlags );
   127         MPhCntContactManager::TDuplicateRemovalStrategy aRemoveDuplicatesStrategy );
   133 
   128 
   134     void ConstructL();
   129     void ConstructL();
   135 
   130 
       
   131     TUint32 FillMatchFlags() const;
       
   132     
       
   133     virtual TInt ReadMatchDigitsValueL(); 
       
   134     
       
   135     /**
       
   136      * Makes the actual matching request using number
       
   137      * Declared virtual to ease unit testing.
       
   138      */
       
   139     virtual void DoMatchL( const TDesC& aNumber );   
       
   140     
       
   141     /**
       
   142      * Enables to inject match strategy to ease unit testing
       
   143      */
       
   144     void SetVPbkPhoneNumberMatchStrategy( 
       
   145             CVPbkPhoneNumberMatchStrategy* aMatchStrategy );
       
   146     
   136 private: // data
   147 private: // data
   137 
   148 
   138     /**
   149     /**
   139      * Match strategy.
   150      * Match strategy.
   140      * Own.
   151      * Own.
   141      */
   152      */
   142     CVPbkPhoneNumberMatchStrategy* iMatchStrategy;
   153     CVPbkPhoneNumberMatchStrategy* iMatchStrategy;
   143 
   154         
   144      /**
   155      /**
   145       * Contact manager is needed with match strategy.
   156       * Contact manager is needed with match strategy.
   146       * Not own.
   157       * Not own.
   147       */
   158       */
   148     CVPbkContactManager& iContactManager;
   159     CVPbkContactManager& iContactManager;
   165       * Own.
   176       * Own.
   166       */
   177       */
   167     CVPbkContactStoreUriArray* iUriArray;
   178     CVPbkContactStoreUriArray* iUriArray;
   168 
   179 
   169     /**
   180     /**
       
   181      * Number of digits used with matching.
       
   182      */
       
   183     TInt iNumberOfDigits;
       
   184 
       
   185     /**
   170      * Number extractor.
   186      * Number extractor.
   171      * Own.
   187      * Own.
   172      */
   188      */
   173     CCntRawPhoneNumberExtractor* iNumberExtractor;
   189     CCntRawPhoneNumberExtractor* iNumberExtractor;
   174 
   190     
   175 protected:  // data
   191     MPhCntContactManager::TDuplicateRemovalStrategy iRemoveDuplicatesStrategy;
   176 
   192     
   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     };
   193     };
   188 
   194 
       
   195 #endif // CPHCNTCONTACTMATCHSTRATEGY_H
   189 
   196 
   190 #endif // CPHCNTCONTACTMATCHSTRATEGY_H