phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 6 e8e3147d53eb
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    41 #include <Pbk2ProcessDecoratorFactory.h>
    41 #include <Pbk2ProcessDecoratorFactory.h>
    42 
    42 
    43 #include <CPbk2MergeConflictsDlg.h>
    43 #include <CPbk2MergeConflictsDlg.h>
    44 #include <CPbk2MergePhotoConflictDlg.h>
    44 #include <CPbk2MergePhotoConflictDlg.h>
    45 
    45 
    46 #include <pbk2uicontrols.rsg> 
    46 #include <Pbk2UIControls.rsg> 
    47 #include <pbk2cmdextres.rsg>
    47 #include <Pbk2CmdExtRes.rsg>
    48 #include <pbk2commonui.rsg>
    48 #include <Pbk2CommonUi.rsg>
    49 //Virtual Phonebook
    49 //Virtual Phonebook
    50 #include <MVPbkContactLink.h>
    50 #include <MVPbkContactLink.h>
    51 #include <MVPbkContactViewBase.h>
    51 #include <MVPbkContactViewBase.h>
    52 #include <CVPbkContactStoreUriArray.h>
    52 #include <CVPbkContactStoreUriArray.h>
    53 #include <MVPbkContactStore.h>
    53 #include <MVPbkContactStore.h>
    55 #include <MVPbkContactOperationBase.h>
    55 #include <MVPbkContactOperationBase.h>
    56 #include <CVPbkContactManager.h>
    56 #include <CVPbkContactManager.h>
    57 #include <MVPbkStoreContact.h>
    57 #include <MVPbkStoreContact.h>
    58 #include <MVPbkContactFieldBinaryData.h>
    58 #include <MVPbkContactFieldBinaryData.h>
    59 #include <MVPbkContactFieldTextData.h>
    59 #include <MVPbkContactFieldTextData.h>
    60 #include <vpbkeng.rsg>
    60 #include <VPbkEng.rsg>
    61 #include <MVPbkContactGroup.h>
    61 #include <MVPbkContactGroup.h>
    62 
    62 
    63 //System
    63 //System
    64 #include <aknnotewrappers.h>
    64 #include <aknnotewrappers.h>
    65 #include <StringLoader.h>
    65 #include <StringLoader.h>
   127         {
   127         {
   128         iUiControl->RegisterCommand( NULL );
   128         iUiControl->RegisterCommand( NULL );
   129         }
   129         }
   130 
   130 
   131     CleanAfterFetching();
   131     CleanAfterFetching();
       
   132     delete iFirstContactString;
       
   133     delete iSecondContactString;
       
   134     delete iMergedContactString;
   132     delete iRetrieveOperation;
   135     delete iRetrieveOperation;
   133     delete iDeleteOperation;
   136     delete iDeleteOperation;
   134     delete iCommitOperation;
   137     delete iCommitOperation;
   135 	delete iDeleteMergedOperation;
   138 	delete iDeleteMergedOperation;
   136     Release( iAppServices );
   139     Release( iAppServices );
   139     delete iMergedContactLink;
   142     delete iMergedContactLink;
   140     delete iStoreContactFirst;
   143     delete iStoreContactFirst;
   141     delete iStoreContactSecond;
   144     delete iStoreContactSecond;
   142     delete iMergedContact;
   145     delete iMergedContact;
   143     delete iMergeResolver;
   146     delete iMergeResolver;
   144     delete iBitmapFirst;
       
   145     delete iBitmapSecond;
       
   146     delete iImgDecoder;
       
   147     delete iWaitDecorator;
   147     delete iWaitDecorator;
   148     if( iGroupsToAdd )
   148     if( iGroupsToAdd )
   149         {
   149         {
   150         iGroupsToAdd->ResetAndDestroy();
   150         iGroupsToAdd->ResetAndDestroy();
   151         delete iGroupsToAdd;
   151         delete iGroupsToAdd;
   200         }    
   200         }    
   201     
   201     
   202     iContactManager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager();
   202     iContactManager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager();
   203     iAppServices = CPbk2ApplicationServices::InstanceL();
   203     iAppServices = CPbk2ApplicationServices::InstanceL();
   204     iPhotoConflictIndex = KErrNotFound;
   204     iPhotoConflictIndex = KErrNotFound;
   205     iDataFirst.Set( KNullDesC8() );
       
   206     iDataSecond.Set( KNullDesC8() );
       
   207     }
   205     }
   208     
   206     
   209 // --------------------------------------------------------------------------
   207 // --------------------------------------------------------------------------
   210 // CPbk2MergeContactsCmd::ExecuteLD
   208 // CPbk2MergeContactsCmd::ExecuteLD
   211 // --------------------------------------------------------------------------
   209 // --------------------------------------------------------------------------
   304     	    GetContactsFromUiFetchL();    	    
   302     	    GetContactsFromUiFetchL();    	    
   305     	    }
   303     	    }
   306     	    break;
   304     	    break;
   307     	case EPhaseGetStoreContacts:
   305     	case EPhaseGetStoreContacts:
   308             {
   306             {
   309             GetStoreContactsL();
   307             GetStoreContacts();
   310             }   
   308             }   
   311             break;
   309             break;
   312     	case EPhaseMerge:
   310     	case EPhaseMerge:
   313     	    {
   311     	    {
   314             AutomaticMergeL();
   312             AutomaticMergeL();
   429 // CPbk2MergeContactsCmd::ShowContactsMergedNoteL
   427 // CPbk2MergeContactsCmd::ShowContactsMergedNoteL
   430 // --------------------------------------------------------------------------
   428 // --------------------------------------------------------------------------
   431 //
   429 //
   432 void CPbk2MergeContactsCmd::ShowContactsMergedNoteL()
   430 void CPbk2MergeContactsCmd::ShowContactsMergedNoteL()
   433     {
   431     {
   434     HBufC* firstContactString = ContactAsStringLC( iStoreContactFirst );
       
   435     HBufC* secondContactString = ContactAsStringLC( iStoreContactSecond );
       
   436     HBufC* mergedContactString = ContactAsStringLC( iMergedContact );
       
   437     HBufC* unnamed = StringLoader::LoadLC( R_QTN_PHOB_UNNAMED );
   432     HBufC* unnamed = StringLoader::LoadLC( R_QTN_PHOB_UNNAMED );
   438     CDesCArrayFlat* strings = new(ELeave) CDesCArrayFlat( 3 );
   433     CDesCArrayFlat* strings = new(ELeave) CDesCArrayFlat( 3 );
   439     CleanupStack::PushL( strings );
   434     CleanupStack::PushL( strings );
   440     
   435     
   441     HBufC* prompt = NULL;
   436     HBufC* prompt = NULL;
   442     if ( (firstContactString->Length() > 0 || secondContactString->Length() > 0)
   437     if ( (iFirstContactString->Length() > 0 || iSecondContactString->Length() > 0)
   443             && mergedContactString->Length() > 0 )
   438             && iMergedContactString->Length() > 0 )
   444         {
   439         {
   445         if ( 0 != firstContactString->Length() )
   440         if ( 0 != iFirstContactString->Length() )
   446             {
   441             {
   447             strings->AppendL( *firstContactString );
   442             strings->AppendL( *iFirstContactString );
   448             }
   443             }
   449         else
   444         else
   450             {
   445             {
   451             strings->AppendL( *unnamed );
   446             strings->AppendL( *unnamed );
   452             }
   447             }
   453         if ( 0 != secondContactString->Length() )
   448         if ( 0 != iSecondContactString->Length() )
   454             {
   449             {
   455             strings->AppendL( *secondContactString );
   450             strings->AppendL( *iSecondContactString );
   456             }
   451             }
   457         else
   452         else
   458             {
   453             {
   459             strings->AppendL( *unnamed );
   454             strings->AppendL( *unnamed );
   460             }
   455             }
   461         strings->AppendL( *mergedContactString );
   456         strings->AppendL( *iMergedContactString );
   462 
   457 
   463         prompt = StringLoader::LoadLC( R_QTN_PHOB_NOTE_CONTACTS_WERE_MERGED, *strings );
   458         prompt = StringLoader::LoadLC( R_QTN_PHOB_NOTE_CONTACTS_WERE_MERGED, *strings );
   464         }
   459         }
   465     else
   460     else
   466         {
   461         {
   473     dlg->SetTextL( *prompt );
   468     dlg->SetTextL( *prompt );
   474     dlg->RunLD();
   469     dlg->RunLD();
   475     CleanupStack::PopAndDestroy( prompt );
   470     CleanupStack::PopAndDestroy( prompt );
   476     CleanupStack::PopAndDestroy( strings );
   471     CleanupStack::PopAndDestroy( strings );
   477     CleanupStack::PopAndDestroy( unnamed );
   472     CleanupStack::PopAndDestroy( unnamed );
   478     CleanupStack::PopAndDestroy( mergedContactString );
   473 
   479     CleanupStack::PopAndDestroy( secondContactString );
       
   480     CleanupStack::PopAndDestroy( firstContactString );
       
   481     }
   474     }
   482 
   475 
   483 // --------------------------------------------------------------------------
   476 // --------------------------------------------------------------------------
   484 // CPbk2MergeContactsCmd::ContactAsStringLC
   477 // CPbk2MergeContactsCmd::ContactAsStringLC
   485 // --------------------------------------------------------------------------
   478 // --------------------------------------------------------------------------
   486 //
   479 //
   487 HBufC* CPbk2MergeContactsCmd::ContactAsStringLC( MVPbkStoreContact* aStoreContact )
   480 HBufC* CPbk2MergeContactsCmd::ContactAsStringL( MVPbkStoreContact* aStoreContact )
   488     {
   481     {
   489     _LIT(KResultFormat, "%S %S");
   482     _LIT(KResultFormat, "%S %S");
   490     TPtrC firstName( KNullDesC() );
   483     TPtrC firstName( KNullDesC() );
   491     TPtrC lastName( KNullDesC() );
   484     TPtrC lastName( KNullDesC() );
   492 	
   485 	
   511         }
   504         }
   512     
   505     
   513     HBufC* result = NULL;
   506     HBufC* result = NULL;
   514     if ( firstName.Length() > 0 && lastName.Length() > 0 )
   507     if ( firstName.Length() > 0 && lastName.Length() > 0 )
   515         {
   508         {
   516         result = HBufC::NewLC( firstName.Length() + lastName.Length() + KResultFormat().Length() );
   509         result = HBufC::NewL( firstName.Length() + lastName.Length() + KResultFormat().Length() );
   517         TPtr resAsDes = result->Des();
   510         TPtr resAsDes = result->Des();
   518         resAsDes.Format( KResultFormat, &firstName, &lastName );
   511         resAsDes.Format( KResultFormat, &firstName, &lastName );
   519         }
   512         }
   520     else if ( firstName.Length() > 0 )
   513     else if ( firstName.Length() > 0 )
   521         {
   514         {
   522         result = firstName.AllocLC(); 
   515         result = firstName.AllocL(); 
   523         }    
   516         }    
   524     else
   517     else
   525         {
   518         {
   526         result = lastName.AllocLC();
   519         result = lastName.AllocL();
   527         }
   520         }
   528     return result;
   521     return result;
   529     }
   522     }
   530 
   523 
   531 // --------------------------------------------------------------------------
   524 // --------------------------------------------------------------------------
   781 
   774 
   782 // --------------------------------------------------------------------------
   775 // --------------------------------------------------------------------------
   783 // CPbk2MergeContactsCmd::RetrieveContactL
   776 // CPbk2MergeContactsCmd::RetrieveContactL
   784 // --------------------------------------------------------------------------
   777 // --------------------------------------------------------------------------
   785 //
   778 //
   786 void CPbk2MergeContactsCmd::RetrieveContactL(
   779 void CPbk2MergeContactsCmd::RetrieveContact(
   787         const MVPbkContactLink& aContactLink )
   780         const MVPbkContactLink& aContactLink )
   788     {
   781     {
   789     // Retrieve the actual store contact from the given link
   782     // Retrieve the actual store contact from the given link
   790     iRetrieveOperation = iAppServices->
   783     TRAPD( error, 
       
   784         iRetrieveOperation = iAppServices->
   791         ContactManager().RetrieveContactL( aContactLink, *this );
   785         ContactManager().RetrieveContactL( aContactLink, *this );
       
   786     );
       
   787     if( error != KErrNone )
       
   788         {
       
   789         Finish( error );
       
   790         }
   792     }
   791     }
   793 
   792 
   794 ////////////////////////////// CALLBACKS /////////////////////////////////////
   793 ////////////////////////////// CALLBACKS /////////////////////////////////////
   795 
   794 
   796 // --------------------------------------------------------------------------
   795 // --------------------------------------------------------------------------
   807         iRetrieveOperation = NULL;
   806         iRetrieveOperation = NULL;
   808 
   807 
   809         if( !iStoreContactFirst )
   808         if( !iStoreContactFirst )
   810             {
   809             {
   811             iStoreContactFirst = aContact;
   810             iStoreContactFirst = aContact;
   812             TRAP_IGNORE( RetrieveContactL( *iContactSecond ) ); 
   811             TRAPD( error, iStoreContactFirst->LockL( *this ) );
       
   812             if( error != KErrNone )
       
   813                 {
       
   814                 Finish( error );
       
   815                 }
   813             }
   816             }
   814         else if( !iStoreContactSecond )
   817         else if( !iStoreContactSecond )
   815             {
   818             {
   816             iStoreContactSecond = aContact;
   819             iStoreContactSecond = aContact;
   817             StartNext();
   820             TRAPD( error, iStoreContactSecond->LockL( *this ) );
       
   821             if( error != KErrNone )
       
   822                 {
       
   823                 Finish( error );
       
   824                 }
   818             }
   825             }
   819         else if( iNextPhase == EPhaseGetGroups 
   826         else if( iNextPhase == EPhaseGetGroups 
   820                  && aContact->Group()
   827                  && aContact->Group()
   821                  && iGroupLinksFirst 
   828                  && iGroupLinksFirst 
   822                  && iGroupLinksSecond
   829                  && iGroupLinksSecond
   864             countFirst = iGroupLinksFirst->Count();
   871             countFirst = iGroupLinksFirst->Count();
   865             countSecond = iGroupLinksSecond->Count();
   872             countSecond = iGroupLinksSecond->Count();
   866             
   873             
   867             if( countFirst )
   874             if( countFirst )
   868                 {
   875                 {
   869                 TRAP( error, RetrieveContactL( iGroupLinksFirst->At( countFirst - 1 ) ); );
   876                 RetrieveContact( iGroupLinksFirst->At( countFirst - 1 ) );
   870                 }
   877                 }
   871             else if( countSecond )
   878             else if( countSecond )
   872                 {
   879                 {
   873                 TRAP( error, RetrieveContactL( iGroupLinksSecond->At( countSecond - 1 ) ); );
   880                 RetrieveContact( iGroupLinksSecond->At( countSecond - 1 ) );
   874                 }
   881                 }
   875             else
   882             else
   876                 {
   883                 {
   877                 StartNext( EPhaseAddGroups );
   884                 StartNext( EPhaseAddGroups );
   878                 }
   885                 }
   912 // --------------------------------------------------------------------------
   919 // --------------------------------------------------------------------------
   913 //
   920 //
   914 void CPbk2MergeContactsCmd::ContactOperationCompleted(
   921 void CPbk2MergeContactsCmd::ContactOperationCompleted(
   915         TContactOpResult aResult )
   922         TContactOpResult aResult )
   916     {
   923     {
   917     if( aResult.iOpCode == MVPbkContactObserver::EContactLock )
   924     if( aResult.iOpCode == MVPbkContactObserver::EContactLock 
       
   925             && iNextPhase == EPhaseGetStoreContacts && !iStoreContactSecond )
       
   926         {
       
   927         RetrieveContact( *iContactSecond );
       
   928         }
       
   929     else if( aResult.iOpCode == MVPbkContactObserver::EContactLock 
       
   930             && iNextPhase == EPhaseGetStoreContacts )
       
   931         {
       
   932         StartNext( EPhaseMerge );
       
   933         }
       
   934     else if( aResult.iOpCode == MVPbkContactObserver::EContactLock )
   918         {
   935         {
   919         TInt countGroups = iGroupsToAdd->Count();
   936         TInt countGroups = iGroupsToAdd->Count();
   920         if( countGroups )
   937         if( countGroups )
   921             {
   938             {
   922             MVPbkStoreContact* group = iGroupsToAdd->At( countGroups - 1 );
   939             MVPbkStoreContact* group = iGroupsToAdd->At( countGroups - 1 );
   968 // --------------------------------------------------------------------------
   985 // --------------------------------------------------------------------------
   969 // CPbk2MergeContactsCmd::ContactOperationFailed
   986 // CPbk2MergeContactsCmd::ContactOperationFailed
   970 // --------------------------------------------------------------------------
   987 // --------------------------------------------------------------------------
   971 //
   988 //
   972 void CPbk2MergeContactsCmd::ContactOperationFailed(
   989 void CPbk2MergeContactsCmd::ContactOperationFailed(
   973         TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/ )
   990         TContactOp aOpCode, TInt aErrorCode, TBool /*aErrorNotified*/ )
   974     {
   991     {
   975     DeleteMergedContact();
   992     if( aOpCode == MVPbkContactObserver::EContactLock && iNextPhase == EPhaseGetStoreContacts )
       
   993         {
       
   994         Finish( aErrorCode );
       
   995         }
       
   996     else
       
   997         {
       
   998         DeleteMergedContact();
       
   999         }
   976     }
  1000     }
   977 
  1001 
   978 // --------------------------------------------------------------------------
  1002 // --------------------------------------------------------------------------
   979 // CPbk2MergeContactsCmd::ProcessDismissed
  1003 // CPbk2MergeContactsCmd::ProcessDismissed
   980 // --------------------------------------------------------------------------
  1004 // --------------------------------------------------------------------------
  1221                 if( versitProp.Name() == EVPbkVersitNamePHOTO )
  1245                 if( versitProp.Name() == EVPbkVersitNamePHOTO )
  1222                     {
  1246                     {
  1223                     if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && 
  1247                     if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && 
  1224                             secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary )
  1248                             secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary )
  1225                         {
  1249                         {
  1226                         iDataFirst.Set( MVPbkContactFieldBinaryData::Cast
       
  1227                             ( firstField->FieldData() ).BinaryData() );
       
  1228                         iDataSecond.Set( MVPbkContactFieldBinaryData::Cast
       
  1229                             ( secondField->FieldData() ).BinaryData() );
       
  1230                         
       
  1231                         iPhotoConflictIndex = i;
  1250                         iPhotoConflictIndex = i;
  1232                         break;
  1251                         break;
  1233                         }
  1252                         }
  1234                     }
  1253                     }
  1235                 }
  1254                 }
  1265         {
  1284         {
  1266         StartNext( EPhaseCreateMergedContact );
  1285         StartNext( EPhaseCreateMergedContact );
  1267         return;
  1286         return;
  1268         }
  1287         }
  1269     
  1288     
  1270     if ( iDataFirst.Length() == 0 || iDataSecond.Length() == 0 )
       
  1271         {
       
  1272         StartNext( EPhaseFinish );
       
  1273         return;
       
  1274         }
       
  1275     
       
  1276     if ( !iBitmapFirst )
       
  1277         {
       
  1278         InitBitmapL( iBitmapFirst, iDataFirst );
       
  1279         return;
       
  1280         }
       
  1281     if ( !iBitmapSecond )
       
  1282         {
       
  1283         InitBitmapL( iBitmapSecond, iDataSecond  );
       
  1284         return;
       
  1285         }
       
  1286     
       
  1287     delete iImgDecoder;
       
  1288     iImgDecoder = NULL;
       
  1289     TInt result = EPbk2ConflictedFirst;
  1289     TInt result = EPbk2ConflictedFirst;
  1290     
  1290     
  1291     CPbk2MergePhotoConflictDlg* dlg = 
  1291     CPbk2MergePhotoConflictDlg* dlg = 
  1292         CPbk2MergePhotoConflictDlg::NewL( iBitmapFirst, iBitmapSecond, &result );
  1292         CPbk2MergePhotoConflictDlg::NewL( iStoreContactFirst, iStoreContactSecond, &result );
  1293     if ( !dlg->ExecuteLD( R_PBK2_MERGE_CONTACTS_PHOTO_CONFLICT_RESOLUTION_DLG ) )
  1293     if ( !dlg->ExecuteLD( R_PBK2_MERGE_CONTACTS_PHOTO_CONFLICT_RESOLUTION_DLG ) )
  1294         {
  1294         {
  1295         // dlg returns 0 if canceled
  1295         // dlg returns 0 if canceled
  1296         Finish( KErrNone );
  1296         Finish( KErrNone );
  1297         }
  1297         }
  1298     else
  1298     else
  1299         {
  1299         {
  1300         ResolveAllPhotoConflicts( (EPbk2ConflictedNumber) result );
  1300         ResolveAllPhotoConflicts( (EPbk2ConflictedNumber) result );
  1301         StartNext( EPhaseCreateMergedContact );
  1301         StartNext( EPhaseCreateMergedContact );
  1302         }
  1302         }
  1303     delete iBitmapFirst;
       
  1304     iBitmapFirst = NULL;
       
  1305     delete iBitmapSecond;
       
  1306     iBitmapSecond = NULL;
       
  1307     }
       
  1308 
       
  1309 // --------------------------------------------------------------------------
       
  1310 // CPbk2MergeContactsCmd::InitBitmapL
       
  1311 // --------------------------------------------------------------------------
       
  1312 //
       
  1313 void CPbk2MergeContactsCmd::InitBitmapL( CFbsBitmap*& aBitmap, TDesC8& aData )
       
  1314     {
       
  1315     delete iImgDecoder;
       
  1316     iImgDecoder = NULL;
       
  1317     iImgDecoder = CImageDecoder::DataNewL
       
  1318         ( iContactManager->FsSession(), aData, CImageDecoder::EOptionAlwaysThread );
       
  1319     
       
  1320     TFrameInfo info = iImgDecoder->FrameInfo();
       
  1321     aBitmap = new ( ELeave ) CFbsBitmap;
       
  1322     User::LeaveIfError( aBitmap->Create
       
  1323         ( info.iOverallSizeInPixels, info.iFrameDisplayMode ));
       
  1324     
       
  1325     iImgDecoder->Convert( &iStatus, *aBitmap );
       
  1326     SetActive();
       
  1327     }
  1303     }
  1328 
  1304 
  1329 // --------------------------------------------------------------------------
  1305 // --------------------------------------------------------------------------
  1330 // CPbk2MergeContactsCmd::AddFieldToMergedContactL
  1306 // CPbk2MergeContactsCmd::AddFieldToMergedContactL
  1331 // --------------------------------------------------------------------------
  1307 // --------------------------------------------------------------------------
  1380 
  1356 
  1381 // --------------------------------------------------------------------------
  1357 // --------------------------------------------------------------------------
  1382 // CPbk2MergeContactsCmd::GetStoreContactsL
  1358 // CPbk2MergeContactsCmd::GetStoreContactsL
  1383 // --------------------------------------------------------------------------
  1359 // --------------------------------------------------------------------------
  1384 //
  1360 //
  1385 void CPbk2MergeContactsCmd::GetStoreContactsL()
  1361 void CPbk2MergeContactsCmd::GetStoreContacts()
  1386     {
  1362     {
  1387     if( iContactFirst && iContactSecond )
  1363     if( iContactFirst && iContactSecond )
  1388         {
  1364         {
  1389         if( !iStoreContactFirst )
  1365         if( !iStoreContactFirst )
  1390             {
  1366             {
  1391             RetrieveContactL( *iContactFirst );
  1367             RetrieveContact( *iContactFirst );
  1392             }
       
  1393         else if( iStoreContactSecond )
       
  1394             {
       
  1395             StartNext( EPhaseMerge );
       
  1396             }
  1368             }
  1397         else
  1369         else
  1398             {
  1370             {
  1399             Finish( KErrArgument );
  1371             Finish( KErrArgument );
  1400             }
  1372             }
  1411 //
  1383 //
  1412 void CPbk2MergeContactsCmd::DeleteSourceContactsL()
  1384 void CPbk2MergeContactsCmd::DeleteSourceContactsL()
  1413     {
  1385     {
  1414     User::LeaveIfNull( iContactFirst );
  1386     User::LeaveIfNull( iContactFirst );
  1415     User::LeaveIfNull( iContactSecond );
  1387     User::LeaveIfNull( iContactSecond );
       
  1388     
       
  1389     iFirstContactString = ContactAsStringL( iStoreContactFirst );
       
  1390     iSecondContactString = ContactAsStringL( iStoreContactSecond );
       
  1391     iMergedContactString = ContactAsStringL( iMergedContact );
       
  1392     
       
  1393     delete iStoreContactFirst;
       
  1394     iStoreContactFirst = NULL;
       
  1395     
       
  1396     delete iStoreContactSecond;
       
  1397     iStoreContactSecond = NULL;
       
  1398     
  1416     if( iContactsToDelete )
  1399     if( iContactsToDelete )
  1417         {
  1400         {
  1418         delete iContactsToDelete;
  1401         delete iContactsToDelete;
  1419         iContactsToDelete = NULL;
  1402         iContactsToDelete = NULL;
  1420         }
  1403         }
  1502         TInt countFirst = iGroupLinksFirst->Count();
  1485         TInt countFirst = iGroupLinksFirst->Count();
  1503         TInt countSecond = iGroupLinksSecond->Count();
  1486         TInt countSecond = iGroupLinksSecond->Count();
  1504         
  1487         
  1505         if( countFirst )
  1488         if( countFirst )
  1506             {
  1489             {
  1507             RetrieveContactL( iGroupLinksFirst->At( countFirst - 1 ) );
  1490             RetrieveContact( iGroupLinksFirst->At( countFirst - 1 ) );
  1508             }
  1491             }
  1509         else if( countSecond )
  1492         else if( countSecond )
  1510             {
  1493             {
  1511             RetrieveContactL( iGroupLinksSecond->At( countSecond - 1 ) );
  1494             RetrieveContact( iGroupLinksSecond->At( countSecond - 1 ) );
  1512             }
  1495             }
  1513         else
  1496         else
  1514             {
  1497             {
  1515             DeleteSourceContactsL();
  1498             DeleteSourceContactsL();
  1516             }
  1499             }