26 #include <CPbk2StoreConfiguration.h> |
26 #include <CPbk2StoreConfiguration.h> |
27 #include <TPbk2CopyContactsResults.h> |
27 #include <TPbk2CopyContactsResults.h> |
28 #include <MPbk2ContactNameFormatter.h> |
28 #include <MPbk2ContactNameFormatter.h> |
29 #include <CPbk2StoreProperty.h> |
29 #include <CPbk2StoreProperty.h> |
30 #include <CPbk2StorePropertyArray.h> |
30 #include <CPbk2StorePropertyArray.h> |
|
31 #include <CPbk2ApplicationServices.h> |
31 #include <MPbk2StoreValidityInformer.h> |
32 #include <MPbk2StoreValidityInformer.h> |
32 #include <MPbk2AppUi.h> |
33 #include <MPbk2AppUi.h> |
33 #include <MPbk2ApplicationServices.h> |
34 #include <MPbk2ApplicationServices.h> |
34 #include <Pbk2MmcUIRes.rsg> |
35 #include <Pbk2MmcUIRes.rsg> |
35 |
36 |
43 #include <MVPbkContactStore.h> |
44 #include <MVPbkContactStore.h> |
44 #include <MVPbkContactLinkArray.h> |
45 #include <MVPbkContactLinkArray.h> |
45 #include <VPbkContactStoreUris.h> |
46 #include <VPbkContactStoreUris.h> |
46 #include <MVPbkContactStoreProperties.h> |
47 #include <MVPbkContactStoreProperties.h> |
47 #include <CVPbkContactStoreUriArray.h> |
48 #include <CVPbkContactStoreUriArray.h> |
|
49 #include <MVPbkContactStoreInfo.h> |
48 |
50 |
49 // System includes |
51 // System includes |
50 #include <pathinfo.h> |
52 #include <pathinfo.h> |
51 #include <StringLoader.h> |
53 #include <StringLoader.h> |
52 #include <aknnotewrappers.h> |
54 #include <aknnotewrappers.h> |
143 // CPmuCopyFromMmcCmd::CPmuCopyFromMmcCmd |
145 // CPmuCopyFromMmcCmd::CPmuCopyFromMmcCmd |
144 // -------------------------------------------------------------------------- |
146 // -------------------------------------------------------------------------- |
145 // |
147 // |
146 CPmuCopyFromMmcCmd::CPmuCopyFromMmcCmd( MPbk2ContactUiControl& aUiControl ) : |
148 CPmuCopyFromMmcCmd::CPmuCopyFromMmcCmd( MPbk2ContactUiControl& aUiControl ) : |
147 CActive( EPriorityStandard ), |
149 CActive( EPriorityStandard ), |
148 iUiControl( &aUiControl ) |
150 iUiControl( &aUiControl ), |
|
151 iCheckDuplicates( ETrue ) |
149 { |
152 { |
150 CActiveScheduler::Add( this ); |
153 CActiveScheduler::Add( this ); |
151 } |
154 } |
152 |
155 |
153 // -------------------------------------------------------------------------- |
156 // -------------------------------------------------------------------------- |
161 iReadStream.Close(); |
164 iReadStream.Close(); |
162 delete iDir; |
165 delete iDir; |
163 delete iDecorator; |
166 delete iDecorator; |
164 delete iImportOperation; |
167 delete iImportOperation; |
165 delete iVCardEngine; |
168 delete iVCardEngine; |
|
169 Release( iAppServices ); |
166 } |
170 } |
167 |
171 |
168 // -------------------------------------------------------------------------- |
172 // -------------------------------------------------------------------------- |
169 // CPmuCopyFromMmcCmd::NewL |
173 // CPmuCopyFromMmcCmd::NewL |
170 // -------------------------------------------------------------------------- |
174 // -------------------------------------------------------------------------- |
184 // CPmuCopyFromMmcCmd::ConstructL |
188 // CPmuCopyFromMmcCmd::ConstructL |
185 // -------------------------------------------------------------------------- |
189 // -------------------------------------------------------------------------- |
186 // |
190 // |
187 inline void CPmuCopyFromMmcCmd::ConstructL() |
191 inline void CPmuCopyFromMmcCmd::ConstructL() |
188 { |
192 { |
|
193 iAppServices = CPbk2ApplicationServices::InstanceL(); |
|
194 |
189 iVCardEngine = CVPbkVCardEng::NewL |
195 iVCardEngine = CVPbkVCardEng::NewL |
190 ( Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager() ); |
196 ( iAppServices->ContactManager() ); |
191 iDecorator = Pbk2ProcessDecoratorFactory::CreateProgressDialogDecoratorL |
197 iDecorator = Pbk2ProcessDecoratorFactory::CreateProgressDialogDecoratorL |
192 ( R_PMU_COPY_PROGRESS_NOTE, EFalse ); |
198 ( R_PMU_COPY_PROGRESS_NOTE, EFalse ); |
193 |
199 |
|
200 |
194 CPbk2StoreConfiguration* storeConfig = CPbk2StoreConfiguration::NewL(); |
201 CPbk2StoreConfiguration* storeConfig = CPbk2StoreConfiguration::NewL(); |
195 CleanupStack::PushL( storeConfig ); |
202 CleanupStack::PushL( storeConfig ); |
196 iTargetStore = Phonebook2::Pbk2AppUi()->ApplicationServices(). |
203 iTargetStore = iAppServices->ContactManager().ContactStoresL().Find( |
197 ContactManager().ContactStoresL().Find( |
|
198 storeConfig->DefaultSavingStoreL() ); |
204 storeConfig->DefaultSavingStoreL() ); |
199 |
|
200 CleanupStack::PopAndDestroy( storeConfig ); |
205 CleanupStack::PopAndDestroy( storeConfig ); |
|
206 iCheckDuplicates = ( iTargetStore->StoreInfo().NumberOfContactsL() > 0 ); |
201 |
207 |
202 // set the default contacts path |
208 // set the default contacts path |
203 iContactsPath = PathInfo::MemoryCardContactsPath(); |
209 iContactsPath = PathInfo::MemoryCardContactsPath(); |
204 } |
210 } |
205 |
211 |
285 __ASSERT_DEBUG( iCommandObserver, Panic( EExecuteLD_PreCond ) ); |
291 __ASSERT_DEBUG( iCommandObserver, Panic( EExecuteLD_PreCond ) ); |
286 |
292 |
287 CleanupStack::PushL( this ); |
293 CleanupStack::PushL( this ); |
288 |
294 |
289 if ( !iTargetStore || |
295 if ( !iTargetStore || |
290 !IsValidStoreL( Phonebook2::Pbk2AppUi()->ApplicationServices(). |
296 !IsValidStoreL( iAppServices->StoreValidityInformer(), iTargetStore ) ) |
291 StoreValidityInformer(), iTargetStore ) ) |
|
292 { |
297 { |
293 // if target store not available finish command |
298 // if target store not available finish command |
294 ShowStoreNotAvailableNoteL |
299 ShowStoreNotAvailableNoteL |
295 ( Phonebook2::Pbk2AppUi()->ApplicationServices(). |
300 ( iAppServices->StoreProperties() ); |
296 StoreProperties() ); |
|
297 iCommandObserver->CommandFinished(*this); |
301 iCommandObserver->CommandFinished(*this); |
298 } |
302 } |
299 else |
303 else |
300 { |
304 { |
301 if ( !ShowMemorySelectionDialogL() ) |
305 if ( !ShowMemorySelectionDialogL() ) |
302 { |
306 { |
303 iCommandObserver->CommandFinished(*this); |
307 iCommandObserver->CommandFinished(*this); |
304 } |
308 } |
305 else |
309 else |
306 { |
310 { |
307 Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(). |
311 iAppServices->ContactManager(). |
308 FsSession().GetDir( |
312 FsSession().GetDir( |
309 iContactsPath, |
313 iContactsPath, |
310 KEntryAttNormal | KEntryAttMatchMask, |
314 KEntryAttNormal | KEntryAttMatchMask, |
311 ESortNone, |
315 ESortNone, |
312 iDir ); |
316 iDir ); |
435 parse.Set(( *iDir )[iCurrentContactIndex].iName, |
441 parse.Set(( *iDir )[iCurrentContactIndex].iName, |
436 &iContactsPath, |
442 &iContactsPath, |
437 NULL ); |
443 NULL ); |
438 |
444 |
439 User::LeaveIfError( |
445 User::LeaveIfError( |
440 iReadStream.Open( Phonebook2::Pbk2AppUi()->ApplicationServices(). |
446 iReadStream.Open( iAppServices->ContactManager().FsSession(), |
441 ContactManager().FsSession(), |
|
442 parse.FullName(), EFileRead ) ); |
447 parse.FullName(), EFileRead ) ); |
443 iImportOperation = |
448 |
444 iVCardEngine->ImportVCardL( *iTargetStore, iReadStream, *this ); |
449 // Duplicate checking is one of the major performance bottlenecks in |
|
450 // contact importing. ImportVCardForSyncL ignores the duplicate check so |
|
451 // it is used if the target store is empty before importing. |
|
452 if ( iCheckDuplicates ) |
|
453 { |
|
454 iImportOperation = |
|
455 iVCardEngine->ImportVCardL( *iTargetStore, iReadStream, *this ); |
|
456 } |
|
457 else |
|
458 { |
|
459 iImportOperation = |
|
460 iVCardEngine->ImportVCardForSyncL( *iTargetStore, iReadStream, *this ); |
|
461 } |
445 ++iCurrentContactIndex; |
462 ++iCurrentContactIndex; |
446 iDecorator->ProcessAdvance( 1 ); |
463 iDecorator->ProcessAdvance( 1 ); |
447 } |
464 } |
448 |
465 |
449 // -------------------------------------------------------------------------- |
466 // -------------------------------------------------------------------------- |
525 TBool CPmuCopyFromMmcCmd::IsDefaultStorePhoneMemoryL() const |
542 TBool CPmuCopyFromMmcCmd::IsDefaultStorePhoneMemoryL() const |
526 { |
543 { |
527 TBool ret = EFalse; |
544 TBool ret = EFalse; |
528 |
545 |
529 const TVPbkContactStoreUriPtr uri = |
546 const TVPbkContactStoreUriPtr uri = |
530 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
547 iAppServices->StoreConfiguration().DefaultSavingStoreL(); |
531 StoreConfiguration().DefaultSavingStoreL(); |
|
532 |
548 |
533 TVPbkContactStoreUriPtr phoneMemoryUri |
549 TVPbkContactStoreUriPtr phoneMemoryUri |
534 ( VPbkContactStoreUris::DefaultCntDbUri() ); |
550 ( VPbkContactStoreUris::DefaultCntDbUri() ); |
535 |
551 |
536 if ( uri.Compare( phoneMemoryUri, |
552 if ( uri.Compare( phoneMemoryUri, |