phonebookui/Phonebook2/GroupExtension/src/CPguAddMembersCmd.cpp
branchRCL_3
changeset 32 2828b4d142c0
parent 0 e686773b3f54
child 35 4ae315f230bc
equal deleted inserted replaced
26:0d28c1c5b6dd 32:2828b4d142c0
    86 CPguAddMembersCmd::CPguAddMembersCmd
    86 CPguAddMembersCmd::CPguAddMembersCmd
    87         ( MVPbkContactLink& aContactGroup,
    87         ( MVPbkContactLink& aContactGroup,
    88           MPbk2ContactUiControl& aUiControl ) :
    88           MPbk2ContactUiControl& aUiControl ) :
    89             CActive( CActive::EPriorityStandard ),
    89             CActive( CActive::EPriorityStandard ),
    90             iUiControl( &aUiControl ),
    90             iUiControl( &aUiControl ),
    91             iGroupLink( aContactGroup )
    91             iGroupLink( aContactGroup ),
       
    92             iAddedContactsCount( 0 )
    92     {
    93     {
    93     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
    94     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
    94             ("CPguAddMembersCmd::CPguAddMembersCmd(0x%x)"), this);
    95             ("CPguAddMembersCmd::CPguAddMembersCmd(0x%x)"), this);
    95 
    96 
    96     CActiveScheduler::Add( this );
    97     CActiveScheduler::Add( this );
   248 // CPguAddMembersCmd::RunError
   249 // CPguAddMembersCmd::RunError
   249 // --------------------------------------------------------------------------
   250 // --------------------------------------------------------------------------
   250 //
   251 //
   251 TInt CPguAddMembersCmd::RunError( TInt aError )
   252 TInt CPguAddMembersCmd::RunError( TInt aError )
   252     {
   253     {
   253     if ( aError != KErrNone )
   254     if ( iState == EAddingContactsToGroup && aError == KErrInUse &&
       
   255          iEntriesToAdd && iEntriesToAdd->Count() > KOneContact )
       
   256         {    
       
   257         // Incase there was more than just one contact being added, ignore
       
   258         // the KErrInUse error and continue with the remaining contacts
       
   259         iState = EAddingContactsToGroup;
       
   260         IssueRequest();   
       
   261         }
       
   262     else if ( aError != KErrNone )
   254         {
   263         {
   255         FinishCommand( aError );
   264         FinishCommand( aError );
   256         }
   265         }
   257 
   266 
   258     return KErrNone;
   267     return KErrNone;
   741 // --------------------------------------------------------------------------
   750 // --------------------------------------------------------------------------
   742 // CPguAddMembersCmd::AddContactsToGroupL
   751 // CPguAddMembersCmd::AddContactsToGroupL
   743 // --------------------------------------------------------------------------
   752 // --------------------------------------------------------------------------
   744 //
   753 //
   745 void CPguAddMembersCmd::AddContactsToGroupL()
   754 void CPguAddMembersCmd::AddContactsToGroupL()
   746     {
   755     { 
   747     TInt count = 0;
   756     if (iEntriesToAdd && 
   748     if ( iEntriesToAdd )
   757         iAddedContactsCount < iEntriesToAdd->Count() )
   749         {
   758         { 
   750         count = iEntriesToAdd->Count();
   759         const MVPbkContactLink& contactToAdd = iEntriesToAdd->At( iAddedContactsCount );
   751         }
   760         iAddedContactsCount++; 
   752 
   761         
   753     for ( TInt i = 0; i < count; ++i )
   762         // If leaves, RunError called
   754         {
   763         iContactGroup->AddContactL( contactToAdd );
   755         TRAPD( err, iContactGroup->AddContactL( iEntriesToAdd->At( i ) ) );
   764       
   756         if ( iDecorator )
   765         if ( iDecorator )
   757             {
   766             {
   758             iDecorator->ProcessAdvance( 1 );
   767             iDecorator->ProcessAdvance( 1 );
   759             }
   768             }     
   760         if ( err == KErrInUse )
   769         iState = EAddingContactsToGroup;
   761             {
   770         }
   762             if ( iEntriesToAdd->Count() == 1 )      		
   771     else
   763                 {
   772         {
   764                 User::Leave( err );
   773         iState = ECommitingTransaction;
   765                 }
   774         }
   766             }
   775     
   767         else
       
   768             {
       
   769             User::LeaveIfError( err );
       
   770             }
       
   771         }
       
   772     iState = ECommitingTransaction;
       
   773     IssueRequest();
   776     IssueRequest();
   774     }
   777     }
   775 
   778 
   776 // --------------------------------------------------------------------------
   779 // --------------------------------------------------------------------------
   777 // CPguAddMembersCmd::CommitTransactionL
   780 // CPguAddMembersCmd::CommitTransactionL