activityfw/afactivitylauncher/src/afapplicationlauncher.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 #include "afapplicationlauncher.h"
       
    18 
       
    19 #include <apacmdln.h>
       
    20 #include <eikenv.h>
       
    21 #include <apgtask.h>
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 //  Construction
       
    25 // -----------------------------------------------------------------------------
       
    26 //
       
    27 TAfApplicationLauncher::TAfApplicationLauncher(RApaLsSession &apaLsSession, RWsSession &wsSession) : mApaLsSession(apaLsSession), mWsSession(wsSession)
       
    28 {
       
    29 }
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 //  
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 TBool TAfApplicationLauncher::isRunning(TUid applicationId)
       
    36 {
       
    37     TApaTaskList taskList(mWsSession);
       
    38     TApaTask task = taskList.FindApp(applicationId);
       
    39     return task.Exists();
       
    40 }
       
    41 
       
    42 void TAfApplicationLauncher::startApplicationL(TUid applicationId, const TDesC &uri)
       
    43 {
       
    44     _LIT(KActivityMarker, "-activity ");
       
    45     RBuf commandLine;
       
    46     CleanupClosePushL(commandLine);    
       
    47     commandLine.ReAllocL(KActivityMarker().Length() + uri.Length());
       
    48     commandLine.Append(KActivityMarker());
       
    49     commandLine.Append(uri);
       
    50     
       
    51     TApaAppInfo appInfo;
       
    52     User::LeaveIfError(mApaLsSession.GetAppInfo(appInfo, applicationId));
       
    53 
       
    54     RProcess application;
       
    55     CleanupClosePushL(application);
       
    56     User::LeaveIfError(application.Create(appInfo.iFullName, commandLine));
       
    57     application.Resume();
       
    58 
       
    59     CleanupStack::PopAndDestroy(&application);
       
    60     CleanupStack::PopAndDestroy(&commandLine);
       
    61 }