|
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 "tstaskmonitor_p.h" |
|
18 #include "tstaskmonitor.h" |
|
19 |
|
20 #include "tstaskmonitorclient.h" |
|
21 #include "tsapplicationtask.h" |
|
22 |
|
23 #include "tsutils.h" |
|
24 using TaskSwitcher::CleanupResetAndDestroyPushL; |
|
25 |
|
26 TsTaskMonitorPrivate::TsTaskMonitorPrivate(TsTaskMonitor *q) : q_ptr(q), mClient(0) |
|
27 { |
|
28 QT_TRAP_THROWING(mClient = CTsTaskMonitorClient::NewL()); |
|
29 mClient->Subscribe(*this); |
|
30 } |
|
31 |
|
32 TsTaskMonitorPrivate::~TsTaskMonitorPrivate() |
|
33 { |
|
34 mClient->CancelSubscribe(); |
|
35 } |
|
36 |
|
37 QList< QSharedPointer<TsTask> > TsTaskMonitorPrivate::taskList() |
|
38 { |
|
39 QList< QSharedPointer<TsTask> > tasks; |
|
40 |
|
41 QT_TRAP_THROWING ( |
|
42 RPointerArray<CTsFswEntry> entries; |
|
43 CleanupResetAndDestroyPushL<CTsFswEntry>(entries); |
|
44 mClient->TaskListL(entries); |
|
45 |
|
46 // TsTask claims ownership of CTsFswEntry, so we have to remove entries from |
|
47 // entries array after adding task to tasks array to prevent double delete of |
|
48 // CTsFswEntry objects in case of leave (for example due to OOM) in the middle |
|
49 // of the loop below. |
|
50 while (entries.Count()) { |
|
51 CTsFswEntry *firstEntry = entries[0]; |
|
52 CleanupStack::PushL(firstEntry); |
|
53 entries.Remove(0); |
|
54 |
|
55 // @todo switch by entry type |
|
56 QT_TRYCATCH_LEAVING(tasks.append(QSharedPointer<TsTask>(new TsApplicationTask(firstEntry)))); |
|
57 |
|
58 CleanupStack::Pop(firstEntry); |
|
59 } |
|
60 |
|
61 CleanupStack::PopAndDestroy(&entries); |
|
62 ); |
|
63 |
|
64 return tasks; |
|
65 } |
|
66 |
|
67 void TsTaskMonitorPrivate::HandleRunningAppChange() |
|
68 { |
|
69 emit q_ptr->taskListChanged(); |
|
70 } |