lbs/internal/lbstestserver/src/cserverlaunch.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // serverlaunch.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "cserverlaunch.h"
       
    19 #include "tserverstartparams.h"
       
    20 
       
    21 /** Launch the server by specified parameters
       
    22 find the process and launch it
       
    23 
       
    24 @param aParams A reference to TProcessStartParams object
       
    25 @return Symbian error code
       
    26 @see TProcessStartParams
       
    27 @internalTechnology
       
    28 @released
       
    29  */
       
    30 TInt CServerLaunch::ServerLaunch(TServerStartParams& aParams)
       
    31 	{
       
    32 	TFindServer serverSearcher(aParams.GetServerName());
       
    33 	TFileName matchingFileName;
       
    34 	TInt error = serverSearcher.Next(matchingFileName); // we haev asked for a exact match, so the retunred filename can be ignored
       
    35 	if(error==KErrNone)
       
    36 		{
       
    37 		return KErrNone; // found it, so some other kind process has just started the server for us
       
    38 		}
       
    39 	else
       
    40 		{
       
    41 		error = CreateServerProcess(aParams);		
       
    42 		}
       
    43 	return error;
       
    44 	}
       
    45 
       
    46 /** create server process by specified parameters
       
    47 signal the clients and start the process, wait for any request.
       
    48 
       
    49 @param aParams A reference to TProcessStartParams object
       
    50 @return Symbian error code
       
    51 @see TProcessStartParams
       
    52 @internalTechnology
       
    53 @released
       
    54  */
       
    55 TInt CServerLaunch::CreateServerProcess(TServerStartParams& aParams)
       
    56 	{
       
    57 	RProcess server;
       
    58  	
       
    59  	TInt r=server.Create(aParams.GetServerFileName(),aParams.GetAsCommandLine());
       
    60 	if (r!=KErrNone)
       
    61 		return r;
       
    62 	TRequestStatus stat;
       
    63 	server.Rendezvous(stat);
       
    64 	if (stat!=KRequestPending)
       
    65 		{
       
    66 		server.Kill(0);
       
    67 		}
       
    68 	else
       
    69 		{
       
    70 		server.Resume();
       
    71 		}
       
    72 	User::WaitForRequest(stat);
       
    73 	r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
       
    74 	server.Close();
       
    75 	return r;
       
    76 	}
       
    77