|
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_UTILS |
|
19 #define C_PCS_ALGORITHM_2_UTILS |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 // FORWARD DECLARATION |
|
26 class CPsData; |
|
27 class CPsQuery; |
|
28 struct TPsMatchLocation; |
|
29 |
|
30 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 class CPcsAlgorithm2Utils : public CBase |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Merge function to merge the search results from different arrays |
|
39 * into a single array in sorted order. |
|
40 * It merges all the result sets that are there in iSearchResultsArr |
|
41 * into single result set. This is a wrapper funciton implemented that |
|
42 * works for all type of key board modes |
|
43 */ |
|
44 static void FormCompleteSearchResultsL(RPointerArray<CPSDATA_R_PTR_ARRAY>& aSearchResultsArr, |
|
45 RPointerArray<CPsData>& aSearchResults); |
|
46 |
|
47 /** |
|
48 * Customized CompareC |
|
49 */ |
|
50 static TInt MyCompareC(const TDesC& aLeft, const TDesC& aRight); |
|
51 |
|
52 /** |
|
53 * TLinearOrder rule for comparison of data objects |
|
54 */ |
|
55 static TInt CompareDataBySortOrder(const CPsData& aObject1, const CPsData& aObject2); |
|
56 |
|
57 /** |
|
58 * TIdentityRelation rule for comparing descriptors case-sensitively. |
|
59 */ |
|
60 static TBool CompareExact(const TDesC& aFirst, const TDesC& aSecond); |
|
61 |
|
62 /** |
|
63 * TLinearOrder rule for comparing queries by length |
|
64 */ |
|
65 static TInt CompareLength(const CPsQuery& aFirst, const CPsQuery& aSecond); |
|
66 |
|
67 /** |
|
68 * Trim off all white spaces and special chars |
|
69 */ |
|
70 static void MyTrim(TDes& aString); |
|
71 |
|
72 /** |
|
73 * Check if the input URI is of contact search in a group template form |
|
74 */ |
|
75 static TBool IsGroupUri(TDesC& aURI); |
|
76 |
|
77 /** |
|
78 * Constructs a bit pattern using the required/supported data fields |
|
79 * For example, 6, 4 and 27 are supported fields <-- 00000111 |
|
80 * 6 and 4 are required fields <-- 00000011 |
|
81 * Bit pattern returned is 00000011. |
|
82 */ |
|
83 static TUint8 FilterDataFieldsL(const RArray<TInt>& aRequiredDataFields, |
|
84 const RArray<TInt>& aSupportedDataFields); |
|
85 |
|
86 /** |
|
87 * Create upper-case match sequence buffer from matching part and append it to |
|
88 * array unless there's equal sequence already present. |
|
89 */ |
|
90 static void AppendMatchToSeqL( RPointerArray<TDesC>& aMatchSeq, const TDesC& aMatch ); |
|
91 |
|
92 /** |
|
93 * Check if two match location items have overlapping indices. |
|
94 */ |
|
95 static TBool MatchesOverlap( const TPsMatchLocation& aFirst, const TPsMatchLocation& aSecond ); |
|
96 }; |
|
97 |
|
98 |
|
99 // CleanupStack helpers for item owning RPointerArrays |
|
100 template <class T> |
|
101 class CleanupResetAndDestroy |
|
102 { |
|
103 public: |
|
104 inline static void PushL(T& aRef) |
|
105 { CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); } |
|
106 private: |
|
107 inline static void ResetAndDestroy(TAny *aPtr) |
|
108 { static_cast<T*>(aPtr)->ResetAndDestroy(); } |
|
109 }; |
|
110 |
|
111 template <class T> |
|
112 inline void CleanupResetAndDestroyPushL(T& aRef) |
|
113 { CleanupResetAndDestroy<T>::PushL(aRef); } |
|
114 |
|
115 #endif // C_PCS_ALGORITHM_2_UTILS |