diff -r 61bc0f252b2b -r bac7acad7cb3 camerauis/cameraapp/generic/src/cameracontroller/camcameracontrolleractive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraapp/generic/src/cameracontroller/camcameracontrolleractive.cpp Wed Sep 01 12:30:54 2010 +0100 @@ -0,0 +1,173 @@ +/* +* 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 "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: CCamCameraControllerActive class implementation. +* +* +*/ + + +#include +#include "camcameracontroller.pan" +#include "camlogging.h" +#include "camcameracontroller.h" +#include "camcameracontrolleractive.h" + +using namespace NCamCameraController; + + +// =========================================================================== +// Costructors and destructor + +// --------------------------------------------------------------------------- +// 2 phase constructor <> +// --------------------------------------------------------------------------- +// +CCamCameraControllerActive* +CCamCameraControllerActive::NewL( CCamCameraController& aController, + TInt aPriority ) + { + CCamCameraControllerActive* self = + new (ELeave) CCamCameraControllerActive( aController, aPriority ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor <> +// --------------------------------------------------------------------------- +// +CCamCameraControllerActive::~CCamCameraControllerActive() + { + PRINT( _L("Camera => ~CCamCameraControllerActive") ); + Cancel(); + PRINT( _L("Camera <= ~CCamCameraControllerActive") ); + } + + +// --------------------------------------------------------------------------- +// 2nd phase constructor +// --------------------------------------------------------------------------- +// +void +CCamCameraControllerActive::ConstructL() + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// 1st phase constructor +// --------------------------------------------------------------------------- +// +CCamCameraControllerActive +::CCamCameraControllerActive( CCamCameraController& aController, + TInt aPriority ) + : CActive( aPriority ), + iController( aController ) + { + } + +// =========================================================================== +// From CActive + +// --------------------------------------------------------------------------- +// DoCancel <> +// --------------------------------------------------------------------------- +// +void +CCamCameraControllerActive::DoCancel() + { + HandleError( KErrCancel ); + } + +// --------------------------------------------------------------------------- +// RunL <> +// --------------------------------------------------------------------------- +// +void +CCamCameraControllerActive::RunL() + { + PRINT( _L("Camera => CCamCameraControllerActive::RunL") ); + User::LeaveIfError( iStatus.Int() ); + + TInt more = iController.ProcessNextRequestL(); + + if( more ) + { + IssueRequest(); + } + else + { + // No more callbacks needed atleast for now. + } + PRINT( _L("Camera <= CCamCameraControllerActive::RunL") ); + } + +// --------------------------------------------------------------------------- +// RunError <> +// +// Called when leave occurs in RunL +// --------------------------------------------------------------------------- +// +TInt +CCamCameraControllerActive::RunError( TInt aError ) + { + PRINT1( _L("Camera => CCamCameraControllerActive::RunError, error:%d"), aError ); + + HandleError( aError ); + + PRINT( _L("Camera <= CCamCameraControllerActive::RunError") ); + return KErrNone; + } + +// =========================================================================== +// New methods + +// --------------------------------------------------------------------------- +// IssueRequest +// --------------------------------------------------------------------------- +// +void +CCamCameraControllerActive::IssueRequest() + { + PRINT( _L("Camera => CCamCameraControllerActive::IssueRequest") ); + + __ASSERT_ALWAYS( !IsActive(), Panic( ECamCameraControllerBusy ) ); + + // Set RunL to be called as soon as possible + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + SetActive(); + + PRINT( _L("Camera <= CCamCameraControllerActive::IssueRequest") ); + } + + +// --------------------------------------------------------------------------- +// HandleError +// --------------------------------------------------------------------------- +// +void +CCamCameraControllerActive::HandleError( TInt aStatus ) + { + iController.EndSequence( aStatus ); + } + +// =========================================================================== +// end of file