serviceproviders/sapi_contacts_vpbk/contactservice/src/contactsynccallback.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 16:06:03 +0300
branchRCL_3
changeset 65 0b68a1b0c15e
parent 22 fc9cf246af83
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of the contactsynccallback class.
*
*/


//system include
#include <e32base.h>

//user include
#include "contactsynccallback.h"
#include "singlecontact.h"
/*
-----------------------------------------------------------------------------
    contactsynccallback::contactsynccallback()
    Description          : Default Constructor
    Return values        : N/A
-----------------------------------------------------------------------------
*/
CContactSyncCallback :: CContactSyncCallback():
                            iIter(NULL),
                            iError(KErrNone),
                            iWaitScheduler(NULL),
                            iErrKey(0)
                     {
                     }

/*
-----------------------------------------------------------------------------
    contactsynccallback::~contactsynccallback()
    Description          : Destructor
    Return values        : N/A
-----------------------------------------------------------------------------
*/
CContactSyncCallback :: ~CContactSyncCallback()
     {
     iIter=NULL;
     }

/*
-----------------------------------------------------------------------------
    contactsynccallback :: GetIter()
    Description          : Getter method to get a pointer to the iterator does a shallow copy.
    Return values        : pointer to class CContactIter
-----------------------------------------------------------------------------
*/

 CContactIter* CContactSyncCallback :: GetIter()
     {
     return iIter;
     }

/*
-----------------------------------------------------------------------------
    contactsynccallback :: GetErrorCode()
    Description          : Getter method to get error code.
    Return values        : Integer error code.
-----------------------------------------------------------------------------
*/
 TInt CContactSyncCallback :: GetErrorCode()
     {
     return iError;
     }
/*
-----------------------------------------------------------------------------
    contactsynccallback :: SetWaitScheduler()
    Description          : setter method for the wait shceduler shallow copy owned by core class.
    Return values        : Integer error code.
-----------------------------------------------------------------------------
*/
 void CContactSyncCallback::SetWaitScheduler(CActiveSchedulerWait *aWaitScheduler)
     {
     iWaitScheduler = aWaitScheduler;
     }
/*
-----------------------------------------------------------------------------
    contactsynccallback :: HandleReturnValue( TOperationEvent aEvent, const TInt& aError, TInt aTransId )
    Description          : virtual method which is called by the core class if there is any event
                         : in the asynchronous call.
    Return values        : N/A
-----------------------------------------------------------------------------
*/
 void CContactSyncCallback :: HandleReturnValue(TOperationEvent aEvent, 
                                                const TInt& aError, 
                                                TInt /*aTransId*/ )
    {
    if(aEvent == EInvalidKey)
        {
        iError = KErrNotSupported;
        //TPtrC8 ptr = CSearchFields :: GetFieldKeyFromId(aError);         
        iErrKey = aError;   
        }
    else
        {
        iError = aError;    
        }    
    //can be CActiveScheduler::Stop(); or to be replaced by wait scheduler.     
    iWaitScheduler->AsyncStop();
    }


/*
-----------------------------------------------------------------------------
    contactsynccallback :: HandleReturnIter( TOperationEvent aEvent, const TInt& aError, CContactIter* aIter, TInt aTransId )
    Description          : virtual method which is called by the core class if
                         : any asynchronous call completes successfully
    Return values        : N/A
-----------------------------------------------------------------------------
*/

 void CContactSyncCallback :: HandleReturnIter( const TInt& /*aError*/, CContactIter* aIter, TInt /*aTransId*/ )
     {         
     iIter = aIter;     
     //can be CActiveScheduler::Stop(); or to be replaced by wait scheduler.    
     iWaitScheduler->AsyncStop();
     }

 
 void CContactSyncCallback :: HandleReturnId(const TInt& /*aError*/,HBufC8* acntId , TInt /*aTransId*/ )
     {
     icntId = acntId;
     
     iWaitScheduler->AsyncStop();
     }

 
 HBufC8* CContactSyncCallback :: GetId()
     {
     return icntId;
     }
 
 void CContactSyncCallback :: HandleReturnArray( const TInt& /*aError*/, RPointerArray<HBufC8>& idArray, TInt /*aTransId*/ )
      {         
      //iIDArray = idArray;
      for(TInt i = 0; i<idArray.Count(); i++)
          {
      TDesC8* idVal = idArray[i];
       HBufC8* idBufVal = idVal->AllocL();
       iIDArray.AppendL(idBufVal);
          }
       //can be CActiveScheduler::Stop(); or to be replaced by wait scheduler.    
      iWaitScheduler->AsyncStop();
      }

void CContactSyncCallback::GetArray(RPointerArray<HBufC8>* aArray)
    {
    for(TInt i = 0; i<iIDArray.Count(); i++)
              {
              TDesC8* idVal = iIDArray[i];
           HBufC8* idBufVal = idVal->AllocL();
           aArray->AppendL(idBufVal);
           delete idVal;
              }
    }