appinstall_plat/appmngr2runtimeapi/tsrc/src/appmngr2testcommand.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Async command handling for AppMngr2 Runtime API STIF tests
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "appmngr2testcommand.h"        // CAppMngr2TestCommand
       
    20 #include "appmngr2testcommandobserver.h" // MAppMngr2TestCommandObserver
       
    21 #include <appmngr2infobase.h>           // CAppMngr2InfoBase
       
    22 
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CAppMngr2TestCommand::NewL()
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CAppMngr2TestCommand* CAppMngr2TestCommand::NewL( CAppMngr2InfoBase& aInfo,
       
    31         MAppMngr2TestCommandObserver& aObs )
       
    32     {
       
    33     CAppMngr2TestCommand* self = new (ELeave) CAppMngr2TestCommand( aInfo, aObs );
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CAppMngr2TestCommand::~CAppMngr2TestCommand()
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CAppMngr2TestCommand::~CAppMngr2TestCommand()
       
    42     {
       
    43     Cancel();
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CAppMngr2TestCommand::DoCancel()
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void CAppMngr2TestCommand::DoCancel()
       
    51     {
       
    52     iInfo.CancelCommand();
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CAppMngr2TestCommand::RunL()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CAppMngr2TestCommand::RunL()
       
    60     {
       
    61     // no need to trap, as RunError calls CommandResult if RunL leaves
       
    62     iInfo.HandleCommandResultL( iStatus.Int() );
       
    63     iObs.CommandResult( *this, iStatus.Int() );
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CAppMngr2TestCommand::RunError()
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TInt CAppMngr2TestCommand::RunError( TInt aError )
       
    71     {
       
    72     iObs.CommandResult( *this, aError );
       
    73     return aError;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CAppMngr2TestCommand::HandleCommandL()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CAppMngr2TestCommand::HandleCommandL( TInt aCommand )
       
    81     {
       
    82     if( IsActive() )
       
    83         {
       
    84         User::Leave( KErrInUse );
       
    85         }
       
    86     iInfo.HandleCommandL( aCommand, iStatus );
       
    87     SetActive();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CAppMngr2TestCommand::CAppMngr2TestOperation()
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CAppMngr2TestCommand::CAppMngr2TestCommand( CAppMngr2InfoBase& aInfo,
       
    95         MAppMngr2TestCommandObserver& aObs ) :
       
    96         CActive( CActive::EPriorityStandard ), iInfo( aInfo ), iObs( aObs )
       
    97     {
       
    98     CActiveScheduler::Add( this );
       
    99     }
       
   100