94
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Task monitor engine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "tsfswengine.h"
|
|
20 |
|
|
21 |
#include "tsfswdatalist.h"
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#include <apgtask.h>
|
|
27 |
#include <AknDef.h>
|
|
28 |
#include <apgwgnam.h>
|
|
29 |
#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
|
|
30 |
#include <featmgr.h>
|
|
31 |
#include <swi/swispubsubdefs.h>
|
|
32 |
#include <s32mem.h>
|
|
33 |
#include <bitmaptransforms.h>
|
|
34 |
|
|
35 |
// time to wait before refreshing content
|
|
36 |
const TInt KContentRefreshDelay = 50000; // 0.05 sec
|
|
37 |
|
|
38 |
|
|
39 |
// --------------------------------------------------------------------------
|
|
40 |
// CTsFswEngine::NewL
|
|
41 |
// --------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CTsFswEngine* CTsFswEngine::NewL( MHsDataObserver& aObserver )
|
|
44 |
{
|
|
45 |
CTsFswEngine* self = NewLC( aObserver );
|
|
46 |
CleanupStack::Pop( self );
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
// --------------------------------------------------------------------------
|
|
51 |
// CTsFswEngine::NewLC
|
|
52 |
// --------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CTsFswEngine* CTsFswEngine::NewLC( MHsDataObserver& aObserver )
|
|
55 |
{
|
|
56 |
CTsFswEngine* self = new ( ELeave ) CTsFswEngine( aObserver );
|
|
57 |
CleanupStack::PushL( self );
|
|
58 |
self->ConstructL();
|
|
59 |
return self;
|
|
60 |
}
|
|
61 |
|
|
62 |
// --------------------------------------------------------------------------
|
|
63 |
// CTsFswEngine::CTsFswEngine
|
|
64 |
// --------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CTsFswEngine::CTsFswEngine( MHsDataObserver& aObserver )
|
|
67 |
:iObserver( aObserver )
|
|
68 |
{
|
|
69 |
}
|
|
70 |
|
|
71 |
// --------------------------------------------------------------------------
|
|
72 |
// CTsFswEngine::ConstructL
|
|
73 |
// --------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CTsFswEngine::ConstructL()
|
|
76 |
{
|
|
77 |
User::LeaveIfError( iWsSession.Connect() );
|
|
78 |
User::LeaveIfError( iAppArcSession.Connect() );
|
|
79 |
|
|
80 |
iDataList = CTsFswDataList::NewL(*this);
|
|
81 |
|
|
82 |
// get an initial list of tasks
|
|
83 |
iDataList->SetAppDataRefreshNeeded();
|
|
84 |
CollectTasksL();
|
|
85 |
|
|
86 |
iUpdateStarter = CPeriodic::NewL( CActive::EPriorityStandard );
|
|
87 |
}
|
|
88 |
|
|
89 |
// --------------------------------------------------------------------------
|
|
90 |
// CTsFswEngine::~CTsFswEngine
|
|
91 |
// --------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
CTsFswEngine::~CTsFswEngine()
|
|
94 |
{
|
|
95 |
|
|
96 |
delete iUpdateStarter;
|
|
97 |
|
|
98 |
iWgIds.Close();
|
|
99 |
|
|
100 |
iAppArcSession.Close();
|
|
101 |
iWsSession.Close();
|
|
102 |
|
|
103 |
delete iDataList;
|
|
104 |
}
|
|
105 |
|
|
106 |
// --------------------------------------------------------------------------
|
|
107 |
// CTsFswEngine::FswDataL
|
|
108 |
// --------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
const RTsFswArray& CTsFswEngine::FswDataL()
|
|
111 |
{
|
|
112 |
return iDataList->FswDataL();
|
|
113 |
}
|
|
114 |
|
|
115 |
// --------------------------------------------------------------------------
|
|
116 |
// CTsFswEngine::UpdateTaskList
|
|
117 |
// Callback from appui
|
|
118 |
// --------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CTsFswEngine::UpdateTaskList()
|
|
121 |
{
|
|
122 |
// There can be many calls in a row, use a timer to prevent degrading
|
|
123 |
// device performance.
|
|
124 |
iDataList->SetDirty();
|
|
125 |
if ( !iUpdateStarter->IsActive() )
|
|
126 |
{
|
|
127 |
iUpdateStarter->Start( KContentRefreshDelay, 0,
|
|
128 |
TCallBack( UpdateStarterCallback, this ) );
|
|
129 |
}
|
|
130 |
// get the foreground app uid and publish it to CFW if different than before
|
|
131 |
TRAP_IGNORE( PublishFgAppUidL() );
|
|
132 |
}
|
|
133 |
|
|
134 |
// --------------------------------------------------------------------------
|
|
135 |
// CTsFswEngine::UpdateStarterCallback
|
|
136 |
// Callback for the timer
|
|
137 |
// --------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
TInt CTsFswEngine::UpdateStarterCallback( TAny* aParam )
|
|
140 |
{
|
|
141 |
CTsFswEngine* self = static_cast<CTsFswEngine*>( aParam );
|
|
142 |
self->iUpdateStarter->Cancel();
|
|
143 |
// get list of tasks and notify observer if there is a change in the list
|
|
144 |
TBool changed = EFalse;
|
|
145 |
TRAPD( err, changed = self->CollectTasksL() );
|
|
146 |
if ( err == KErrNone && changed )
|
|
147 |
{
|
|
148 |
self->iObserver.DataChanged();
|
|
149 |
}
|
|
150 |
return 0;
|
|
151 |
}
|
|
152 |
|
|
153 |
// --------------------------------------------------------------------------
|
|
154 |
// CTsFswEngine::CollectTasksL
|
|
155 |
// --------------------------------------------------------------------------
|
|
156 |
//
|
|
157 |
TBool CTsFswEngine::CollectTasksL()
|
|
158 |
{
|
|
159 |
TBool changed = iDataList->CollectTasksL();
|
|
160 |
return changed;
|
|
161 |
}
|
|
162 |
|
|
163 |
// --------------------------------------------------------------------------
|
|
164 |
// CTsFswEngine::ForegroundAppUidL
|
|
165 |
// --------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
TUid CTsFswEngine::ForegroundAppUidL( TInt aType )
|
|
168 |
{
|
|
169 |
// Do not use GetFocusWindowGroup or others.
|
|
170 |
// We want to see only "real" application uids in FgApp,
|
|
171 |
// i.e. stuff that would also be shown in the task swapper
|
|
172 |
// area of Taskswitcher.
|
|
173 |
|
|
174 |
TUid result = KNullUid;
|
|
175 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
|
|
176 |
CleanupClosePushL( allWgIds );
|
|
177 |
User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) );
|
|
178 |
TInt count = allWgIds.Count();
|
|
179 |
for ( TInt i = 0; i < count; ++i )
|
|
180 |
{
|
|
181 |
// Depending on aType we may not need to bother with iParentId here.
|
|
182 |
// If aType == EUseEmbeddedUid => embedded apps are treated as others.
|
|
183 |
// If aType == EUseStandaloneUid => embedded apps must be ignored.
|
|
184 |
if ( allWgIds[i].iParentId > 0
|
|
185 |
&& aType == CTsFswEngine::EUseStandaloneUid )
|
|
186 |
{
|
|
187 |
continue;
|
|
188 |
}
|
|
189 |
|
|
190 |
CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(
|
|
191 |
iWsSession, allWgIds[i].iId );
|
|
192 |
TUid newUid = wgn->AppUid();
|
|
193 |
TBool hidden = wgn->Hidden();
|
|
194 |
CleanupStack::PopAndDestroy( wgn );
|
|
195 |
|
|
196 |
if ( !hidden && newUid.iUid && !iDataList->IsHiddenUid(newUid) )
|
|
197 |
{
|
|
198 |
result = newUid;
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
CleanupStack::PopAndDestroy( &allWgIds );
|
|
203 |
|
|
204 |
return result;
|
|
205 |
}
|
|
206 |
|
|
207 |
// --------------------------------------------------------------------------
|
|
208 |
// CTsFswEngine::PublishFgAppUidL
|
|
209 |
// --------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
void CTsFswEngine::PublishFgAppUidL()
|
|
212 |
{
|
|
213 |
TUid newUid = ForegroundAppUidL( CTsFswEngine::EUseEmbeddedUid );
|
|
214 |
if ( iFgAppUid != newUid && newUid.iUid )
|
|
215 |
{
|
|
216 |
iFgAppUid = newUid;
|
|
217 |
iDataList->MoveEntryAtStart(newUid.iUid, EFalse);
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
// end of file
|