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