author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:18:30 +0300 | |
branch | RCL_3 |
changeset 102 | ba63c83f4716 |
parent 88 | 3321d3e205b6 |
permissions | -rw-r--r-- |
83 | 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: File containing application list classes |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
//INCLUDES: |
|
20 |
#include "tsfswdatalist.h" |
|
21 |
#include "tsfswengine.h" |
|
22 |
#include "tsfsalwaysshownapplist.h" |
|
23 |
#include "tsfshiddenapplist.h" |
|
24 |
#include "tsfswidgetlist.h" |
|
25 |
#include "tsfswiconcache.h" |
|
26 |
#include "enginelogging.h" |
|
27 |
#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL |
|
28 |
#include <featmgr.h> |
|
29 |
#include <apgwgnam.h> |
|
30 |
||
31 |
// Special case: ovi store secure widget UID |
|
32 |
const TUid KTsOviStoreSecureWidgetUid = { 0x2001A93E }; |
|
33 |
||
34 |
// ================= MEMBER FUNCTIONS ======================= |
|
35 |
||
36 |
// -------------------------------------------------------------------------- |
|
37 |
// CTsFswDataList::NewL |
|
38 |
// -------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
CTsFswDataList* CTsFswDataList::NewL(CTsFswEngine& aEngine) |
|
41 |
{ |
|
42 |
CTsFswDataList* self = new (ELeave) CTsFswDataList(aEngine); |
|
43 |
CleanupStack::PushL (self ); |
|
44 |
self->ConstructL ( ); |
|
45 |
CleanupStack::Pop ( self ); |
|
46 |
return self; |
|
47 |
} |
|
48 |
||
49 |
// -------------------------------------------------------------------------- |
|
50 |
// CTsFswDataList::CTsFswDataList |
|
51 |
// -------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
CTsFswDataList::CTsFswDataList(CTsFswEngine& aEngine) : |
|
54 |
iEngine(aEngine) |
|
55 |
{ |
|
56 |
} |
|
57 |
||
58 |
// -------------------------------------------------------------------------- |
|
59 |
// CTsFswDataList::~CTsFswDataList |
|
60 |
// -------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CTsFswDataList::~CTsFswDataList( ) |
|
63 |
{ |
|
64 |
// delete the bitmaps as the hash map cannot do that |
|
65 |
THashMapIter<TInt, CFbsBitmap*> iter( iScreenshots ); |
|
66 |
while ( const TInt* key = iter.NextKey() ) |
|
67 |
{ |
|
68 |
CFbsBitmap** value = iter.CurrentValue(); |
|
69 |
delete *value; |
|
70 |
} |
|
71 |
iScreenshots.Close(); |
|
72 |
delete iAppIcons; |
|
73 |
||
74 |
iData.ResetAndDestroy(); |
|
75 |
||
76 |
delete iHiddenAppList; |
|
77 |
delete iAlwaysShownAppList; |
|
78 |
delete iWidgetList; |
|
79 |
iAppArcSession.Close(); |
|
80 |
iWsSession.Close(); |
|
81 |
} |
|
82 |
||
83 |
// -------------------------------------------------------------------------- |
|
84 |
// CTsFswDataList::ConstructL |
|
85 |
// -------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
void CTsFswDataList::ConstructL( ) |
|
88 |
{ |
|
89 |
User::LeaveIfError( iWsSession.Connect() ); |
|
90 |
User::LeaveIfError( iAppArcSession.Connect() ); |
|
91 |
iHiddenAppList = CTsFsHiddenAppList::NewL( iEngine ); |
|
92 |
iAlwaysShownAppList = CTsFsAlwaysShownAppList::NewL(); |
|
93 |
||
94 |
iWidgetsSupported = FeatureManager::FeatureSupported( KFeatureIdWebWidgets ); |
|
95 |
if ( iWidgetsSupported ) |
|
96 |
{ |
|
97 |
iWidgetList = CTsFsWidgetList::NewL(); |
|
98 |
} |
|
99 |
||
100 |
// create app icon retriever instance |
|
101 |
iAppIcons = CTsFswIconCache::NewL(); |
|
102 |
} |
|
103 |
||
104 |
// -------------------------------------------------------------------------- |
|
105 |
// CTsFswDataList::FswDataL |
|
106 |
// -------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
const RTsFswArray& CTsFswDataList::FswDataL() |
|
109 |
{ |
|
110 |
TSLOG_CONTEXT( FswDataL, TSLOG_LOCAL ); |
|
111 |
TSLOG1_IN( "dirty flag = %d", iTaskListDirty ); |
|
112 |
||
113 |
// check the dirty flag and refresh if needed |
|
114 |
if ( iTaskListDirty ) |
|
115 |
{ |
|
116 |
CollectTasksL(); |
|
117 |
// clear dirty flag |
|
118 |
SetDirty(EFalse); |
|
119 |
} |
|
120 |
||
121 |
// Get app icon for entries without screenshot, |
|
122 |
// do this only here as the app icon is not needed in case a screenshot |
|
123 |
// is already available. |
|
124 |
for ( TInt i = 0, ie = iData.Count(); i != ie; ++i ) |
|
125 |
{ |
|
126 |
if ( !iData[i]->ScreenshotHandle() ) |
|
127 |
{ |
|
128 |
CFbsBitmap* bmp; |
|
129 |
CFbsBitmap* mask; |
|
130 |
TUid appUid = iData[i]->AppUid(); |
|
131 |
// this will leave with -46 in case of widgets if we do not have AllFiles cap |
|
132 |
TRAPD( err, iAppIcons->GetIconL( appUid, bmp, mask ) ); |
|
133 |
if ( err == KErrNone && bmp ) |
|
134 |
{ |
|
135 |
iData[i]->SetAppIconHandles( bmp->Handle(), |
|
136 |
mask ? mask->Handle() : 0 ); |
|
137 |
} |
|
138 |
else |
|
139 |
{ |
|
140 |
iAppIcons->DefaultIcon( bmp, mask ); |
|
141 |
iData[i]->SetAppIconHandles( bmp->Handle(), |
|
142 |
mask ? mask->Handle() : 0 ); |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
||
147 |
TSLOG_OUT(); |
|
148 |
return iData; |
|
149 |
} |
|
150 |
||
151 |
// -------------------------------------------------------------------------- |
|
152 |
// CTsFswDataList::CollectTasksL |
|
153 |
// -------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
TBool CTsFswDataList::CollectTasksL() |
|
156 |
{ |
|
157 |
// clear dirty flag |
|
158 |
TBool changed = iTaskListDirty; |
|
159 |
||
160 |
RTsFswArray newAppsList; |
|
161 |
RTsFswArray newWidgetsList; |
|
162 |
||
163 |
CleanupResetAndDestroyPushL(newAppsList); |
|
164 |
CleanupResetAndDestroyPushL(newWidgetsList); |
|
165 |
||
166 |
CollectAppsL(newAppsList); |
|
167 |
CollectWidgetsL(newWidgetsList); |
|
168 |
||
169 |
changed |= FitDataToListL(newAppsList, EFalse); |
|
170 |
changed |= FitDataToListL(newWidgetsList, ETrue); |
|
171 |
||
172 |
CleanupStack::PopAndDestroy( &newWidgetsList ); |
|
173 |
CleanupStack::PopAndDestroy( &newAppsList ); |
|
174 |
||
175 |
return changed; |
|
176 |
} |
|
177 |
||
178 |
||
179 |
// -------------------------------------------------------------------------- |
|
180 |
// CTsFswDataList::AlwaysShown() |
|
181 |
// -------------------------------------------------------------------------- |
|
182 |
// |
|
183 |
CTsFsAlwaysShownAppList* CTsFswDataList::AlwaysShownApps() |
|
184 |
{ |
|
185 |
return iAlwaysShownAppList; |
|
186 |
} |
|
187 |
||
188 |
// -------------------------------------------------------------------------- |
|
189 |
// CTsFswDataList::HiddenApps() |
|
190 |
// -------------------------------------------------------------------------- |
|
191 |
// |
|
192 |
CTsFsHiddenAppList* CTsFswDataList::HiddenApps() |
|
193 |
{ |
|
194 |
return iHiddenAppList; |
|
195 |
} |
|
196 |
||
197 |
// -------------------------------------------------------------------------- |
|
198 |
// CTsFswDataList::Widgets() |
|
199 |
// -------------------------------------------------------------------------- |
|
200 |
// |
|
201 |
CTsFsWidgetList* CTsFswDataList::Widgets() |
|
202 |
{ |
|
203 |
return iWidgetList; |
|
204 |
} |
|
205 |
||
206 |
// -------------------------------------------------------------------------- |
|
207 |
// CTsFswDataList::SetDirty() |
|
208 |
// -------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
void CTsFswDataList::SetDirty(TBool aDirty) |
|
211 |
{ |
|
212 |
iTaskListDirty = aDirty; |
|
213 |
} |
|
214 |
||
215 |
// -------------------------------------------------------------------------- |
|
216 |
// CTsFswDataList::SetAppDataRefreshNeeded() |
|
217 |
// -------------------------------------------------------------------------- |
|
218 |
// |
|
219 |
void CTsFswDataList::SetAppDataRefreshNeeded() |
|
220 |
{ |
|
221 |
iAppDataRefreshNeeded = ETrue; |
|
222 |
} |
|
223 |
||
224 |
// -------------------------------------------------------------------------- |
|
225 |
// CTsFswDataList::ForwardScreenshot |
|
226 |
// -------------------------------------------------------------------------- |
|
227 |
// |
|
228 |
TBool CTsFswDataList::StoreScreenshot(TInt aId, CFbsBitmap* aBmp) |
|
229 |
{ |
|
230 |
TBool changed = EFalse; |
|
231 |
CFbsBitmap** oldbmp = iScreenshots.Find( aId ); |
|
232 |
if ( oldbmp ) |
|
233 |
{ |
|
234 |
delete *oldbmp; |
|
235 |
} |
|
236 |
if ( iScreenshots.Insert( aId, aBmp ) != KErrNone ) |
|
237 |
{ |
|
238 |
delete aBmp; |
|
239 |
iScreenshots.Remove( aId ); |
|
240 |
} |
|
241 |
else |
|
242 |
{ |
|
243 |
changed = AssignScreenshotHandle( aId, aBmp->Handle() ); |
|
244 |
} |
|
245 |
return changed; |
|
246 |
} |
|
247 |
||
248 |
// -------------------------------------------------------------------------- |
|
249 |
// CTsFswDataList::RemoveScreenshotByWgId |
|
250 |
// -------------------------------------------------------------------------- |
|
251 |
// |
|
252 |
TBool CTsFswDataList::RemoveScreenshot(TInt aId) |
|
253 |
{ |
|
254 |
TBool changed = EFalse; |
|
255 |
CFbsBitmap** bmp = iScreenshots.Find( aId ); |
|
256 |
||
257 |
if ( bmp ) |
|
258 |
{ |
|
259 |
changed |= AssignScreenshotHandle( aId, 0 ); |
|
260 |
changed |= RemoveScreenshotFromParent( (*bmp)->Handle()); |
|
261 |
delete *bmp; |
|
262 |
iScreenshots.Remove( aId ); |
|
263 |
} |
|
264 |
return changed; |
|
265 |
} |
|
266 |
||
267 |
||
268 |
||
269 |
// -------------------------------------------------------------------------- |
|
270 |
// CTsFswDataList::FindScreenshotByWgId |
|
271 |
// -------------------------------------------------------------------------- |
|
272 |
// |
|
273 |
CFbsBitmap** CTsFswDataList::FindScreenshot(TInt aId) |
|
274 |
{ |
|
275 |
CFbsBitmap** result = 0; |
|
276 |
result = iScreenshots.Find( aId ); |
|
277 |
return result; |
|
278 |
} |
|
279 |
||
280 |
// -------------------------------------------------------------------------- |
|
281 |
// CTsFswDataList::MoveEntryAtStart |
|
282 |
// -------------------------------------------------------------------------- |
|
283 |
// |
|
284 |
TBool CTsFswDataList::MoveEntryAtStart(TInt aAppId, TBool aWidget) |
|
285 |
{ |
|
286 |
TSLOG_CONTEXT( MoveEntryAtStart, TSLOG_LOCAL ); |
|
287 |
||
288 |
TBool wasMoved(EFalse); |
|
289 |
TInt appId(0); |
|
290 |
//check embeded case |
|
291 |
if( !aWidget ) |
|
292 |
{ |
|
293 |
TInt wgId(0); |
|
294 |
CApaWindowGroupName::FindByAppUid(TUid::Uid(aAppId), iWsSession, wgId); |
|
295 |
TInt parentWgId = FindMostTopParentWgId( wgId ); |
|
296 |
if( parentWgId != KErrNotFound ) |
|
297 |
{ |
|
298 |
TUid appUid = TUid::Uid(0); |
|
299 |
AppUidForWgId(parentWgId, appUid); |
|
300 |
appId = appUid.iUid; |
|
301 |
} |
|
302 |
} |
|
303 |
||
304 |
if( !appId ) |
|
305 |
{ |
|
306 |
appId = aAppId; |
|
307 |
} |
|
308 |
||
309 |
for ( TInt i = 0; i < iData.Count(); ++i ) |
|
310 |
{ |
|
311 |
if( iData[i]->AppUid().iUid == appId && |
|
312 |
((iData[i]->Widget() == aWidget) || (iData[i]->AppUid() == KTsOviStoreSecureWidgetUid ))) |
|
313 |
{ |
|
314 |
CTsFswEntry* entry = iData[i]; |
|
315 |
iData.Remove(i); |
|
316 |
iData.Insert(entry, 0); |
|
317 |
SetDirty(ETrue); |
|
318 |
wasMoved = ETrue; |
|
319 |
break; |
|
320 |
} |
|
321 |
} |
|
322 |
TSLOG_OUT(); |
|
323 |
return wasMoved; |
|
324 |
} |
|
325 |
||
326 |
// -------------------------------------------------------------------------- |
|
327 |
// CTsFswDataList:: |
|
328 |
// -------------------------------------------------------------------------- |
|
329 |
// |
|
330 |
void CTsFswDataList::CollectAppsL(RTsFswArray& aAppsList) |
|
331 |
{ |
|
332 |
TSLOG_CONTEXT( CollectTasksL, TSLOG_LOCAL ); |
|
333 |
TSLOG_IN(); |
|
334 |
||
335 |
// update app data if needed |
|
336 |
// (usually on startup and when new apps might have been installed) |
|
337 |
if ( iAppDataRefreshNeeded ) |
|
338 |
{ |
|
339 |
TSLOG0( TSLOG_INFO, "refreshing app data" ); |
|
340 |
iAppArcSession.GetAllApps(); |
|
341 |
iAlwaysShownAppList->InitializeAlwaysShownListL(); |
|
342 |
iAppDataRefreshNeeded = EFalse; |
|
343 |
} |
|
344 |
||
345 |
// get all window groups |
|
346 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
347 |
CleanupClosePushL( allWgIds ); |
|
348 |
User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) ); |
|
349 |
||
350 |
TInt count = allWgIds.Count(); |
|
351 |
for ( TInt i = 0; i < count; ++i ) |
|
352 |
{ |
|
353 |
// ignore uninteresting entries (e.g. embedded apps) |
|
354 |
if ( allWgIds[i].iParentId > 0 ) |
|
355 |
{ |
|
356 |
continue; |
|
357 |
} |
|
358 |
||
359 |
// get window group name |
|
360 |
TInt wgId = allWgIds[i].iId; |
|
361 |
CApaWindowGroupName* windowName = |
|
362 |
CApaWindowGroupName::NewLC( iWsSession, wgId ); |
|
363 |
TUid appUid = windowName->AppUid(); |
|
364 |
||
365 |
// ignore entries with null uid |
|
366 |
if ( !appUid.iUid ) |
|
367 |
{ |
|
368 |
CleanupStack::PopAndDestroy( windowName ); |
|
369 |
continue; |
|
370 |
} |
|
371 |
||
372 |
// will append the task to our own list only if it is not hidden |
|
373 |
TBool onHiddenList = iHiddenAppList->IsHiddenL( |
|
374 |
appUid, iWsSession, wgId ); |
|
375 |
||
376 |
// get screen number (-1=console, 0=main screen, 1=cover ui) |
|
377 |
TInt appScreen = 0; |
|
378 |
TInt scrNumErr = iAppArcSession.GetDefaultScreenNumber( appScreen, appUid ); |
|
379 |
||
380 |
// check if it is on always-shown list |
|
381 |
TBool mustShow = iAlwaysShownAppList->IsAlwaysShownApp( appUid ); |
|
382 |
||
383 |
#ifdef _DEBUG |
|
384 |
const TDesC& captionDbg( windowName->Caption() ); |
|
385 |
TSLOG4( TSLOG_INFO, "[%d] wgid=%d appuid=%x (%S)", i, wgId, |
|
386 |
appUid.iUid, &captionDbg ); |
|
387 |
TSLOG4( TSLOG_INFO, "hidden=%d onhiddenlist=%d mustshow=%d scrno=%d", |
|
388 |
windowName->Hidden(), onHiddenList, mustShow, appScreen ); |
|
389 |
#endif |
|
390 |
if ( iWidgetsSupported && appUid.iUid == KWidgetAppUidValue ) |
|
391 |
{ |
|
392 |
//continue, leave widgetui, do nothing |
|
393 |
} |
|
394 |
// add item to task list if it is always-shown OR it is not hidden |
|
395 |
// and it is not on cover ui |
|
396 |
else if (mustShow || (!onHiddenList && !windowName->Hidden() && (appScreen |
|
397 |
== 0 || appScreen == -1) && scrNumErr == KErrNone)) |
|
398 |
{ |
|
399 |
AddEntryL(wgId, appUid, windowName, aAppsList, EFalse); |
|
400 |
} |
|
401 |
CleanupStack::PopAndDestroy( windowName ); |
|
402 |
} |
|
403 |
CleanupStack::PopAndDestroy( &allWgIds ); |
|
404 |
TSLOG_OUT(); |
|
405 |
} |
|
406 |
||
407 |
// -------------------------------------------------------------------------- |
|
408 |
// CTsFswDataList::AddEntryL |
|
409 |
// -------------------------------------------------------------------------- |
|
410 |
// |
|
411 |
TBool CTsFswDataList::AddEntryL( TInt aWgId, const TUid& aAppUid, |
|
412 |
CApaWindowGroupName* aWgName, RTsFswArray& aNewList, |
|
413 |
TBool aIsWidget ) |
|
414 |
{ |
|
415 |
TBool changed = EFalse; |
|
416 |
CTsFswEntry* entry = CTsFswEntry::NewLC(); |
|
417 |
entry->SetWgId( aWgId ); |
|
418 |
entry->SetAppUid( aAppUid ); |
|
419 |
entry->SetWidget( aIsWidget ); |
|
420 |
||
421 |
// check if present in old list and if yes then take some of the old data |
|
422 |
TBool found = ConsiderOldDataL( *entry, aAppUid, changed, aNewList ); |
|
423 |
||
424 |
// if not present previously then find out app name |
|
425 |
// and check if screenshot is already available |
|
426 |
if ( !found ) |
|
427 |
{ |
|
428 |
// when adding a new entry to the list it is changed for sure |
|
429 |
changed = ETrue; |
|
430 |
HBufC* name = FindAppNameLC( aWgName, aAppUid, aWgId ); |
|
431 |
if ( name ) |
|
432 |
{ |
|
433 |
entry->SetAppNameL( *name ); |
|
434 |
} |
|
435 |
CleanupStack::PopAndDestroy( name ); |
|
436 |
||
437 |
entry->SetAlwaysShown( iAlwaysShownAppList->IsAlwaysShownApp( aAppUid ) ); |
|
438 |
if ( aWgName ) |
|
439 |
{ |
|
440 |
entry->SetSystemApp( aWgName->IsSystem() ); |
|
441 |
} |
|
442 |
} |
|
443 |
TInt h = LookupScreenshotHandle( aWgId ); |
|
444 |
if ( h ) |
|
445 |
{ |
|
446 |
entry->SetScreenshotHandle( h ); |
|
447 |
} |
|
448 |
// add to new list, ownership is transferred |
|
449 |
aNewList.AppendL( entry ); |
|
450 |
CleanupStack::Pop( entry ); |
|
451 |
return changed; |
|
452 |
} |
|
453 |
||
454 |
// -------------------------------------------------------------------------- |
|
455 |
// CTsFswDataList::ConsiderOldDataL |
|
456 |
// -------------------------------------------------------------------------- |
|
457 |
// |
|
458 |
TBool CTsFswDataList::ConsiderOldDataL( CTsFswEntry& aEntry, |
|
459 |
const TUid& aAppUid, |
|
460 |
TBool& aChanged, |
|
461 |
RTsFswArray& aNewList ) |
|
462 |
{ |
|
463 |
for ( TInt entryIdx = 0, oldCount = iData.Count(); |
|
464 |
entryIdx < oldCount; ++entryIdx ) |
|
465 |
{ |
|
466 |
// Enough to check appuid, no need to bother with wgid as the |
|
467 |
// screenshot handle is up-to-date or will be updated later anyway. |
|
468 |
if ( iData[entryIdx]->AppUid() == aAppUid ) |
|
469 |
{ |
|
470 |
iData[entryIdx]->SetWgId( aEntry.WgId()); |
|
471 |
// if positions do not match then the list is different than before |
|
472 |
if ( entryIdx != aNewList.Count() ) |
|
473 |
{ |
|
474 |
aChanged = ETrue; |
|
475 |
} |
|
476 |
CTsFswEntry* oldEntry = iData[entryIdx]; |
|
477 |
aEntry.SetAppNameL( oldEntry->AppName() ); |
|
478 |
aEntry.SetScreenshotHandle( oldEntry->ScreenshotHandle() ); |
|
479 |
aEntry.SetAlwaysShown( oldEntry->AlwaysShown() ); |
|
480 |
aEntry.SetSystemApp( oldEntry->SystemApp() ); |
|
481 |
return ETrue; |
|
482 |
} |
|
483 |
} |
|
484 |
return EFalse; |
|
485 |
} |
|
486 |
// -------------------------------------------------------------------------- |
|
487 |
// CTsFswDataList::CollectWidgetsL |
|
488 |
// -------------------------------------------------------------------------- |
|
489 |
// |
|
490 |
void CTsFswDataList::CollectWidgetsL(RTsFswArray& aWidgetsList) |
|
491 |
{ |
|
492 |
if( iWidgetsSupported ) |
|
493 |
{ |
|
494 |
iWidgetList->InitializeWidgetListL(); |
|
495 |
const RWidgetInfoArray& arr( iWidgetList->RunningWidgets() ); |
|
496 |
for ( TInt i = 0, ie = arr.Count(); i != ie; ++i ) |
|
497 |
{ |
|
498 |
//verify if widget is working in full screen mode |
|
499 |
if( arr[i]->iFileSize ) |
|
500 |
{ |
|
501 |
// wgid will be a special negative value |
|
502 |
// windowgroupname is not needed here so pass NULL |
|
503 |
AddEntryL( -(i+1), arr[i]->iUid, 0, aWidgetsList, ETrue ); |
|
504 |
} |
|
505 |
} |
|
506 |
} |
|
507 |
} |
|
508 |
||
509 |
// -------------------------------------------------------------------------- |
|
510 |
// CTsFswDataList::FindParentWgId |
|
511 |
// -------------------------------------------------------------------------- |
|
512 |
// |
|
513 |
TInt CTsFswDataList::FindParentWgId( TInt aWgId ) |
|
514 |
{ |
|
515 |
TInt parent( KErrNotFound ); |
|
516 |
RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
517 |
// Ask for window group list from RWsSession |
|
518 |
TInt error = iWsSession.WindowGroupList( 0, &allWgIds ); |
|
519 |
if ( !error ) |
|
520 |
{ |
|
521 |
TInt count( allWgIds.Count() ); |
|
522 |
for ( TInt i( 0 ); i < count; i++ ) |
|
523 |
{ |
|
524 |
RWsSession::TWindowGroupChainInfo info = allWgIds[i]; |
|
525 |
if ( info.iId == aWgId && info.iParentId > 0) |
|
526 |
{ |
|
527 |
parent = info.iParentId; |
|
528 |
break; |
|
529 |
} |
|
530 |
} |
|
531 |
} |
|
532 |
allWgIds.Close(); |
|
533 |
return parent; |
|
534 |
} |
|
535 |
||
536 |
// -------------------------------------------------------------------------- |
|
537 |
// CTsFswDataList::FindMostTopParentWgId |
|
538 |
// -------------------------------------------------------------------------- |
|
539 |
// |
|
540 |
TInt CTsFswDataList::FindMostTopParentWgId( TInt aWgId ) |
|
541 |
{ |
|
542 |
TInt parent( KErrNotFound ); |
|
543 |
parent = FindParentWgId( aWgId ); |
|
544 |
if( parent != KErrNotFound) |
|
545 |
{ |
|
546 |
TInt topParent = FindMostTopParentWgId(parent); |
|
547 |
if( topParent != KErrNotFound ) |
|
548 |
{ |
|
549 |
parent = topParent; |
|
550 |
} |
|
551 |
} |
|
552 |
return parent; |
|
553 |
} |
|
554 |
||
555 |
// -------------------------------------------------------------------------- |
|
556 |
// CTsFswDataList::FindAppNameLC |
|
557 |
// -------------------------------------------------------------------------- |
|
558 |
// |
|
559 |
HBufC* CTsFswDataList::FindAppNameLC( CApaWindowGroupName* aWindowName, |
|
560 |
const TUid& aAppUid, |
|
561 |
TInt aWgId ) |
|
562 |
{ |
|
563 |
//Retrieve the app name |
|
564 |
TApaAppInfo info; |
|
565 |
iAppArcSession.GetAppInfo( info, aAppUid ); |
|
566 |
TPtrC caption = info.iShortCaption; |
|
567 |
||
568 |
HBufC* tempName = 0; |
|
569 |
if ( !caption.Length() && aWindowName ) // if not set - use thread name instead |
|
570 |
{ |
|
571 |
if ( aWindowName->Caption().Length() ) |
|
572 |
{ |
|
573 |
tempName = aWindowName->Caption().AllocL(); |
|
574 |
//put on cleanupstack after the if |
|
575 |
} |
|
576 |
else |
|
577 |
{ |
|
578 |
TThreadId threadId; |
|
579 |
TInt err = iWsSession.GetWindowGroupClientThreadId( |
|
580 |
aWgId, threadId ); |
|
581 |
if ( err == KErrNone ) |
|
582 |
{ |
|
583 |
RThread thread; |
|
584 |
CleanupClosePushL( thread ); |
|
585 |
err = thread.Open ( threadId ); |
|
586 |
if ( err==KErrNone ) |
|
587 |
{ |
|
588 |
tempName = thread.Name().AllocL(); // codescanner::forgottoputptroncleanupstack |
|
589 |
// tempName put on cleanupstack after the if |
|
590 |
} |
|
591 |
CleanupStack::PopAndDestroy( &thread ); |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
else |
|
596 |
{ |
|
597 |
tempName = caption.AllocL(); |
|
598 |
//put on cleanupstack after the if |
|
599 |
} |
|
600 |
CleanupStack::PushL( tempName ); |
|
601 |
return tempName; |
|
602 |
} |
|
603 |
||
604 |
// -------------------------------------------------------------------------- |
|
605 |
// CTsFswDataList::AssignScreenshotHandle |
|
606 |
// Called when a screenshot arrives to check if there is a corresponding |
|
607 |
// application in the task list. Firstly try to match screenshot into parental |
|
608 |
// application then into standalone one. |
|
609 |
// -------------------------------------------------------------------------- |
|
610 |
// |
|
611 |
TBool CTsFswDataList::AssignScreenshotHandle( TInt aWgIdForScreenshot, |
|
612 |
TInt aBitmapHandle ) |
|
613 |
{ |
|
614 |
// aWgIdForScreenshot, aBitmapHandle); |
|
615 |
TBool changed = EFalse; |
|
616 |
TInt parentWgId = FindMostTopParentWgId( aWgIdForScreenshot ); |
|
617 |
// now parentWgId is a valid wgid or KErrNotFound (-1) |
|
618 |
if (parentWgId != KErrNotFound) |
|
619 |
{ |
|
620 |
AssignScreenshotHandle( parentWgId, aBitmapHandle, changed ); |
|
621 |
} |
|
622 |
if (!changed) |
|
623 |
{ |
|
624 |
AssignScreenshotHandle( aWgIdForScreenshot, aBitmapHandle, changed ); |
|
625 |
} |
|
626 |
return changed; |
|
627 |
} |
|
628 |
||
629 |
// -------------------------------------------------------------------------- |
|
630 |
// CTsFswDataList::AssignScreenshotHandle |
|
631 |
// Called when a screenshot arrives to check if there is a corresponding |
|
632 |
// application in the task list. It might be tried to be match into parental |
|
633 |
// or standalone application. |
|
634 |
// -------------------------------------------------------------------------- |
|
635 |
// |
|
636 |
void CTsFswDataList::AssignScreenshotHandle(TInt aWgIdForScreenshot, |
|
637 |
TInt aBitmapHandle, TBool& aAsigned) |
|
638 |
{ |
|
639 |
aAsigned = EFalse; |
|
640 |
for (TInt i = 0, ie = iData.Count(); i != ie; ++i) |
|
641 |
{ |
|
642 |
if (iData[i]->Widget() || iData[i]->AppUid() == KTsOviStoreSecureWidgetUid ) |
|
643 |
{ |
|
644 |
TInt widgetId = iData[i]->AppUid().iUid; |
|
645 |
if (widgetId == aWgIdForScreenshot) |
|
646 |
{ |
|
647 |
iData[i]->SetScreenshotHandle(aBitmapHandle); |
|
648 |
aAsigned = ETrue; |
|
649 |
SetDirty(ETrue); |
|
650 |
break; |
|
651 |
} |
|
652 |
continue; |
|
653 |
} |
|
654 |
TInt appWgId = iData[i]->WgId(); |
|
655 |
if (appWgId == aWgIdForScreenshot) |
|
656 |
{ |
|
657 |
iData[i]->SetScreenshotHandle(aBitmapHandle); |
|
658 |
aAsigned = ETrue; |
|
659 |
SetDirty(ETrue); |
|
660 |
break; |
|
661 |
} |
|
662 |
} |
|
663 |
} |
|
664 |
||
665 |
// -------------------------------------------------------------------------- |
|
666 |
// CTsFswDataList::LookupScreenshotHandle |
|
667 |
// Called to check if there is a screenshot already stored for the given |
|
668 |
// app. (or a screenshot with a wgid for which aWgIdForApp is the parent) |
|
669 |
// -------------------------------------------------------------------------- |
|
670 |
// |
|
671 |
TInt CTsFswDataList::LookupScreenshotHandle( TInt aWgIdForApp ) |
|
672 |
{ |
|
673 |
CFbsBitmap** bmp = NULL; |
|
674 |
||
675 |
if ( aWgIdForApp > 0 ) |
|
676 |
{ |
|
677 |
// must check if there is a screenshot for which aWgIdForApp is the parent |
|
678 |
THashMapIter<TInt, CFbsBitmap*> iter( iScreenshots ); |
|
679 |
while ( const TInt* wgid = iter.NextKey() ) |
|
680 |
{ |
|
681 |
if ( FindMostTopParentWgId( *wgid ) == aWgIdForApp ) |
|
682 |
{ |
|
683 |
THashMapIter<TInt, CFbsBitmap*> iter2( iScreenshots ); |
|
684 |
TBool hasChild = false; |
|
685 |
while ( const TInt* wgid2 = iter2.NextKey() ) |
|
686 |
{ |
|
687 |
if ( FindParentWgId( *wgid2 ) == *wgid ) |
|
688 |
{ |
|
689 |
hasChild = true; |
|
690 |
break; |
|
691 |
} |
|
692 |
} |
|
693 |
if ( !hasChild ) |
|
694 |
{ |
|
695 |
bmp = iter.CurrentValue(); |
|
696 |
if ( bmp ) |
|
697 |
{ |
|
698 |
return (*bmp)->Handle(); |
|
699 |
} |
|
700 |
} |
|
701 |
} |
|
702 |
} |
|
703 |
if ( !bmp ) |
|
704 |
{ |
|
705 |
bmp = iScreenshots.Find( aWgIdForApp ); |
|
706 |
if ( bmp ) |
|
707 |
{ |
|
708 |
// there is a screenshot stored for this wgid |
|
709 |
return (*bmp)->Handle(); |
|
710 |
} |
|
711 |
} |
|
712 |
} |
|
713 |
else if ( aWgIdForApp < 0 ) |
|
714 |
{ |
|
715 |
// Must be a widget, wgid is useless in this case. |
|
716 |
// Do not do anything for now => no screenshot for widgets. |
|
717 |
} |
|
718 |
return 0; |
|
719 |
} |
|
720 |
||
721 |
// -------------------------------------------------------------------------- |
|
722 |
// CTsFswDataList::FitDataToListL |
|
723 |
// -------------------------------------------------------------------------- |
|
724 |
// |
|
725 |
TBool CTsFswDataList::FitDataToListL(RTsFswArray& aListToFit, |
|
726 |
TBool aConsiderWidgets) |
|
727 |
{ |
|
728 |
TSLOG_CONTEXT( FitDataToListL, TSLOG_LOCAL ); |
|
729 |
TBool changed = EFalse; |
|
730 |
TInt listCount = aListToFit.Count(); |
|
731 |
TInt dataCount = iData.Count(); |
|
732 |
||
733 |
//remove items that dont't exists in newly collected list |
|
734 |
//consider widget and non-widget type |
|
735 |
for (TInt i = dataCount -1; i >= 0; --i) |
|
736 |
{ |
|
737 |
if ( (iData[i]->Widget() == aConsiderWidgets) && |
|
738 |
!CheckIfExists(*iData[i], aListToFit) ) |
|
739 |
{ |
|
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
740 |
if( aConsiderWidgets ) |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
741 |
{ |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
742 |
RemoveScreenshot( iData[i]->AppUid().iUid ); |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
743 |
} |
83 | 744 |
delete iData[i]; |
745 |
iData.Remove(i); |
|
746 |
changed = ETrue; |
|
747 |
} |
|
748 |
} |
|
749 |
||
750 |
//add new item at start |
|
751 |
for (TInt i = 0; i < aListToFit.Count(); ++i) |
|
752 |
{ |
|
753 |
if (!CheckIfExists(*aListToFit[i], iData)) |
|
754 |
{ |
|
755 |
iData.Insert(aListToFit[i], 0); |
|
756 |
aListToFit[i] = 0; |
|
757 |
changed = ETrue; |
|
758 |
} |
|
759 |
} |
|
760 |
||
761 |
TSLOG1_OUT( "change flag = %d", changed ); |
|
762 |
return changed; |
|
763 |
} |
|
764 |
||
765 |
// -------------------------------------------------------------------------- |
|
766 |
// CTsFswDataList::CheckIfExists |
|
767 |
// -------------------------------------------------------------------------- |
|
768 |
// |
|
769 |
TBool CTsFswDataList::CheckIfExists(const CTsFswEntry& aEntry, |
|
770 |
const RTsFswArray& aList) const |
|
771 |
{ |
|
772 |
TSLOG_CONTEXT( FitDataToListL, TSLOG_LOCAL ); |
|
773 |
TBool exists(EFalse); |
|
774 |
TInt dataCount = aList.Count(); |
|
775 |
for (TInt entryIdx = 0; entryIdx < dataCount; ++entryIdx) |
|
776 |
{ |
|
777 |
if (aList[entryIdx]->AppUid() == aEntry.AppUid()) |
|
778 |
{ |
|
779 |
exists = ETrue; |
|
780 |
break; |
|
781 |
} |
|
782 |
} |
|
783 |
TSLOG_OUT(); |
|
784 |
return exists; |
|
785 |
} |
|
786 |
||
787 |
// -------------------------------------------------------------------------- |
|
788 |
// CTsFswDataList::AppUidForWgIdL |
|
789 |
// -------------------------------------------------------------------------- |
|
790 |
// |
|
791 |
TBool CTsFswDataList::IsAlwaysShownAppL( TInt aWgId ) |
|
792 |
{ |
|
793 |
return iAlwaysShownAppList->IsAlwaysShownApp( AppUidForWgIdL(aWgId) ); |
|
794 |
} |
|
795 |
||
796 |
// -------------------------------------------------------------------------- |
|
797 |
// CTsFswDataList::AppUidForWgId |
|
798 |
// -------------------------------------------------------------------------- |
|
799 |
// |
|
800 |
TInt CTsFswDataList::AppUidForWgId( TInt aWgId, TUid& aUid ) |
|
801 |
{ |
|
802 |
TRAPD(err, aUid = AppUidForWgIdL( aWgId ) ); |
|
803 |
return err; |
|
804 |
} |
|
805 |
||
806 |
// -------------------------------------------------------------------------- |
|
807 |
// CTsFswDataList::AppUidForWgIdL |
|
808 |
// -------------------------------------------------------------------------- |
|
809 |
// |
|
810 |
TUid CTsFswDataList::AppUidForWgIdL( TInt aWgId ) |
|
811 |
{ |
|
812 |
CApaWindowGroupName* windowName = |
|
813 |
CApaWindowGroupName::NewLC( iWsSession, aWgId ); |
|
814 |
TUid appUid = windowName->AppUid(); |
|
815 |
CleanupStack::PopAndDestroy( windowName ); |
|
816 |
return appUid; |
|
817 |
} |
|
818 |
||
819 |
// -------------------------------------------------------------------------- |
|
820 |
// CTsFswDataList::RemoveScreenshotFromParent |
|
821 |
// -------------------------------------------------------------------------- |
|
822 |
// |
|
823 |
TBool CTsFswDataList::RemoveScreenshotFromParent( TInt aBmpHandle ) |
|
824 |
{ |
|
825 |
TBool changed(EFalse); |
|
826 |
for( TInt i = 0; i < iData.Count(); ++i) |
|
827 |
{ |
|
828 |
if ( !iData[i]->Widget() && iData[i]->ScreenshotHandle() == aBmpHandle ) |
|
829 |
{ |
|
830 |
changed = ETrue; |
|
831 |
iData[i]->SetScreenshotHandle( |
|
832 |
LookupScreenshotHandle( iData[i]->WgId()) ); |
|
833 |
} |
|
834 |
} |
|
835 |
return changed; |
|
836 |
} |
|
837 |
||
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
838 |
// -------------------------------------------------------------------------- |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
839 |
// CTsFswDataList::CheckForWgIdUsage |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
840 |
// -------------------------------------------------------------------------- |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
841 |
// |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
842 |
TBool CTsFswDataList::CheckForWgIdUsage( TInt aWgId ) |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
843 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
844 |
// check the dirty flag and refresh if needed |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
845 |
if ( iTaskListDirty ) |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
846 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
847 |
TRAP_IGNORE ( CollectTasksL(); ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
848 |
// clear dirty flag |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
849 |
SetDirty(EFalse); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
850 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
851 |
TBool used( EFalse ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
852 |
TInt count = iData.Count(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
853 |
for (TInt i = 0; i < count; i++ ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
854 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
855 |
if( iData[i]->WgId() == aWgId ) |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
856 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
857 |
used = ETrue; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
858 |
break; |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
859 |
} |
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
860 |
} |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
861 |
return used; |
88
3321d3e205b6
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
83
diff
changeset
|
862 |
} |
83 | 863 |
// end of file |