messagingfw/msgtestfw/misc/LaunchAutoSend/src/LaunchAutoSend.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // LaunchAutoSend.cpp
       
    15 //
       
    16 
       
    17 #include <e32std.h>
       
    18 #include <e32base.h>
       
    19 
       
    20 _LIT(KMsvAutoSendExe, "Autosend.exe");
       
    21 const TUid KMsvAutoSendExeUid = {0x1000A402}; //268477442
       
    22 
       
    23 void DoExecuteL(const TDesC& aCmd)
       
    24 	{
       
    25 	CActiveScheduler* activeSch = new (ELeave) CActiveScheduler();
       
    26 	CleanupStack::PushL(activeSch);
       
    27 	CActiveScheduler::Install(activeSch);
       
    28 
       
    29 	RProcess process;
       
    30 	User::LeaveIfError(process.Create(KMsvAutoSendExe, aCmd,
       
    31 							TUidType(KNullUid, KNullUid, KMsvAutoSendExeUid)));
       
    32 	
       
    33 	TRequestStatus status = KRequestPending;
       
    34 	process.Logon(status);
       
    35 	process.Resume();
       
    36 	User::WaitForRequest(status);
       
    37 
       
    38 	//Check the process completion status
       
    39 	TInt err = (process.ExitType() == EExitPanic) ? KErrGeneral: status.Int();
       
    40 	process.Close();
       
    41 	User::LeaveIfError(err);
       
    42 	
       
    43 	CleanupStack::PopAndDestroy(activeSch);
       
    44 	}
       
    45 
       
    46 TInt Execute(const TDesC& aCmd)
       
    47 	{
       
    48 	__UHEAP_MARK;
       
    49 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    50 
       
    51 	TRAPD(err, DoExecuteL(aCmd));
       
    52 
       
    53 	delete cleanup;
       
    54 	__UHEAP_MARKEND;
       
    55 
       
    56 	return err;
       
    57 	}
       
    58 
       
    59 GLDEF_C TInt E32Main()
       
    60 	{
       
    61 	TBuf<0x100> cmd;
       
    62 	User::CommandLine(cmd);
       
    63 	return Execute(cmd);
       
    64 	}