9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 #include "applicationlauncher_p.h" |
17 #include "applicationlauncher_p.h" |
18 |
18 |
19 #include <apgcli.h> |
19 #include <apgcli.h> |
20 #include <apacmdln.h> |
20 #include <apacmdln.h> |
21 #include <APGTASK.H> |
21 #include <apgtask.h> |
22 #include <eikenv.h> |
22 #include <eikenv.h> |
23 |
23 |
24 #include <XQConversions> |
24 #include <XQConversions> |
25 |
25 |
26 bool ApplicationLauncherPrivate::isRunning(int applicationId) |
26 bool ApplicationLauncherPrivate::isRunning(int applicationId) |
30 return task.Exists(); |
30 return task.Exists(); |
31 } |
31 } |
32 |
32 |
33 void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId) |
33 void ApplicationLauncherPrivate::startApplication(int applicationId, const QString &activityId) |
34 { |
34 { |
35 QString actId = "\""+activityId+"\""; |
35 QString actId = "\""+activityId+"\""; |
36 QString uri = QString("-activity appto://%1?activityname=%2").arg(uint(applicationId), 8, 16, QChar('0')).arg(actId); |
36 QString uri = QString("-activity appto://%1?activityname=%2").arg(uint(applicationId), 8, 16, QChar('0')).arg(actId); |
37 |
37 |
38 QT_TRAP_THROWING( |
38 QT_TRAP_THROWING( { |
39 { |
39 HBufC *uriAsDescriptor = XQConversions::qStringToS60Desc(uri); |
40 HBufC* uriAsDescriptor = XQConversions::qStringToS60Desc(uri); |
|
41 CleanupStack::PushL(uriAsDescriptor); |
40 CleanupStack::PushL(uriAsDescriptor); |
42 |
41 |
43 RApaLsSession apaLsSession; |
42 RApaLsSession apaLsSession; |
44 User::LeaveIfError(apaLsSession.Connect()); |
43 User::LeaveIfError(apaLsSession.Connect()); |
45 CleanupClosePushL(apaLsSession); |
44 CleanupClosePushL(apaLsSession); |
46 |
45 |
47 TApaAppInfo appInfo; |
46 TApaAppInfo appInfo; |
48 TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); |
47 TInt retVal = apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)); |
49 |
48 |
50 if(retVal == KErrNone) { |
49 if (retVal == KErrNone) { |
51 RProcess application; |
50 RProcess application; |
52 User::LeaveIfError(application.Create(appInfo.iFullName, *uriAsDescriptor)); |
51 User::LeaveIfError(application.Create(appInfo.iFullName, *uriAsDescriptor)); |
53 application.Resume(); |
52 application.Resume(); |
54 } else { |
53 } else { |
55 // @todo |
54 // @todo |
56 } |
55 } |
57 |
56 |
58 CleanupStack::PopAndDestroy(&apaLsSession); |
57 CleanupStack::PopAndDestroy(&apaLsSession); |
59 CleanupStack::PopAndDestroy(uriAsDescriptor); |
58 CleanupStack::PopAndDestroy(uriAsDescriptor); |
60 } |
59 } |
61 ); |
60 ); |
62 } |
61 } |
63 |
62 |
64 void ApplicationLauncherPrivate::bringToForeground(int applicationId) |
63 void ApplicationLauncherPrivate::bringToForeground(int applicationId) |
65 { |
64 { |
66 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |
65 TApaTaskList taskList(CEikonEnv::Static()->WsSession()); |