srsf/vcommandexecutor/src/nssvcommandexecutor.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2005 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "rubydebug.h"
       
    21 #include    "nssvcapplauncher.hrh"
       
    22 #include    "nssvcapplauncher.h"
       
    23 #include    <e32std.h>
       
    24 #include    <bacline.h>
       
    25 
       
    26 //=============================================================================
       
    27 
       
    28 TInt ReadArgumentL( TInt& aArgument )
       
    29     {
       
    30     CCommandLineArguments* args = CCommandLineArguments::NewLC();
       
    31     // First argument is program name. Therefore there must be two arguments
       
    32     if ( args->Count() < 2 )
       
    33         {
       
    34         User::Leave( KErrArgument ); 
       
    35         }
       
    36     // We are interested in only the second argument (command to be executed).
       
    37     TPtrC argumentPrt( args->Arg( 1 ) );
       
    38     // Convert argument to TInt
       
    39     TLex lex( argumentPrt );
       
    40     User::LeaveIfError( lex.Val( aArgument ) );
       
    41     
       
    42     CleanupStack::PopAndDestroy( args );
       
    43     
       
    44     return KErrNone;
       
    45     }
       
    46 
       
    47 //=============================================================================
       
    48 
       
    49 void ExecuteL()
       
    50     {
       
    51     // Create active scheduler (to run active objects)
       
    52     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
    53     CleanupStack::PushL( scheduler );
       
    54     CActiveScheduler::Install( scheduler );
       
    55     
       
    56     // Command line argument
       
    57     TInt clArgument( -1 );
       
    58     ReadArgumentL( clArgument );
       
    59     
       
    60     if ( clArgument >= ECalendar && clArgument <= EMediaVolumeDown )
       
    61         {
       
    62         __UHEAP_MARK;
       
    63         CNssVCAppLauncher* appLauncher = CNssVCAppLauncher::NewL();
       
    64         CleanupStack::PushL( appLauncher );
       
    65         
       
    66         appLauncher->ExecuteCommandL( clArgument );
       
    67         
       
    68         CleanupStack::PopAndDestroy ( appLauncher ); 
       
    69         __UHEAP_MARKEND;
       
    70         }
       
    71         
       
    72     // Delete active scheduler
       
    73     CleanupStack::PopAndDestroy( scheduler );
       
    74     }
       
    75     
       
    76 //=============================================================================
       
    77 
       
    78 GLDEF_C TInt E32Main()
       
    79     {
       
    80     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    81     
       
    82     RUBY_TRAP_IGNORE( ExecuteL() );
       
    83     
       
    84     delete cleanup;
       
    85     
       
    86     return KErrNone;
       
    87     }
       
    88 
       
    89 // End of File