A class for managing Top Contact properties of contacts. All main operations are asynchronous and accept two observers. One used to signal completion and return result if necessary. Another one used to signal an error if operation fails.
A client that re-orders the existing top contacts in the phone
class CTopContactManagerClient : public CActive, public MVPbkOperationObserver, public MVPbkOperationErrorObserver, public MVPbkOperationResultObserver<MVPbkContactViewBase*> ...
// MVPbkOperationObserver void CTopContactManagerClient::VPbkOperationCompleted( MVPbkContactOperationBase*) { FinishCommand( KErrNone ); }
//From MVPbkOperationErrorObserver void CTopContactManagerClient::VPbkOperationFailed( MVPbkContactOperationBase*, TInt aError ) { FinishCommand( aError ); }
// From MVPbkOperationResultObserver void CTopContactManagerClient::VPbkOperationResultCompleted( MVPbkContactOperationBase*, MVPbkContactViewBase* aView ) { iView = aView; delete iTopContactOperation; iTopContactOperation = NULL; IssueRequest(EShowMoveDlg); } // -------------------------------------------------------------------------- // CTopContactManagerClient::RunL // State Machine using TopContactManager // -------------------------------------------------------------------------- // void CTopContactManagerClient::RunL() { switch(iState) { case ELoadingTopContacts: { // This async call will fall into VPbkOperationResultCompleted on success with // MVPbkContactOperationBase object as a result // Otherwise, it will fall into VPbkOperationFailed callback iTopContactOperation = iVPbkTopContactManager->GetTopContactsViewL( *this, *this ); break; } case EShowMoveDlg: { ShowDlgL(); // confirm re-ordering top contacts with user break; } case ESavingTopContacts: { // Do re-ordering via Top Manager // This async call will fall into VPbkOperationResultCompleted on success with // MVPbkContactOperationBase object as a result // Otherwise, it will fall into VPbkOperationFailed callback iTopContactOperation = iVPbkTopContactManager->SetTopOrderL( *iTopContacts, *this, *this ); CleanupStack::PopAndDestroy(); //topContacts break; }