94
|
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 |
{
|
99
|
35 |
QString commandLine = QString("-activity %1").arg(QString(uri.toEncoded()));
|
94
|
36 |
|
102
|
37 |
TRAP_IGNORE(
|
94
|
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;
|
102
|
46 |
User::LeaveIfError(apaLsSession.GetAppInfo(appInfo, TUid::Uid(applicationId)));
|
94
|
47 |
|
102
|
48 |
RProcess application;
|
|
49 |
User::LeaveIfError(application.Create(appInfo.iFullName, *commandLineAsDescriptor));
|
|
50 |
application.Resume();
|
94
|
51 |
|
|
52 |
CleanupStack::PopAndDestroy(&apaLsSession);
|
|
53 |
CleanupStack::PopAndDestroy(commandLineAsDescriptor);
|
102
|
54 |
);
|
94
|
55 |
}
|
|
56 |
|
|
57 |
void ApplicationLauncherPrivate::bringToForeground(int applicationId)
|
|
58 |
{
|
|
59 |
TApaTaskList taskList(CEikonEnv::Static()->WsSession());
|
|
60 |
TApaTask task = taskList.FindApp(TUid::Uid(applicationId));
|
|
61 |
if (task.Exists()) {
|
|
62 |
task.BringToForeground();
|
|
63 |
} else {
|
|
64 |
qCritical("Cannot bring to forward task %08x", applicationId);
|
|
65 |
}
|
|
66 |
}
|