|
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 "applicationlauncher_p.h" |
|
18 |
|
19 #include <apgcli.h> |
|
20 #include <apacmdln.h> |
|
21 #include <apgtask.h> |
|
22 #include <eikenv.h> |
|
23 |
|
24 #include <XQConversions> |
|
25 |
|
26 bool ApplicationLauncherPrivate::isRunning(int applicationId) |
|
27 { |
|
28 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
|
29 TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); |
|
30 return task.Exists(); |
|
31 } |
|
32 |
|
33 void ApplicationLauncherPrivate::startApplication(int applicationId, const QUrl &uri) |
|
34 { |
|
35 QString commandLine = QString("-activity %1").arg(uri.toString()); |
|
36 |
|
37 QT_TRAP_THROWING( { |
|
38 HBufC *commandLineAsDescriptor = XQConversions::qStringToS60Desc(commandLine); |
|
39 CleanupStack::PushL(commandLineAsDescriptor); |
|
40 |
|
41 RApaLsSession apaLsSession; |
|
42 User::LeaveIfError(apaLsSession.Connect()); |
|
43 CleanupClosePushL(apaLsSession); |
|
44 |
|
45 TApaAppInfo appInfo; |
|
46 TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); |
|
47 |
|
48 if (retVal == KErrNone) { |
|
49 RProcess application; |
|
50 User::LeaveIfError(application.Create(appInfo.iFullName, *commandLineAsDescriptor)); |
|
51 application.Resume(); |
|
52 } else { |
|
53 // @todo ? |
|
54 } |
|
55 |
|
56 CleanupStack::PopAndDestroy(&apaLsSession); |
|
57 CleanupStack::PopAndDestroy(commandLineAsDescriptor); |
|
58 } |
|
59 ); |
|
60 } |
|
61 |
|
62 void ApplicationLauncherPrivate::bringToForeground(int applicationId) |
|
63 { |
|
64 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
|
65 TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); |
|
66 if (task.Exists()) { |
|
67 task.BringToForeground(); |
|
68 } else { |
|
69 qCritical("Cannot bring to forward task %08x", applicationId); |
|
70 } |
|
71 } |