diff -r f742655b05bf -r d38647835c2e convergedconnectionhandler/cchclientapi/src/cchserviceimplasynchroniser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/convergedconnectionhandler/cchclientapi/src/cchserviceimplasynchroniser.cpp Wed Sep 01 12:29:57 2010 +0100 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "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: cch client api implementation +* +*/ + + +#include "cchserviceimplasynchroniser.h" +#include "cchlogger.h" + +CCchServiceImplAsynchroniser::CCchServiceImplAsynchroniser(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi) : + CActive(EPriorityStandard),// Standard priority + iCch( aCch ), + iServiceId( aServiceId ), + iCchUi( aCchUi ), + iState ( EIdle ) + + { + } + +CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewLC(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi) + { + CCchServiceImplAsynchroniser* self = + new (ELeave) CCchServiceImplAsynchroniser(aCch, aServiceId, aCchUi ); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CCchServiceImplAsynchroniser* CCchServiceImplAsynchroniser::NewL(CCchImpl& aCch, TInt aServiceId, CCchUiPrivateApi& aCchUi) + { + CCchServiceImplAsynchroniser* self = + CCchServiceImplAsynchroniser::NewLC(aCch, aServiceId, aCchUi ); + CleanupStack::Pop(); // self; + return self; + } + +void CCchServiceImplAsynchroniser::Enable( TCCHSubserviceType aType ) + { + CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable IN" ); + if (iState == EIdle) + { + iState = EEnabling; + TServiceSelection selection( iServiceId, aType ); + SetActive(); + iCch.CchClient().EnableService( selection, iStatus, EFalse ); + } + else + { + CCHLOGSTRING( "CCchServiceImplAsynchroniser already active" ); + } + CCHLOGSTRING( "CCchServiceImplAsynchroniser::Enable OUT" ); + } + +void CCchServiceImplAsynchroniser::Disable( TCCHSubserviceType aType ) + { + CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable IN" ); + if (iState != EIdle) + { + Cancel(); + } + iState = EDisabling; + TRequestStatus status = KErrNone; + TServiceSelection selection( iServiceId, aType ); + SetActive(); + iCch.CchClient().DisableService( selection, iStatus ); + + CCHLOGSTRING( "CCchServiceImplAsynchroniser::Disable OUT" ); + } + + +void CCchServiceImplAsynchroniser::ConstructL() + { + CActiveScheduler::Add(this); // Add to scheduler + } + +CCchServiceImplAsynchroniser::~CCchServiceImplAsynchroniser() + { + Cancel(); // Cancel any request, if outstanding + // Delete instance variables if any + } + +void CCchServiceImplAsynchroniser::DoCancel() + { + if ( EEnabling == iState ) + { + iCch.CchClient().EnableServiceCancel(); + } + else if ( EDisabling == iState ) + { + iCch.CchClient().DisableServiceCancel(); + } + } + +void CCchServiceImplAsynchroniser::RunL() + { + CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL IN" ); + if (iStatus.Int() != KErrCancel) + { + switch (iState) + { + case EEnabling: + { + if ( iCch.ConnectivityDialogsAllowed() ) + { + iCchUi.ManualEnableResultL( iServiceId, iStatus.Int() ); + } + CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EEnabling done" ); + iState = EIdle; + break; + } + case EDisabling: + { + CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL EDisabling done" ); + iState = EIdle; + break; + } + default: + { + break; + } + + } + } + iState = EIdle; + CCHLOGSTRING( "CCchServiceImplAsynchroniser::RunL OUT" ); + } + +TInt CCchServiceImplAsynchroniser::RunError(TInt aError) + { + return aError; + }