|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mcsrunningappsfswmonitor.h" |
|
20 #include "mcsrunningappshandler.h" |
|
21 #include "menueng.h" |
|
22 |
|
23 const TInt KMaxHiddenApps = 25; |
|
24 const TUid KPSUidUikon = { 0x101F8773 }; |
|
25 const TUint32 KUikAppHiddenList = 0x00000010; |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // CMcsRunningAppsFswMonitor::NewL |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 CMcsRunningAppsFswMonitor* CMcsRunningAppsFswMonitor::NewL( |
|
32 CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler, |
|
33 TInt aPriority ) |
|
34 { |
|
35 CMcsRunningAppsFswMonitor* self = |
|
36 new ( ELeave ) CMcsRunningAppsFswMonitor( aEng, aRunningAppsHandler, |
|
37 aPriority ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // CMcsRunningAppsFswMonitor::~CMcsRunningAppsFswMonitor |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 CMcsRunningAppsFswMonitor::~CMcsRunningAppsFswMonitor() |
|
49 { |
|
50 Cancel(); |
|
51 iEng.DequeueOperation( *this ); |
|
52 iFSWStatusProperty.Close(); |
|
53 iFswHiddenApps.Close(); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CMcsRunningAppsFswMonitor::CMcsRunningAppsFswMonitor |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 CMcsRunningAppsFswMonitor::CMcsRunningAppsFswMonitor( |
|
61 CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler, TInt aPriority): |
|
62 CActive( aPriority ), |
|
63 iEng(aEng), |
|
64 iRunningAppsHandler(aRunningAppsHandler) |
|
65 { |
|
66 CActiveScheduler::Add( this ); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CMcsRunningAppsFswMonitor::ConstructL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CMcsRunningAppsFswMonitor::ConstructL() |
|
74 { |
|
75 // Create P&S watcher for FSW status changes and read initial apps list |
|
76 if ( KErrNone == iFSWStatusProperty.Attach( KPSUidUikon, KUikAppHiddenList ) ) |
|
77 { |
|
78 // read list |
|
79 TRAP_IGNORE( UpdateFswHiddenApplicationsL() ) |
|
80 Start(); |
|
81 } |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CMcsRunningAppsFswMonitor::IsFswHidden |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 TBool CMcsRunningAppsFswMonitor::IsFswHidden( TUid aUid ) |
|
89 { |
|
90 TBool result(EFalse); |
|
91 if( KErrNotFound != iFswHiddenApps.Find( aUid ) ) |
|
92 { |
|
93 result = ETrue; |
|
94 } |
|
95 return result; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CMcsRunningAppsFswMonitor::RunMenuEngOperationL |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 void CMcsRunningAppsFswMonitor::RunMenuEngOperationL() |
|
103 { |
|
104 UpdateFswHiddenApplicationsL(); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CMcsRunningAppsFswMonitor::CompletedMenuEngOperation |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CMcsRunningAppsFswMonitor::CompletedMenuEngOperation( TInt /*aErr*/ ) |
|
112 { |
|
113 // If there was error, ignore it (what else could we do?). |
|
114 // When next AppArc update occurs, we will run again. |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------- |
|
118 // CMcsRunningAppsFswMonitor::UpdateFswHiddenApplicationsL |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 void CMcsRunningAppsFswMonitor::UpdateFswHiddenApplicationsL() |
|
122 { |
|
123 // the maximum size of array (25 32-bit UIDs equal 100 bytes) |
|
124 // 1. read current data |
|
125 TBuf16 <2*KMaxHiddenApps> retrievedList; |
|
126 TInt err = iFSWStatusProperty.Get( retrievedList ); |
|
127 |
|
128 // 2. convert the buffer to dynamic array with right uid values |
|
129 TInt i = 0; |
|
130 iFswHiddenApps.Reset(); |
|
131 TUint32 listValue; |
|
132 while( i < KMaxHiddenApps && KErrNone == err ) |
|
133 { |
|
134 // 32-bit uid values are retrieved in two 16-bit parts |
|
135 listValue = retrievedList[2*i] << 16; |
|
136 listValue += retrievedList[2*i+1]; |
|
137 |
|
138 // the value NULL marks the end of array -> leave the loop |
|
139 if ( listValue ) |
|
140 { |
|
141 TUid t ( KNullUid ); |
|
142 t.iUid = listValue; |
|
143 iFswHiddenApps.AppendL( t ); |
|
144 } |
|
145 else |
|
146 { |
|
147 err = KErrEof; |
|
148 } |
|
149 i++; |
|
150 } |
|
151 |
|
152 iRunningAppsHandler->HandleListUpdateL( iFswHiddenApps, |
|
153 MMcsRunningAppsHandler::EFswHiddenApps ); |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CMcsRunningAppsFswMonitor::Start |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 void CMcsRunningAppsFswMonitor::Start() |
|
162 { |
|
163 if (!IsActive()) |
|
164 { |
|
165 iFSWStatusProperty.Subscribe(iStatus); |
|
166 SetActive(); |
|
167 } |
|
168 } |
|
169 // --------------------------------------------------------- |
|
170 // CMcsRunningAppsFswMonitor::DoCancel |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 void CMcsRunningAppsFswMonitor::DoCancel() |
|
174 { |
|
175 iFSWStatusProperty.Cancel(); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------- |
|
179 // CMcsRunningAppsFswMonitor::RunL |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 void CMcsRunningAppsFswMonitor::RunL() |
|
183 { |
|
184 User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL. |
|
185 Start(); |
|
186 iEng.QueueOperationL( *this ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CMcsRunningAppsFswMonitor::RunError() |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TInt CMcsRunningAppsFswMonitor::RunError( TInt /*aError*/ ) |
|
194 { |
|
195 Start(); |
|
196 return KErrNone; |
|
197 } |
|
198 |
|
199 // End of File |