|
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: Class that checks if chosen applications should be hidden |
|
15 * from the task swap. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "tsfshiddenapplist.h" |
|
22 #include <apgwgnam.h> |
|
23 |
|
24 #include <eikenv.h> |
|
25 |
|
26 // the maximum size of array (25 32-bit UIDs equal 100 bytes) |
|
27 const TInt KMaxHiddenApps = 25; |
|
28 |
|
29 /** |
|
30 * Category id for the hidden application list. |
|
31 */ |
|
32 const TUid KPSUidUikon = { 0x101F8773 }; |
|
33 const TUint32 KUikAppHiddenList = 0x00000010; |
|
34 |
|
35 /** |
|
36 * Apps that are always hidden, no matter what settings the system reports. |
|
37 */ |
|
38 const TUint32 KTsFsAlwaysHiddenUidArray[] = |
|
39 { |
|
40 0x100056CF // screensaver |
|
41 }; |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CTsFsHiddenAppList::NewL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CTsFsHiddenAppList* CTsFsHiddenAppList::NewL( |
|
48 MTsFsHiddenAppListObserver& aObserver ) |
|
49 { |
|
50 CTsFsHiddenAppList* self = |
|
51 new ( ELeave ) CTsFsHiddenAppList( aObserver ); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CTsFsHiddenAppList::NewLC |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CTsFsHiddenAppList* CTsFsHiddenAppList::NewLC( |
|
63 MTsFsHiddenAppListObserver& aObserver ) |
|
64 { |
|
65 CTsFsHiddenAppList* self = CTsFsHiddenAppList::NewL( aObserver ); |
|
66 CleanupStack::PushL( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CTsFsHiddenAppList::~CTsFsHiddenAppList |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CTsFsHiddenAppList::~CTsFsHiddenAppList() |
|
75 { |
|
76 Cancel(); |
|
77 |
|
78 ResetArray(); |
|
79 delete iHiddenAppList; |
|
80 |
|
81 iProperty.Close(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CTsFsHiddenAppList::IsHiddenL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TBool CTsFsHiddenAppList::IsHiddenL( TUid aAppUid, |
|
89 const RWsSession& aWsSession, |
|
90 TInt aWgId ) |
|
91 { |
|
92 TBool ret = EFalse; |
|
93 |
|
94 CApaWindowGroupName* windowName = |
|
95 CApaWindowGroupName::NewLC( aWsSession, aWgId ); |
|
96 |
|
97 if ( windowName->Hidden() ) |
|
98 { |
|
99 ret = ETrue; |
|
100 } |
|
101 else |
|
102 { |
|
103 for ( TInt i = 0, ie = iHiddenAppList->Count(); i != ie; ++i ) |
|
104 { |
|
105 if ( aAppUid.iUid == iHiddenAppList->At( i ) ) |
|
106 { |
|
107 ret = ETrue; |
|
108 break; |
|
109 } |
|
110 } |
|
111 if ( !ret ) |
|
112 { |
|
113 for ( TInt i = 0, |
|
114 arrCnt = sizeof( KTsFsAlwaysHiddenUidArray ) / sizeof( TUint32 ); |
|
115 i != arrCnt; ++i ) |
|
116 { |
|
117 if ( KTsFsAlwaysHiddenUidArray[i] == aAppUid.iUid ) |
|
118 { |
|
119 ret = ETrue; |
|
120 break; |
|
121 } |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 CleanupStack::PopAndDestroy( windowName ); |
|
127 return ret; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CTsFsHiddenAppList::CTsFsHiddenAppList |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 CTsFsHiddenAppList::CTsFsHiddenAppList( |
|
135 MTsFsHiddenAppListObserver& aObserver ) |
|
136 :CActive( CActive::EPriorityHigh ), iObserver( aObserver ) |
|
137 { |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CTsFsHiddenAppList::ConstructL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CTsFsHiddenAppList::ConstructL() |
|
145 { |
|
146 const TInt KMaxGranularity = 4; |
|
147 CActiveScheduler::Add( this ); |
|
148 |
|
149 iHiddenAppList = new (ELeave) CArrayFixFlat<TInt>( KMaxGranularity ); |
|
150 User::LeaveIfError( iProperty.Attach( KPSUidUikon, KUikAppHiddenList, EOwnerThread ) ); |
|
151 |
|
152 // must not call RunL directly from here as things are not fully initialized yet |
|
153 TRequestStatus* status = &iStatus; |
|
154 User::RequestComplete( status, KErrNone ); |
|
155 SetActive(); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CTsFsHiddenAppList::ResetArray |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CTsFsHiddenAppList::ResetArray() |
|
163 { |
|
164 if ( iHiddenAppList ) |
|
165 { |
|
166 iHiddenAppList->Reset(); |
|
167 } |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CTsFsHiddenAppList::UpdateListL |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CTsFsHiddenAppList::UpdateListL() |
|
175 { |
|
176 ResetArray(); |
|
177 |
|
178 // hidden list array |
|
179 TBuf16 <2*KMaxHiddenApps> hiddenList; |
|
180 iProperty.Get( hiddenList ); |
|
181 |
|
182 for ( TInt i = 0; i < hiddenList.Length(); i = i + 2 ) |
|
183 { |
|
184 TUint32 uid = 0x00000000; |
|
185 uid = hiddenList[i]; |
|
186 uid = uid << 16; // codescanner::magicnumbers |
|
187 uid |= hiddenList[i+1]; |
|
188 |
|
189 if ( uid != 0 ) |
|
190 { |
|
191 iHiddenAppList->AppendL( uid ); |
|
192 } |
|
193 else |
|
194 { |
|
195 break; |
|
196 } |
|
197 } |
|
198 |
|
199 iObserver.HiddenAppListUpdated(); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CTsFsHiddenAppList::DoCancel |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CTsFsHiddenAppList::DoCancel() |
|
207 { |
|
208 iProperty.Cancel(); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CTsFsHiddenAppList::RunL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CTsFsHiddenAppList::RunL() |
|
216 { |
|
217 if ( !IsActive() ) |
|
218 { |
|
219 iProperty.Subscribe( iStatus ); |
|
220 SetActive(); |
|
221 } |
|
222 UpdateListL(); |
|
223 } |
|
224 |
|
225 |
|
226 // end of file |