16 */ |
16 */ |
17 |
17 |
18 //INCLUDES: |
18 //INCLUDES: |
19 |
19 |
20 #include "tsfswdatalist.h" |
20 #include "tsfswdatalist.h" |
21 #include "tsfswengine.h" |
|
22 #include "tsentrykeygenerator.h" |
21 #include "tsentrykeygenerator.h" |
23 #include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL |
22 #include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL |
24 #include <apgwgnam.h> |
23 #include <apgwgnam.h> |
25 #include <bitstd.h> |
24 #include <bitstd.h> |
26 #include <AknIconUtils.h> // avkon |
25 #include <AknIconUtils.h> // avkon |
27 #include <apgicnfl.h> // fbsbitmap |
26 #include <apgicnfl.h> // fbsbitmap |
28 #include <AknIconSrvClient.h> |
27 #include <AknIconSrvClient.h> |
29 #include <fbs.h> |
28 #include <fbs.h> |
30 #include <APGWGNAM.H> |
29 #include <apgwgnam.h> |
31 |
30 |
32 |
31 |
33 // size for the created app icons |
32 // size for the created app icons |
34 const TInt KAppIconWidth = 128; |
33 const TInt KAppIconWidth = 128; |
35 const TInt KAppIconHeight = 128; |
34 const TInt KAppIconHeight = 128; |
36 |
35 |
37 //uids to be hidden |
36 //uids to be hidden |
38 const TUid KHsApplicationUid = { 0x20022F35 }; |
37 const TUid KHsApplicationUid = { 0x20022F35 }; |
39 |
38 |
|
39 const TInt KMaxLookupSize(75); |
|
40 |
40 // ================= MEMBER FUNCTIONS ======================= |
41 // ================= MEMBER FUNCTIONS ======================= |
41 |
42 |
42 // -------------------------------------------------------------------------- |
43 // -------------------------------------------------------------------------- |
43 // CTsFswDataList::NewL |
44 // CTsFswDataList::NewL |
44 // -------------------------------------------------------------------------- |
45 // -------------------------------------------------------------------------- |
45 // |
46 // |
46 CTsFswDataList* CTsFswDataList::NewL(MHsDataObserver &observer) |
47 CTsFswDataList* CTsFswDataList::NewL(MTsResourceManager& resources, |
47 { |
48 MTsWindowGroupsMonitor &monitor, |
48 CTsFswDataList* self = new (ELeave) CTsFswDataList(observer); |
49 MHsDataObserver& observer) |
|
50 { |
|
51 CTsFswDataList* self = new (ELeave) CTsFswDataList(resources, monitor, observer); |
49 CleanupStack::PushL(self); |
52 CleanupStack::PushL(self); |
50 self->ConstructL(); |
53 self->ConstructL(); |
51 CleanupStack::Pop(self); |
54 CleanupStack::Pop(self); |
52 return self; |
55 return self; |
53 } |
56 } |
54 |
57 |
55 // -------------------------------------------------------------------------- |
58 // -------------------------------------------------------------------------- |
56 // CTsFswDataList::CTsFswDataList |
59 // CTsFswDataList::CTsFswDataList |
57 // -------------------------------------------------------------------------- |
60 // -------------------------------------------------------------------------- |
58 // |
61 // |
59 CTsFswDataList::CTsFswDataList(MHsDataObserver& observer) : |
62 CTsFswDataList::CTsFswDataList(MTsResourceManager& resources, |
|
63 MTsWindowGroupsMonitor &monitor, |
|
64 MHsDataObserver& observer) |
|
65 : |
|
66 CTsWindowGroupsObserver(monitor), |
|
67 mResources(resources), |
60 mObserver(observer) |
68 mObserver(observer) |
61 { |
69 { |
62 } |
70 } |
63 |
71 |
64 // -------------------------------------------------------------------------- |
72 // -------------------------------------------------------------------------- |
100 |
105 |
101 // -------------------------------------------------------------------------- |
106 // -------------------------------------------------------------------------- |
102 // CTsFswDataList::CollectTasksL |
107 // CTsFswDataList::CollectTasksL |
103 // -------------------------------------------------------------------------- |
108 // -------------------------------------------------------------------------- |
104 // |
109 // |
105 TBool CTsFswDataList::CollectTasksL() |
110 void CTsFswDataList::HandleWindowGroupChanged(MTsResourceManager &, |
106 { |
111 const TArray<RWsSession::TWindowGroupChainInfo> &wgList) |
107 TBool changed = EFalse; |
112 { |
108 RTsFswArray newAppsList; |
113 TRAP_IGNORE(RTsFswArray newAppsList; |
109 CleanupResetAndDestroyPushL(newAppsList); |
114 CleanupResetAndDestroyPushL(newAppsList); |
110 CollectAppsL(newAppsList); |
115 CollectAppsL(newAppsList, wgList); |
111 changed |= FitDataToListL(newAppsList); |
116 FitDataToList(newAppsList); |
112 CleanupStack::PopAndDestroy(&newAppsList); |
117 CleanupStack::PopAndDestroy(&newAppsList)); |
113 return changed; |
118 |
114 } |
119 } |
115 |
120 |
116 // -------------------------------------------------------------------------- |
121 // -------------------------------------------------------------------------- |
117 // CTsFswDataList:: |
122 // CTsFswDataList:: |
118 // -------------------------------------------------------------------------- |
123 // -------------------------------------------------------------------------- |
119 // |
124 // |
120 void CTsFswDataList::CollectAppsL(RTsFswArray& appsList) |
125 void CTsFswDataList::CollectAppsL(RTsFswArray& appsList, |
121 { |
126 const TArray<RWsSession::TWindowGroupChainInfo> &wgList) |
122 // gets allowed uids - running apps without hidden uids, null uids, filtered uid |
127 { |
123 GetAllowedUidsL(); |
128 TInt offset(KErrNotFound); |
124 |
129 for (TInt i = 0; i < wgList.Count(); ++i) { |
125 // get all window groups |
130 TTsEntryKey key = TsEntryKeyGeneraror::GenerateL(wgList[i].iId, wgList); |
126 RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
127 CleanupClosePushL(allWgIds); |
|
128 User::LeaveIfError(mWsSession.WindowGroupList(0, &allWgIds)); |
|
129 |
|
130 TInt count = allWgIds.Count(); |
|
131 for (TInt i = 0; i < count; ++i) { |
|
132 TTsEntryKey key = TsEntryKeyGeneraror::GenerateL(allWgIds[i].iId, allWgIds.Array()); |
|
133 //skip this entry if it is already on list |
131 //skip this entry if it is already on list |
134 if (FindEntry(appsList, key) >= 0) { |
132 if (FindEntry(appsList, key) >= 0) { |
135 continue; |
133 continue; |
136 } |
134 } |
137 |
135 |
138 // get window group name |
136 // get window group name |
139 TInt wgId = key.mParentId; |
137 TInt wgId = key.mParentId; |
140 CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(mWsSession, wgId); |
138 CApaWindowGroupName* windowName = CApaWindowGroupName::NewLC(mResources.WsSession(), wgId); |
141 TUid appUid = windowName->AppUid(); |
139 TUid appUid = windowName->AppUid(); |
142 |
140 |
143 // add item to task list if uid is allowed |
141 //Check hidden applications |
144 if (mAllowedUids.Find(appUid) >= 0) { |
142 if (KErrNotFound != (offset = mHiddenUids.Find(appUid))) { |
|
143 UpdateLookupTableL(mHiddenUids, offset); |
|
144 } else if (KErrNotFound != (offset = mAllowedUids.Find(appUid))) { |
|
145 UpdateLookupTableL(mAllowedUids, offset); |
145 AddEntryL(key, appUid, windowName, appsList); |
146 AddEntryL(key, appUid, windowName, appsList); |
|
147 } else if(VerifyApplicationL(appUid)) { |
|
148 AddEntryL(key, appUid, windowName, appsList); |
146 } |
149 } |
147 CleanupStack::PopAndDestroy(windowName); |
150 CleanupStack::PopAndDestroy(windowName); |
148 } |
151 } |
149 CleanupStack::PopAndDestroy(&allWgIds); |
152 CompressLookupTable(mHiddenUids); |
|
153 CompressLookupTable(mAllowedUids); |
150 } |
154 } |
151 |
155 |
152 // -------------------------------------------------------------------------- |
156 // -------------------------------------------------------------------------- |
153 // CTsFswDataList::AddEntryL |
157 // CTsFswDataList::AddEntryL |
154 // -------------------------------------------------------------------------- |
158 // -------------------------------------------------------------------------- |
300 { |
305 { |
301 bitmapArg = maskArg = NULL; |
306 bitmapArg = maskArg = NULL; |
302 |
307 |
303 TSize size(KAppIconWidth, KAppIconHeight); |
308 TSize size(KAppIconWidth, KAppIconHeight); |
304 CApaMaskedBitmap* apaMaskedBitmap = CApaMaskedBitmap::NewLC(); |
309 CApaMaskedBitmap* apaMaskedBitmap = CApaMaskedBitmap::NewLC(); |
305 TInt err = mAppArcSession.GetAppIcon(aAppUid, size, *apaMaskedBitmap); |
310 TInt err = mResources.ApaSession().GetAppIcon(aAppUid, size, *apaMaskedBitmap); |
306 TInt iconsCount(0); |
311 TInt iconsCount(0); |
307 if (err == KErrNone) { |
312 if (err == KErrNone) { |
308 err = mAppArcSession.NumberOfOwnDefinedIcons(aAppUid, iconsCount); |
313 err = mResources.ApaSession().NumberOfOwnDefinedIcons(aAppUid, iconsCount); |
309 } |
314 } |
310 |
315 |
311 if ((err == KErrNone) && (iconsCount > 0)) { |
316 if ((err == KErrNone) && (iconsCount > 0)) { |
312 bitmapArg = static_cast<CFbsBitmap*> (apaMaskedBitmap); |
317 bitmapArg = static_cast<CFbsBitmap*> (apaMaskedBitmap); |
313 TInt maskHandle = apaMaskedBitmap->Mask()->Handle(); |
318 TInt maskHandle = apaMaskedBitmap->Mask()->Handle(); |
376 |
381 |
377 // -------------------------------------------------------------------------- |
382 // -------------------------------------------------------------------------- |
378 // CTsFswDataList::SetScreenshotL |
383 // CTsFswDataList::SetScreenshotL |
379 // -------------------------------------------------------------------------- |
384 // -------------------------------------------------------------------------- |
380 // |
385 // |
381 TBool CTsFswDataList::SetScreenshotL(const CFbsBitmap* bitmap, UpdatePriority priority, TInt wgId) |
386 void CTsFswDataList::SetScreenshotL(const CFbsBitmap* bitmap, UpdatePriority priority, TInt wgId) |
382 { |
387 { |
383 RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
388 TInt pos = FindEntry(mData, GenerateKeyL(wgId)); |
384 CleanupClosePushL(allWgIds); |
389 User::LeaveIfError(pos); |
385 User::LeaveIfError(mWsSession.WindowGroupList(0, &allWgIds)); |
390 mData[pos]->SetScreenshotL(bitmap, priority); |
386 TTsEntryKey key = TsEntryKeyGeneraror::GenerateL(wgId, allWgIds.Array()); |
|
387 TInt pos = FindEntry(mData, key); |
|
388 TBool updated(EFalse); |
|
389 if (pos >= 0) { |
|
390 updated = mData[pos]->SetScreenshotL(bitmap, priority); |
|
391 } |
|
392 else { |
|
393 User::Leave(KErrNotFound); |
|
394 } |
|
395 CleanupStack::PopAndDestroy(&allWgIds); |
|
396 return updated; |
|
397 } |
391 } |
398 |
392 |
399 // -------------------------------------------------------------------------- |
393 // -------------------------------------------------------------------------- |
400 // CTsFswDataList::RemoveScreenshotL |
394 // CTsFswDataList::RemoveScreenshotL |
401 // -------------------------------------------------------------------------- |
395 // -------------------------------------------------------------------------- |
402 // |
396 // |
403 TBool CTsFswDataList::RemoveScreenshotL(TInt wgId) |
397 void CTsFswDataList::RemoveScreenshotL(TInt wgId) |
404 { |
398 { |
405 RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
399 |
406 CleanupClosePushL(allWgIds); |
400 TInt pos = FindEntry(mData, GenerateKeyL(wgId)); |
407 User::LeaveIfError(mWsSession.WindowGroupList(0, &allWgIds)); |
401 User::LeaveIfError(pos); |
408 TTsEntryKey key = TsEntryKeyGeneraror::GenerateL(wgId, allWgIds.Array()); |
402 mData[pos]->RemoveScreenshotL(); |
409 TInt pos = FindEntry(mData, key); |
|
410 TBool updated(EFalse); |
|
411 if (pos >= 0) { |
|
412 updated = mData[pos]->RemoveScreenshot(); |
|
413 } |
|
414 else { |
|
415 User::Leave(KErrNotFound); |
|
416 } |
|
417 CleanupStack::PopAndDestroy(&allWgIds); |
|
418 return updated; |
|
419 } |
403 } |
420 |
404 |
421 // -------------------------------------------------------------------------- |
405 // -------------------------------------------------------------------------- |
422 // CTsFswDataList::EstablishOrder |
406 // CTsFswDataList::EstablishOrder |
423 // -------------------------------------------------------------------------- |
407 // -------------------------------------------------------------------------- |
443 |
427 |
444 // -------------------------------------------------------------------------- |
428 // -------------------------------------------------------------------------- |
445 // CTsFswDataList::GetAllowedUidsL |
429 // CTsFswDataList::GetAllowedUidsL |
446 // -------------------------------------------------------------------------- |
430 // -------------------------------------------------------------------------- |
447 // |
431 // |
448 void CTsFswDataList::GetAllowedUidsL() |
432 TBool CTsFswDataList::VerifyApplicationL(TUid uid) |
449 { |
433 { |
450 mAllowedUids.Close(); |
434 TBool retVal(EFalse); |
451 TApaAppInfo* appInfo = new (ELeave) TApaAppInfo(); |
435 TApaAppInfo appInfo; |
452 CleanupStack::PushL(appInfo); |
|
453 TApaAppCapabilityBuf appCap; |
436 TApaAppCapabilityBuf appCap; |
454 |
437 |
455 User::LeaveIfError(mAppArcSession.GetAllApps(0)); |
438 User::LeaveIfError(mResources.ApaSession().GetAllApps(0)); |
456 // for every application get uid, hidden and missing attribute |
439 // for every application get uid, hidden and missing attribute |
457 // and add to aArray. |
440 // and add to aArray. |
458 while (KErrNone == mAppArcSession.GetNextApp(*appInfo)) { |
441 while (KErrNone == mResources.ApaSession().GetNextApp(appInfo)) { |
459 TUid uid = appInfo->iUid; |
442 User::LeaveIfError(mResources.ApaSession().GetAppCapability(appCap, appInfo.iUid)); |
460 User::LeaveIfError(mAppArcSession.GetAppCapability(appCap, uid)); |
443 if(!appCap().iAppIsHidden) { |
461 // do not add hidden app and with null uid. |
444 if (uid == appInfo.iUid) { |
462 if (!appCap().iAppIsHidden && !IsHiddenUid(uid) && uid.iUid) { |
445 retVal = ETrue; |
463 mAllowedUids.AppendL(uid); |
446 mAllowedUids.InsertL(appInfo.iUid, mAllowedUids.Count()); |
464 } |
447 } |
465 } |
448 } else if(KErrNotFound == mHiddenUids.Find(appInfo.iUid)) { |
466 CleanupStack::PopAndDestroy(appInfo); |
449 mHiddenUids.InsertL(appInfo.iUid, mHiddenUids.Count()); |
467 } |
450 } |
468 |
451 } |
|
452 if (EFalse == retVal && KErrNotFound == mHiddenUids.Find(uid)) { |
|
453 mHiddenUids.InsertL(uid, mHiddenUids.Count()); |
|
454 } |
|
455 return retVal; |
|
456 } |
|
457 |
|
458 // -------------------------------------------------------------------------- |
|
459 // CTsFswDataList::GenerateKeyL(TInt) |
|
460 // -------------------------------------------------------------------------- |
|
461 // |
|
462 TTsEntryKey CTsFswDataList::GenerateKeyL(TInt wgId) |
|
463 { |
|
464 RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
465 CleanupClosePushL(allWgIds); |
|
466 User::LeaveIfError(mResources.WsSession().WindowGroupList(0, &allWgIds)); |
|
467 const TTsEntryKey key = TsEntryKeyGeneraror::GenerateL(wgId, allWgIds.Array()); |
|
468 CleanupStack::PopAndDestroy(&allWgIds); |
|
469 return key; |
|
470 } |
|
471 |
|
472 // -------------------------------------------------------------------------- |
|
473 // CTsFswDataList::CompressLookupTable(RArray<TUid> &) |
|
474 // -------------------------------------------------------------------------- |
|
475 // |
|
476 void CTsFswDataList::CompressLookupTable(RArray<TUid> &array) |
|
477 { |
|
478 while(KMaxLookupSize < array.Count()) { |
|
479 array.Remove(0); |
|
480 } |
|
481 } |
|
482 |
|
483 // -------------------------------------------------------------------------- |
|
484 // CTsFswDataList::UpdateLookupTableL(RArray<TUid> &, TInt) |
|
485 // -------------------------------------------------------------------------- |
|
486 // |
|
487 void CTsFswDataList::UpdateLookupTableL(RArray<TUid> &array, TInt offset) |
|
488 { |
|
489 const TUid uid(array[offset]); |
|
490 array.Remove(offset); |
|
491 array.InsertL(uid, array.Count()); |
|
492 } |
469 // end of file |
493 // end of file |