appfw/apparchitecture/apgrfx/APSCLI.CPP
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-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 // Client access to the AppArc server
       
    15 // 
       
    16 // apscli.cpp
       
    17 //
       
    18 
       
    19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    20 #if !defined(__APA_INTERNAL_H__)
       
    21 #include "apainternal.h"
       
    22 #endif
       
    23 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <e32svr.h>
       
    27 #include <e32math.h>
       
    28 #include <apasvst.h>
       
    29 #include <e32uid.h>
       
    30 
       
    31 _LIT(KNameApaImage,"APSEXE");
       
    32 const TUid KServerUid3  = { 0x10003A3F };
       
    33 
       
    34 /**
       
    35 StartupApaServerProcess
       
    36 Start the server in a process. Simultaneous launching of two such processes 
       
    37 should be detected when the second one attempts to create the server object, 
       
    38 failing with KErrAlreadyExists.
       
    39 
       
    40 @publishedPartner 
       
    41 @released
       
    42 */
       
    43 EXPORT_C TInt StartupApaServerProcess()
       
    44 	{
       
    45 	const TUidType uidType(KNullUid, KNullUid, KServerUid3);
       
    46 	TInt r=KErrNone;
       
    47 	
       
    48 	// On ARM or any EKA2 target, the server is an EXE.
       
    49 	// Create a process from it.
       
    50 	RProcess server;
       
    51 	r=server.Create(KNameApaImage,KNullDesC,uidType);
       
    52 	
       
    53 	if (r!=KErrNone)
       
    54 		return r;
       
    55 	TRequestStatus stat;
       
    56 	server.Rendezvous(stat);
       
    57 	if (stat!=KRequestPending)
       
    58 		server.Kill(0);		// abort startup
       
    59 	else
       
    60 		server.Resume();	// logon OK - start the server
       
    61 	User::WaitForRequest(stat);		// wait for start or death
       
    62 	server.Close();
       
    63 	return stat.Int();
       
    64 	}
       
    65