74 /// Unnamed namespace for local definitions |
74 /// Unnamed namespace for local definitions |
75 namespace { |
75 namespace { |
76 |
76 |
77 const TInt KFirstContact = 0; |
77 const TInt KFirstContact = 0; |
78 const TInt KSecondContact = 1; |
78 const TInt KSecondContact = 1; |
|
79 const TInt KAmountToMerge = 2; |
|
80 const TInt KDeletionDelay = 1000000; // 1s |
79 |
81 |
80 _LIT( KLocalStore, "cntdb://c:contacts.cdb" ); |
82 _LIT( KLocalStore, "cntdb://c:contacts.cdb" ); |
81 |
83 |
82 enum TPbk2PanicCodes |
84 enum TPbk2PanicCodes |
83 { |
85 { |
127 { |
129 { |
128 iUiControl->RegisterCommand( NULL ); |
130 iUiControl->RegisterCommand( NULL ); |
129 } |
131 } |
130 |
132 |
131 CleanAfterFetching(); |
133 CleanAfterFetching(); |
|
134 iTimer.Cancel(); |
|
135 iTimer.Close(); |
132 delete iFirstContactString; |
136 delete iFirstContactString; |
133 delete iSecondContactString; |
137 delete iSecondContactString; |
134 delete iMergedContactString; |
138 delete iMergedContactString; |
135 delete iRetrieveOperation; |
139 delete iRetrieveOperation; |
136 delete iDeleteOperation; |
140 delete iDeleteOperation; |
200 } |
204 } |
201 |
205 |
202 iContactManager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(); |
206 iContactManager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(); |
203 iAppServices = CPbk2ApplicationServices::InstanceL(); |
207 iAppServices = CPbk2ApplicationServices::InstanceL(); |
204 iPhotoConflictIndex = KErrNotFound; |
208 iPhotoConflictIndex = KErrNotFound; |
|
209 User::LeaveIfError( iTimer.CreateLocal() ); |
205 } |
210 } |
206 |
211 |
207 // -------------------------------------------------------------------------- |
212 // -------------------------------------------------------------------------- |
208 // CPbk2MergeContactsCmd::ExecuteLD |
213 // CPbk2MergeContactsCmd::ExecuteLD |
209 // -------------------------------------------------------------------------- |
214 // -------------------------------------------------------------------------- |
485 |
490 |
486 MVPbkStoreContactFieldCollection& fields = aStoreContact->Fields(); |
491 MVPbkStoreContactFieldCollection& fields = aStoreContact->Fields(); |
487 for ( TInt i(0); i < fields.FieldCount(); ++i ) |
492 for ( TInt i(0); i < fields.FieldCount(); ++i ) |
488 { |
493 { |
489 MVPbkStoreContactField& field = fields.FieldAt( i ); |
494 MVPbkStoreContactField& field = fields.FieldAt( i ); |
490 if ( field.BestMatchingFieldType()->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME ) |
495 const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
491 { |
496 if ( fieldType ) |
492 MVPbkContactFieldData& data = field.FieldData(); |
497 { |
493 __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) ); |
498 if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME ) |
494 MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data ); |
499 { |
495 firstName.Set( textData.Text() ); |
500 MVPbkContactFieldData& data = field.FieldData(); |
496 } |
501 __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) ); |
497 else if ( field.BestMatchingFieldType()->FieldTypeResId() == R_VPBK_FIELD_TYPE_LASTNAME ) |
502 MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data ); |
498 { |
503 firstName.Set( textData.Text() ); |
499 MVPbkContactFieldData& data = field.FieldData(); |
504 } |
500 __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) ); |
505 else if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LASTNAME ) |
501 MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data ); |
506 { |
502 lastName.Set( textData.Text() ); |
507 MVPbkContactFieldData& data = field.FieldData(); |
|
508 __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) ); |
|
509 MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data ); |
|
510 lastName.Set( textData.Text() ); |
|
511 } |
503 } |
512 } |
504 } |
513 } |
505 |
514 |
506 HBufC* result = NULL; |
515 HBufC* result = NULL; |
507 if ( firstName.Length() > 0 && lastName.Length() > 0 ) |
516 if ( firstName.Length() > 0 && lastName.Length() > 0 ) |
638 __ASSERT_DEBUG( !iAllContactsView, Panic( EPbk2ViewsAlreadyCreated )); |
647 __ASSERT_DEBUG( !iAllContactsView, Panic( EPbk2ViewsAlreadyCreated )); |
639 CPbk2FetchDlg::TParams params; |
648 CPbk2FetchDlg::TParams params; |
640 params.iResId = R_PBK2_MULTIPLE_ENTRY_FETCH_NO_GROUPS_DLG; |
649 params.iResId = R_PBK2_MULTIPLE_ENTRY_FETCH_NO_GROUPS_DLG; |
641 params.iCbaId = R_PBK2_SOFTKEYS_MERGE_BACK_MARK; |
650 params.iCbaId = R_PBK2_SOFTKEYS_MERGE_BACK_MARK; |
642 params.iNaviPaneId = R_PBK2_MERGE_CONTACTS_FETCH_NAVILABEL; |
651 params.iNaviPaneId = R_PBK2_MERGE_CONTACTS_FETCH_NAVILABEL; |
|
652 params.iMinSelection = KAmountToMerge; |
643 |
653 |
644 CPbk2StorePropertyArray& storeProperties = |
654 CPbk2StorePropertyArray& storeProperties = |
645 Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties(); |
655 Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties(); |
646 |
656 |
647 // Fetch dlg uses this view instead of AllNameslistView if it is not suitable |
657 // Fetch dlg uses this view instead of AllNameslistView if it is not suitable |
751 // CPbk2MergeContactsCmd::StartNext |
761 // CPbk2MergeContactsCmd::StartNext |
752 // --------------------------------------------------------------------------- |
762 // --------------------------------------------------------------------------- |
753 // |
763 // |
754 void CPbk2MergeContactsCmd::StartNext( TPhase aPhase ) |
764 void CPbk2MergeContactsCmd::StartNext( TPhase aPhase ) |
755 { |
765 { |
756 __ASSERT_DEBUG( !IsActive(), Panic( EPbk2WronglyActivated )); |
766 __ASSERT_DEBUG( !IsActive(), Panic( EPbk2WronglyActivated )); |
757 iNextPhase = aPhase; |
767 |
758 TRequestStatus* status = &iStatus; |
768 iNextPhase = aPhase; |
759 User::RequestComplete(status, KErrNone); |
769 |
|
770 if ( iNextPhase == EPhaseGetGroups ) |
|
771 { |
|
772 iTimer.After( iStatus, KDeletionDelay ); |
|
773 } |
|
774 else |
|
775 { |
|
776 TRequestStatus* status = &iStatus; |
|
777 User::RequestComplete( status, KErrNone ); |
|
778 } |
760 SetActive(); |
779 SetActive(); |
761 } |
780 } |
762 |
781 |
763 // --------------------------------------------------------------------------- |
782 // --------------------------------------------------------------------------- |
764 // CPbk2MergeContactsCmd::StartNext |
783 // CPbk2MergeContactsCmd::StartNext |
1234 const MVPbkStoreContactField* firstField; |
1253 const MVPbkStoreContactField* firstField; |
1235 const MVPbkStoreContactField* secondField; |
1254 const MVPbkStoreContactField* secondField; |
1236 conflict.GetFieldsL( firstField, secondField ); |
1255 conflict.GetFieldsL( firstField, secondField ); |
1237 |
1256 |
1238 const MVPbkFieldType* fieldType = firstField->BestMatchingFieldType(); |
1257 const MVPbkFieldType* fieldType = firstField->BestMatchingFieldType(); |
1239 TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties(); |
1258 if ( fieldType ) |
1240 TInt count = versitPropArr.Count(); |
1259 { |
1241 |
1260 TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties(); |
1242 for( TInt idx = 0; idx < count; idx++ ) |
1261 TInt count = versitPropArr.Count(); |
1243 { |
1262 |
1244 TVPbkFieldVersitProperty versitProp = versitPropArr[idx]; |
1263 for( TInt idx = 0; idx < count; idx++ ) |
1245 if( versitProp.Name() == EVPbkVersitNamePHOTO ) |
|
1246 { |
1264 { |
1247 if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && |
1265 TVPbkFieldVersitProperty versitProp = versitPropArr[idx]; |
1248 secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary ) |
1266 if( versitProp.Name() == EVPbkVersitNamePHOTO ) |
1249 { |
1267 { |
1250 iPhotoConflictIndex = i; |
1268 if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && |
1251 break; |
1269 secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary ) |
|
1270 { |
|
1271 iPhotoConflictIndex = i; |
|
1272 break; |
|
1273 } |
1252 } |
1274 } |
1253 } |
1275 } |
1254 } |
1276 } |
1255 } |
1277 } |
1256 } |
1278 } |