|
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 QString &activityId) |
|
34 { |
|
35 QString actId = "\""+activityId+"\""; |
|
36 QString uri = QString("-activity appto://%1?activityname=%2").arg(uint(applicationId), 8, 16, QChar('0')).arg(actId); |
|
37 |
|
38 QT_TRAP_THROWING( |
|
39 { |
|
40 HBufC* uriAsDescriptor = XQConversions::qStringToS60Desc(uri); |
|
41 CleanupStack::PushL(uriAsDescriptor); |
|
42 |
|
43 RApaLsSession apaLsSession; |
|
44 User::LeaveIfError(apaLsSession.Connect()); |
|
45 CleanupClosePushL(apaLsSession); |
|
46 |
|
47 TApaAppInfo appInfo; |
|
48 TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); |
|
49 |
|
50 if(retVal == KErrNone) { |
|
51 RProcess application; |
|
52 User::LeaveIfError(application.Create(appInfo.iFullName, *uriAsDescriptor)); |
|
53 application.Resume(); |
|
54 } else { |
|
55 // @todo |
|
56 } |
|
57 |
|
58 CleanupStack::PopAndDestroy(&apaLsSession); |
|
59 CleanupStack::PopAndDestroy(uriAsDescriptor); |
|
60 } |
|
61 ); |
|
62 } |
|
63 |
|
64 void ApplicationLauncherPrivate::bringToForeground(int applicationId) |
|
65 { |
|
66 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
|
67 TApaTask task = taskList.FindApp(TUid::Uid(applicationId)); |
|
68 if (task.Exists()) { |
|
69 task.BringToForeground(); |
|
70 } else { |
|
71 qCritical("Cannot bring to forward task %08x", applicationId); |
|
72 } |
|
73 } |