predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsAlgorithm2Helper.h
branchRCL_3
changeset 58 d4f567ce2e7c
parent 0 e686773b3f54
child 64 c1e8ba0c2b16
equal deleted inserted replaced
57:2666d9724c76 58:d4f567ce2e7c
    20 
    20 
    21 // INCLUDES
    21 // INCLUDES
    22 #include <e32cmn.h>
    22 #include <e32cmn.h>
    23 #include <e32math.h>
    23 #include <e32math.h>
    24 #include <e32hashtab.h>
    24 #include <e32hashtab.h>
       
    25 #include <MPbkGlobalSetting.h> // For name order setting
    25 
    26 
    26 #include "CPcsPlugin.h"
    27 #include "CPcsPlugin.h"
    27 #include "CPsData.h"
    28 #include "CPsData.h"
    28 #include "CPcsCache.h"
    29 #include "CPcsCache.h"
    29 #include "CPcsKeyMap.h"
    30 #include "CPcsKeyMap.h"
    34 class CPcsAlgorithm2;
    35 class CPcsAlgorithm2;
    35 class CPsData;
    36 class CPsData;
    36 class CPsDataPluginInterface;
    37 class CPsDataPluginInterface;
    37 
    38 
    38 // CLASS DECLARATION
    39 // CLASS DECLARATION
    39 class CPcsAlgorithm2Helper : public CBase
    40 class CPcsAlgorithm2Helper : public CBase, private MPbkGlobalSettingObserver
    40     {
    41     {
    41 public:
    42 public:
    42 
    43 
    43     /**
    44     /**
    44      * Two phase construction
    45      * Two phase construction
    51     virtual ~CPcsAlgorithm2Helper();
    52     virtual ~CPcsAlgorithm2Helper();
    52 
    53 
    53 private:
    54 private:
    54 
    55 
    55     /**
    56     /**
    56      * Filter subset results for ITU-T Mode. Entire search query is 
    57      * Filter subset results for Mixed mode. Some portion of query can be in 
    57      * entered in ITU-T mode.
    58      * ITU-T mode and some portion in Qwerty mode.
    58      */
    59      */
    59     void FilterResultsL(CPcsAlgorithm2FilterHelper* aAlgorithmFilterHelper,
    60     void FilterResultsSingleL(CPcsAlgorithm2FilterHelper* aAlgorithmFilterHelper,
    60                         RPointerArray<CPcsPoolElement>& searchSet,
    61                               RPointerArray<CPcsPoolElement>& aSearchSet,
    61                         const TDesC& searchQuery, TBool isSearchInGroup,
    62                               CPsQuery& aSearchQuery,
    62                         RArray<TInt>& aContactsInGroup);
    63                               TUint8 aFilteredDataMatch,
       
    64                               TBool aIsSearchInGroup,
       
    65                               const RArray<TInt>& aContactsInGroup);
       
    66     
    63     /**
    67     /**
    64      * Filter subset results for Qwerty Mode. Entire search query is 
    68      * Create a buffer containing the first name and last name of a contact in the
    65      * entered in Qwerty mode.
    69      * order specified in Phonebook settings.
    66      */
    70      */
    67     void FilterResultsQwertyL(CPcsAlgorithm2FilterHelper* aAlgorithmFilterHelper,
    71     HBufC* CreateNameBufLC( const CPsData& aContactData, TInt aFirstNameIndex, TInt aLastNameIndex ) const;
    68                               RPointerArray<CPcsPoolElement>& searchSet,
    72     
    69                               const TDesC& searchQuery, TBool isSearchInGroup,
    73     /**
    70                               RArray<TInt>& aContactsInGroup);
    74      * Get and store the order of first and last name.
       
    75      */
       
    76     void UpdateNameOrderL();
    71 
    77 
       
    78 private: // from MPbkGlobalSettingObserver
    72     /**
    79     /**
    73      * Filter subset results for Mixed mode. Some portion of query is in 
    80      * React to change in Phonebook settings.
    74      * ITU-T mode and some portion in Qwert mode.
       
    75      */
    81      */
    76     void FilterResultsMixedL(CPcsAlgorithm2FilterHelper* aAlgorithmFilterHelper,
    82     void SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey );
    77                              RPointerArray<CPcsPoolElement>& searchSet, 
    83     
    78                              CPsQuery& searchQuery, TBool isSearchInGroup, 
       
    79                              RArray<TInt>& aContactsInGroup);
       
    80 
       
    81     /**
       
    82      * Convert the search query to a string.
       
    83      * If the mode is ITU-T, character is converted to numeric.
       
    84      * If the mode is Qwerty, character is retained as is.
       
    85      */
       
    86     void ExtractQueryL(CPsQuery& aPsQuery, TDes& aOutput);
       
    87 
       
    88     /**
       
    89      * Convert the input search query to a string.
       
    90      * Mode is referred in the CPsQuery.
       
    91      * If the mode is ITU-T, character is converted to numeric.
       
    92      * If the mode is Qwerty, character is retained as is.
       
    93      */
       
    94     void ExtractQueryL(TDesC& aInput, CPsQuery& aPsQuery, TDes& aOutput);
       
    95 
       
    96 public:
    84 public:
    97 
       
    98     /**
       
    99      * Search Function for ITU-T style
       
   100      */
       
   101     void SearchITUL(const CPsSettings& aSettings, CPsQuery& aQuery,
       
   102                     TBool isGroupSearch, RArray<TInt>& aContactsInGroup,
       
   103                     RPointerArray<CPsData>& searchResults,
       
   104                     RPointerArray<CPsPattern>& searchSeqs);
       
   105 
       
   106     /**
       
   107      * Search Function for QWERTY style
       
   108      */
       
   109     void SearchQWERTYL(const CPsSettings& aSettings, CPsQuery& aQuery,
       
   110                        TBool isGroupSearch, RArray<TInt>& aContactsInGroup,
       
   111                        RPointerArray<CPsData>& searchResults,
       
   112                        RPointerArray<CPsPattern>& searchSeqs);
       
   113 
    85 
   114     /**
    86     /**
   115      * Search Function for mixed style
    87      * Search Function for mixed style
   116      * Some chars are entered in ITU-T and some in QWERTY
    88      * Some chars are entered in ITU-T and some in QWERTY
   117      */
    89      */
   118     void SearchMixedL(const CPsSettings& aSettings, CPsQuery& aQuery,
    90     void SearchSingleL(const CPsSettings& aSettings, 
   119                       TBool isGroupSearch, RArray<TInt>& aContactsInGroup,
    91                        CPsQuery& aQuery,
   120                       RPointerArray<CPsData>& searchResults,
    92                        TBool aIsGroupSearch, 
   121                       RPointerArray<CPsPattern>& searchSeqs);
    93                        const RArray<TInt>& aContactsInGroup,
       
    94                        RPointerArray<CPsData>& aSearchResults,
       
    95                        RPointerArray<CPsPattern>& aSearchSeqs);
   122 
    96 
   123     /**
    97     /**
   124      * Funciton to search matching sequences in the input text
    98      * Funciton to search matching sequences in the input text
   125      */
    99      */
   126     void SearchMatchSeqL(HBufC* aQuery, TDesC& aData,
   100     void SearchMatchSeqL(CPsQuery& aPsQuery,
   127                          RPointerArray<TDesC>& aMatchSet, CPsQuery& aPsQuery, 
   101                          const TDesC& aData,
       
   102                          RPointerArray<TDesC>& aMatchSet,
   128                          RArray<TPsMatchLocation>& aMatchLocation);
   103                          RArray<TPsMatchLocation>& aMatchLocation);
   129 
   104 
   130     /**
   105     /**
   131      * Sort search sequences
   106      * Sort search sequences
   132      */
   107      */
   133     void SortSearchSeqsL(RPointerArray<TDesC>& aMatchSet);
   108     void SortSearchSeqsL(RPointerArray<TDesC>& aMatchSet);
   134 
   109 
   135 private:
       
   136 
       
   137     /**
       
   138      * Constructs a bit pattern using the required/supported data fields
       
   139      * For example, 6, 4 and 27 are supported fields <-- 00000111
       
   140      *              6 and 4 are required fields      <-- 00000011
       
   141      * Bit pattern returned is 00000011.
       
   142      */
       
   143     TUint8 FilterDataFieldsL(RArray<TInt>& aRequiredDataFields,
       
   144                              RArray<TInt>& aSupportedDataFields);
       
   145 private:
   110 private:
   146 
   111 
   147     /**
   112     /**
   148      * Constructor
   113      * Constructor
   149      */
   114      */
   162     CPcsAlgorithm2* iAlgorithm;
   127     CPcsAlgorithm2* iAlgorithm;
   163 
   128 
   164     /**
   129     /**
   165      * Pointer to key map instance. Not owned.
   130      * Pointer to key map instance. Not owned.
   166      */
   131      */
   167     CPcsKeyMap* keyMap;
   132     CPcsKeyMap* iKeyMap;
   168 
   133 
   169     /**
   134     /**
   170      * Array of result sets from different data stores.
   135      * Array of result sets from different data stores.
   171      */
   136      */
   172     typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY;
   137     typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY;
   173     RPointerArray<CPSDATA_R_PTR_ARRAY> iSearchResultsArr;
   138     RPointerArray<CPSDATA_R_PTR_ARRAY> iSearchResultsArr;
       
   139     
       
   140     /**
       
   141      * Phonebook settings store for reading name order.
       
   142      */
       
   143     MPbkGlobalSetting* iPbkSettings;
       
   144     
       
   145     /**
       
   146      * Contact name display order 
       
   147      */
       
   148     enum TNameOrder
       
   149         {
       
   150         EFirstnameLastname,
       
   151         ELastnameFirstname
       
   152         };
       
   153     TNameOrder iNameOrder;
       
   154     
       
   155     /**
       
   156      * Counter of the matched contacts requested by PCS client
       
   157      */
       
   158     TInt iMaxCount;
   174     };
   159     };
   175 
   160 
   176 #endif // C_PCS_ALGORITHM_2_HELPER
   161 #endif // C_PCS_ALGORITHM_2_HELPER