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