imservices/ossprotocoladaptation/src/processlauncher/processlaunher.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2007-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:  implementation of launching of process
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "processlaunher.h"
       
    21 
       
    22 #include <e32std.h>
       
    23 #include "ossprotocolpluginlogger.h"
       
    24 
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CProcessLauncher::CProcessLauncher
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CProcessLauncher::CProcessLauncher() :
       
    36 		CActive ( EPriorityStandard )
       
    37 	{
       
    38 	CActiveScheduler::Add ( this );
       
    39 	}
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CProcessLauncher::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CProcessLauncher::ConstructL ( const TDesC16& aprocessname )
       
    47 	{
       
    48 	LOGGER ( TXT ( "CProcessLauncher::ConstructL()" ) );
       
    49 	iProcessName = aprocessname.AllocL();
       
    50 	}
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CProcessLauncher::NewL
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CProcessLauncher* CProcessLauncher::NewL ( const TDesC16& aprocessname )
       
    58 	{
       
    59 	LOGGER ( TXT ( "CProcessLauncher::NewL()" ) );
       
    60 
       
    61 	CProcessLauncher* self =
       
    62 	    new ( ELeave ) CProcessLauncher();
       
    63 
       
    64 	CleanupStack::PushL ( self );
       
    65 	self->ConstructL ( aprocessname );
       
    66 	CleanupStack::Pop();
       
    67 
       
    68 	return self;
       
    69 	}
       
    70 
       
    71 // Destructor
       
    72 CProcessLauncher::~CProcessLauncher()
       
    73 	{
       
    74 	Cancel();
       
    75 	delete iProcessName;
       
    76 	}
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CProcessLauncher::DoCancel
       
    81 //
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CProcessLauncher::DoCancel()
       
    85 	{
       
    86 	iLauncher.LogonCancel ( iStatus );
       
    87 
       
    88 	}
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CProcessLauncher::RunL
       
    92 //
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 void CProcessLauncher::RunL()
       
    96 	{
       
    97 	TInt answer ( iStatus.Int() );
       
    98 
       
    99 	if ( answer != KErrNone )
       
   100 		{
       
   101 		LOGGER ( TXT ( "CProcessLauncher::dd terminated with the reason %d" ), answer );
       
   102 
       
   103 		User::LeaveIfError ( answer );
       
   104 		}
       
   105 
       
   106 	Cancel();
       
   107 	}
       
   108 
       
   109 // ---------------------------------------------------------
       
   110 // CProcessLauncher::RunError
       
   111 //
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 TInt CProcessLauncher::RunError ( TInt aError )
       
   115 	{
       
   116 	if ( IsActive() )
       
   117 		{
       
   118 		Cancel();
       
   119 		}
       
   120 
       
   121 	return aError;
       
   122 	}
       
   123 // ---------------------------------------------------------
       
   124 // CProcessLauncher::LaunchProcessL
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 void CProcessLauncher::LaunchProcessL()
       
   128 	{
       
   129 	LOGGER ( TXT ( "CProcessLauncher::LaunchProcessL() start" ) );
       
   130 	TInt result = KErrNotFound;
       
   131 
       
   132 	result = iLauncher.Create ( *iProcessName, KNullDesC );
       
   133 
       
   134 	if ( result != KErrNone )
       
   135 		{
       
   136 		LOGGER ( TXT ( "CProcessLauncher::launching isoserver is failed with the reason %d" ), result );
       
   137 		User::Leave ( result );
       
   138 		}
       
   139 
       
   140 	// When the launcher exits we'll get the exit code in iStatus
       
   141 	iStatus = KRequestPending;
       
   142 
       
   143 	SetActive();
       
   144 
       
   145 	iLauncher.Logon ( iStatus );
       
   146 
       
   147 	iLauncher.Resume();
       
   148 
       
   149 	//iLauncher.Close();
       
   150 	LOGGER ( TXT ( "CProcessLauncher::LaunchProcessL() End " ) );
       
   151 	}
       
   152 	
       
   153 // End of file