|
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 |
|
23 // User includes |
|
24 #include <aipspropertyobserver.h> |
|
25 #include <aiutility.h> |
|
26 #include <aifwdefs.h> |
|
27 #include "aiecomobserver.h" |
|
28 #include "aistateobserver.h" |
|
29 |
|
30 #include "aistateprovider.h" |
|
31 |
|
32 // Constants |
|
33 |
|
34 // ======== LOCAL FUNCTIONS ======== |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // ---------------------------------------------------------------------------- |
|
39 // CAiStateProvider::NewL() |
|
40 // Two-phased constructor. |
|
41 // ---------------------------------------------------------------------------- |
|
42 // |
|
43 CAiStateProvider* CAiStateProvider::NewL( |
|
44 MAiStateObserver& aObserver, CCoeEnv& aCoeEnv ) |
|
45 { |
|
46 CAiStateProvider* self = |
|
47 CAiStateProvider::NewLC( aObserver, aCoeEnv ); |
|
48 |
|
49 CleanupStack::Pop( self ); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CAiStateProvider::NewLC() |
|
56 // Two-phased constructor. |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 CAiStateProvider* CAiStateProvider::NewLC( |
|
60 MAiStateObserver& aObserver, CCoeEnv& aCoeEnv ) |
|
61 { |
|
62 CAiStateProvider* self = |
|
63 new ( ELeave ) CAiStateProvider( aObserver, aCoeEnv ); |
|
64 |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CAiStateProvider::~CAiStateProvider() |
|
73 // C++ default destructor. |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 CAiStateProvider::~CAiStateProvider() |
|
77 { |
|
78 iObserver.NotifyStateChange( EAiFwUiShutdown ); |
|
79 |
|
80 iCoeEnv.RemoveMessageMonitorObserver( *this ); |
|
81 |
|
82 delete iEcomObserver; |
|
83 |
|
84 iSkinSrv.Close(); |
|
85 |
|
86 Release( iBackupRestoreObserver ); |
|
87 |
|
88 delete iLightObserver; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // CAiStateProvider::CAiStateProvider() |
|
93 // C++ default constructor. |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 CAiStateProvider::CAiStateProvider( MAiStateObserver& aObserver, |
|
97 CCoeEnv& aCoeEnv ) |
|
98 : iObserver( aObserver ), iCoeEnv( aCoeEnv ) |
|
99 { |
|
100 iObserver.NotifyStateChange( EAiFwUiStartup ); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CAiStateProvider::ConstructL() |
|
105 // 2nd phase constructor |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 void CAiStateProvider::ConstructL() |
|
109 { |
|
110 iLightObserver = CHWRMLight::NewL( this ); |
|
111 |
|
112 iBackupRestoreObserver = AiUtility::CreatePSPropertyObserverL( |
|
113 TCallBack( BackupRestoreEvent, this ), |
|
114 KUidSystemCategory, conn::KUidBackupRestoreKey ); |
|
115 |
|
116 User::LeaveIfError( iSkinSrv.Connect( this ) ); |
|
117 |
|
118 iEcomObserver = CAiEcomObserver::NewL(); |
|
119 iEcomObserver->AddObserverL( this ); |
|
120 |
|
121 iCoeEnv.AddMessageMonitorObserverL( *this ); |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // CAiStateProvider::MonitorWsMessage() |
|
126 // |
|
127 // ---------------------------------------------------------------------------- |
|
128 // |
|
129 void CAiStateProvider::MonitorWsMessage( const TWsEvent& aEvent ) |
|
130 { |
|
131 TInt type( aEvent.Type() ); |
|
132 |
|
133 if ( type == KAknFullOrPartialForegroundGained ) |
|
134 { |
|
135 iObserver.NotifyStateChange( EAiFwForeground ); |
|
136 } |
|
137 else if ( type == KAknFullOrPartialForegroundLost ) |
|
138 { |
|
139 iObserver.NotifyStateChange( EAiFwBackground ); |
|
140 } |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CAiStateProvider::LightStatusChanged() |
|
145 // |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CAiStateProvider::LightStatusChanged( TInt aTarget, |
|
149 CHWRMLight::TLightStatus aStatus ) |
|
150 { |
|
151 if ( aTarget == CHWRMLight::EPrimaryDisplay ) |
|
152 { |
|
153 if ( aStatus == CHWRMLight::ELightOn ) |
|
154 { |
|
155 iObserver.NotifyStateChange( EAiFwBacklightOn ); |
|
156 } |
|
157 else if ( aStatus == CHWRMLight::ELightOff ) |
|
158 { |
|
159 iObserver.NotifyStateChange( EAiFwBacklightOff ); |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 // ---------------------------------------------------------------------------- |
|
165 // CAiStateProvider::SkinContentChanged() |
|
166 // |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 void CAiStateProvider::SkinContentChanged() |
|
170 { |
|
171 } |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // CAiStateProvider::SkinConfigurationChanged() |
|
175 // |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 void CAiStateProvider::SkinConfigurationChanged( |
|
179 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
180 { |
|
181 if ( aReason == EAknsSkinStatusConfigurationDeployed ) |
|
182 { |
|
183 iObserver.NotifyStateChange( EAiFwGeneralThemeChange ); |
|
184 } |
|
185 } |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // CAiStateProvider::SkinPackageChanged() |
|
189 // |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CAiStateProvider::SkinPackageChanged( |
|
193 const TAknsSkinStatusPackageChangeReason /*aReason*/ ) |
|
194 { |
|
195 } |
|
196 |
|
197 // ---------------------------------------------------------------------------- |
|
198 // CAiStateProvider::NotifyEcomRegistryChanged() |
|
199 // |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 void CAiStateProvider::NotifyEcomRegistryChanged() |
|
203 { |
|
204 iObserver.NotifyUpdatePlugins(); |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CAiStateProvider::LoadPlugin() |
|
209 // |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 TInt CAiStateProvider::LoadPlugin( const THsPublisherInfo& aPublisherInfo, |
|
213 TAiFwLoadReason aReason ) |
|
214 { |
|
215 return iObserver.NotifyLoadPlugin( aPublisherInfo, aReason ); |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // CAiStateProvider::DestroyPlugin() |
|
220 // |
|
221 // ---------------------------------------------------------------------------- |
|
222 // |
|
223 void CAiStateProvider::DestroyPlugin( const THsPublisherInfo& aPublisherInfo, |
|
224 TAiFwDestroyReason aReason ) |
|
225 { |
|
226 iObserver.NotifyDestroyPlugin( aPublisherInfo, aReason ); |
|
227 } |
|
228 |
|
229 // ---------------------------------------------------------------------------- |
|
230 // CAiStateProvider::ChangePluginState() |
|
231 // |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 void CAiStateProvider::ChangePluginState( TAiFwState aState ) |
|
235 { |
|
236 if ( aState == EAiFwOnline || aState == EAiFwOffline ) |
|
237 { |
|
238 iObserver.NotifyStateChange( aState ); |
|
239 } |
|
240 } |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CAiStateProvider::OnlineStateInUse() |
|
244 // |
|
245 // ---------------------------------------------------------------------------- |
|
246 // |
|
247 TBool CAiStateProvider::OnlineStateInUse() const |
|
248 { |
|
249 return iObserver.OnlineStateInUse(); |
|
250 } |
|
251 |
|
252 // ---------------------------------------------------------------------------- |
|
253 // CAiStateProvider::BackupRestoreEvent() |
|
254 // |
|
255 // ---------------------------------------------------------------------------- |
|
256 // |
|
257 /* static */ TInt CAiStateProvider::BackupRestoreEvent( TAny* aAny ) |
|
258 { |
|
259 CAiStateProvider* self = static_cast< CAiStateProvider* >( aAny ); |
|
260 |
|
261 const TUint mask( conn::KBURPartTypeMask ^ conn::EBURNormal ); |
|
262 |
|
263 TInt value( 0 ); |
|
264 |
|
265 if ( self->iBackupRestoreObserver->Get( value ) == KErrNone ) |
|
266 { |
|
267 if ( value & mask ) |
|
268 { |
|
269 // Any type of backup or restore operation |
|
270 self->iObserver.NotifyStateChange( EAiFwBackupRestoreStart ); |
|
271 } |
|
272 else |
|
273 { |
|
274 self->iObserver.NotifyStateChange( EAiFwBackupRestoreEnd ); |
|
275 } |
|
276 } |
|
277 |
|
278 return KErrNone; |
|
279 } |
|
280 |
|
281 // End of file |
|
282 |