appinstall_plat/appmngr2runtimeapi/tsrc/src/appmngr2testcommand.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:51:10 +0200
changeset 0 ba25891c3a9e
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* Copyright (c) 2008 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:   Async command handling for AppMngr2 Runtime API STIF tests
*
*/


#include "appmngr2testcommand.h"        // CAppMngr2TestCommand
#include "appmngr2testcommandobserver.h" // MAppMngr2TestCommandObserver
#include <appmngr2infobase.h>           // CAppMngr2InfoBase


// ======== MEMBER FUNCTIONS ========

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::NewL()
// -----------------------------------------------------------------------------
//
CAppMngr2TestCommand* CAppMngr2TestCommand::NewL( CAppMngr2InfoBase& aInfo,
        MAppMngr2TestCommandObserver& aObs )
    {
    CAppMngr2TestCommand* self = new (ELeave) CAppMngr2TestCommand( aInfo, aObs );
    return self;
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::~CAppMngr2TestCommand()
// -----------------------------------------------------------------------------
//
CAppMngr2TestCommand::~CAppMngr2TestCommand()
    {
    Cancel();
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::DoCancel()
// -----------------------------------------------------------------------------
//
void CAppMngr2TestCommand::DoCancel()
    {
    iInfo.CancelCommand();
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::RunL()
// -----------------------------------------------------------------------------
//
void CAppMngr2TestCommand::RunL()
    {
    // no need to trap, as RunError calls CommandResult if RunL leaves
    iInfo.HandleCommandResultL( iStatus.Int() );
    iObs.CommandResult( *this, iStatus.Int() );
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::RunError()
// -----------------------------------------------------------------------------
//
TInt CAppMngr2TestCommand::RunError( TInt aError )
    {
    iObs.CommandResult( *this, aError );
    return aError;
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::HandleCommandL()
// -----------------------------------------------------------------------------
//
void CAppMngr2TestCommand::HandleCommandL( TInt aCommand )
    {
    if( IsActive() )
        {
        User::Leave( KErrInUse );
        }
    iInfo.HandleCommandL( aCommand, iStatus );
    SetActive();
    }

// -----------------------------------------------------------------------------
// CAppMngr2TestCommand::CAppMngr2TestOperation()
// -----------------------------------------------------------------------------
//
CAppMngr2TestCommand::CAppMngr2TestCommand( CAppMngr2InfoBase& aInfo,
        MAppMngr2TestCommandObserver& aObs ) :
        CActive( CActive::EPriorityStandard ), iInfo( aInfo ), iObs( aObs )
    {
    CActiveScheduler::Add( this );
    }