22 #include <CPbk2SortOrderManager.h> |
22 #include <CPbk2SortOrderManager.h> |
23 #include <Pbk2ContactNameFormatterFactory.h> |
23 #include <Pbk2ContactNameFormatterFactory.h> |
24 #include <MPbk2ContactNameFormatter.h> |
24 #include <MPbk2ContactNameFormatter.h> |
25 #include <CPbk2DuplicateContactFinder.h> |
25 #include <CPbk2DuplicateContactFinder.h> |
26 #include <MPbk2DuplicateContactObserver.h> |
26 #include <MPbk2DuplicateContactObserver.h> |
|
27 #include <RPbk2LocalizedResourceFile.h> |
|
28 #include "Pbk2DataCaging.hrh" |
|
29 #include "Pbk2PresentationUtils.h" |
|
30 #include <Pbk2Presentation.rsg> |
|
31 #include <CVPbkFieldTypeSelector.h> |
|
32 #include <CVPbkFieldTypeIterator.h> |
|
33 #include <CVPbkFieldTypeRefsList.h> |
27 |
34 |
28 // Virtual Phonebook |
35 // Virtual Phonebook |
29 #include <CVPbkContactManager.h> |
36 #include <CVPbkContactManager.h> |
30 #include <MVPbkContactOperationBase.h> |
37 #include <MVPbkContactOperationBase.h> |
31 #include <CVPbkContactLinkArray.h> |
38 #include <CVPbkContactLinkArray.h> |
32 #include <MVPbkStoreContact.h> |
39 #include <MVPbkStoreContact.h> |
|
40 |
|
41 // System includes |
|
42 #include <barsread.h> |
|
43 |
33 |
44 |
34 /// Unnamed namespace for local definitions |
45 /// Unnamed namespace for local definitions |
35 namespace { |
46 namespace { |
36 |
47 |
37 NONSHARABLE_CLASS(CPbk2DuplicateOperation) : |
48 NONSHARABLE_CLASS(CPbk2DuplicateOperation) : |
220 { |
231 { |
221 iDuplicates.ResetAndDestroy(); |
232 iDuplicates.ResetAndDestroy(); |
222 delete iDuplicateFinder; |
233 delete iDuplicateFinder; |
223 delete iNameFormatter; |
234 delete iNameFormatter; |
224 delete iSortOrderManager; |
235 delete iSortOrderManager; |
|
236 delete iFieldTypeRefsList; |
225 } |
237 } |
226 |
238 |
227 // -------------------------------------------------------------------------- |
239 // -------------------------------------------------------------------------- |
228 // CPbk2ContactDuplicatePolicy::NewL |
240 // CPbk2ContactDuplicatePolicy::NewL |
229 // -------------------------------------------------------------------------- |
241 // -------------------------------------------------------------------------- |
250 iContactManager.FieldTypes() ); |
262 iContactManager.FieldTypes() ); |
251 iNameFormatter = Pbk2ContactNameFormatterFactory::CreateL( |
263 iNameFormatter = Pbk2ContactNameFormatterFactory::CreateL( |
252 iContactManager.FieldTypes(), *iSortOrderManager, |
264 iContactManager.FieldTypes(), *iSortOrderManager, |
253 &iContactManager.FsSession() ); |
265 &iContactManager.FsSession() ); |
254 |
266 |
255 const MVPbkFieldTypeList* fieldTypesForFind = |
267 const MVPbkFieldTypeList* fieldTypesForFind = aFieldTypeForFind; |
256 &iSortOrderManager->SortOrder(); |
268 if ( !fieldTypesForFind ) |
257 if ( aFieldTypeForFind ) |
|
258 { |
269 { |
259 fieldTypesForFind = aFieldTypeForFind; |
270 iFieldTypeRefsList = CreateFieldTypesForFindL(iContactManager); |
|
271 fieldTypesForFind = iFieldTypeRefsList; |
260 } |
272 } |
261 iDuplicateFinder = CPbk2DuplicateContactFinder::NewL( iContactManager, |
273 iDuplicateFinder = CPbk2DuplicateContactFinder::NewL( iContactManager, |
262 *iNameFormatter, *fieldTypesForFind, iDuplicates ); |
274 *iNameFormatter, *fieldTypesForFind, iDuplicates ); |
263 } |
275 } |
264 |
276 |
277 return CPbk2DuplicateOperation::NewL( *iDuplicateFinder, iDuplicates, |
289 return CPbk2DuplicateOperation::NewL( *iDuplicateFinder, iDuplicates, |
278 aDuplicates, aContact, aTargetStore, aObserver, |
290 aDuplicates, aContact, aTargetStore, aObserver, |
279 aMaxDuplicatesToFind ); |
291 aMaxDuplicatesToFind ); |
280 } |
292 } |
281 |
293 |
|
294 // -------------------------------------------------------------------------- |
|
295 // CPbk2ContactDuplicatePolicy::CreateFieldTypesForFindL |
|
296 // -------------------------------------------------------------------------- |
|
297 // |
|
298 MVPbkFieldTypeList* CPbk2ContactDuplicatePolicy::CreateFieldTypesForFindL |
|
299 (CVPbkContactManager& aContactManager) const |
|
300 { |
|
301 RFs fs = aContactManager.FsSession(); |
|
302 RPbk2LocalizedResourceFile resFile(&fs); |
|
303 resFile.OpenLC(KPbk2RomFileDrive, |
|
304 KDC_RESOURCE_FILES_DIR, |
|
305 Pbk2PresentationUtils::PresentationResourceFile()); |
|
306 |
|
307 // Create resource reader. |
|
308 TResourceReader resReader; |
|
309 resReader.SetBuffer(resFile.AllocReadLC(R_TITLE_FIELD_SELECTOR)); |
|
310 |
|
311 // Create title field selector. |
|
312 CVPbkFieldTypeSelector* titleFieldSelector = CVPbkFieldTypeSelector::NewL |
|
313 (resReader, aContactManager.FieldTypes()); |
|
314 CleanupStack::PushL(titleFieldSelector); |
|
315 |
|
316 // Create field type list for find. |
|
317 CVPbkFieldTypeRefsList* fieldTypeRefsList = CVPbkFieldTypeRefsList::NewL(); |
|
318 CleanupStack::PushL(fieldTypeRefsList); |
|
319 const MVPbkFieldType* fieldType = NULL; |
|
320 |
|
321 // Create field type iterator. |
|
322 CVPbkFieldTypeIterator* fieldTypeIterator = |
|
323 CVPbkFieldTypeIterator::NewLC(*titleFieldSelector, |
|
324 aContactManager.FieldTypes()); |
|
325 while(fieldTypeIterator->HasNext()) |
|
326 { |
|
327 fieldType = fieldTypeIterator->Next(); |
|
328 if (fieldType) |
|
329 { |
|
330 // Filter the Versit type for find. |
|
331 if (EVPbkNonVersitTypeNone == fieldType->NonVersitType()) |
|
332 { |
|
333 fieldTypeRefsList->AppendL(*fieldType); |
|
334 } |
|
335 } |
|
336 } |
|
337 |
|
338 CleanupStack::PopAndDestroy(); // fieldTypeIterator |
|
339 CleanupStack::Pop(fieldTypeRefsList); |
|
340 CleanupStack::PopAndDestroy(); // titleFieldSelector |
|
341 CleanupStack::PopAndDestroy(); // resReader |
|
342 CleanupStack::PopAndDestroy(); // resFile |
|
343 |
|
344 return fieldTypeRefsList; |
|
345 } |
|
346 |
282 // End of File |
347 // End of File |