|
1 /* |
|
2 * Copyright (c) 2004-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: Implementation of CStartupAdaptationStub class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "StartupAdaptationStub.h" |
|
22 #include "CommandProcessingEngine.h" |
|
23 #include "StartupAdaptationStubModel.h" |
|
24 #include "sastubeventlistener.h" |
|
25 #include "StartupAdaptationStubDebug.h" |
|
26 #include <startupadaptationobserver.h> |
|
27 |
|
28 using namespace StartupAdaptation; |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CStartupAdaptationStub::NewL |
|
34 // Two-phased constructor. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CStartupAdaptationStub* CStartupAdaptationStub::NewL( TAny* aConstructionParameters ) |
|
38 { |
|
39 RDEBUG( _L( "CStartupAdaptationStub::NewL." ) ); |
|
40 |
|
41 CStartupAdaptationStub* self = |
|
42 new( ELeave ) CStartupAdaptationStub( |
|
43 static_cast<MStartupAdaptationObserver*>( aConstructionParameters ) ); |
|
44 |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop(); |
|
48 |
|
49 RDEBUG( _L( "CStartupAdaptationStub::NewL finished." ) ); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // Destructor |
|
56 CStartupAdaptationStub::~CStartupAdaptationStub() |
|
57 { |
|
58 RDEBUG( _L( "CStartupAdaptationStub::~CStartupAdaptationStub." ) ); |
|
59 |
|
60 delete iEventListener; |
|
61 delete iModel; |
|
62 delete iEngine; |
|
63 |
|
64 RDEBUG( _L( "CStartupAdaptationStub::~CStartupAdaptationStub finished." ) ); |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CStartupAdaptationStub::CommandL |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CStartupAdaptationStub::CommandL( |
|
74 const TCommand aCommandId, |
|
75 TDesC8& /*aData*/ ) |
|
76 { |
|
77 RDEBUG_1( _L( "CStartupAdaptationStub::CommandL( %d )." ), aCommandId ); |
|
78 |
|
79 TInt duration = iModel->GetDurationForNextCall( aCommandId ); |
|
80 iEngine->ExecuteCommandL( aCommandId, duration ); |
|
81 |
|
82 RDEBUG( _L( "CStartupAdaptationStub::CommandL finished." ) ); |
|
83 } |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CStartupAdaptationStub::CommandL |
|
88 // |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CStartupAdaptationStub::CancelCommandL( |
|
92 const TCommand /*aCommandId*/ ) |
|
93 { |
|
94 RDEBUG( _L( "CStartupAdaptationStub::CancelCommandL." ) ); |
|
95 |
|
96 iEngine->Cancel(); |
|
97 |
|
98 RDEBUG( _L( "CStartupAdaptationStub::CancelCommandL finished." ) ); |
|
99 } |
|
100 |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CStartupAdaptationStub::Version |
|
104 // |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TVersion CStartupAdaptationStub::Version() const |
|
108 { |
|
109 return TVersion( 0, 1, 0 ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CStartupAdaptationStub::CommandProcessedL |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CStartupAdaptationStub::CommandProcessedL( |
|
119 const TInt aCommandId ) |
|
120 { |
|
121 RDEBUG_1( _L( "CStartupAdaptationStub::CommandProcessedL( %d )." ), aCommandId ); |
|
122 |
|
123 switch ( aCommandId ) |
|
124 { |
|
125 case EGlobalStateChange: |
|
126 { |
|
127 TResponsePckg responsePckg( |
|
128 iModel->GetGlobalStateChangeResponse() ); |
|
129 iObserver->ResponseL( |
|
130 static_cast<TCommand>( aCommandId ), |
|
131 responsePckg ); |
|
132 break; |
|
133 } |
|
134 case EExecuteSelftests: |
|
135 { |
|
136 TResponsePckg responsePckg( iModel->GetSelftestResponse() ); |
|
137 iObserver->ResponseL( |
|
138 static_cast<TCommand>( aCommandId ), |
|
139 responsePckg ); |
|
140 break; |
|
141 } |
|
142 case EValidateRTCTime: |
|
143 { |
|
144 TResponsePckg responsePckg( |
|
145 iModel->GetRTCTimeValidityResponse() ); |
|
146 iObserver->ResponseL( |
|
147 static_cast<TCommand>( aCommandId ), |
|
148 responsePckg ); |
|
149 break; |
|
150 } |
|
151 case ESetWakeupAlarm: |
|
152 { |
|
153 TResponsePckg responsePckg( iModel->GetSetAlarmResponse() ); |
|
154 iObserver->ResponseL( |
|
155 static_cast<TCommand>( aCommandId ), |
|
156 responsePckg ); |
|
157 break; |
|
158 } |
|
159 case ECancelWakeupAlarm: |
|
160 { |
|
161 TResponsePckg responsePckg( KErrNone ); |
|
162 iObserver->ResponseL( |
|
163 static_cast<TCommand>( aCommandId ), |
|
164 responsePckg ); |
|
165 break; |
|
166 } |
|
167 case EExecuteReset: |
|
168 { |
|
169 TResponsePckg responsePckg( iModel->GetResetResponse() ); |
|
170 iObserver->ResponseL( |
|
171 static_cast<TCommand>( aCommandId ), |
|
172 responsePckg ); |
|
173 break; |
|
174 } |
|
175 case EExecuteShutdown: |
|
176 { |
|
177 TResponsePckg responsePckg( iModel->GetShutdownResponse() ); |
|
178 iObserver->ResponseL( |
|
179 static_cast<TCommand>( aCommandId ), |
|
180 responsePckg ); |
|
181 break; |
|
182 } |
|
183 case EExecuteDOSRfs: |
|
184 { |
|
185 TResponsePckg responsePckg( iModel->GetRFSResponse() ); |
|
186 iObserver->ResponseL( |
|
187 static_cast<TCommand>( aCommandId ), |
|
188 responsePckg ); |
|
189 break; |
|
190 } |
|
191 case EGetSimChanged: |
|
192 { |
|
193 TBooleanResponse response; |
|
194 iModel->GetSimChangedResponse( response ); |
|
195 TBooleanResponsePckg responsePckg( response ); |
|
196 iObserver->ResponseL( |
|
197 static_cast<TCommand>( aCommandId ), |
|
198 responsePckg ); |
|
199 break; |
|
200 } |
|
201 case EGetSimOwned: |
|
202 { |
|
203 TBooleanResponse response; |
|
204 iModel->GetSimOwnedResponse( response ); |
|
205 TBooleanResponsePckg responsePckg( response ); |
|
206 iObserver->ResponseL( |
|
207 static_cast<TCommand>( aCommandId ), |
|
208 responsePckg ); |
|
209 break; |
|
210 } |
|
211 case ESecurityStateChange: |
|
212 { |
|
213 TSecurityStateResponse response; |
|
214 iModel->GetSecurityStateChangeResponse( response ); |
|
215 TSecurityStateResponsePckg responsePckg( response ); |
|
216 iObserver->ResponseL( |
|
217 static_cast<TCommand>( aCommandId ), |
|
218 responsePckg ); |
|
219 break; |
|
220 } |
|
221 case EGetGlobalStartupMode: |
|
222 { |
|
223 TGlobalStartupModeResponse response; |
|
224 iModel->GetStartupModeResponse( response ); |
|
225 TGlobalStartupModeResponsePckg responsePckg( response ); |
|
226 iObserver->ResponseL( |
|
227 static_cast<TCommand>( aCommandId ), |
|
228 responsePckg ); |
|
229 break; |
|
230 } |
|
231 case EGetSIMLanguages: |
|
232 { |
|
233 RLanguageListResponse response; |
|
234 CleanupClosePushL( response ); |
|
235 iModel->GetLanguageListResponse( response ); |
|
236 TLanguageListResponsePckg responsePckg( response ); |
|
237 iObserver->ResponseL( |
|
238 static_cast<TCommand>( aCommandId ), |
|
239 responsePckg ); |
|
240 CleanupStack::PopAndDestroy(); |
|
241 break; |
|
242 } |
|
243 case EActivateRfForEmergencyCall: |
|
244 { |
|
245 TResponsePckg responsePckg( iModel->GetActivateRfResponse() ); |
|
246 iObserver->ResponseL( |
|
247 static_cast<TCommand>( aCommandId ), |
|
248 responsePckg ); |
|
249 break; |
|
250 } |
|
251 case EDeactivateRfAfterEmergencyCall: |
|
252 { |
|
253 TResponsePckg responsePckg( iModel->GetDeactivateRfResponse() ); |
|
254 iObserver->ResponseL( |
|
255 static_cast<TCommand>( aCommandId ), |
|
256 responsePckg ); |
|
257 break; |
|
258 } |
|
259 case EGetHiddenReset: |
|
260 { |
|
261 TBooleanResponse response; |
|
262 iModel->GetHiddenResetResponse( response ); |
|
263 TBooleanResponsePckg responsePckg( response ); |
|
264 iObserver->ResponseL( |
|
265 static_cast<TCommand>( aCommandId ), |
|
266 responsePckg ); |
|
267 break; |
|
268 } |
|
269 default: |
|
270 RDEBUG_1( _L( "CStartupAdaptationStub: Unexpected command: %d." ), aCommandId ); |
|
271 User::Panic( _L( "Unexpected command" ), KErrNotSupported ); |
|
272 break; |
|
273 }; |
|
274 |
|
275 |
|
276 RDEBUG( _L( "CStartupAdaptationStub::CommandProcessedL finished." ) ); |
|
277 } |
|
278 |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CStartupAdaptationStub::SendEvent |
|
282 // |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 void CStartupAdaptationStub::SendEvent( const TInt aEvent, const TInt aArg ) |
|
286 { |
|
287 RDEBUG_2( _L( "CStartupAdaptationStub: SendEvent 0x%08x, 0x%08x." ), aEvent, aArg ); |
|
288 |
|
289 TInt errorCode = KErrNone; |
|
290 TEvent eventID = static_cast<TEvent>( aEvent ); |
|
291 if ( eventID == EFatalError ) |
|
292 { |
|
293 TFatalErrorTypePckg params( static_cast<TFatalErrorType>( aArg ) ); |
|
294 TRAP( errorCode, iObserver->EventL( eventID, params ) ); |
|
295 } |
|
296 else if ( eventID == ESimEvent ) |
|
297 { |
|
298 TSimEventTypePckg params( static_cast<TSimEventType>( aArg ) ); |
|
299 TRAP( errorCode, iObserver->EventL( eventID, params ) ); |
|
300 } |
|
301 else |
|
302 { |
|
303 TBuf8<1> dummy; |
|
304 TRAP( errorCode, iObserver->EventL( eventID, dummy ) ); |
|
305 } |
|
306 |
|
307 if ( errorCode != KErrNone ) |
|
308 { |
|
309 RDEBUG_1( _L( "CStartupAdaptationStub: EventL leave code %d." ), errorCode ); |
|
310 } |
|
311 } |
|
312 |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CStartupAdaptationStub::CStartupAdaptationStub |
|
316 // C++ default constructor can NOT contain any code, that might leave. |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 CStartupAdaptationStub::CStartupAdaptationStub( |
|
320 MStartupAdaptationObserver* anObserver ) |
|
321 : iObserver( anObserver ), |
|
322 iEventListener( NULL ) |
|
323 { |
|
324 RDEBUG( _L( "CStartupAdaptationStub::CStartupAdaptationStub." ) ); |
|
325 |
|
326 __ASSERT_ALWAYS( anObserver, User::Invariant() ); |
|
327 |
|
328 RDEBUG( _L( "CStartupAdaptationStub::CStartupAdaptationStub finished." ) ); |
|
329 } |
|
330 |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CStartupAdaptationStub::ConstructL |
|
334 // Symbian 2nd phase constructor can leave. |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 void CStartupAdaptationStub::ConstructL() |
|
338 { |
|
339 RDEBUG( _L( "CStartupAdaptationStub::ConstructL." ) ); |
|
340 |
|
341 iEngine = CCommandProcessingEngine::NewL( *this ); |
|
342 iModel = CStartupAdaptationStubModel::NewL(); |
|
343 |
|
344 #ifdef __STARTER_MODULE_TEST_SUPPORT__ |
|
345 iEventListener = CSAStubEventListener::NewL( *this ); |
|
346 #endif // __STARTER_MODULE_TEST_SUPPORT__ |
|
347 |
|
348 RDEBUG( _L( "CStartupAdaptationStub::ConstructL finished." ) ); |
|
349 } |
|
350 |
|
351 |
|
352 // End of File |