phonebookui/Phonebook2/GroupExtension/src/CPguRemoveFromGroupCmd.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Phonebook 2 Group UI Extension remove from group command.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPguRemoveFromGroupCmd.h"
       
    21 
       
    22 // Phonebook2
       
    23 #include <Pbk2GroupUIRes.rsg>
       
    24 #include <MPbk2CommandObserver.h>
       
    25 #include <MPbk2ContactUiControl.h>
       
    26 #include <CPbk2GeneralConfirmationQuery.h>
       
    27 #include <MPbk2ApplicationServices.h>
       
    28 #include <MPbk2AppUi.h>
       
    29 
       
    30 // Virtual Phonebook
       
    31 #include <CVPbkContactManager.h>
       
    32 #include <MVPbkContactLink.h>
       
    33 #include <MVPbkContactGroup.h>
       
    34 #include <MVPbkContactOperationBase.h>
       
    35 
       
    36 // System includes
       
    37 #include <coemain.h>
       
    38 #include <eikprogi.h> // CEikProgessInfo
       
    39 #include <akninputblock.h>
       
    40 
       
    41 // Debugging headers
       
    42 #include <Pbk2Debug.h>
       
    43 
       
    44 /// Unnamed namespace for local definitions
       
    45 namespace {
       
    46 
       
    47 const TInt KOne( 1 );
       
    48 const TInt KFirstContact( 0 );
       
    49 
       
    50 #ifdef _DEBUG
       
    51 
       
    52 enum TPanicCode
       
    53     {
       
    54     EPanicPreCond_ExecuteLD = 1,
       
    55     EPanicContactNotGroup, 
       
    56     EInvalidState,
       
    57     EPanicNullPointer
       
    58     };
       
    59 
       
    60 void Panic( TPanicCode aReason )
       
    61     {
       
    62     _LIT( KPanicText, "CPguRemoveFromGroupCmd" );
       
    63     User::Panic( KPanicText, aReason );
       
    64     }
       
    65 
       
    66 #endif // _DEBUG
       
    67 
       
    68 } /// namespace
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // CPbk2AknProgressDialog::CPbk2AknProgressDialog
       
    72 // --------------------------------------------------------------------------
       
    73 // 
       
    74 CPbk2AknProgressDialog::CPbk2AknProgressDialog(
       
    75 		CEikDialog** aSelfPtr,
       
    76 		TBool aVisibilityDelayOff ):
       
    77 	CAknProgressDialog( aSelfPtr, aVisibilityDelayOff ),
       
    78 	iEndCallKeyPressed( EFalse )
       
    79 	{
       
    80 	
       
    81 	}
       
    82 		
       
    83 // --------------------------------------------------------------------------
       
    84 // CPbk2AknProgressDialog::~CPbk2AknProgressDialog
       
    85 // --------------------------------------------------------------------------
       
    86 //
       
    87 CPbk2AknProgressDialog::~CPbk2AknProgressDialog()
       
    88     {
       
    89 
       
    90     }
       
    91 
       
    92 // --------------------------------------------------------------------------
       
    93 // CPbk2AknProgressDialog::OfferKeyEventL
       
    94 // --------------------------------------------------------------------------
       
    95 //
       
    96 TKeyResponse CPbk2AknProgressDialog::OfferKeyEventL
       
    97         ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
    98 	{	
       
    99 	if( aType == EEventKey  && aKeyEvent.iCode == EKeyEscape )
       
   100 		{
       
   101 		if( !iEndCallKeyPressed )
       
   102 		    {
       
   103 		    iEndCallKeyPressed = ETrue;
       
   104 		    }
       
   105 		}
       
   106 	return CAknProgressDialog::OfferKeyEventL( aKeyEvent, aType );
       
   107 	}
       
   108 
       
   109 // --------------------------------------------------------------------------
       
   110 // CPbk2AknProgressDialog::OkToExitL
       
   111 // --------------------------------------------------------------------------
       
   112 //
       
   113 TBool CPbk2AknProgressDialog::OkToExitL(TInt aButtonId)
       
   114 	{
       
   115 	if( iEndCallKeyPressed )
       
   116 		{
       
   117 		iEndCallKeyPressed = EFalse;
       
   118 	    if ( iCallback )
       
   119             {
       
   120             iCallback->DialogDismissedL(aButtonId);
       
   121             }
       
   122         return ETrue;
       
   123 		}	
       
   124 	return CAknProgressDialog::OkToExitL( aButtonId );
       
   125 	}
       
   126 
       
   127 // --------------------------------------------------------------------------
       
   128 // CPguRemoveFromGroupCmd::CPguRemoveFromGroupCmd
       
   129 // --------------------------------------------------------------------------
       
   130 //    
       
   131 CPguRemoveFromGroupCmd::CPguRemoveFromGroupCmd(
       
   132 	    MVPbkContactLink& aContactGroup, 
       
   133 	    MPbk2ContactUiControl& aUiControl ) :
       
   134 	CActive( EPriorityIdle ),
       
   135     iUiControl( &aUiControl ),
       
   136     iGroupLink( aContactGroup )
       
   137     {
       
   138     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   139         ("CPguRemoveFromGroupCmd::CPguRemoveFromGroupCmd(0x%x)"),this);
       
   140     CActiveScheduler::Add( this );
       
   141     }
       
   142 
       
   143 // --------------------------------------------------------------------------
       
   144 // CPguRemoveFromGroupCmd::~CPguRemoveFromGroupCmd
       
   145 // --------------------------------------------------------------------------
       
   146 //
       
   147 CPguRemoveFromGroupCmd::~CPguRemoveFromGroupCmd()
       
   148     {
       
   149     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   150         ("CPguRemoveFromGroupCmd::~CPguRemoveFromGroupCmd(0x%x)"),
       
   151         this);
       
   152 	Cancel();
       
   153     if( iUiControl )
       
   154         {
       
   155         iUiControl->RegisterCommand( NULL );
       
   156         }
       
   157 	
       
   158 	delete iSelectedContacts;
       
   159 	delete iProgressDialog;
       
   160 	delete iStoreContact;
       
   161     delete iRetrieveOperation;
       
   162     delete iContactGroup;
       
   163     delete iInputBlock;
       
   164     }
       
   165 
       
   166 // --------------------------------------------------------------------------
       
   167 // CPguRemoveFromGroupCmd::NewLC
       
   168 // --------------------------------------------------------------------------
       
   169 //
       
   170 CPguRemoveFromGroupCmd* CPguRemoveFromGroupCmd::NewLC(
       
   171         MVPbkContactLink& aContactGroup, 
       
   172         MPbk2ContactUiControl& aUiControl )
       
   173     {
       
   174     CPguRemoveFromGroupCmd* self = new(ELeave) CPguRemoveFromGroupCmd(
       
   175                                         aContactGroup, aUiControl );
       
   176     CleanupStack::PushL( self );
       
   177     self->ConstructL();
       
   178     return self;
       
   179     }
       
   180 
       
   181 // --------------------------------------------------------------------------
       
   182 // CPguRemoveFromGroupCmd::ConstructL
       
   183 // --------------------------------------------------------------------------
       
   184 //
       
   185 inline void CPguRemoveFromGroupCmd::ConstructL()
       
   186     {
       
   187     // UI input not allowed during async. operation
       
   188     ReactivateUIBlockL();   
       
   189     
       
   190     // Save focus 
       
   191     iFocusedContactIndex = iUiControl->FocusedContactIndex();
       
   192 
       
   193 	iSelectedContacts = iUiControl->SelectedContactsOrFocusedContactL();
       
   194 	__ASSERT_DEBUG(iSelectedContacts, Panic(EPanicNullPointer));
       
   195 	iTotalContactsToRemove = iSelectedContacts->Count();    
       
   196     iUiControl->RegisterCommand( this );
       
   197     }
       
   198 
       
   199 // --------------------------------------------------------------------------
       
   200 // CPguRemoveFromGroupCmd::ExecuteLD
       
   201 // --------------------------------------------------------------------------
       
   202 //
       
   203 void CPguRemoveFromGroupCmd::ExecuteLD()
       
   204     {
       
   205     __ASSERT_DEBUG(iCommandObserver, Panic(EPanicPreCond_ExecuteLD));
       
   206     
       
   207     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
       
   208         ("CPguRemoveFromGroupCmd::ExecuteLD(0x%x)"), this);
       
   209 
       
   210     CleanupStack::PushL( this );
       
   211 	 
       
   212     if ( iSelectedContacts )
       
   213         {
       
   214         if ( iSelectedContacts->Count() > KOne )
       
   215             {
       
   216             // Move straight to confirm phase
       
   217             iState = EConfirming;
       
   218             IssueRequest();
       
   219             }
       
   220         else if ( iSelectedContacts->Count() == KOne )
       
   221             {
       
   222             // If the array contains only one contact, we have to retrieve it
       
   223             // to get its name for the confirmation query
       
   224             iState = ERetrieving;
       
   225             IssueRequest();
       
   226             }
       
   227         }
       
   228         
       
   229     CleanupStack::Pop( this );
       
   230     }  
       
   231 
       
   232 // --------------------------------------------------------------------------
       
   233 // CPguRemoveFromGroupCmd::AddObserver
       
   234 // --------------------------------------------------------------------------
       
   235 //        
       
   236 void CPguRemoveFromGroupCmd::AddObserver( MPbk2CommandObserver& aObserver )
       
   237     {
       
   238     iCommandObserver = &aObserver;
       
   239     }
       
   240 
       
   241 // --------------------------------------------------------------------------
       
   242 // CPguRemoveFromGroupCmd::ResetUiControl
       
   243 // --------------------------------------------------------------------------
       
   244 //
       
   245 void CPguRemoveFromGroupCmd::ResetUiControl
       
   246         ( MPbk2ContactUiControl& aUiControl )
       
   247     {
       
   248     if ( iUiControl == &aUiControl )
       
   249         {
       
   250         iUiControl = NULL;
       
   251         }
       
   252     }
       
   253 
       
   254 // --------------------------------------------------------------------------
       
   255 // CPguRemoveFromGroupCmd::DoCancel
       
   256 // --------------------------------------------------------------------------
       
   257 //
       
   258 void CPguRemoveFromGroupCmd::DoCancel()
       
   259     {
       
   260     delete iRetrieveOperation;
       
   261     iRetrieveOperation = NULL;
       
   262     if (iUiControl)
       
   263         {
       
   264         iUiControl->SetBlank( EFalse );
       
   265         }    
       
   266     TRAP_IGNORE( DeleteProgressNoteL() );
       
   267     }
       
   268 
       
   269 // --------------------------------------------------------------------------
       
   270 // CPguRemoveFromGroupCmd::RunL
       
   271 // --------------------------------------------------------------------------
       
   272 //    
       
   273 void CPguRemoveFromGroupCmd::RunL()
       
   274     {
       
   275     PBK2_DEBUG_PRINT
       
   276         (PBK2_DEBUG_STRING("CPguRemoveFromGroupCmd::RunL()"), this);
       
   277 
       
   278 	switch ( iState )
       
   279 		{
       
   280 		case ERetrieving:
       
   281 			{
       
   282 			// UI input not allowed during async. operation
       
   283 			ReactivateUIBlockL();	
       
   284 			
       
   285             const MVPbkContactLink& link =
       
   286                 iSelectedContacts->At( KFirstContact );
       
   287             RetrieveContactL( link );
       
   288 			break; 
       
   289 			}
       
   290 		case EConfirming:
       
   291 			{
       
   292 			ConfirmRemovingL();
       
   293 			break;
       
   294 			}
       
   295 		case ERetrievingGroupContact:
       
   296 			{
       
   297 	         // UI input not allowed during async. operation
       
   298 	        ReactivateUIBlockL();
       
   299 	        
       
   300 			InitProgressDlgL();
       
   301 			RetrieveContactL( iGroupLink );
       
   302 			break;
       
   303 			}
       
   304 		case ERemoving:
       
   305 			{
       
   306 			HandleRemovingL();
       
   307 			break;
       
   308 			}
       
   309 		case ECompleting:
       
   310 	        {
       
   311 	        CompleteL();
       
   312             DeleteProgressNoteL();
       
   313             break;	        
       
   314 	        }
       
   315         case ECompletingWithError:
       
   316             {
       
   317             CompleteWithError();
       
   318             DeleteProgressNoteL();
       
   319             break;
       
   320             }
       
   321 		default:
       
   322 		    {
       
   323             __ASSERT_DEBUG( EFalse, Panic( EInvalidState ) );
       
   324 		    break;
       
   325 		    }
       
   326 		}		
       
   327 
       
   328     PBK2_DEBUG_PRINT
       
   329         (PBK2_DEBUG_STRING("CPguRemoveFromGroupCmd::RunL end")); 
       
   330     }
       
   331 
       
   332 // --------------------------------------------------------------------------
       
   333 // CPguRemoveFromGroupCmd::RunError
       
   334 // --------------------------------------------------------------------------
       
   335 //
       
   336 TInt CPguRemoveFromGroupCmd::RunError( TInt aError )
       
   337     {
       
   338     iCommandObserver->CommandFinished( *this );
       
   339     return aError;
       
   340     }    
       
   341 
       
   342 // --------------------------------------------------------------------------
       
   343 // CPguRemoveFromGroupCmd::VPbkSingleContactOperationComplete
       
   344 // --------------------------------------------------------------------------
       
   345 //    
       
   346 void CPguRemoveFromGroupCmd::VPbkSingleContactOperationComplete
       
   347         ( MVPbkContactOperationBase& /*aOperation*/,
       
   348           MVPbkStoreContact* aContact )
       
   349     {
       
   350     delete iRetrieveOperation;
       
   351     iRetrieveOperation = NULL;
       
   352     
       
   353     if ( iState == ERetrievingGroupContact )
       
   354     	{
       
   355 	    iContactGroup = aContact->Group();    	
       
   356 
       
   357 	    __ASSERT_DEBUG(iContactGroup, Panic(EPanicContactNotGroup));
       
   358 	        
       
   359 	    TRAPD( error, iContactGroup->LockL( *this ) );
       
   360         
       
   361         if ( error != KErrNone )
       
   362             {            
       
   363             CCoeEnv::Static()->HandleError( error );
       
   364             
       
   365             iState = ECompletingWithError;
       
   366             IssueRequest();
       
   367             }
       
   368 	    }
       
   369 	else
       
   370 		{
       
   371 		// We now have a store contact and we can issue a confirmation
       
   372         iStoreContact = aContact;
       
   373         iState = EConfirming;
       
   374         IssueRequest();
       
   375 		}
       
   376     }
       
   377 
       
   378 // --------------------------------------------------------------------------
       
   379 // CPguRemoveFromGroupCmd::VPbkSingleContactOperationFailed
       
   380 // --------------------------------------------------------------------------
       
   381 //    
       
   382 void CPguRemoveFromGroupCmd::VPbkSingleContactOperationFailed
       
   383         ( MVPbkContactOperationBase& /*aOperation*/,  TInt aError )
       
   384     {
       
   385     delete iRetrieveOperation;
       
   386     iRetrieveOperation = NULL;
       
   387     
       
   388     iState = ECompletingWithError;
       
   389     IssueRequest();
       
   390 
       
   391     CCoeEnv::Static()->HandleError( aError );
       
   392     }
       
   393 
       
   394 // --------------------------------------------------------------------------
       
   395 // CPguRemoveFromGroupCmd::ContactOperationCompleted
       
   396 // --------------------------------------------------------------------------
       
   397 //
       
   398 void CPguRemoveFromGroupCmd::ContactOperationCompleted
       
   399         ( TContactOpResult aResult )
       
   400     {
       
   401     if ( aResult.iOpCode == MVPbkContactObserver::EContactLock )
       
   402         {        		
       
   403         iState = ERemoving;
       
   404         IssueRequest();
       
   405         }
       
   406 	else if ( aResult.iOpCode == MVPbkContactObserver::EContactCommit )
       
   407         {
       
   408         if ( iCommandObserver )
       
   409             {
       
   410             iCommandObserver->CommandFinished( *this );
       
   411             }
       
   412         }	
       
   413     }
       
   414 
       
   415 // --------------------------------------------------------------------------
       
   416 // CPguRemoveFromGroupCmd::ContactOperationFailed
       
   417 // --------------------------------------------------------------------------
       
   418 //    
       
   419 void CPguRemoveFromGroupCmd::ContactOperationFailed
       
   420         ( TContactOp /*aOpCode*/, TInt aErrorCode, TBool aErrorNotified )
       
   421     {
       
   422     iState = ECompletingWithError;
       
   423     IssueRequest();
       
   424 
       
   425     if ( !aErrorNotified )
       
   426         {
       
   427         CCoeEnv::Static()->HandleError( aErrorCode );
       
   428         }
       
   429     }
       
   430 
       
   431 // --------------------------------------------------------------------------
       
   432 // CPguRemoveFromGroupCmd::ContactViewReady
       
   433 // --------------------------------------------------------------------------
       
   434 //	
       
   435 void CPguRemoveFromGroupCmd::ContactViewReady
       
   436         ( MVPbkContactViewBase& /*aView*/ )
       
   437 	{
       
   438 	// Do nothing
       
   439 	}
       
   440 
       
   441 // --------------------------------------------------------------------------
       
   442 // CPguRemoveFromGroupCmd::ContactViewUnavailable
       
   443 // --------------------------------------------------------------------------
       
   444 //	
       
   445 void CPguRemoveFromGroupCmd::ContactViewUnavailable
       
   446         ( MVPbkContactViewBase& /*aView*/ )
       
   447 	{
       
   448 	// Do nothing
       
   449 	}
       
   450 
       
   451 // --------------------------------------------------------------------------
       
   452 // CPguRemoveFromGroupCmd::ContactAddedToView
       
   453 // --------------------------------------------------------------------------
       
   454 //	
       
   455 void CPguRemoveFromGroupCmd::ContactAddedToView
       
   456         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   457           const MVPbkContactLink& /*aContactLink*/ )
       
   458 	{
       
   459 	// Do nothing
       
   460 	}
       
   461 
       
   462 // --------------------------------------------------------------------------
       
   463 // CPguRemoveFromGroupCmd::ContactRemovedFromView
       
   464 // --------------------------------------------------------------------------
       
   465 //	
       
   466 void CPguRemoveFromGroupCmd::ContactRemovedFromView
       
   467         ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
       
   468           const MVPbkContactLink& /*aContactLink*/ )
       
   469 	{
       
   470 	// Do nothing
       
   471 	}
       
   472 
       
   473 // --------------------------------------------------------------------------
       
   474 // CPguRemoveFromGroupCmd::ContactViewError
       
   475 // --------------------------------------------------------------------------
       
   476 //	
       
   477 void CPguRemoveFromGroupCmd::ContactViewError
       
   478         ( MVPbkContactViewBase& /*aView*/, TInt aError,
       
   479           TBool /*aErrorNotified*/ )
       
   480 	{
       
   481     iState = ECompletingWithError;
       
   482     IssueRequest();
       
   483 
       
   484     CCoeEnv::Static()->HandleError( aError );
       
   485 	}
       
   486 
       
   487 // --------------------------------------------------------------------------
       
   488 // CPguRemoveFromGroupCmd::DialogDismissedL
       
   489 // --------------------------------------------------------------------------
       
   490 //
       
   491 void CPguRemoveFromGroupCmd::DialogDismissedL( TInt /*aButtonId*/ )
       
   492     {
       
   493     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   494         "CPbkRemoveFromGroupCmd::DialogDismissedL"));
       
   495         
       
   496     iProgressDialog = NULL;        
       
   497     iDialogDismissed = ETrue;    
       
   498     // Notify command owner that the command has finished
       
   499     if ( iCommandObserver )
       
   500         {
       
   501         iCommandObserver->CommandFinished( *this );
       
   502         }
       
   503     }
       
   504 
       
   505 // --------------------------------------------------------------------------
       
   506 // CPguRemoveFromGroupCmd::MoreContactsToRemove
       
   507 // --------------------------------------------------------------------------
       
   508 //
       
   509 inline TBool CPguRemoveFromGroupCmd::MoreContactsToRemove() const
       
   510     {
       
   511     return ( iSelectedContacts && 
       
   512         ( iTotalContactsToRemove > iRemovedCount ) );
       
   513     }
       
   514 
       
   515 // --------------------------------------------------------------------------
       
   516 // CPguRemoveFromGroupCmd::IsProcessDone
       
   517 // --------------------------------------------------------------------------
       
   518 //	
       
   519 TBool CPguRemoveFromGroupCmd::IsProcessDone() const
       
   520     {
       
   521     return !MoreContactsToRemove();
       
   522     }
       
   523 
       
   524 // --------------------------------------------------------------------------
       
   525 // CPguRemoveFromGroupCmd::StepL
       
   526 // --------------------------------------------------------------------------
       
   527 //
       
   528 void CPguRemoveFromGroupCmd::StepL()
       
   529     {
       
   530     PBK2_DEBUG_PRINT
       
   531         (PBK2_DEBUG_STRING("CPbkRemoveFromGroup::StepL()"), this);
       
   532 
       
   533     if ( MoreContactsToRemove() && 
       
   534          iSelectedContacts->Count() > iRemovedCount )
       
   535         {
       
   536         const MVPbkContactLink& contactLink = 
       
   537         	iSelectedContacts->At( iRemovedCount );
       
   538         TRAPD( err, iContactGroup->RemoveContactL( contactLink ) );
       
   539         if ( err == KErrInUse )
       
   540             {
       
   541             // If there is only one contact that failed, 
       
   542             // system error info note is shown and the process is terminated.
       
   543             if ( iSelectedContacts->Count() == KOne )
       
   544                 {
       
   545                 CCoeEnv::Static()->HandleError( err ); 
       
   546                 iState = ECompletingWithError;
       
   547                 }
       
   548             }
       
   549         else
       
   550             {
       
   551             User::LeaveIfError( err ); 
       
   552             }
       
   553         ++iRemovedCount;
       
   554         }
       
   555     }
       
   556 
       
   557 // --------------------------------------------------------------------------
       
   558 // CPguRemoveFromGroupCmd::IssueRequest
       
   559 // --------------------------------------------------------------------------
       
   560 //    	
       
   561 void CPguRemoveFromGroupCmd::IssueRequest()
       
   562     {
       
   563     if ( !IsActive() )
       
   564         {
       
   565         TRequestStatus* status = &iStatus;
       
   566         User::RequestComplete( status, KErrNone );
       
   567         SetActive();        
       
   568         }
       
   569     } 
       
   570 
       
   571 // --------------------------------------------------------------------------
       
   572 // CPguRemoveFromGroupCmd::CompleteL
       
   573 // --------------------------------------------------------------------------
       
   574 //
       
   575 void CPguRemoveFromGroupCmd::CompleteL()
       
   576     {
       
   577     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   578         "CPguRemoveFromGroupCmd::ProcessFinished(0x%x)"), this);
       
   579 
       
   580     if ( iUiControl )
       
   581         {
       
   582         iUiControl->SetBlank( EFalse );
       
   583         // Try to set focused contact
       
   584         iUiControl->SetFocusedContactIndexL( iFocusedContactIndex );
       
   585         // Clear listbox selections
       
   586         iUiControl->UpdateAfterCommandExecution();
       
   587         }
       
   588     }
       
   589 
       
   590 // --------------------------------------------------------------------------
       
   591 // CPguRemoveFromGroupCmd::CompleteWithError
       
   592 // --------------------------------------------------------------------------
       
   593 //   
       
   594 void CPguRemoveFromGroupCmd::CompleteWithError()
       
   595     {
       
   596     if ( iUiControl )
       
   597         {
       
   598         iUiControl->SetBlank( EFalse );
       
   599         }
       
   600     }
       
   601 
       
   602 // --------------------------------------------------------------------------
       
   603 // CPguRemoveFromGroupCmd::DeleteProgressNoteL
       
   604 // --------------------------------------------------------------------------
       
   605 //    	
       
   606 void CPguRemoveFromGroupCmd::DeleteProgressNoteL()
       
   607     {
       
   608     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   609         "CPguRemoveFromGroupCmd::DeleteProgressNote start"));
       
   610         
       
   611     if ( iProgressDialog && !iDialogDismissed )
       
   612         {
       
   613         // Delete the dialog
       
   614         iProgressDialog->ProcessFinishedL();
       
   615         iProgressDialog = NULL;
       
   616         }
       
   617     else if ( iCommandObserver )
       
   618         {        
       
   619         iCommandObserver->CommandFinished( *this );
       
   620         }
       
   621 
       
   622     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   623         "CPguRemoveFromGroupCmd::DeleteProgressNote end"));
       
   624     }
       
   625 
       
   626 // --------------------------------------------------------------------------
       
   627 // CPguRemoveFromGroupCmd::RetrieveContactL
       
   628 // --------------------------------------------------------------------------
       
   629 //    
       
   630 void CPguRemoveFromGroupCmd::RetrieveContactL
       
   631         ( const MVPbkContactLink& aContactLink)
       
   632     {
       
   633     // Retrieve the actual store contact from the given link
       
   634     iRetrieveOperation = Phonebook2::Pbk2AppUi()->ApplicationServices().
       
   635         ContactManager().RetrieveContactL( aContactLink, *this );
       
   636     }
       
   637 
       
   638 // --------------------------------------------------------------------------
       
   639 // CPguRemoveFromGroupCmd::ConfirmRemovingL
       
   640 // --------------------------------------------------------------------------
       
   641 //	
       
   642 void CPguRemoveFromGroupCmd::ConfirmRemovingL()
       
   643 	{
       
   644 	// When popping up the query, the input block will lose its focus, and it can't 
       
   645     // block the event. So delete the input block before the query pops up.
       
   646     if (iInputBlock)
       
   647         {
       
   648         delete iInputBlock;
       
   649         iInputBlock = NULL;
       
   650         }
       
   651     
       
   652     //original we will ask user if they really want to remove contacts from group,
       
   653     //but currently we decide that we will just do it without asking user
       
   654     TInt count = iSelectedContacts->Count();
       
   655     if (count >= 1)
       
   656         {
       
   657         // If the query result is confirm, restart the input block again to
       
   658         // keep blocking other event during the command execution.
       
   659         if (!iInputBlock)
       
   660             {
       
   661             iInputBlock = CAknInputBlock::NewLC();
       
   662             CleanupStack::Pop(iInputBlock);
       
   663             }
       
   664 
       
   665         // Retrieve the group contact
       
   666         iState = ERetrievingGroupContact;
       
   667         IssueRequest();
       
   668         }
       
   669     else
       
   670         {
       
   671         // Complete command, leave UI control as it was
       
   672         iState = ECompletingWithError;
       
   673         IssueRequest();
       
   674         }
       
   675 	
       
   676 	
       
   677 
       
   678 	}
       
   679 
       
   680 // --------------------------------------------------------------------------
       
   681 // CPguRemoveFromGroupCmd::InitProgressDlgL
       
   682 // --------------------------------------------------------------------------
       
   683 //    
       
   684 void CPguRemoveFromGroupCmd::InitProgressDlgL()
       
   685 	{
       
   686     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   687         "CPguRemoveFromGroupCmd::InitProgressDlgL"));
       
   688     
       
   689     if ( iUiControl )
       
   690         {
       
   691         iUiControl->SetBlank( ETrue );
       
   692         }
       
   693     
       
   694     CAknProgressDialog* progressDialog = new(ELeave) CPbk2AknProgressDialog(
       
   695             reinterpret_cast<CEikDialog**>(NULL), EFalse );
       
   696     progressDialog->PrepareLC( R_QTN_PHOB2_WNOTE_REM_FROM_GROUP );
       
   697     iProgressDlgInfo = progressDialog->GetProgressInfoL();
       
   698     iProgressDlgInfo->SetFinalValue( iTotalContactsToRemove );
       
   699     progressDialog->SetCallback( this );
       
   700     iDialogDismissed = EFalse;
       
   701     progressDialog->RunLD();
       
   702     iProgressDialog = progressDialog;	
       
   703     
       
   704     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
       
   705         "CPguRemoveFromGroupCmd::InitProgressDlgL end"));
       
   706 	}
       
   707 
       
   708 // --------------------------------------------------------------------------
       
   709 // CPguRemoveFromGroupCmd::HandleRemovingL
       
   710 // --------------------------------------------------------------------------
       
   711 //
       
   712 void CPguRemoveFromGroupCmd::HandleRemovingL()
       
   713 	{
       
   714     if ( !IsProcessDone() )
       
   715         {
       
   716         // Process one step
       
   717         StepL();
       
   718         
       
   719         // Incrementing progress of the process
       
   720         iProgressDlgInfo->SetAndDraw( iRemovedCount );
       
   721 
       
   722         // Issue request to remove next item
       
   723         IssueRequest();
       
   724         }
       
   725     else
       
   726         {
       
   727         // Process is completed, all entries have been removed
       
   728         iState = ECompleting;
       
   729         IssueRequest();
       
   730         }	
       
   731 	}
       
   732 
       
   733 // --------------------------------------------------------------------------
       
   734 // CPguRemoveFromGroupCmd::ReactivateUIBlockL
       
   735 // --------------------------------------------------------------------------
       
   736 //
       
   737 void CPguRemoveFromGroupCmd::ReactivateUIBlockL()
       
   738     {
       
   739     // Use CAknInputBlock to block user input
       
   740     
       
   741     if( iInputBlock )
       
   742         {
       
   743         delete iInputBlock;
       
   744         iInputBlock = NULL;
       
   745         }
       
   746     
       
   747     iInputBlock = CAknInputBlock::NewLC();
       
   748     CleanupStack::Pop( iInputBlock );   
       
   749     }
       
   750 
       
   751 //  End of File