|
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: State Provider |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <AknDef.h> |
|
20 #include <connect/sbdefs.h> |
|
21 #include <e32property.h> |
|
22 #include <swi/swispubsubdefs.h> |
|
23 #include <swi/swiutils.h> |
|
24 #include <sacls.h> // KSWIUidsCurrentlyBeingProcessed |
|
25 |
|
26 // User includes |
|
27 #include <aipspropertyobserver.h> |
|
28 #include <aiutility.h> |
|
29 #include <aifwdefs.h> |
|
30 #include "aiecomobserver.h" |
|
31 #include "aistateobserver.h" |
|
32 |
|
33 #include "aistateprovider.h" |
|
34 |
|
35 #include "debug.h" |
|
36 |
|
37 // Constants |
|
38 |
|
39 // ======== LOCAL FUNCTIONS ======== |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CAiStateProvider::NewL() |
|
45 // Two-phased constructor. |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CAiStateProvider* CAiStateProvider::NewL( MAiStateObserver& aObserver ) |
|
49 { |
|
50 CAiStateProvider* self = |
|
51 CAiStateProvider::NewLC( aObserver ); |
|
52 |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------------------------------- |
|
59 // CAiStateProvider::NewLC() |
|
60 // Two-phased constructor. |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 CAiStateProvider* CAiStateProvider::NewLC( MAiStateObserver& aObserver ) |
|
64 { |
|
65 CAiStateProvider* self = |
|
66 new ( ELeave ) CAiStateProvider( aObserver ); |
|
67 |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 |
|
71 return self; |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CAiStateProvider::~CAiStateProvider() |
|
76 // C++ default destructor. |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CAiStateProvider::~CAiStateProvider() |
|
80 { |
|
81 Stop(); |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CAiStateProvider::CAiStateProvider() |
|
86 // C++ default constructor. |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 CAiStateProvider::CAiStateProvider( MAiStateObserver& aObserver ) |
|
90 : iObserver( aObserver ) |
|
91 { |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CAiStateProvider::ConstructL() |
|
96 // 2nd phase constructor |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 void CAiStateProvider::ConstructL() |
|
100 { |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CAiStateProvider::StartL() |
|
105 // |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 void CAiStateProvider::StartL( CCoeEnv& aCoeEnv ) |
|
109 { |
|
110 if ( !iStarted ) |
|
111 { |
|
112 iStarted = ETrue; |
|
113 |
|
114 iObserver.NotifyStateChange( EAiFwUiStartup ); |
|
115 |
|
116 iLightObserver = CHWRMLight::NewL( this ); |
|
117 |
|
118 iBackupRestoreObserver = AiUtility::CreatePSPropertyObserverL( |
|
119 TCallBack( BackupRestoreEvent, this ), |
|
120 KUidSystemCategory, conn::KUidBackupRestoreKey ); |
|
121 |
|
122 iSwiUidListObserver = AiUtility::CreatePSPropertyObserverL( |
|
123 TCallBack( SwiUidListEvent, this ), |
|
124 KUidSystemCategory, KSWIUidsCurrentlyBeingProcessed ); |
|
125 |
|
126 User::LeaveIfError( iSkinSrv.Connect( this ) ); |
|
127 |
|
128 iEcomObserver = CAiEcomObserver::NewL(); |
|
129 iEcomObserver->AddObserverL( this ); |
|
130 |
|
131 iCoeEnv = &aCoeEnv; |
|
132 |
|
133 iCoeEnv->AddMessageMonitorObserverL( *this ); |
|
134 } |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CAiStateProvider::Stop() |
|
139 // |
|
140 // ---------------------------------------------------------------------------- |
|
141 // |
|
142 void CAiStateProvider::Stop() |
|
143 { |
|
144 if ( iStarted ) |
|
145 { |
|
146 iStarted = EFalse; |
|
147 |
|
148 iObserver.NotifyStateChange( EAiFwUiShutdown ); |
|
149 |
|
150 if ( iCoeEnv ) |
|
151 { |
|
152 iCoeEnv->RemoveMessageMonitorObserver( *this ); |
|
153 } |
|
154 |
|
155 iCoeEnv = NULL; |
|
156 |
|
157 delete iEcomObserver; |
|
158 iEcomObserver = NULL; |
|
159 |
|
160 iSkinSrv.Close(); |
|
161 |
|
162 Release( iBackupRestoreObserver ); |
|
163 iBackupRestoreObserver = NULL; |
|
164 |
|
165 Release( iSwiUidListObserver ); |
|
166 iSwiUidListObserver = NULL; |
|
167 |
|
168 delete iLightObserver; |
|
169 iLightObserver = NULL; |
|
170 } |
|
171 } |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // CAiStateProvider::MonitorWsMessage() |
|
175 // |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 void CAiStateProvider::MonitorWsMessage( const TWsEvent& aEvent ) |
|
179 { |
|
180 TInt type( aEvent.Type() ); |
|
181 |
|
182 if ( type == KAknFullOrPartialForegroundGained ) |
|
183 { |
|
184 iObserver.NotifyStateChange( EAiFwForeground ); |
|
185 } |
|
186 else if ( type == KAknFullOrPartialForegroundLost ) |
|
187 { |
|
188 iObserver.NotifyStateChange( EAiFwBackground ); |
|
189 } |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CAiStateProvider::LightStatusChanged() |
|
194 // |
|
195 // ---------------------------------------------------------------------------- |
|
196 // |
|
197 void CAiStateProvider::LightStatusChanged( TInt aTarget, |
|
198 CHWRMLight::TLightStatus aStatus ) |
|
199 { |
|
200 if ( aTarget == CHWRMLight::EPrimaryDisplay ) |
|
201 { |
|
202 if ( aStatus == CHWRMLight::ELightOn ) |
|
203 { |
|
204 iObserver.NotifyStateChange( EAiFwBacklightOn ); |
|
205 } |
|
206 else if ( aStatus == CHWRMLight::ELightOff ) |
|
207 { |
|
208 iObserver.NotifyStateChange( EAiFwBacklightOff ); |
|
209 } |
|
210 } |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CAiStateProvider::SkinContentChanged() |
|
215 // |
|
216 // ---------------------------------------------------------------------------- |
|
217 // |
|
218 void CAiStateProvider::SkinContentChanged() |
|
219 { |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CAiStateProvider::SkinConfigurationChanged() |
|
224 // |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CAiStateProvider::SkinConfigurationChanged( |
|
228 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
229 { |
|
230 if ( aReason == EAknsSkinStatusConfigurationDeployed ) |
|
231 { |
|
232 iObserver.NotifyStateChange( EAiFwGeneralThemeChange ); |
|
233 } |
|
234 } |
|
235 |
|
236 // ---------------------------------------------------------------------------- |
|
237 // CAiStateProvider::SkinPackageChanged() |
|
238 // |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 void CAiStateProvider::SkinPackageChanged( |
|
242 const TAknsSkinStatusPackageChangeReason /*aReason*/ ) |
|
243 { |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CAiStateProvider::NotifyEcomRegistryChanged() |
|
248 // |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 void CAiStateProvider::NotifyEcomRegistryChanged() |
|
252 { |
|
253 __PRINTS( "CAiStateProvider::NotifyEcomRegistryChanged" ); |
|
254 |
|
255 iObserver.NotifyReloadPlugins(); |
|
256 |
|
257 __PRINTS( "CAiStateProvider::NotifyEcomRegistryChanged - done" ); |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CAiStateProvider::LoadPlugin() |
|
262 // |
|
263 // ---------------------------------------------------------------------------- |
|
264 // |
|
265 void CAiStateProvider::LoadPlugin( const TAiFwPublisherInfo& aInfo ) |
|
266 { |
|
267 iObserver.NotifyLoadPlugin( aInfo ); |
|
268 } |
|
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CAiStateProvider::DestroyPlugin() |
|
272 // |
|
273 // ---------------------------------------------------------------------------- |
|
274 // |
|
275 void CAiStateProvider::DestroyPlugin( const TAiFwPublisherInfo& aInfo ) |
|
276 { |
|
277 iObserver.NotifyDestroyPlugin( aInfo ); |
|
278 } |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CAiStateProvider::ChangePluginState() |
|
282 // |
|
283 // ---------------------------------------------------------------------------- |
|
284 // |
|
285 void CAiStateProvider::ChangePluginState( TAiFwState aState ) |
|
286 { |
|
287 if ( aState == EAiFwOnline || aState == EAiFwOffline ) |
|
288 { |
|
289 iObserver.NotifyStateChange( aState ); |
|
290 } |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // CAiStateProvider::BackupRestoreEvent() |
|
295 // |
|
296 // ---------------------------------------------------------------------------- |
|
297 // |
|
298 /* static */ TInt CAiStateProvider::BackupRestoreEvent( TAny* aAny ) |
|
299 { |
|
300 CAiStateProvider* self = static_cast< CAiStateProvider* >( aAny ); |
|
301 |
|
302 const TUint mask( conn::KBURPartTypeMask ^ conn::EBURNormal ); |
|
303 |
|
304 TInt value( 0 ); |
|
305 |
|
306 if ( self->iBackupRestoreObserver->Get( value ) == KErrNone ) |
|
307 { |
|
308 if ( value & mask ) |
|
309 { |
|
310 // Any type of backup or restore operation |
|
311 self->iObserver.NotifyStateChange( EAiFwBackupRestoreStart ); |
|
312 } |
|
313 else |
|
314 { |
|
315 self->iObserver.NotifyStateChange( EAiFwBackupRestoreEnd ); |
|
316 } |
|
317 } |
|
318 |
|
319 return KErrNone; |
|
320 } |
|
321 |
|
322 // ---------------------------------------------------------------------------- |
|
323 // CAiStateProvider::SwiUidLIstEvent() |
|
324 // |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 /* static */ TInt CAiStateProvider::SwiUidListEvent( TAny* aAny ) |
|
328 { |
|
329 CAiStateProvider* self = static_cast< CAiStateProvider* >( aAny ); |
|
330 |
|
331 RArray< TUid > list; |
|
332 |
|
333 if ( Swi::GetAllUids( list ) == KErrNone ) |
|
334 { |
|
335 self->iObserver.NotifyReleasePlugins( list ); |
|
336 } |
|
337 |
|
338 list.Reset(); |
|
339 |
|
340 return KErrNone; |
|
341 } |
|
342 |
|
343 // End of file |
|
344 |