|
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: Identifies a contact in cache pools |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_PCS_ALGORITHM_2_MULTI_SEARCH_HELPER |
|
19 #define C_PCS_ALGORITHM_2_MULTI_SEARCH_HELPER |
|
20 |
|
21 // SYSTEM INCLUDES |
|
22 #include <e32cmn.h> |
|
23 #include <e32math.h> |
|
24 |
|
25 // USER INCLUDES |
|
26 #include "CPsData.h" |
|
27 #include "CPcsCache.h" |
|
28 #include "CPcsKeyMap.h" |
|
29 #include "CPsQuery.h" |
|
30 #include "CPcsAlgorithm2.h" |
|
31 #include "CPcsDebug.h" |
|
32 #include "CPcsKeyMap.h" |
|
33 #include "CPsQueryItem.h" |
|
34 #include "CPcsPoolElement.h" |
|
35 #include "CWords.h" |
|
36 #include "CPcsAlgorithm2FilterHelper.h" |
|
37 |
|
38 // FORWARD DECLARATION |
|
39 class CPcsAlgorithm2; |
|
40 class CPsData; |
|
41 class CPsQuery; |
|
42 class TMultiSearchMap; |
|
43 |
|
44 #define MAX_DATA_FIELDS 8 |
|
45 |
|
46 // CLASS DECLARATION |
|
47 class CPcsAlgorithm2MultiSearchHelper : public CBase |
|
48 { |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Two phase construction |
|
53 */ |
|
54 static CPcsAlgorithm2MultiSearchHelper* NewL(CPcsAlgorithm2* aAlgorithm); |
|
55 |
|
56 /** |
|
57 * Destructor |
|
58 */ |
|
59 virtual ~CPcsAlgorithm2MultiSearchHelper(); |
|
60 |
|
61 private: |
|
62 |
|
63 /** |
|
64 * Filter subset results for multi query mode. |
|
65 */ |
|
66 void FilterResultsMultiL(CPcsAlgorithm2FilterHelper* aAlgorithmFilterHelper, |
|
67 RPointerArray<CPcsPoolElement>& searchSet, |
|
68 RPointerArray<CPsQuery>& searchQuery, TUint8 aFilteredDataMatch, |
|
69 TBool isGroupSearch, RArray<TInt>& aContactsInGroup, |
|
70 TInt keyboardMode); |
|
71 |
|
72 /** |
|
73 * Convert the search query to a string. |
|
74 * If the mode is ITU-T, character is converted to numeric. |
|
75 * If the mode is Qwerty, character is retained as is. |
|
76 */ |
|
77 void ExtractQueryL(CPsQuery& aPsQuery, TDes& aOutput); |
|
78 |
|
79 /** |
|
80 * Convert the input search query to a string. |
|
81 * Mode is referred in the CPsQuery. |
|
82 * If the mode is ITU-T, character is converted to numeric. |
|
83 * If the mode is Qwerty, character is retained as is. |
|
84 */ |
|
85 void ExtractQueryL(TDesC& aInput, CPsQuery& aPsQuery, TDes& aOutput); |
|
86 /** |
|
87 * Converts the input data to the key board mode specified by the query. |
|
88 * Mode is referred in the CPsQuery. |
|
89 * If the mode is ITU-T, data is converted to numeric. |
|
90 * If the mode is Qwerty, data is retained as is. |
|
91 */ |
|
92 void ConvertdDataToKeyBoardModeL(CPsQuery* aQuery, TPtrC aInputData, |
|
93 TBuf<KPsQueryMaxLen>& aOutputData); |
|
94 |
|
95 public: |
|
96 |
|
97 /** |
|
98 * Search Function for multi query |
|
99 * Initials search feature |
|
100 */ |
|
101 void SearchMultiL(const CPsSettings& aSettings, RPointerArray<CPsQuery>& aQuery, |
|
102 TBool isGroupSearch, RArray<TInt>& aContactsInGroup, |
|
103 RPointerArray<CPsData>& searchResults, |
|
104 RPointerArray<CPsPattern>& searchSeqs, TInt keyboardMode); |
|
105 |
|
106 /** |
|
107 * Funtion to Search matching sequences for multi query |
|
108 */ |
|
109 void SearchMatchSeqMultiL(RPointerArray<CPsQuery>& aPsQuery, |
|
110 TDesC& aData, RPointerArray<TDesC>& aMatchSet, |
|
111 RArray<TPsMatchLocation>& aMatchLocation); |
|
112 |
|
113 private: |
|
114 |
|
115 /** |
|
116 * Constructs a bit pattern using the required/supported data fields |
|
117 * For example, 6, 4 and 27 are supported fields <-- 00000111 |
|
118 * 6 and 4 are required fields <-- 00000011 |
|
119 * Bit pattern returned is 00000011. |
|
120 */ |
|
121 TUint8 FilterDataFieldsL(RArray<TInt>& aRequiredDataFields, |
|
122 RArray<TInt>& aSupportedDataFields); |
|
123 /** |
|
124 * Set the bits corresponding to word matches |
|
125 * |
|
126 * @param aIndex Index of data element |
|
127 * @param aPosition Word matched for predictive search |
|
128 */ |
|
129 void SetWordMap(TInt aIndex, TInt aPosition); |
|
130 |
|
131 /** |
|
132 * Checks if data at data index and word at word index |
|
133 * is matched for predictive search |
|
134 * |
|
135 * @param aDataIndex Index of data element |
|
136 * @param aWordIndex Word index |
|
137 * @return TRUE if word matched else FALSE |
|
138 */ |
|
139 TBool IsWordMatch(TInt aDataIndex, TInt aWordIndex); |
|
140 |
|
141 /** |
|
142 * Resets iWordMatches member variable |
|
143 */ |
|
144 void ClearWordMatches(); |
|
145 |
|
146 public: |
|
147 |
|
148 /** |
|
149 * Utility function that counts no of bit set in 32 bit number |
|
150 */ |
|
151 TInt BitsSet32(TUint32 aData); |
|
152 |
|
153 /** |
|
154 * Utility function to split the query into multiple queries |
|
155 */ |
|
156 RPointerArray<CPsQuery> MultiQueryL(CPsQuery& aQuery); |
|
157 |
|
158 /** |
|
159 * Convert the search query (multiple) to a list |
|
160 */ |
|
161 void ConvertQueryToListL(RPointerArray<CPsQuery>& aSearchQuery, |
|
162 RPointerArray<HBufC>& aQueryList); |
|
163 |
|
164 private: |
|
165 |
|
166 /** |
|
167 * Constructor |
|
168 */ |
|
169 CPcsAlgorithm2MultiSearchHelper(); |
|
170 |
|
171 /** |
|
172 * 2nd phase construtor |
|
173 */ |
|
174 void ConstructL(CPcsAlgorithm2* aAlgorithm); |
|
175 |
|
176 private: |
|
177 |
|
178 /** |
|
179 * Pointer to algorithm instance. Not owned. |
|
180 */ |
|
181 CPcsAlgorithm2* iAlgorithm; |
|
182 |
|
183 /** |
|
184 * Pointer to key map instance. Not owned. |
|
185 */ |
|
186 CPcsKeyMap* keyMap; |
|
187 |
|
188 /** |
|
189 * Array of result sets from different data stores. |
|
190 */ |
|
191 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
|
192 RPointerArray<CPSDATA_R_PTR_ARRAY> iMultiSearchResultsArr; |
|
193 |
|
194 /** |
|
195 * Array of word macthes. |
|
196 */ |
|
197 TUint8 iWordMatches[MAX_DATA_FIELDS]; |
|
198 }; |
|
199 |
|
200 #endif // C_PCS_ALGORITHM_2_MULTI_SEARCH_HELPER |