|
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: Inline finction definitions for class TSearchParams. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <StringLoader.h> |
|
20 |
|
21 const TInt KIpsPlgArrayGranularity = 3; |
|
22 // <cmail> mirrored |
|
23 //_LIT( KIpsPlgPattern, "*%0U*" ); |
|
24 _LIT( KIpsPlgPattern, "*" ); |
|
25 // </cmail> |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CIpsPlgSearch::TSearchParams::TSearchParams() |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CIpsPlgSearch::TSearchParams::TSearchParams( |
|
33 const RPointerArray<TDesC>& aSearchStrings, |
|
34 const TFSMailMsgId& aMailbox, |
|
35 const RArray<TFSMailMsgId> aFolderIds, |
|
36 const TFSMailSortCriteria& aSortCriteria ) |
|
37 : |
|
38 iSearchStrings( NULL ), |
|
39 iMailbox( aMailbox ), |
|
40 iSortCriteria( aSortCriteria ) |
|
41 { |
|
42 TRAP_IGNORE( SetSearchStringsL( aSearchStrings ) ); |
|
43 TRAP_IGNORE( SetFolderIdsL( aFolderIds ) ); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CIpsPlgSearch::TSearchParams::~TSearchParams() |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CIpsPlgSearch::TSearchParams::~TSearchParams() |
|
51 { |
|
52 iFolderIds.Reset(); |
|
53 RemoveArray(); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CIpsPlgSearch::TSearchParams::operator=() |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CIpsPlgSearch::TSearchParams& CIpsPlgSearch::TSearchParams::operator=( |
|
61 const TSearchParams& aParams ) |
|
62 { |
|
63 // Make sure the lists are empty. |
|
64 iFolderIds.Reset(); |
|
65 RemoveArray(); |
|
66 |
|
67 TRAP_IGNORE( SetSearchStringsL( *aParams.iSearchStrings ) ); |
|
68 iMailbox = aParams.iMailbox; |
|
69 TRAP_IGNORE( SetFolderIdsL( aParams.iFolderIds ) ); |
|
70 iSortCriteria = aParams.iSortCriteria; |
|
71 |
|
72 return *this; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CIpsPlgSearch::TSearchParams::operator=() |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CIpsPlgSearch::TSearchParams::operator+=( |
|
80 const TSearchParams& aParams ) |
|
81 { |
|
82 // Update folder list and sort criteria. |
|
83 TRAP_IGNORE( AddFolderIdsL( aParams.iFolderIds ) ); |
|
84 iSortCriteria = aParams.iSortCriteria; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CIpsPlgSearch::TSearchParams::RemoveArray() |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CIpsPlgSearch::TSearchParams::RemoveArray() |
|
92 { |
|
93 if ( iSearchStrings ) |
|
94 { |
|
95 iSearchStrings->Reset(); |
|
96 } |
|
97 |
|
98 delete iSearchStrings; |
|
99 iSearchStrings = NULL; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CIpsPlgSearch::TSearchParams::SetSearchStringsL() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CIpsPlgSearch::TSearchParams::SetSearchStringsL( |
|
107 const RPointerArray<TDesC>& aSearchStrings ) |
|
108 { |
|
109 RemoveArray(); |
|
110 |
|
111 iSearchStrings = |
|
112 new( ELeave ) CDesC16ArrayFlat( KIpsPlgArrayGranularity ); |
|
113 |
|
114 for ( TInt item = 0; item < aSearchStrings.Count(); item++ ) |
|
115 { |
|
116 // <cmail> mirrored |
|
117 |
|
118 // Add the wildcards here. |
|
119 //TBuf<5> pattern( KIpsPlgPattern ); |
|
120 RBuf destroyThisHackStringNow; |
|
121 destroyThisHackStringNow.CreateL( |
|
122 aSearchStrings[item]->Length() + 2 ); |
|
123 CleanupClosePushL( destroyThisHackStringNow ); |
|
124 |
|
125 destroyThisHackStringNow.Insert(0, KIpsPlgPattern); |
|
126 destroyThisHackStringNow.Append(*aSearchStrings[item]); |
|
127 destroyThisHackStringNow.Append(KIpsPlgPattern); |
|
128 /* |
|
129 StringLoader::Format( |
|
130 destroyThisHackStringNow, pattern, 0, *aSearchStrings[item] ); |
|
131 */ |
|
132 |
|
133 // </cmail> |
|
134 |
|
135 |
|
136 iSearchStrings->AppendL( destroyThisHackStringNow ); //<cmail> |
|
137 |
|
138 CleanupStack::PopAndDestroy( &destroyThisHackStringNow ); |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CIpsPlgSearch::TSearchParams::SetSearchStringsL() |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CIpsPlgSearch::TSearchParams::SetSearchStringsL( |
|
147 const CDesC16Array& aSearchStrings ) |
|
148 { |
|
149 RemoveArray(); |
|
150 |
|
151 iSearchStrings = |
|
152 new( ELeave ) CDesC16ArrayFlat( KIpsPlgArrayGranularity ); |
|
153 |
|
154 for ( TInt item = 0; item < aSearchStrings.Count(); item++ ) |
|
155 { |
|
156 iSearchStrings->AppendL( aSearchStrings[item] ); //<cmail> |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // CIpsPlgSearch::TSearchParams::SetFolderIdsL() |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CIpsPlgSearch::TSearchParams::SetFolderIdsL( |
|
165 const RArray<TFSMailMsgId>& aFolderIds ) |
|
166 { |
|
167 for ( TInt item = 0; item < aFolderIds.Count(); item++ ) |
|
168 { |
|
169 iFolderIds.AppendL( aFolderIds[item] ); |
|
170 } |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CIpsPlgSearch::TSearchParams::FolderExists() |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 TBool CIpsPlgSearch::TSearchParams::FolderExists( const TFSMailMsgId& aFolderId ) |
|
178 { |
|
179 for ( TInt existing = 0; existing < iFolderIds.Count(); existing++ ) |
|
180 { |
|
181 if ( aFolderId == iFolderIds[existing] ) |
|
182 { |
|
183 return ETrue; |
|
184 } |
|
185 } |
|
186 |
|
187 return EFalse; |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CIpsPlgSearch::TSearchParams::AddFolderIdsL() |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CIpsPlgSearch::TSearchParams::AddFolderIdsL( |
|
195 const RArray<TFSMailMsgId>& aFolderIds ) |
|
196 { |
|
197 for ( TInt item = 0; item < aFolderIds.Count(); item++ ) |
|
198 { |
|
199 if ( !FolderExists( aFolderIds[item] ) ) |
|
200 { |
|
201 iFolderIds.AppendL( aFolderIds[item] ); |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CIpsPlgSearch::TMsgContainer::SetFolderIdsL() |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 TMsvId CIpsPlgSearch::TMsgContainer::Id() const |
|
211 { |
|
212 return iId; |
|
213 } |
|
214 |
|
215 // End of File |