|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "susadaptionserver.h" |
|
17 #include "susadaptionsession.h" |
|
18 #include "susadaptionclisrv.h" |
|
19 #include "suspanic.h" |
|
20 #include "ssmdebug.h" |
|
21 |
|
22 |
|
23 // ------------------- Policy Server Security Setup ---------------------- |
|
24 |
|
25 const TUint KRangeCount = 8; |
|
26 const TInt KRanges[KRangeCount] = // add the required ranges here |
|
27 { |
|
28 0, |
|
29 ERequestCoopSysStateChange, //State Adaptation Range |
|
30 EGetSimOwned, //Sim Adaptation Range |
|
31 EValidateRtc, //Rtc Adaptation Range |
|
32 ESecurityStateChange, //Misc Adaptation Range |
|
33 EActivateRfForEmergencyCall, //Emergency Call Adaptation Range |
|
34 ESetAsPriorityClient, //Setting Priority Client |
|
35 EEndOfSusAdaptionOpCodes //Dummy |
|
36 }; |
|
37 |
|
38 /** |
|
39 Maps to index in the array KPolicyElements |
|
40 */ |
|
41 const TInt KCapabilitiesForRequest1 = 0; |
|
42 const TInt KCapabilitiesForRequest2 = 1; |
|
43 const TInt KSecurityCheckForRequest3 = 2; |
|
44 |
|
45 /** |
|
46 Specifies the appropriate action to take for each range in KRanges. |
|
47 The n:th element of KElementsIndex specifies the appropriate action to take for the n:th range in KRanges. |
|
48 */ |
|
49 const TUint8 KElementsIndex[KRangeCount] = |
|
50 { |
|
51 CPolicyServer::ENotSupported, |
|
52 CPolicyServer::ECustomCheck, |
|
53 KCapabilitiesForRequest1, |
|
54 CPolicyServer::ECustomCheck, |
|
55 CPolicyServer::ECustomCheck, |
|
56 KCapabilitiesForRequest2, |
|
57 KSecurityCheckForRequest3, |
|
58 CPolicyServer::ENotSupported |
|
59 }; |
|
60 |
|
61 //ESetAsPriorityClient request is allowed only for priotity clients(Telephony). Inorder to prevent the access |
|
62 //client request will be policed using C32 SID |
|
63 #define KC32SecureId 0x10003D33 |
|
64 |
|
65 /** |
|
66 Array containing the different security checks performed by this server |
|
67 */ |
|
68 const CPolicyServer::TPolicyElement KPolicyElements[] = |
|
69 { |
|
70 {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient}, //lint !e778 suppress Constant expression evaluates to 0 in operation '+' |
|
71 {_INIT_SECURITY_POLICY_C2(ECapabilityPowerMgmt, ECapabilityWriteDeviceData), CPolicyServer::EFailClient}, |
|
72 {_INIT_SECURITY_POLICY_S0(KC32SecureId), CPolicyServer::EFailClient} |
|
73 }; |
|
74 |
|
75 /** |
|
76 Setup a security policy. |
|
77 */ |
|
78 const CPolicyServer::TPolicy KSusAdaptionServerPolicy = |
|
79 { |
|
80 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
|
81 KRangeCount, |
|
82 KRanges, |
|
83 KElementsIndex, |
|
84 KPolicyElements |
|
85 }; |
|
86 |
|
87 // ------------------- AdaptionServer Implementation ---------------------- |
|
88 |
|
89 /** |
|
90 */ |
|
91 |
|
92 #define KSsmSecureId 0x2000D75B |
|
93 #define KAlarmServerSecureId 0x101F5027 |
|
94 #define KSusSecureId 0x2000D766 |
|
95 |
|
96 |
|
97 CPolicyServer::TCustomResult CSsmAdaptationServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/) |
|
98 { |
|
99 CPolicyServer::TCustomResult customResult; |
|
100 switch(aMsg.Function()) |
|
101 { |
|
102 case ERequestCoopSysStateChange:/*State Adaptation OpCodes*/ |
|
103 case ERequestCoopSysSelfTest: |
|
104 case ERequestCoopSysPerformRestartActions: |
|
105 case ERequestCoopSysPerformShutdownActions: |
|
106 case ERequestCoopSysPerformRfsActions: |
|
107 case ERequestCoopSysCancel: |
|
108 case ESecurityStateChange:/*Misc Adaptation OpCodes*/ |
|
109 case EGetGlobalStartupMode: |
|
110 case EPrepareSimLanguages: |
|
111 case EMiscCancel: |
|
112 case EGetHiddenReset: |
|
113 case EGetSimLanguagesArray: |
|
114 { |
|
115 if(aMsg.SecureId() == KSsmSecureId) |
|
116 { |
|
117 customResult = EPass; |
|
118 } |
|
119 else |
|
120 { |
|
121 customResult = EFail; |
|
122 } |
|
123 break; |
|
124 } |
|
125 case EGetLastCoopSysEvent: |
|
126 case ENotifyCoopSysEvent: |
|
127 case ENotifyCoopSysCancel: |
|
128 { |
|
129 if(aMsg.SecureId() == KSusSecureId) |
|
130 { |
|
131 customResult = EPass; |
|
132 } |
|
133 else |
|
134 { |
|
135 customResult = EFail; |
|
136 } |
|
137 break; |
|
138 } |
|
139 case EValidateRtc:/*Rtc Adaptation OpCodes*/ |
|
140 case ERtcCancel: |
|
141 { |
|
142 // On licensee devices processes other than the alarm server need to check the validity of the RTC, |
|
143 // so they should be allowed to validate the Rtc and to cancel the validate rtc request. |
|
144 customResult = EPass; |
|
145 break; |
|
146 } |
|
147 case ESetWakeupAlarm: |
|
148 case EUnsetWakeupAlarm: |
|
149 { |
|
150 if(aMsg.SecureId() == KAlarmServerSecureId) |
|
151 { |
|
152 customResult = EPass; |
|
153 } |
|
154 else |
|
155 { |
|
156 customResult = EFail; |
|
157 } |
|
158 break; |
|
159 } |
|
160 default: |
|
161 { |
|
162 customResult = EFail; |
|
163 break; |
|
164 } |
|
165 } |
|
166 |
|
167 return customResult; |
|
168 } |
|
169 |
|
170 |
|
171 CSsmAdaptationServer::CSsmAdaptationServer( ): CPolicyServer(EPriorityStandard, KSusAdaptionServerPolicy) |
|
172 ,iPriorityClientSession(NULL) |
|
173 { |
|
174 } |
|
175 |
|
176 /** |
|
177 */ |
|
178 CSsmAdaptationServer::~CSsmAdaptationServer( ) |
|
179 { |
|
180 const TInt ignore = User::SetCritical (User::ENotCritical ); |
|
181 |
|
182 // Observers must be deleted before their corresponding adaptation |
|
183 delete iStateAdaptationObservers; |
|
184 iStateAdaptationObservers = NULL; |
|
185 delete iStateAdaptation; |
|
186 iStateAdaptation = NULL; |
|
187 |
|
188 // Observers must be deleted before their corresponding adaptation |
|
189 delete iSimAdaptationObservers; |
|
190 iSimAdaptationObservers = NULL; |
|
191 delete iSimAdaptation; |
|
192 iSimAdaptation = NULL; |
|
193 |
|
194 delete iEmergencyCallRfAdaptation; |
|
195 iEmergencyCallRfAdaptation = NULL; |
|
196 delete iMiscAdaptation; |
|
197 iMiscAdaptation = NULL; |
|
198 delete iRtcAdaptation; |
|
199 iRtcAdaptation = NULL; |
|
200 |
|
201 //Delete iSusAdaptationPluginLoader after deleting all the adaptations as it will close |
|
202 //all the loaded libraries. |
|
203 delete iSusAdaptationPluginLoader; |
|
204 } //lint !e529 suppress Symbol 'ignore' not subsequently referenced |
|
205 |
|
206 /** |
|
207 */ |
|
208 CSsmAdaptationServer* CSsmAdaptationServer::NewLC( ) |
|
209 { |
|
210 CSsmAdaptationServer* server = new(ELeave) CSsmAdaptationServer(); |
|
211 CleanupStack::PushL (server ); |
|
212 server->ConstructL ( ); |
|
213 return server; |
|
214 } |
|
215 |
|
216 /** |
|
217 */ |
|
218 void CSsmAdaptationServer::ConstructL( ) |
|
219 { |
|
220 |
|
221 __ASSERT_ALWAYS( KErrNone == User::SetCritical(User::ESystemCritical), |
|
222 User::Panic(KPanicSsmSus, EAdaptionServerError1)); |
|
223 |
|
224 __ASSERT_ALWAYS( KErrNone == User::RenameThread(KSusAdaptionServerName), |
|
225 User::Panic(KPanicSsmSus, EAdaptionServerError2)); |
|
226 |
|
227 iSusAdaptationPluginLoader = CSusAdaptationPluginLoader::NewL(); |
|
228 TInt err = Start(KSusAdaptionServerName); |
|
229 #ifdef TESTSUSADAPTATIONPLUGINLOAD_OOM |
|
230 if (err != KErrNone && err != KErrAlreadyExists) |
|
231 { |
|
232 User::Leave(err); |
|
233 } |
|
234 #else |
|
235 User::LeaveIfError(err); |
|
236 #endif |
|
237 } |
|
238 |
|
239 /** |
|
240 */ |
|
241 CSession2* CSsmAdaptationServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
|
242 { |
|
243 // Check we're the right version |
|
244 TVersion v(KSsmAdaptationMajorVersionNumber, KSsmAdaptationMinorVersionNumber, |
|
245 KSsmAdaptationBuildVersionNumber); |
|
246 if ( !User::QueryVersionSupported(v,aVersion) ) |
|
247 { |
|
248 User::Leave (KErrNotSupported ); |
|
249 } |
|
250 |
|
251 // version supported, go ahead |
|
252 return CSsmAdaptationSession::NewL ( ); |
|
253 } |
|
254 void CSsmAdaptationServer::DoRequestCoopSysStateChangeL(const RMessage2& aMessage) |
|
255 { |
|
256 if( iStateAdaptation == NULL ) |
|
257 { |
|
258 LoadStateAdaptationL(); |
|
259 } |
|
260 iStateAdaptation->DoRequestCoopSysStateChangeL(aMessage); |
|
261 } |
|
262 void CSsmAdaptationServer::DoRequestCoopSysSelfTestL(const RMessage2& aMessage) |
|
263 { |
|
264 if( iStateAdaptation == NULL ) |
|
265 { |
|
266 LoadStateAdaptationL(); |
|
267 } |
|
268 |
|
269 iStateAdaptation->DoRequestCoopSysSelfTestL(aMessage); |
|
270 } |
|
271 |
|
272 void CSsmAdaptationServer::DoRequestCoopSysPerformRestartActionsL(const RMessage2& aMessage) |
|
273 { |
|
274 if( iStateAdaptation == NULL ) |
|
275 { |
|
276 LoadStateAdaptationL(); |
|
277 } |
|
278 |
|
279 iStateAdaptation->DoRequestCoopSysPerformRestartActionsL(aMessage); |
|
280 } |
|
281 |
|
282 void CSsmAdaptationServer::DoRequestCoopSysPerformShutdownActionsL(const RMessage2& aMessage) |
|
283 { |
|
284 if( iStateAdaptation == NULL ) |
|
285 { |
|
286 LoadStateAdaptationL(); |
|
287 } |
|
288 |
|
289 iStateAdaptation->DoRequestCoopSysPerformShutdownActionsL(aMessage); |
|
290 } |
|
291 |
|
292 void CSsmAdaptationServer::DoRequestCoopSysPerformRfsActionsL(const RMessage2& aMessage) |
|
293 { |
|
294 if( iStateAdaptation == NULL ) |
|
295 { |
|
296 LoadStateAdaptationL(); |
|
297 } |
|
298 |
|
299 iStateAdaptation->DoRequestCoopSysPerformRfsActionsL(aMessage); |
|
300 } |
|
301 |
|
302 void CSsmAdaptationServer::DoRequestCoopSysCancelL(const RMessage2& aMessage) |
|
303 { |
|
304 if( iStateAdaptation == NULL ) |
|
305 { |
|
306 LoadStateAdaptationL(); |
|
307 } |
|
308 |
|
309 iStateAdaptation->DoRequestCancel(aMessage); |
|
310 } |
|
311 void CSsmAdaptationServer::DoNotifyCoopSysEventL(const RMessage2& aMessage) |
|
312 { |
|
313 if( iStateAdaptationObservers == NULL ) |
|
314 { |
|
315 LoadStateAdaptationObserversL(); |
|
316 } |
|
317 iStateAdaptationObservers->DoNotifyCoopSysEventL(aMessage) ; |
|
318 } |
|
319 void CSsmAdaptationServer::DoNotifyCoopSysEventCancelL(const RMessage2& aMessage) |
|
320 { |
|
321 if( iStateAdaptationObservers == NULL ) |
|
322 { |
|
323 LoadStateAdaptationObserversL(); |
|
324 } |
|
325 iStateAdaptationObservers->DoNotifyCoopSysEventCancelL(aMessage); |
|
326 } |
|
327 void CSsmAdaptationServer::DoGetLastCoopSysEventL(const RMessage2& aMessage) |
|
328 { |
|
329 if( iStateAdaptationObservers == NULL ) |
|
330 { |
|
331 LoadStateAdaptationObserversL(); |
|
332 } |
|
333 iStateAdaptationObservers->DoGetLastCoopSysEvent(aMessage); |
|
334 } |
|
335 |
|
336 //SIM ADAPTATION RELATED |
|
337 |
|
338 void CSsmAdaptationServer::DoGetSimOwnedL(const RMessage2& aMessage) |
|
339 { |
|
340 if( iSimAdaptation == NULL ) |
|
341 { |
|
342 LoadSimAdaptationL(); |
|
343 } |
|
344 |
|
345 iSimAdaptation->DoGetSimOwnedL(aMessage); |
|
346 } |
|
347 void CSsmAdaptationServer::DoGetSimCancelL(const RMessage2& aMessage) |
|
348 { |
|
349 if( iSimAdaptation == NULL ) |
|
350 { |
|
351 LoadSimAdaptationL(); |
|
352 } |
|
353 |
|
354 iSimAdaptation->DoGetSimCancel(aMessage); |
|
355 } |
|
356 void CSsmAdaptationServer::DoNotifySimEventL(const RMessage2& aMessage) |
|
357 { |
|
358 if( iSimAdaptationObservers == NULL ) |
|
359 { |
|
360 LoadSimAdaptationObserversL(); |
|
361 } |
|
362 |
|
363 iSimAdaptationObservers->DoNotifySimEventL(aMessage); |
|
364 } |
|
365 void CSsmAdaptationServer::DoNotifySimCancelL(const RMessage2& aMessage) |
|
366 { |
|
367 if( iSimAdaptationObservers == NULL ) |
|
368 { |
|
369 LoadSimAdaptationObserversL(); |
|
370 } |
|
371 |
|
372 iSimAdaptationObservers->DoNotifySimEventCancelL(aMessage); |
|
373 } |
|
374 void CSsmAdaptationServer::DoGetLastSimEventL(const RMessage2& aMessage) |
|
375 { |
|
376 if( iSimAdaptationObservers == NULL ) |
|
377 { |
|
378 LoadSimAdaptationObserversL(); |
|
379 } |
|
380 |
|
381 iSimAdaptationObservers->DoGetLastSimEvent(aMessage); |
|
382 } |
|
383 // RTC ADAPTATION RELATED |
|
384 |
|
385 void CSsmAdaptationServer::DoValidateRtcL(const RMessage2& aMessage) |
|
386 { |
|
387 if( iRtcAdaptation == NULL ) |
|
388 { |
|
389 LoadRtcAdaptationL(); |
|
390 } |
|
391 |
|
392 iRtcAdaptation->DoValidateRtcL(aMessage); |
|
393 } |
|
394 void CSsmAdaptationServer::DoSetWakeupAlarmL(const RMessage2& aMessage) |
|
395 { |
|
396 if( iRtcAdaptation == NULL ) |
|
397 { |
|
398 LoadRtcAdaptationL(); |
|
399 } |
|
400 |
|
401 iRtcAdaptation->DoSetWakeupAlarmL(aMessage); |
|
402 } |
|
403 void CSsmAdaptationServer::DoUnsetWakeupAlarmL(const RMessage2& aMessage) |
|
404 { |
|
405 if( iRtcAdaptation == NULL ) |
|
406 { |
|
407 LoadRtcAdaptationL(); |
|
408 } |
|
409 iRtcAdaptation->DoUnsetWakeupAlarmL(aMessage); |
|
410 } |
|
411 void CSsmAdaptationServer::DoRtcCancelL(const RMessage2& aMessage) |
|
412 { |
|
413 if( iRtcAdaptation == NULL ) |
|
414 { |
|
415 LoadRtcAdaptationL(); |
|
416 } |
|
417 iRtcAdaptation->DoRtcCancelL(aMessage); |
|
418 } |
|
419 |
|
420 //MISC ADAPTATION RELATED |
|
421 void CSsmAdaptationServer::DoSecurityStateChangeL(const RMessage2& aMessage) |
|
422 { |
|
423 if( iMiscAdaptation == NULL ) |
|
424 { |
|
425 LoadMiscAdaptationL(); |
|
426 } |
|
427 |
|
428 iMiscAdaptation->DoSecurityStateChangeL(aMessage); |
|
429 } |
|
430 void CSsmAdaptationServer::DoGetGlobalStartupModeL(const RMessage2& aMessage) |
|
431 { |
|
432 if( iMiscAdaptation == NULL ) |
|
433 { |
|
434 LoadMiscAdaptationL(); |
|
435 } |
|
436 |
|
437 iMiscAdaptation->DoGetGlobalStartupModeL(aMessage); |
|
438 } |
|
439 void CSsmAdaptationServer::DoPrepareSimLanguagesL(const RMessage2& aMessage) |
|
440 { |
|
441 if( iMiscAdaptation == NULL ) |
|
442 { |
|
443 LoadMiscAdaptationL(); |
|
444 } |
|
445 |
|
446 iMiscAdaptation->DoPrepareSimLanguagesL(aMessage); |
|
447 } |
|
448 |
|
449 void CSsmAdaptationServer::DoGetSimLanguagesArrayL(const RMessage2& aMessage) |
|
450 { |
|
451 if( iMiscAdaptation == NULL ) |
|
452 { |
|
453 LoadMiscAdaptationL(); |
|
454 } |
|
455 iMiscAdaptation->DoGetSimLanguagesArrayL(aMessage); |
|
456 |
|
457 } |
|
458 |
|
459 void CSsmAdaptationServer::DoMiscAdaptationCancelL(const RMessage2& aMessage) |
|
460 { |
|
461 if( iMiscAdaptation == NULL ) |
|
462 { |
|
463 LoadMiscAdaptationL(); |
|
464 } |
|
465 |
|
466 iMiscAdaptation->DoMiscAdaptationCancelL(aMessage); |
|
467 } |
|
468 |
|
469 void CSsmAdaptationServer::DoMiscAdaptationHiddenResetL(const RMessage2& aMessage) |
|
470 { |
|
471 if( iMiscAdaptation == NULL ) |
|
472 { |
|
473 LoadMiscAdaptationL(); |
|
474 } |
|
475 |
|
476 iMiscAdaptation->DoMiscAdaptationHiddenResetL(aMessage); |
|
477 } |
|
478 |
|
479 //EMERGENCY CALL RF ADAPTATION RELATED |
|
480 void CSsmAdaptationServer::DoActivateRfForEmergencyCallL(const RMessage2& aMessage) |
|
481 { |
|
482 if( iEmergencyCallRfAdaptation == NULL ) |
|
483 { |
|
484 LoadEmergencyCallRfAdaptationL(); |
|
485 } |
|
486 |
|
487 iEmergencyCallRfAdaptation->DoActivateRfForEmergencyCallL(aMessage); |
|
488 } |
|
489 void CSsmAdaptationServer::DoDeactivateRfForEmergencyCallL(const RMessage2& aMessage) |
|
490 { |
|
491 if( iEmergencyCallRfAdaptation == NULL ) |
|
492 { |
|
493 LoadEmergencyCallRfAdaptationL(); |
|
494 } |
|
495 |
|
496 iEmergencyCallRfAdaptation->DoDeactivateRfForEmergencyCallL(aMessage); |
|
497 } |
|
498 void CSsmAdaptationServer::DoEmergencyCallRfCancelL(const RMessage2& aMessage) |
|
499 { |
|
500 if( iEmergencyCallRfAdaptation == NULL ) |
|
501 { |
|
502 LoadEmergencyCallRfAdaptationL(); |
|
503 } |
|
504 |
|
505 iEmergencyCallRfAdaptation->DoEmergencyCallRfAdaptationCancelL(aMessage); |
|
506 } |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 void CSsmAdaptationServer::LoadStateAdaptationL() |
|
512 { |
|
513 MStateAdaptation *stateAdaptationPlugin = iSusAdaptationPluginLoader->CreateStateAdaptationL(); |
|
514 CleanupReleasePushL(*stateAdaptationPlugin); |
|
515 //From here stateAdaptationPlugin object will be owned by iStateAdaptation |
|
516 iStateAdaptation = CStateAdaptationRequests::NewL(*stateAdaptationPlugin); |
|
517 CleanupStack::Pop(stateAdaptationPlugin); |
|
518 } |
|
519 |
|
520 void CSsmAdaptationServer::LoadStateAdaptationObserversL() |
|
521 { |
|
522 if( iStateAdaptation == NULL ) |
|
523 { |
|
524 // Load the State adaptation to use it's adaptation plugin |
|
525 LoadStateAdaptationL(); |
|
526 } |
|
527 iStateAdaptationObservers = CStateAdaptationObservers::NewL(iStateAdaptation->Adaptation()); |
|
528 } |
|
529 |
|
530 void CSsmAdaptationServer::LoadSimAdaptationL() |
|
531 { |
|
532 MSimAdaptation *simAdaptation = iSusAdaptationPluginLoader->CreateSimAdaptationL(); |
|
533 CleanupReleasePushL(*simAdaptation); |
|
534 //From here simAdaptation plugin object will be owned by iSimAdaptation |
|
535 iSimAdaptation = CSimAdaptationRequests::NewL(*simAdaptation); |
|
536 CleanupStack::Pop(simAdaptation); |
|
537 } |
|
538 void CSsmAdaptationServer::LoadSimAdaptationObserversL() |
|
539 { |
|
540 if( iSimAdaptation == NULL ) |
|
541 { |
|
542 // Load the SIM adaptation to use it's adaptation plugin |
|
543 LoadSimAdaptationL(); |
|
544 } |
|
545 iSimAdaptationObservers = CSimAdaptationObservers::NewL(iSimAdaptation->Adaptation()); |
|
546 } |
|
547 void CSsmAdaptationServer::LoadRtcAdaptationL() |
|
548 { |
|
549 MRtcAdaptation *rtcAdaptationPlugin = iSusAdaptationPluginLoader->CreateRtcAdaptationL(); |
|
550 CleanupReleasePushL(*rtcAdaptationPlugin); |
|
551 //From here rtcAdaptationPlugin object object will be owned by iRtcAdaptation |
|
552 iRtcAdaptation = CRtcAdaptation::NewL(*rtcAdaptationPlugin); |
|
553 CleanupStack::Pop(rtcAdaptationPlugin); |
|
554 } |
|
555 void CSsmAdaptationServer::LoadMiscAdaptationL() |
|
556 { |
|
557 MMiscAdaptation *miscAdaptationPlugin = iSusAdaptationPluginLoader->CreateMiscAdaptationL(); |
|
558 CleanupReleasePushL(*miscAdaptationPlugin); |
|
559 //From here miscAdaptationPlugin object will be owned by iMiscAdaptation |
|
560 iMiscAdaptation = CMiscAdaptation::NewL(*miscAdaptationPlugin); |
|
561 CleanupStack::Pop(miscAdaptationPlugin); |
|
562 } |
|
563 void CSsmAdaptationServer::LoadEmergencyCallRfAdaptationL() |
|
564 { |
|
565 MEmergencyCallRfAdaptation *emergencyCallRfAdaptationPlugin = iSusAdaptationPluginLoader->CreateEmergencyCallRfAdaptationL(); |
|
566 CleanupReleasePushL(*emergencyCallRfAdaptationPlugin); |
|
567 //From here emergencyCallRfAdaptationPlugin object will be owned by iEmergencyCallRfAdaptation |
|
568 iEmergencyCallRfAdaptation = CEmergencyCallRfAdaptation::NewL(*emergencyCallRfAdaptationPlugin); |
|
569 CleanupStack::Pop(emergencyCallRfAdaptationPlugin); |
|
570 //Reserve memory for performing Emergency call during OOM condition |
|
571 iEmergencyCallRfAdaptation->ReserveMemoryL(); |
|
572 } |
|
573 |
|
574 #ifdef _DEBUG |
|
575 void CSsmAdaptationServer::UnloadAdaptationsAndObservers() |
|
576 { |
|
577 delete iStateAdaptation; |
|
578 iStateAdaptation = NULL; |
|
579 delete iStateAdaptationObservers; |
|
580 iStateAdaptationObservers = NULL; |
|
581 delete iSimAdaptation; |
|
582 iSimAdaptation = NULL; |
|
583 delete iSimAdaptationObservers; |
|
584 iSimAdaptationObservers = NULL; |
|
585 delete iEmergencyCallRfAdaptation; |
|
586 iEmergencyCallRfAdaptation = NULL; |
|
587 delete iMiscAdaptation; |
|
588 iMiscAdaptation = NULL; |
|
589 delete iRtcAdaptation; |
|
590 iRtcAdaptation = NULL; |
|
591 } |
|
592 #endif |
|
593 |
|
594 /** |
|
595 * Sets the calling client as a priority client. This also loads the emergency client dll, |
|
596 * if it is not already loaded. |
|
597 */ |
|
598 TInt CSsmAdaptationServer::SetAsPriorityClientL(CSsmAdaptationSession* aSession) |
|
599 { |
|
600 if(iPriorityClientSession == NULL ) |
|
601 { |
|
602 if(iEmergencyCallRfAdaptation == NULL) |
|
603 { |
|
604 LoadEmergencyCallRfAdaptationL(); |
|
605 } |
|
606 iPriorityClientSession = aSession; |
|
607 iEmergencyCallRfAdaptation->SetPriorityClientSession(iPriorityClientSession); |
|
608 return KErrNone; |
|
609 } |
|
610 return KErrAlreadyExists; |
|
611 } |
|
612 |
|
613 /* |
|
614 * Remove priority Client |
|
615 */ |
|
616 void CSsmAdaptationServer::RemovePriorityClient(CSsmAdaptationSession* aSession) |
|
617 { |
|
618 if(aSession == iPriorityClientSession) |
|
619 { |
|
620 iPriorityClientSession = NULL; |
|
621 iEmergencyCallRfAdaptation->RemovePriorityClientSession(); |
|
622 } |
|
623 } |
|
624 |
|
625 //RMessage2 related functionality |
|
626 //C Class |
|
627 |
|
628 void CAdaptationMessage::ReadL(TInt aParamNumber,TPtr8 aParam) |
|
629 { |
|
630 iMessage.ReadL(aParamNumber,aParam); |
|
631 } |
|
632 |
|
633 TInt CAdaptationMessage::GetDesLength(TInt aParam) |
|
634 { |
|
635 return iMessage.GetDesLength(aParam); |
|
636 } |
|
637 |
|
638 TInt CAdaptationMessage::Function() const |
|
639 { |
|
640 return iMessage.Function(); |
|
641 } |
|
642 |
|
643 CSession2 *CAdaptationMessage::Session() const |
|
644 { |
|
645 return iMessage.Session(); |
|
646 } |
|
647 |
|
648 TInt CAdaptationMessage::Int0() const |
|
649 { |
|
650 return iMessage.Int0(); |
|
651 } |
|
652 |
|
653 void CAdaptationMessage::WriteL(TInt aParam, const TDesC8 &aDes) |
|
654 { |
|
655 iMessage.WriteL(aParam,aDes); |
|
656 } |
|
657 |
|
658 CAdaptationMessage::CAdaptationMessage(const RMessage2 &aMessage): CBase(),iMessage(aMessage) |
|
659 ,iMessageAvailable(ETrue),iUsingReservedHeap(EFalse) |
|
660 { |
|
661 } |
|
662 |
|
663 void CAdaptationMessage::Complete(TInt aReason) |
|
664 { |
|
665 iMessage.Complete(aReason); |
|
666 } |
|
667 |
|
668 |
|
669 void RSsmAdaptationRequestQueue::NotifyAndRemoveAll() |
|
670 { |
|
671 TInt index,count = iQueue.Count(); |
|
672 |
|
673 for(index =0;index < count ;index++) |
|
674 { |
|
675 iQueue[index]->Complete(KErrServerTerminated); |
|
676 delete iQueue[index]; |
|
677 iQueue[index] = NULL; |
|
678 } |
|
679 iQueue.Reset(); |
|
680 } |
|
681 |
|
682 void RSsmAdaptationRequestQueue::NotifyAndRemoveAll(RHeap *aReservedHeap) |
|
683 { |
|
684 TInt index,count = iQueue.Count(); |
|
685 |
|
686 for(index =0;index < count ;index++) |
|
687 { |
|
688 iQueue[index]->Complete(KErrServerTerminated); |
|
689 if(iQueue[index]->iUsingReservedHeap) |
|
690 { |
|
691 aReservedHeap->Free(iQueue[index]); |
|
692 } |
|
693 else |
|
694 { |
|
695 delete iQueue[index]; |
|
696 } |
|
697 iQueue[index] = NULL; |
|
698 } |
|
699 iQueue.Reset(); |
|
700 } |
|
701 |
|
702 void RSsmAdaptationRequestQueue::Close() |
|
703 { |
|
704 iQueue.Close(); |
|
705 } |
|
706 TBool RSsmAdaptationRequestQueue::IsEmpty() |
|
707 { |
|
708 if(iQueue.Count() == 0) |
|
709 { |
|
710 return ETrue; |
|
711 } |
|
712 else |
|
713 { |
|
714 return EFalse; |
|
715 } |
|
716 } |
|
717 void RSsmAdaptationRequestQueue::RemoveFromQueueAndComplete(const RMessage2 &aMessage) |
|
718 { |
|
719 |
|
720 CAdaptationMessage *messageToBeDeleted; |
|
721 |
|
722 // iQueue.Count() is recalculated each time as the object is removed from the |
|
723 // array(which reduces the number of object pointers in the array |
|
724 for(TInt index = 0; index < iQueue.Count(); index++ ) |
|
725 { |
|
726 if(aMessage.Session() == iQueue[index]->Session()) |
|
727 { |
|
728 messageToBeDeleted = iQueue[index]; |
|
729 DEBUGPRINT2A("RSsmAdaptationRequestQueue cancelling request with function id: %d", messageToBeDeleted->Function()); |
|
730 iQueue.Remove(index); |
|
731 messageToBeDeleted->Complete(KErrCancel); |
|
732 delete messageToBeDeleted; |
|
733 index--; |
|
734 } |
|
735 } |
|
736 |
|
737 } |
|
738 |
|
739 void RSsmAdaptationRequestQueue::RemoveFromQueueAndComplete(const RMessage2 &aMessage, RHeap *aReservedHeap ) |
|
740 { |
|
741 |
|
742 CAdaptationMessage *messageToBeDeleted; |
|
743 |
|
744 // iQueue.Count() is recalculated each time as the object is removed from the |
|
745 // array(which reduces the number of object pointers in the array |
|
746 for(TInt index = 0; index < iQueue.Count(); ++index ) |
|
747 { |
|
748 if(aMessage.Session() == iQueue[index]->Session()) |
|
749 { |
|
750 messageToBeDeleted = iQueue[index]; |
|
751 DEBUGPRINT2A("RSsmAdaptationRequestQueue(aMessage,ReservedHeap)called to cancel the request with function id: %d", messageToBeDeleted->Function()); |
|
752 iQueue.Remove(index); |
|
753 messageToBeDeleted->Complete(KErrCancel); |
|
754 if(messageToBeDeleted->iUsingReservedHeap) |
|
755 { |
|
756 aReservedHeap->Free(messageToBeDeleted); |
|
757 } |
|
758 else |
|
759 { |
|
760 delete messageToBeDeleted; |
|
761 } |
|
762 --index; |
|
763 } |
|
764 } |
|
765 } |
|
766 void RSsmAdaptationRequestQueue::Dequeue(CAdaptationMessage *&aCurrentMessage) |
|
767 { |
|
768 aCurrentMessage = iQueue[0]; |
|
769 iQueue.Remove(0); |
|
770 } |
|
771 TInt RSsmAdaptationRequestQueue::Queue(CAdaptationMessage *aPendingRequest) |
|
772 { |
|
773 return iQueue.Append(aPendingRequest); |
|
774 } |
|
775 |
|
776 TInt RSsmAdaptationRequestQueue::Reserve(TInt aReserverCount) |
|
777 { |
|
778 return(iQueue.Reserve(aReserverCount)); |
|
779 } |
|
780 |
|
781 /** |
|
782 * Method to get number of object pointers in the Queue |
|
783 */ |
|
784 TInt RSsmAdaptationRequestQueue::Count() |
|
785 { |
|
786 return iQueue.Count(); |
|
787 } |
|
788 |