コード例 #1
0
// ---------------------------------------------------------------------------
// Launches the app server.
// ---------------------------------------------------------------------------
// 
EXPORT_C void RAlfClientBase::LaunchAppL( 
    TUid aAppUid, 
    TUint aServerDifferentiator, 
    TThreadId& aThreadId )
	{
	RApaLsSession apa;
	User::LeaveIfError( apa.Connect() );
	CleanupClosePushL( apa );
	
	TApaAppInfo info;
	User::LeaveIfError( apa.GetAppInfo( info, aAppUid ) );

	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
	cmdLine->SetExecutableNameL( info.iFullName );
	cmdLine->SetServerRequiredL( aServerDifferentiator );
    // Set the command to start the server in background
    cmdLine->SetCommandL( EApaCommandBackground );        

	TRequestStatus status;	
	TInt err = apa.StartApp( *cmdLine, aThreadId, &status );
    
    User::LeaveIfError( err );
    
    User::WaitForRequest(status);
    
    User::LeaveIfError( status.Int() );
    
	CleanupStack::PopAndDestroy( cmdLine );
	CleanupStack::PopAndDestroy( &apa );
	}
コード例 #2
0
void RAlfClientBase::StartAsyncL(TRequestStatus* aStatus)
    {
    ASSERT(iApa==0 && iCmdLine == 0);
    // Start the server application
    TName serverName;
    TUint differentiator( 0 );
    
    differentiator = KAlfAppServerInterfaceUid3;
    ConstructServerName( 
        serverName, 
        TUid::Uid(KAlfAppServerInterfaceUid3) , 
        differentiator );
    
    TFindServer serverFinder(serverName);
    TFullName fullName;
    if (serverFinder.Next(fullName) == KErrNone)
        {
        User::Leave(KErrAlreadyExists);
        }
        
    TThreadId threadId;
    // we don't have proper destructor and thus we don't take
    // "normal" ownership on our members...
    
    // assign to member after poping from cleanup stack - codescanner now happy
  RApaLsSession*  apa = new (ELeave) RApaLsSession;
	CleanupStack::PushL(apa);
	User::LeaveIfError( apa->Connect() );
	CleanupClosePushL( *apa );
	
	TApaAppInfo info;
	User::LeaveIfError( apa->GetAppInfo( info, TUid::Uid(KAlfAppServerInterfaceUid3) ) );

	CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
	cmdLine->SetExecutableNameL( info.iFullName );
	cmdLine->SetServerRequiredL( differentiator );
    // Set the command to start the server in background
    cmdLine->SetCommandL( EApaCommandBackground );        

	User::LeaveIfError(apa->StartApp( *cmdLine, threadId, aStatus ));

    CleanupStack::Pop(3);
    iCmdLine=cmdLine;
    iApa = apa;
    }