|
1 /* |
|
2 * Copyright (c) 2000 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 terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32debug.h> |
|
21 #include <e32math.h> |
|
22 #include <e32cmn.h> |
|
23 |
|
24 |
|
25 |
|
26 #include <e32property.h> |
|
27 #include <PSVariables.h> // Property values |
|
28 #include <coreapplicationuisdomainpskeys.h> |
|
29 |
|
30 |
|
31 #include "SCPServer.h" |
|
32 #include "SCPSession.h" |
|
33 #include "SCPLockSettingEventHandler.h" |
|
34 #include "SCPLockNotificationEventHandler.h" |
|
35 |
|
36 // For Central Repository |
|
37 #include <centralrepository.h> |
|
38 #include "SCPCodePrivateCRKeys.h" |
|
39 #include "SCPLockCode.h" |
|
40 |
|
41 #ifdef SCP_SMS_LOCK_AVAILABLE |
|
42 #include <RemoteLockSettings.h> |
|
43 #endif // SCP_SMS_LOCK_AVAILABLE |
|
44 |
|
45 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
46 #include <SCPParamObject.h> |
|
47 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
48 #include <featmgr.h> |
|
49 #include "SCPDebug.h" |
|
50 #include <TerminalControl3rdPartyAPI.h> |
|
51 #include <TerminalControl3rdPartyParamsPlugin.h> |
|
52 #include <utf.h> |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 |
|
55 // C++ default constructor can NOT contain any code, that |
|
56 // might leave. |
|
57 // |
|
58 CSCPSession::CSCPSession( CSCPServer& aServer ) |
|
59 : CSession2(), |
|
60 iServer( aServer ), |
|
61 iLockCommandState( ESCPLockCmdStateIdle ), |
|
62 iUnlockMessageSent( EFalse ), |
|
63 iLockOperationTimer( NULL ), |
|
64 iPendingCallStatus( NULL ), |
|
65 iALParamValue(NULL) |
|
66 { |
|
67 } |
|
68 |
|
69 // Symbian 2nd phase constructor can leave. |
|
70 void CSCPSession::ConstructL() |
|
71 { |
|
72 iServer.SessionOpened(); |
|
73 } |
|
74 |
|
75 // Static constructor. |
|
76 CSCPSession* CSCPSession::NewL( CSCPServer& aServer ) |
|
77 { |
|
78 CSCPSession* self = CSCPSession::NewLC( aServer ); |
|
79 CleanupStack::Pop( self ); |
|
80 |
|
81 return self; |
|
82 } |
|
83 |
|
84 // Static constructor, leaves object pointer to the cleanup stack. |
|
85 CSCPSession* CSCPSession::NewLC( CSCPServer& aServer ) |
|
86 { |
|
87 CSCPSession* self = new(ELeave) CSCPSession( aServer ); |
|
88 |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // Destructor |
|
97 CSCPSession::~CSCPSession() |
|
98 { |
|
99 Dprint( (_L("--> CSCPSession::~CSCPSession()")) ); |
|
100 |
|
101 delete iLockOperationTimer; |
|
102 iLockOperationTimer = NULL; |
|
103 |
|
104 delete iNotificationHandler; |
|
105 iNotificationHandler = NULL; |
|
106 |
|
107 delete iSettingHandler; |
|
108 iSettingHandler = NULL; |
|
109 |
|
110 iPendingCallStatus = NULL; |
|
111 |
|
112 iServer.SessionClosed(); |
|
113 if(iALParamValue) { |
|
114 delete iALParamValue; |
|
115 } |
|
116 |
|
117 Dprint( (_L("<-- CSCPSession::~CSCPSession()")) ); |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // TBool CSCPSession::IsOperationInProgress( TSCPAdminCommand aCommand ) |
|
124 // Checks from the state variable, if the given command is actually in progress |
|
125 // |
|
126 // Status : Approved |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 TBool CSCPSession::IsOperationInProgress( TSCPAdminCommand aCommand ) |
|
130 { |
|
131 Dprint( (_L("--> CSCPSession::IsOperationInProgress( %d )"), aCommand )); |
|
132 |
|
133 TBool ret = EFalse; |
|
134 |
|
135 if ( aCommand == ESCPCommandLockPhone ) |
|
136 { |
|
137 if ( ( iLockCommandState == ESCPLockCmdStateInProgress ) |
|
138 || ( iLockCommandState == ESCPLockCmdStateInProgressAcknowledged ) |
|
139 ) |
|
140 { |
|
141 ret = ETrue; |
|
142 } |
|
143 } |
|
144 |
|
145 if ( aCommand == ESCPCommandUnlockPhone ) |
|
146 { |
|
147 if ( iUnlockMessageSent ) |
|
148 { |
|
149 ret = ETrue; |
|
150 } |
|
151 } |
|
152 |
|
153 Dprint( (_L("<-- CSCPSession::IsOperationInProgress(): %d"), ret )); |
|
154 |
|
155 return ret; |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------- |
|
159 // TBool CSCPSession::AcknowledgeOperation( TSCPAdminCommand aCommand ) |
|
160 // Set the state variable accordingly, if it was set in a waiting state |
|
161 // and return the status value respectively. |
|
162 // |
|
163 // Status : Approved |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 TBool CSCPSession::AcknowledgeOperation( TSCPAdminCommand aCommand ) |
|
167 { |
|
168 Dprint( (_L("--> CSCPSession::AcknowledgeOperation( %d )"), aCommand )); |
|
169 |
|
170 // The return parameter, set this if the ack was awaited |
|
171 TBool ret = EFalse; |
|
172 |
|
173 if ( aCommand == ESCPCommandLockPhone ) |
|
174 { |
|
175 switch ( iLockCommandState ) |
|
176 { |
|
177 case ( ESCPLockCmdStateInProgress ): |
|
178 { |
|
179 // Acknowledgement received, now just wait for the actual |
|
180 // call to finish |
|
181 Dprint( (_L("CSCPSession::AcknowledgeOperation( %d ): \ |
|
182 Lock-op acknowledged"), aCommand )); |
|
183 iLockCommandState = ESCPLockCmdStateInProgressAcknowledged; |
|
184 iSettingHandler->AckReceived(); |
|
185 |
|
186 ret = ETrue; |
|
187 break; |
|
188 } |
|
189 |
|
190 case ( ESCPLockCmdStateFinishedAckPending ): |
|
191 { |
|
192 // OK, the operation is completed |
|
193 Dprint( (_L("CSCPSession::AcknowledgeOperation( %d ): \ |
|
194 Lock-op acknowledged"), aCommand )); |
|
195 iLockCommandState = ESCPLockCmdStateIdle; |
|
196 iUnlockMessageSent = EFalse; |
|
197 |
|
198 Dprint( (_L("CSCPSession::AcknowledgeOperation( %d ): \ |
|
199 Completing wait"), aCommand )); |
|
200 User::RequestComplete( iPendingCallStatus, KErrNone ); |
|
201 iPendingCallStatus = NULL; |
|
202 |
|
203 ret = ETrue; |
|
204 break; |
|
205 } |
|
206 |
|
207 case ( ESCPLockCmdStateIdle ): |
|
208 // Flow through, nothing here |
|
209 |
|
210 case ( ESCPLockCmdStateInProgressAcknowledged ): |
|
211 // Flow through, nothing here |
|
212 |
|
213 default: |
|
214 // No action |
|
215 break; |
|
216 } |
|
217 } |
|
218 |
|
219 if ( aCommand == ESCPCommandUnlockPhone ) |
|
220 { |
|
221 if ( iUnlockMessageSent ) |
|
222 { |
|
223 Dprint( (_L("CSCPSession::AcknowledgeOperation( %d ): \ |
|
224 Completing Unlock-event"), aCommand )); |
|
225 |
|
226 ret = ETrue; |
|
227 // Complete the call |
|
228 iUnlockMessageSent = EFalse; |
|
229 User::RequestComplete( iPendingCallStatus, KErrNone ); |
|
230 iPendingCallStatus = NULL; |
|
231 } |
|
232 } |
|
233 |
|
234 Dprint( (_L("<-- CSCPSession::AcknowledgeOperation(): %d"), ret )); |
|
235 return ret; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // void CSCPSession::HandleGetCodeMessageL( const RMessage2 &aMessage ) |
|
240 // Gets the stored code from the server and returns it to the |
|
241 // client thread. |
|
242 // |
|
243 // Status : Approved |
|
244 // --------------------------------------------------------- |
|
245 // |
|
246 void CSCPSession::HandleGetCodeMessageL( const RMessage2 &aMessage ) |
|
247 { |
|
248 Dprint( (_L("--> CSCPSession::HandleGetCodeMessageL()") )); |
|
249 |
|
250 TSCPSecCode code; |
|
251 code.Zero(); |
|
252 |
|
253 if ( iServer.GetCode( code ) != KErrNone ) |
|
254 { |
|
255 User::Leave( KErrGeneral ); |
|
256 } |
|
257 |
|
258 aMessage.WriteL( 0, code ); |
|
259 |
|
260 Dprint( (_L("<-- CSCPSession::HandleGetCodeMessageL()") )); |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------- |
|
264 // void CSCPSession::HandleSetCodeMessageL( const RMessage2 &aMessage ) |
|
265 // Reads the code from the client buffer, and sends it to the server. |
|
266 // |
|
267 // Status : Approved |
|
268 // --------------------------------------------------------- |
|
269 // |
|
270 void CSCPSession::HandleSetCodeMessageL( const RMessage2 &aMessage ) |
|
271 { |
|
272 Dprint( (_L("--> CSCPSession::HandleSetCodeMessageL()") )); |
|
273 RMobilePhone::TMobilePassword code; |
|
274 |
|
275 aMessage.ReadL( 0, code ); |
|
276 |
|
277 TSCPSecCode curCode; |
|
278 iServer.GetCode( curCode ); |
|
279 |
|
280 if ( curCode.Compare( code ) == 0 ) |
|
281 { |
|
282 TInt retErrorNone = KErrNone; |
|
283 // The codes are already the same. |
|
284 User::Leave( retErrorNone ); |
|
285 } |
|
286 |
|
287 #ifndef __WINS__ |
|
288 // No access to the ISA side in emulator |
|
289 |
|
290 // Check the given code, leave on error |
|
291 iServer.CheckISACodeL( code ); |
|
292 #endif // __WINS__ |
|
293 |
|
294 TInt ret = iServer.StoreCode( code ); |
|
295 if ( ret != KErrNone ) |
|
296 { |
|
297 User::Leave( ret ); |
|
298 } |
|
299 |
|
300 Dprint( (_L("<-- CSCPSession::HandleSetCodeMessageL()") )); |
|
301 } |
|
302 |
|
303 |
|
304 //#ifndef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
305 |
|
306 // --------------------------------------------------------- |
|
307 // void CSCPSession::HandleChangeCodeMessageL( const RMessage2 &aMessage ) |
|
308 // Fetches the stored code from the server, reads the new code |
|
309 // from the client side, and calls the method to change the code. |
|
310 // |
|
311 // Status : Approved |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 void CSCPSession::HandleChangeCodeMessageL( const RMessage2 &aMessage ) |
|
315 { |
|
316 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
317 { |
|
318 Dprint( (_L("--> CSCPSession::HandleChangeCodeMessageL()") )); |
|
319 |
|
320 RMobilePhone::TMobilePassword newPassword; |
|
321 |
|
322 aMessage.ReadL( 0, newPassword ); |
|
323 |
|
324 // Possible leave will result in an error status for the client |
|
325 iServer.ChangeISACodeL( newPassword ); |
|
326 |
|
327 Dprint( (_L("<-- CSCPSession::HandleChangeCodeMessageL()") )); |
|
328 } |
|
329 else |
|
330 |
|
331 /* |
|
332 #else // __SAP_DEVICE_LOCK_ENHANCEMENTS active |
|
333 |
|
334 // --------------------------------------------------------- |
|
335 // void CSCPSession::HandleChangeCodeMessageL( const RMessage2 &aMessage ) |
|
336 // Send the code in slot 0 to the server for storage. |
|
337 // |
|
338 // |
|
339 // Status : Approved |
|
340 // --------------------------------------------------------- |
|
341 // |
|
342 void CSCPSession::HandleChangeCodeMessageL( const RMessage2 &aMessage ) |
|
343 */ |
|
344 { |
|
345 Dprint( (_L("--> CSCPSession::HandleChangeCodeMessageL()") )); |
|
346 (void)aMessage; |
|
347 |
|
348 HBufC* codeHBuf = HBufC::NewLC( KSCPMaxEnhCodeLen + 1 ); |
|
349 TPtr codeBuf = codeHBuf->Des(); |
|
350 aMessage.ReadL( 0, codeBuf ); |
|
351 |
|
352 if ( !iServer.IsValidEnhCode( codeBuf ) ) |
|
353 { |
|
354 Dprint( (_L("CSCPSession::HandleChangeCodeMessageL(): ERROR:\ |
|
355 Invalid code format") )); |
|
356 CleanupStack::PopAndDestroy( codeHBuf ); |
|
357 User::Leave( KErrArgument ); |
|
358 } |
|
359 |
|
360 iServer.StoreEnhCode( codeBuf ); |
|
361 |
|
362 CleanupStack::PopAndDestroy( codeHBuf ); |
|
363 |
|
364 Dprint( (_L("<-- CSCPSession::HandleChangeCodeMessageL()") )); |
|
365 } |
|
366 } |
|
367 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
368 |
|
369 |
|
370 |
|
371 // --------------------------------------------------------- |
|
372 // void CSCPSession::HandleSetLockStateMessageL( const RMessage2 &aMessage ) |
|
373 // Sets the DOS lock setting to enabled/disabled, |
|
374 // and activates or deactivates Autolock via SetDOSLockSetting. |
|
375 // |
|
376 // Status : Approved |
|
377 // --------------------------------------------------------- |
|
378 // |
|
379 void CSCPSession::HandleSetLockStateMessageL( const RMessage2 &aMessage ) |
|
380 { |
|
381 Dprint( (_L("--> CSCPSession::HandleSetLockStateMessageL()") )); |
|
382 |
|
383 TInt lockState = aMessage.Int0(); |
|
384 |
|
385 Dprint( (_L("CSCPSession::HandleSetLockStateMessageL(), lock command: %d"), |
|
386 lockState )); |
|
387 |
|
388 SetDOSLockSettingL( lockState, ETrue, aMessage ); |
|
389 |
|
390 Dprint( (_L("<-- CSCPSession::HandleSetLockStateMessageL()") )); |
|
391 } |
|
392 |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // void CSCPSession::SetDOSLockSettingL( TBool aLocked, const RMessage2 &aMessage ) |
|
396 // Checks whether a lock operation is already in progress, if not, |
|
397 // starts the operation by creating the two active objects responsible for handling |
|
398 // the call, and sets the state variable accordingly. |
|
399 // |
|
400 // Status : Approved |
|
401 // --------------------------------------------------------- |
|
402 |
|
403 void CSCPSession::SetDOSLockSettingL( TBool aLocked, |
|
404 TBool aAutolock, |
|
405 const RMessage2 &aMessage ) |
|
406 { |
|
407 // Only one lock/unlock phone command can be in progress at a time |
|
408 if ( ( IsOperationInProgress( ESCPCommandLockPhone ) ) |
|
409 || ( IsOperationInProgress( ESCPCommandUnlockPhone ) ) |
|
410 || ( iServer.IsOperationInProgress( ESCPCommandLockPhone ) ) |
|
411 || ( iServer.IsOperationInProgress( ESCPCommandUnlockPhone ) ) |
|
412 ) |
|
413 { |
|
414 User::Leave( KErrInUse ); |
|
415 } |
|
416 |
|
417 // Fetch the stored password from the server |
|
418 TSCPSecCode storedCode; |
|
419 if ( iServer.GetCode( storedCode ) != KErrNone ) |
|
420 { |
|
421 Dprint( (_L("CSCPSession::HandleLockPhoneMessageL():\ |
|
422 FAILED to get stored code!") )); |
|
423 User::Leave( KErrGeneral ); |
|
424 } |
|
425 |
|
426 // Create a timer object for this call |
|
427 iLockOperationTimer = CSCPTimer::NewL( KSCPLockOperationTimeout, NULL, this ); |
|
428 |
|
429 // Set the state parameter for this session, a lock command is now in progress |
|
430 iLockCommandState = ESCPLockCmdStateInProgress; |
|
431 |
|
432 #ifndef __WINS__ // The notification handler is not used in emulator |
|
433 |
|
434 // Don't create the notification handler if it won't be used |
|
435 // (because DOS lock won't be disabled) |
|
436 if ( ( aLocked ) || ( ( !IsSMSLockActiveL() ) && ( !IsAutolockActive() ) ) ) |
|
437 { |
|
438 iNotificationHandler = CSCPLockNotificationEventHandler::NewL( &iServer ); |
|
439 } |
|
440 |
|
441 #endif // WINS |
|
442 |
|
443 iSettingHandler = CSCPLockSettingEventHandler::NewL( |
|
444 aMessage, this, aLocked, aAutolock, &iServer ); |
|
445 iSettingHandler->StartL(); |
|
446 |
|
447 } |
|
448 |
|
449 |
|
450 // --------------------------------------------------------- |
|
451 // void CSCPSession::HandleQueryMessageL( const RMessage2 &aMessage ) |
|
452 // Checks if the given operation is in progress, and acknowledges the |
|
453 // message. The return value is computed based on the calls, if either |
|
454 // is true, so is the return value. |
|
455 // |
|
456 // Status : Approved |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 void CSCPSession::HandleQueryMessageL( const RMessage2 &aMessage ) |
|
460 { |
|
461 Dprint( (_L("--> CSCPSession::HandleQueryMessageL()") )); |
|
462 |
|
463 #ifdef SCP_ENFORCE_SECURITY |
|
464 // Check the process permissions for this call |
|
465 switch ( (TSCPAdminCommand)aMessage.Int0() ) |
|
466 { |
|
467 case ( ESCPCommandLockPhone ): |
|
468 { |
|
469 // Only Security Observer allowed |
|
470 if ( aMessage.SecureId() != KAknNfySrvUid /*KSCPServerSIDSecurityObserver*/ ) |
|
471 { |
|
472 Dprint( (_L("CSCPSession::HandleQueryMessageL():\ |
|
473 ERROR: Permission denied") )); |
|
474 User::Leave( KErrPermissionDenied ); |
|
475 } |
|
476 break; |
|
477 } |
|
478 |
|
479 case ( ESCPCommandUnlockPhone ): |
|
480 { |
|
481 // Only Autolock allowed |
|
482 if ( aMessage.SecureId() != KSCPServerSIDAutolock ) |
|
483 { |
|
484 Dprint( (_L("CSCPSession::HandleSetParamMessageL():\ |
|
485 ERROR: Permission denied") )); |
|
486 User::Leave( KErrPermissionDenied ); |
|
487 } |
|
488 break; |
|
489 } |
|
490 |
|
491 default: |
|
492 { |
|
493 Dprint( (_L("CSCPSession::HandleQueryMessageL():DEFAULT:\ |
|
494 Permission denied") )); |
|
495 User::Leave( KErrPermissionDenied ); |
|
496 } |
|
497 break; |
|
498 } |
|
499 #endif |
|
500 |
|
501 // Check from the server, if another session has initiated a lock operation |
|
502 // Also if an acknowledgement was awaited for this operation, the return |
|
503 // value should be true |
|
504 TSCPAdminCommand commandQueried = (TSCPAdminCommand)aMessage.Int0(); |
|
505 |
|
506 TBool ret1 = iServer.IsOperationInProgress( commandQueried ); |
|
507 |
|
508 TBool ret2 = iServer.AcknowledgementReceived( commandQueried ); |
|
509 |
|
510 TBool ret = ret1 || ret2; |
|
511 |
|
512 // Return the reply |
|
513 TInt retWrap = (TInt)ret; |
|
514 |
|
515 TPckg<TInt> retPackage(retWrap); |
|
516 aMessage.WriteL(1, retPackage ); |
|
517 |
|
518 Dprint( (_L("<-- CSCPSession::HandleQueryMessageL()") )); |
|
519 } |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 // --------------------------------------------------------- |
|
525 // void CSCPSession::HandleGetLockStateMessageL( const RMessage2 &aMessage ) |
|
526 // Retrieves the Autolock status and returns it as the lock state. |
|
527 // |
|
528 // Status : Approved |
|
529 // --------------------------------------------------------- |
|
530 // |
|
531 void CSCPSession::HandleGetLockStateMessageL( const RMessage2 &aMessage ) |
|
532 { |
|
533 Dprint( (_L("--> CSCPSession::HandleGetLockStateMessageL()") )); |
|
534 |
|
535 // Check the autolock variable |
|
536 |
|
537 TInt autolockState; // the state |
|
538 TInt checkFor; // the "active state" |
|
539 |
|
540 TInt err( KErrGeneral ); |
|
541 |
|
542 RProperty Property; |
|
543 |
|
544 #ifdef RD_REMOTELOCK |
|
545 err = Property.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
546 checkFor = EAutolockOff; |
|
547 #else //RD_REMOTELOCK |
|
548 |
|
549 err = Property.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
550 checkFor = EAutolockOn; |
|
551 |
|
552 #endif//RD_REMOTELOCK |
|
553 |
|
554 User::LeaveIfError( err ); |
|
555 |
|
556 TBool ret = EFalse; |
|
557 #ifdef RD_REMOTELOCK |
|
558 if ( autolockState > checkFor ) |
|
559 { |
|
560 ret = ETrue; |
|
561 } |
|
562 #else//RD_REMOTELOCK |
|
563 if ( autolockState == checkFor ) |
|
564 { |
|
565 ret = ETrue; |
|
566 } |
|
567 #endif //RD_REMOTELOCK |
|
568 TPckg<TBool> retpackage(ret); |
|
569 |
|
570 aMessage.WriteL( 0, retpackage ); |
|
571 |
|
572 Dprint( (_L("<-- CSCPSession::HandleGetLockStateMessageL()") )); |
|
573 } |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 // --------------------------------------------------------- |
|
579 // void CSCPSession::HandleSetParamMessageL( const RMessage2 &aMessage ) |
|
580 // Extract the parameters and send them to the server, then pack the response. |
|
581 // |
|
582 // Status : Approved |
|
583 // --------------------------------------------------------- |
|
584 // |
|
585 void CSCPSession::HandleSetParamMessageL( const RMessage2 &aMessage ) |
|
586 { |
|
587 Dprint((_L("[CSCPSession]-> HandleSetParamMessageL() >>>"))); |
|
588 |
|
589 TBool oldALState = EFalse; |
|
590 |
|
591 #ifndef __WINS__ // No need to check for lock setting changes in emulator |
|
592 |
|
593 if ( ( (TSCPParameterID)aMessage.Int0() == ESCPAutolockPeriod ) || |
|
594 ( (TSCPParameterID)aMessage.Int0() == ESCPMaxAutolockPeriod ) ) |
|
595 { |
|
596 // Save the old Autolock state, the lock setting will have to be |
|
597 // changed, if the period is changed from 0 -> X or from X -> 0. |
|
598 oldALState = IsAutolockActive(); |
|
599 } |
|
600 |
|
601 #endif // __WINS__ |
|
602 |
|
603 // Copy the client data into a local buffer |
|
604 HBufC* setBuffer = HBufC::NewLC( aMessage.GetDesLength(1) ); |
|
605 TPtr bufPtr = setBuffer->Des(); |
|
606 aMessage.ReadL( 1, bufPtr ); |
|
607 |
|
608 TBool lNotifyChange = EFalse; |
|
609 TPckgBuf<TUint32> lCallerIDBuf; |
|
610 aMessage.ReadL(2, lCallerIDBuf); |
|
611 TBool lSetParamRequired = ETrue; |
|
612 const TSCPParameterID lParamID = (TSCPParameterID)aMessage.Int0(); |
|
613 |
|
614 /* Check if the new value is the same as the old one, call SCPServer |
|
615 * only if the values are different (or old value was not found)... |
|
616 */ |
|
617 switch(lParamID) { |
|
618 case ESCPMaxAutolockPeriod: |
|
619 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
620 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
621 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
622 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
623 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
624 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
625 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
626 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
627 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
628 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
629 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
630 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
631 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
632 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: { |
|
633 HBufC* lOldValue = HBufC :: NewLC(25); |
|
634 TPtr lOldValPtr = lOldValue->Des(); |
|
635 Dprint(_L("[CSCPSession]-> Initiating GetParameterValueL(), fetching earlier values...")); |
|
636 TInt ret = iServer.GetParameterValueL(lParamID, lOldValPtr, aMessage.SecureId()); |
|
637 Dprint(_L("[CSCPSession]-> GetParameterValueL() completed, ret=%d"), ret); |
|
638 switch(ret) { |
|
639 case KErrNone: |
|
640 // If the old and the new values are same, no need to set them in SCPServer |
|
641 if(0 == (lOldValue->Des().CompareC(setBuffer->Des()))) { |
|
642 Dprint(_L("[CSCPSession]-> INFO: Old and New values are the same...")); |
|
643 lSetParamRequired = EFalse; |
|
644 lNotifyChange = EFalse; |
|
645 } |
|
646 else { |
|
647 lNotifyChange = ETrue; |
|
648 } |
|
649 break; |
|
650 case KErrNotFound: |
|
651 lNotifyChange = ETrue; |
|
652 break; |
|
653 default: |
|
654 User :: LeaveIfError(ret); |
|
655 } |
|
656 CleanupStack :: PopAndDestroy(lOldValue); |
|
657 } |
|
658 break; |
|
659 default: |
|
660 break; |
|
661 } |
|
662 |
|
663 if(lSetParamRequired) { |
|
664 Dprint(_L("[CSCPSession]-> Initiating SetParameterValueL()...")); |
|
665 TInt ret = iServer.SetParameterValueL(lParamID, *setBuffer, lCallerIDBuf()); |
|
666 Dprint(_L("[CSCPSession]-> SetParameterValueL() returned, ret=%d"), ret); |
|
667 User::LeaveIfError( ret ); |
|
668 } |
|
669 |
|
670 // Should the message be completed immediatelly? |
|
671 TBool completeRequest = ETrue; |
|
672 |
|
673 #ifndef __WINS__ // No need to check for lock setting changes in emulator |
|
674 |
|
675 if ( ( lParamID == ESCPAutolockPeriod ) || |
|
676 ( lParamID == ESCPMaxAutolockPeriod ) ) |
|
677 { |
|
678 // Autolock state may have changed, check if the lock setting must be changed. |
|
679 TBool currentALState = IsAutolockActive(); |
|
680 |
|
681 if ( ( !oldALState ) && ( currentALState ) ) |
|
682 { |
|
683 // Autolock activated, enable lock |
|
684 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): Enabling DOS lock") )); |
|
685 SetDOSLockSettingL( ETrue, EFalse, aMessage ); |
|
686 completeRequest = EFalse; |
|
687 } |
|
688 else if ( ( oldALState ) && ( !currentALState ) ) |
|
689 { |
|
690 //Autolock deactivated, disable lock, if SMS Lock is not active |
|
691 if ( !IsSMSLockActiveL() ) |
|
692 { |
|
693 Dprint( (_L("CSCPSession::HandleSetParamMessageL():\ |
|
694 Disabling DOS lock") )); |
|
695 SetDOSLockSettingL( EFalse, EFalse, aMessage ); |
|
696 completeRequest = EFalse; |
|
697 } |
|
698 else |
|
699 { |
|
700 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): SMS Lock active,\ |
|
701 leaving DOS lock on") )); |
|
702 } |
|
703 } |
|
704 else |
|
705 { |
|
706 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): Autolock (Max.) period\ |
|
707 changed, no lock change") )); |
|
708 } |
|
709 } |
|
710 |
|
711 #endif // __WINS__ |
|
712 |
|
713 |
|
714 // Ok, complete the message here |
|
715 if(completeRequest) { |
|
716 Dprint(_L("[CSCPSession]-> aMessage.Complete()...")); |
|
717 aMessage.Complete( KErrNone ); |
|
718 |
|
719 if(lNotifyChange) { |
|
720 HBufC8* lTmpBuff = HBufC8 :: NewLC(setBuffer->Length()); |
|
721 lTmpBuff->Des().Copy(setBuffer->Des()); |
|
722 |
|
723 // No need to return an error condition if notification (subsequent) fails! |
|
724 TRAPD(lErr, NotifyChangeL(lParamID, lTmpBuff->Des(), lCallerIDBuf())); |
|
725 |
|
726 if(KErrNone != lErr) { |
|
727 Dprint(_L("[CSCPSession]-> INFO: NotifyAllStakeHoldersL() could not complete, lErr=%d"), lErr); |
|
728 } |
|
729 |
|
730 CleanupStack :: PopAndDestroy(); // lTmpBuff |
|
731 } |
|
732 } |
|
733 else { |
|
734 /* Control gets here only if lParamID == ESCPMaxAutolockPeriod or |
|
735 * if lParamID == ESCPAutolockPeriod and if the |
|
736 */ |
|
737 iALParamID = lParamID; |
|
738 iALParamCallerID = lCallerIDBuf(); |
|
739 |
|
740 if(iALParamValue) { |
|
741 delete iALParamValue; |
|
742 iALParamValue = NULL; |
|
743 } |
|
744 |
|
745 // No need to return an error condition if notification (subsequent) fails! |
|
746 TRAPD(lErr, iALParamValue = HBufC8 :: NewL(setBuffer->Length())); |
|
747 |
|
748 if(lErr == KErrNone) { |
|
749 iALParamValue->Des().Copy(setBuffer->Des()); |
|
750 } |
|
751 } |
|
752 |
|
753 CleanupStack :: PopAndDestroy(setBuffer); |
|
754 Dprint((_L("[CSCPSession]-> HandleSetParamMessageL() <<<"))); |
|
755 } |
|
756 |
|
757 // --------------------------------------------------------- |
|
758 // void CSCPSession::HandleGetParamMessageL( const RMessage2 &aMessage ) |
|
759 // Check the access permissions, then extract the parameters and send |
|
760 // them to the server, then pack the response. |
|
761 // |
|
762 // Status : Approved |
|
763 // --------------------------------------------------------- |
|
764 // |
|
765 void CSCPSession::HandleGetParamMessageL( const RMessage2 &aMessage ) |
|
766 { |
|
767 Dprint( (_L("--> CSCPSession::HandleGetParamMessageL()") )); |
|
768 |
|
769 #ifdef SCP_ENFORCE_SECURITY |
|
770 |
|
771 // Check the access for this parameter |
|
772 switch ( (TSCPParameterID)aMessage.Int0() ) |
|
773 { |
|
774 default: |
|
775 // For the current parameters, we allow Gs and Terminal Control Server |
|
776 if ( ( aMessage.SecureId() != KSCPServerSIDTerminalControl ) && |
|
777 ( aMessage.SecureId() != KSCPServerSIDGeneralSettings ) && |
|
778 ( aMessage.SecureId() != KDevEncUiUid ) ) |
|
779 { |
|
780 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): ERROR:\ |
|
781 Permission denied") )); |
|
782 User::Leave( KErrPermissionDenied ); |
|
783 } |
|
784 break; |
|
785 } |
|
786 #endif // SCP_ENFORCE_SECURITY |
|
787 |
|
788 // Init a local buffer to store the return value |
|
789 HBufC* getBuffer = HBufC::NewLC( aMessage.GetDesMaxLength(1) ); |
|
790 TPtr bufPtr = getBuffer->Des(); |
|
791 |
|
792 TInt ret = iServer.GetParameterValueL( |
|
793 (TSCPParameterID)aMessage.Int0(), |
|
794 bufPtr, |
|
795 aMessage.SecureId() |
|
796 ); |
|
797 |
|
798 User::LeaveIfError( ret ); |
|
799 |
|
800 // OK, send the data to the client side |
|
801 aMessage.WriteL( 1, bufPtr ); |
|
802 |
|
803 CleanupStack::PopAndDestroy( getBuffer ); |
|
804 |
|
805 Dprint( (_L("<-- CSCPSession::HandleGetParamMessageL()") )); |
|
806 } |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 // --------------------------------------------------------- |
|
812 // void CSCPSession::HandleCheckConfigMessageL( const RMessage2 &aMessage ) |
|
813 // Propagate the check config -call to the server. |
|
814 // |
|
815 // Status : Approved |
|
816 // --------------------------------------------------------- |
|
817 // |
|
818 void CSCPSession::HandleCheckConfigMessageL( const RMessage2 &aMessage ) |
|
819 { |
|
820 // Check if the server configuration is in sync |
|
821 TInt valerr = KErrNone; |
|
822 |
|
823 TRAP( valerr, iServer.ValidateConfigurationL( aMessage.Int0() ) ); |
|
824 Dprint( (_L("CSCPServer::ConstructL(): Validation returned: %d"), valerr )); |
|
825 |
|
826 // Write the return value to slot 1 |
|
827 TPckg<TInt> retPackage(valerr); |
|
828 |
|
829 aMessage.WriteL( 1, retPackage ); |
|
830 } |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
836 |
|
837 // --------------------------------------------------------- |
|
838 // void CSCPSession::HandleAuthenticationMessageL() |
|
839 // Copy the given data into a local buffer, and propagate the call |
|
840 // to the server. |
|
841 // |
|
842 // Status : Approved |
|
843 // --------------------------------------------------------- |
|
844 // |
|
845 void CSCPSession::HandleAuthenticationMessageL( const RMessage2 &aMessage ) |
|
846 { |
|
847 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
848 { |
|
849 FeatureManager::UnInitializeLib(); |
|
850 User::Leave(KErrNotSupported); |
|
851 } |
|
852 if ((aMessage.SecureId() != KSCPServerSIDAutolock)&&(aMessage.SecureId() != KAknNfySrvUid)&& |
|
853 (aMessage.SecureId() != KSCPServerSIDGeneralSettings)&&(aMessage.SecureId() != KSCPServerSIDSysAp)&& |
|
854 (aMessage.SecureId() != KSCPServerSIDTerminalControl)) |
|
855 { |
|
856 Dprint( (_L("CSCPSession::HandleAuthenticationMessageL():\ |
|
857 ERROR: Permission denied") )); |
|
858 User::Leave( KErrPermissionDenied ); |
|
859 } |
|
860 Dprint( (_L("--> CSCPSession::HandleAuthenticationMessage()") )); |
|
861 |
|
862 HBufC* servBuf = NULL; |
|
863 TInt status = KErrNone; |
|
864 |
|
865 // The slot 0 contains the given password |
|
866 TInt passwordLen = aMessage.GetDesLength(0); |
|
867 if ( passwordLen > 0 ) |
|
868 { |
|
869 servBuf = HBufC::NewLC( passwordLen ); |
|
870 } |
|
871 else |
|
872 { |
|
873 // We cannot accept an empty code |
|
874 Dprint( (_L("<-- ERROR: CSCPSession::HandleAuthenticationMessage():\ |
|
875 returning KErrArgument, buffer empty") )); |
|
876 User::Leave( KErrArgument ); |
|
877 } |
|
878 |
|
879 TPtr servBufPtr = servBuf->Des(); |
|
880 |
|
881 TInt ret = aMessage.Read( 0, servBufPtr ); |
|
882 |
|
883 // Try to get the ISA code from the server, giving the password and flags |
|
884 TSCPSecCode isaCodeToReturn; |
|
885 CSCPParamObject* addParams = NULL; |
|
886 TInt flags = aMessage.Int3(); |
|
887 if ( ret == KErrNone ) |
|
888 { |
|
889 status = iServer.CheckCodeAndGiveISAL( servBufPtr, |
|
890 isaCodeToReturn, |
|
891 addParams, |
|
892 flags ); |
|
893 } |
|
894 |
|
895 servBufPtr.Zero(); |
|
896 CleanupStack::PopAndDestroy( servBuf ); |
|
897 |
|
898 if ( ret != KErrNone ) |
|
899 { |
|
900 // Fail the call |
|
901 Dprint( (_L("<-- ERROR: CSCPSession::HandleAuthenticationMessage():\ |
|
902 returning %d"), ret )); |
|
903 User::Leave( ret ); |
|
904 } |
|
905 |
|
906 // If additional parameters are passed to client side, add them to slot 2 |
|
907 if ( addParams != NULL ) |
|
908 { |
|
909 HBufC8* paramBuf; |
|
910 TInt pRet = addParams->GetBuffer( paramBuf ); |
|
911 |
|
912 if ( pRet != KErrNone ) |
|
913 { |
|
914 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
915 failed to get additional parameter buffer: %d"), pRet )); |
|
916 } |
|
917 else |
|
918 { |
|
919 TPtr8 paramPtr = paramBuf->Des(); |
|
920 if ( aMessage.GetDesMaxLength( 2 ) >= paramPtr.Length() ) |
|
921 { |
|
922 aMessage.Write( 2, paramPtr ); |
|
923 } |
|
924 else |
|
925 { |
|
926 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
927 WARNING: not enough space for additional parameters") )); |
|
928 } |
|
929 |
|
930 delete paramBuf; |
|
931 } |
|
932 |
|
933 delete addParams; |
|
934 } |
|
935 |
|
936 // OK, we either have the correct ISA code or don't, return it to the client in slot 1 |
|
937 User::LeaveIfError( aMessage.Write( 1, isaCodeToReturn ) ); |
|
938 |
|
939 Dprint( (_L("<-- CSCPSession::HandleAuthenticationMessage(): %d"), status )); |
|
940 User::LeaveIfError( status ); |
|
941 } |
|
942 |
|
943 |
|
944 // --------------------------------------------------------- |
|
945 // void CSCPSession::HandleChangeEnhCodeMessageL() |
|
946 // Copy the given data into local buffers, and propagate the call |
|
947 // to the server. |
|
948 // |
|
949 // Status : Approved |
|
950 // --------------------------------------------------------- |
|
951 // |
|
952 void CSCPSession::HandleChangeEnhCodeMessageL( const RMessage2 &aMessage ) |
|
953 { |
|
954 |
|
955 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
956 { |
|
957 FeatureManager::UnInitializeLib(); |
|
958 User::Leave(KErrNotSupported); |
|
959 } |
|
960 Dprint( (_L("--> CSCPSession::HandleChangeEnhCodeMessage()") )); |
|
961 |
|
962 HBufC* oldPassBuf = NULL; |
|
963 HBufC* newPassBuf = NULL; |
|
964 |
|
965 TInt oldPasswordLen = aMessage.GetDesLength(0); |
|
966 TInt newPasswordLen = aMessage.GetDesLength(1); |
|
967 |
|
968 if ( ( newPasswordLen == 0 ) || ( oldPasswordLen == 0 ) ) |
|
969 { |
|
970 // We cannot accept an empty code |
|
971 Dprint( (_L("<-- ERROR: CSCPSession::HandleChangeEnhCodeMessage():\ |
|
972 returning KErrArgument, buffer empty") )); |
|
973 User::Leave( KErrArgument ); |
|
974 } |
|
975 else |
|
976 { |
|
977 oldPassBuf = HBufC::NewLC( oldPasswordLen ); |
|
978 newPassBuf = HBufC::NewLC( newPasswordLen ); |
|
979 } |
|
980 |
|
981 TPtr oldPassPtr = oldPassBuf->Des(); |
|
982 TPtr newPassPtr = newPassBuf->Des(); |
|
983 |
|
984 // Read the strings, slot 0 = old password, slot 1 = new password |
|
985 TRAPD( err, aMessage.ReadL( 0, oldPassPtr ) ); |
|
986 TRAP( err, aMessage.ReadL( 1, newPassPtr ) ); |
|
987 |
|
988 // A buffer for the updated DOS password |
|
989 TSCPSecCode newDosCode; |
|
990 newDosCode.Zero(); |
|
991 |
|
992 CSCPParamObject* addParams = NULL; |
|
993 if ( err != KErrNone ) |
|
994 { |
|
995 Dprint( (_L("<-- ERROR: CSCPSession::HandleChangeEnhCodeMessage():\ |
|
996 failed to read the strings to server side: %d"), err )); |
|
997 } |
|
998 else |
|
999 { |
|
1000 err = iServer.CheckAndChangeEnhCodeL( oldPassPtr, newPassPtr, addParams, newDosCode ); |
|
1001 } |
|
1002 |
|
1003 // If additional parameters are passed to client side, add them to slot 2 |
|
1004 if ( addParams != NULL ) |
|
1005 { |
|
1006 HBufC8* paramBuf; |
|
1007 TInt pRet = addParams->GetBuffer( paramBuf ); |
|
1008 |
|
1009 if ( pRet != KErrNone ) |
|
1010 { |
|
1011 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1012 failed to get additional parameter buffer: %d"), pRet )); |
|
1013 } |
|
1014 else |
|
1015 { |
|
1016 TPtr8 paramPtr = paramBuf->Des(); |
|
1017 if ( aMessage.GetDesMaxLength( 2 ) >= paramPtr.Length() ) |
|
1018 { |
|
1019 aMessage.Write( 2, paramPtr ); |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1024 WARNING: not enough space for additional parameters") )); |
|
1025 } |
|
1026 |
|
1027 delete paramBuf; |
|
1028 } |
|
1029 |
|
1030 delete addParams; |
|
1031 } |
|
1032 |
|
1033 if ( err == KErrNone ) |
|
1034 { |
|
1035 // Copy the new DOS code to slot 3 |
|
1036 TInt ret = aMessage.Write( 3, newDosCode ); |
|
1037 if ( ret != KErrNone ) |
|
1038 { |
|
1039 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1040 WARNING: failed to write the new DOS code to client-side") )); |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 /* Get the very first character of the new lock code and set the default input mode of the |
|
1045 lock code query on the basis of the first character. */ |
|
1046 ch = newPassPtr[0]; |
|
1047 def_mode = ch.IsDigit() ? 0 : 1; |
|
1048 |
|
1049 CRepository* repository = CRepository :: NewL(KCRUidSCPParameters); |
|
1050 CleanupStack::PushL( repository ); |
|
1051 |
|
1052 User::LeaveIfError(repository->Set( KSCPLockCodeDefaultInputMode , def_mode) ); |
|
1053 CleanupStack :: PopAndDestroy(repository); |
|
1054 |
|
1055 /* Set the value in the cenrep that the default lock code has been changed if it is not |
|
1056 * already set |
|
1057 * */ |
|
1058 repository = CRepository :: NewL(KCRUidSCPLockCode); |
|
1059 CleanupStack :: PushL(repository); |
|
1060 User :: LeaveIfError(repository->Set(KSCPLockCodeDefaultLockCode, 0)); |
|
1061 CleanupStack::PopAndDestroy( repository ); |
|
1062 repository = NULL; |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 oldPassPtr.Zero(); |
|
1067 newPassPtr.Zero(); |
|
1068 CleanupStack::PopAndDestroy( newPassBuf ); |
|
1069 CleanupStack::PopAndDestroy( oldPassBuf ); |
|
1070 |
|
1071 Dprint( (_L("<-- CSCPSession::HandleChangeEnhCodeMessage(): %d"), err )); |
|
1072 |
|
1073 if ( err != KErrNone ) |
|
1074 { |
|
1075 User::Leave( err ); |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 |
|
1080 // --------------------------------------------------------- |
|
1081 // void CSCPSession::HandleQueryChangeMessageL() |
|
1082 // Check from the server, if the password is allowed to be changed. |
|
1083 // |
|
1084 // Status : Approved |
|
1085 // --------------------------------------------------------- |
|
1086 // |
|
1087 |
|
1088 void CSCPSession::HandleQueryChangeMessageL( const RMessage2 &aMessage ) |
|
1089 { |
|
1090 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1091 { |
|
1092 FeatureManager::UnInitializeLib(); |
|
1093 User::Leave(KErrNotSupported); |
|
1094 } |
|
1095 Dprint( (_L("--> CSCPSession::HandleQueryChangeMessage()") )); |
|
1096 |
|
1097 CSCPParamObject* addParams = NULL; |
|
1098 |
|
1099 TInt ret = iServer.IsPasswordChangeAllowedL( addParams ); |
|
1100 |
|
1101 // Return the reply in slot 0 |
|
1102 |
|
1103 TPckg<TInt> retPackage(ret); |
|
1104 aMessage.WriteL(0, retPackage ); |
|
1105 |
|
1106 // If additional parameters are passed to client side, add them to slot 1 |
|
1107 if ( addParams != NULL ) |
|
1108 { |
|
1109 HBufC8* paramBuf; |
|
1110 TInt pRet = addParams->GetBuffer( paramBuf ); |
|
1111 |
|
1112 if ( pRet != KErrNone ) |
|
1113 { |
|
1114 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1115 failed to get additional parameter buffer: %d"), pRet )); |
|
1116 } |
|
1117 else |
|
1118 { |
|
1119 TPtr8 paramPtr = paramBuf->Des(); |
|
1120 if ( aMessage.GetDesMaxLength( 1 ) >= paramPtr.Length() ) |
|
1121 { |
|
1122 aMessage.Write( 1, paramPtr ); |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1127 WARNING: not enough space for additional parameters") )); |
|
1128 } |
|
1129 |
|
1130 delete paramBuf; |
|
1131 } |
|
1132 |
|
1133 delete addParams; |
|
1134 } |
|
1135 |
|
1136 Dprint( (_L("<-- CSCPSession::HandleQueryChangeMessage()") )); |
|
1137 } |
|
1138 |
|
1139 |
|
1140 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1141 |
|
1142 |
|
1143 |
|
1144 // --------------------------------------------------------- |
|
1145 // void CSCPSession::LockOperationCompleted() |
|
1146 // The method is called from iSettinghandler, when the call has |
|
1147 // been completed. The active objects are deleted, and the state |
|
1148 // is set to reflect the situation. |
|
1149 // |
|
1150 // Status : Approved |
|
1151 // --------------------------------------------------------- |
|
1152 // |
|
1153 void CSCPSession::LockOperationCompleted() |
|
1154 { |
|
1155 Dprint( (_L("--> CSCPSession::LockOperationCompleted()") )); |
|
1156 |
|
1157 // Delete the timer, the call is complete |
|
1158 if ( iLockOperationTimer ) |
|
1159 { |
|
1160 delete iLockOperationTimer; |
|
1161 iLockOperationTimer = NULL; |
|
1162 } |
|
1163 |
|
1164 if ( iNotificationHandler ) |
|
1165 { |
|
1166 delete iNotificationHandler; |
|
1167 iNotificationHandler = NULL; |
|
1168 } |
|
1169 |
|
1170 if ( iSettingHandler ) |
|
1171 { |
|
1172 delete iSettingHandler; |
|
1173 iSettingHandler = NULL; |
|
1174 } |
|
1175 |
|
1176 iPendingCallStatus = NULL; |
|
1177 |
|
1178 iLockCommandState = ESCPLockCmdStateIdle; |
|
1179 iUnlockMessageSent = EFalse; |
|
1180 |
|
1181 if(iALParamValue) { |
|
1182 TRAPD(lErr, NotifyChangeL(iALParamID, iALParamValue->Des(), iALParamCallerID)); |
|
1183 if(lErr == KErrNone) { |
|
1184 Dprint( (_L("[CSCPSession]-> INFO: Notification complete...") )); |
|
1185 } |
|
1186 else { |
|
1187 Dprint( (_L("[CSCPSession]-> INFO: Unable to complete notification...") )); |
|
1188 } |
|
1189 delete iALParamValue; |
|
1190 iALParamValue = NULL; |
|
1191 } |
|
1192 Dprint( (_L("<-- CSCPSession::LockOperationCompleted()") )); |
|
1193 } |
|
1194 |
|
1195 |
|
1196 // --------------------------------------------------------- |
|
1197 // void CSCPSession::Timeout( TAny* aParam ) |
|
1198 // This method will be called in case the lock operation times |
|
1199 // out. |
|
1200 // |
|
1201 // Status : Approved |
|
1202 // --------------------------------------------------------- |
|
1203 // |
|
1204 void CSCPSession::Timeout( TAny* aParam ) |
|
1205 { |
|
1206 Dprint( (_L("--> CSCPSession::Timeout()") )); |
|
1207 (void)aParam; |
|
1208 |
|
1209 // Since the timeout should only occur if the system is |
|
1210 // somehow in an invalid state, reset all the state information |
|
1211 // here. |
|
1212 |
|
1213 if ( ( iUnlockMessageSent ) || |
|
1214 ( iLockCommandState == ESCPLockCmdStateFinishedAckPending ) |
|
1215 ) |
|
1216 { |
|
1217 // Signal timeout by completing the request |
|
1218 User::RequestComplete( iPendingCallStatus, KErrCancel ); |
|
1219 iPendingCallStatus = NULL; |
|
1220 } |
|
1221 else |
|
1222 { |
|
1223 if ( iNotificationHandler ) |
|
1224 { |
|
1225 iNotificationHandler->Cancel(); |
|
1226 } |
|
1227 iSettingHandler->Cancel(); |
|
1228 } |
|
1229 |
|
1230 iUnlockMessageSent = EFalse; |
|
1231 iLockCommandState = ESCPLockCmdStateIdle; |
|
1232 |
|
1233 Dprint( (_L("<-- CSCPSession::Timeout()") )); |
|
1234 } |
|
1235 |
|
1236 // --------------------------------------------------------- |
|
1237 // void CSCPSession::LockOperationPending( TSCPAdminCommand aCommand, |
|
1238 // TRequestStatus* aStatus ) |
|
1239 // Saves the status ptr of the pending call, and sets the relevant |
|
1240 // state variable. |
|
1241 // |
|
1242 // Status : Approved |
|
1243 // --------------------------------------------------------- |
|
1244 // |
|
1245 void CSCPSession::LockOperationPending( TSCPAdminCommand aCommand, |
|
1246 TRequestStatus* aStatus ) |
|
1247 { |
|
1248 Dprint( (_L("--> CSCPSession::LockOperationPending()") )); |
|
1249 iPendingCallStatus = aStatus; |
|
1250 *iPendingCallStatus = KRequestPending; |
|
1251 |
|
1252 switch ( aCommand ) |
|
1253 { |
|
1254 case ( ESCPCommandUnlockPhone ) : |
|
1255 { |
|
1256 iUnlockMessageSent = ETrue; |
|
1257 break; |
|
1258 } |
|
1259 |
|
1260 case ( ESCPCommandLockPhone ) : |
|
1261 { |
|
1262 iLockCommandState = ESCPLockCmdStateFinishedAckPending; |
|
1263 break; |
|
1264 } |
|
1265 } |
|
1266 |
|
1267 Dprint( (_L("<-- CSCPSession::LockOperationPending()") )); |
|
1268 } |
|
1269 |
|
1270 |
|
1271 // --------------------------------------------------------- |
|
1272 // TBool CSCPSession::IsSMSLockActiveL() |
|
1273 // Retrieves the SMS Lock status using the Remote Lock |
|
1274 // Settings API. |
|
1275 // |
|
1276 // Status : Approved |
|
1277 // --------------------------------------------------------- |
|
1278 // |
|
1279 TBool CSCPSession::IsSMSLockActiveL() |
|
1280 { |
|
1281 TBool smsLockState = EFalse; |
|
1282 |
|
1283 #ifdef SCP_SMS_LOCK_AVAILABLE |
|
1284 |
|
1285 CRemoteLockSettings* smsLockSettings = CRemoteLockSettings::NewLC(); |
|
1286 |
|
1287 if ( !smsLockSettings->GetEnabled( smsLockState ) ) |
|
1288 { |
|
1289 smsLockState = EFalse; |
|
1290 } |
|
1291 |
|
1292 CleanupStack::PopAndDestroy( smsLockSettings ); |
|
1293 |
|
1294 #endif // SCP_SMS_LOCK_AVAILABLE |
|
1295 |
|
1296 return smsLockState; |
|
1297 } |
|
1298 |
|
1299 |
|
1300 // --------------------------------------------------------- |
|
1301 // TBool CSCPSession::IsAutolockActive() |
|
1302 // Retrieves the Autolock status using by retrieving |
|
1303 // the period from the server. |
|
1304 // |
|
1305 // Status : Approved |
|
1306 // --------------------------------------------------------- |
|
1307 // |
|
1308 TBool CSCPSession::IsAutolockActive() |
|
1309 { |
|
1310 TBool ret = EFalse; |
|
1311 |
|
1312 TInt autolockPeriod = 0; |
|
1313 TInt servRet = KErrNone; |
|
1314 TRAPD( err, servRet = iServer.GetAutolockPeriodL( autolockPeriod ) ); |
|
1315 |
|
1316 if ( ( err == KErrNone ) && ( servRet == KErrNone ) && ( autolockPeriod > 0 ) ) |
|
1317 { |
|
1318 ret = ETrue; |
|
1319 } |
|
1320 |
|
1321 return ret; |
|
1322 } |
|
1323 |
|
1324 |
|
1325 // --------------------------------------------------------- |
|
1326 // void CSCPSession::ServiceL( const RMessage2 &aMessage ) |
|
1327 // The initial entry point for a service call, propagates the |
|
1328 // call based on the function. |
|
1329 // |
|
1330 // Status : Approved |
|
1331 // --------------------------------------------------------- |
|
1332 // |
|
1333 void CSCPSession::ServiceL( const RMessage2 &aMessage ) |
|
1334 { |
|
1335 switch ( aMessage.Function() ) |
|
1336 { |
|
1337 case ( ESCPServSetPhoneLock ): |
|
1338 { |
|
1339 TRAPD( err, HandleSetLockStateMessageL( aMessage ) ); |
|
1340 if ( err != KErrNone ) |
|
1341 { |
|
1342 aMessage.Complete( err ); |
|
1343 } |
|
1344 } |
|
1345 break; |
|
1346 |
|
1347 case ( ESCPServSetParam ): |
|
1348 { |
|
1349 TRAPD( err, HandleSetParamMessageL( aMessage ) ); |
|
1350 if ( err != KErrNone ) |
|
1351 { |
|
1352 aMessage.Complete( err ); |
|
1353 } |
|
1354 } |
|
1355 break; |
|
1356 |
|
1357 case ESCPApplicationUninstalled: { |
|
1358 TInt lErr = KErrNone; |
|
1359 TRAP(lErr, HandleCleanupL(aMessage)); |
|
1360 if(lErr != KErrNone) { |
|
1361 aMessage.Complete(lErr); |
|
1362 } |
|
1363 } |
|
1364 break; |
|
1365 case ESCPServUISetAutoLock: { |
|
1366 TInt lErr = KErrNone; |
|
1367 TRAP(lErr, HandleSetALPeriodL(aMessage)); |
|
1368 if(lErr != KErrNone) { |
|
1369 aMessage.Complete(lErr); |
|
1370 } |
|
1371 } |
|
1372 break; |
|
1373 default: |
|
1374 { |
|
1375 TRAPD( err, DispatchSynchronousMessageL(aMessage) ); |
|
1376 aMessage.Complete( err ); |
|
1377 } |
|
1378 break; |
|
1379 } |
|
1380 } |
|
1381 |
|
1382 |
|
1383 // --------------------------------------------------------- |
|
1384 // void CSCPSession::DispatchSynchronousMessageL( const RMessage2 &aMessage ) |
|
1385 // A dispatch function for synchronous calls, calls the function dependent |
|
1386 // handler method. |
|
1387 // |
|
1388 // Status : Approved |
|
1389 // --------------------------------------------------------- |
|
1390 // |
|
1391 void CSCPSession::DispatchSynchronousMessageL( const RMessage2 &aMessage ) |
|
1392 { |
|
1393 Dprint( (_L("--> CSCPSession::DispatchSynchronousMessageL()") )); |
|
1394 |
|
1395 switch ( aMessage.Function() ) |
|
1396 { |
|
1397 case ( ESCPServGetCode ): |
|
1398 { |
|
1399 HandleGetCodeMessageL( aMessage ); |
|
1400 break; |
|
1401 } |
|
1402 |
|
1403 //#ifndef __SAP_DEVICE_LOCK_ENHANCEMENTS ..recheck |
|
1404 // No longer supported for enhanced security code |
|
1405 case ( ESCPServSetCode ): |
|
1406 { |
|
1407 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1408 { |
|
1409 HandleSetCodeMessageL( aMessage ); |
|
1410 } |
|
1411 else |
|
1412 { |
|
1413 User::Leave(KErrNotSupported); |
|
1414 } |
|
1415 break; |
|
1416 } |
|
1417 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1418 |
|
1419 case ( ESCPServChangeCode ): |
|
1420 { |
|
1421 HandleChangeCodeMessageL( aMessage ); |
|
1422 break; |
|
1423 } |
|
1424 |
|
1425 case ( ESCPServQueryAdminCmd ): |
|
1426 { |
|
1427 HandleQueryMessageL( aMessage ); |
|
1428 break; |
|
1429 } |
|
1430 |
|
1431 case ( ESCPServGetLockState ): |
|
1432 { |
|
1433 HandleGetLockStateMessageL( aMessage ); |
|
1434 break; |
|
1435 } |
|
1436 |
|
1437 case ( ESCPServGetParam ): |
|
1438 { |
|
1439 HandleGetParamMessageL( aMessage ); |
|
1440 break; |
|
1441 } |
|
1442 |
|
1443 case ( ESCPServCheckConfig ): |
|
1444 { |
|
1445 HandleCheckConfigMessageL( aMessage ); |
|
1446 break; |
|
1447 } |
|
1448 |
|
1449 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1450 |
|
1451 case ( ESCPServAuthenticateS60 ): |
|
1452 { |
|
1453 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1454 { |
|
1455 HandleAuthenticationMessageL( aMessage ); |
|
1456 } |
|
1457 else |
|
1458 { |
|
1459 User::Leave(KErrNotSupported); |
|
1460 } |
|
1461 |
|
1462 break; |
|
1463 } |
|
1464 |
|
1465 case ( ESCPServChangeEnhCode ): |
|
1466 { |
|
1467 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1468 { |
|
1469 HandleChangeEnhCodeMessageL( aMessage ); |
|
1470 } |
|
1471 else |
|
1472 { |
|
1473 User::Leave(KErrNotSupported); |
|
1474 } |
|
1475 break; |
|
1476 } |
|
1477 |
|
1478 case ( ESCPServCodeChangeQuery ): |
|
1479 { |
|
1480 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1481 { |
|
1482 HandleQueryChangeMessageL( aMessage ); |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 User::Leave(KErrNotSupported); |
|
1487 } |
|
1488 break; |
|
1489 } |
|
1490 |
|
1491 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1492 |
|
1493 default: |
|
1494 { |
|
1495 User::Leave( KErrNotSupported ); |
|
1496 break; |
|
1497 } |
|
1498 } |
|
1499 |
|
1500 Dprint( (_L("<-- CSCPSession::DispatchSynchronousMessageL()") )); |
|
1501 } |
|
1502 |
|
1503 // End of File |
|
1504 |
|
1505 TInt CSCPSession :: NotifyAllStakeHoldersL(const RArray<const TParamChange>& aChange, TUint32 aCallerID) { |
|
1506 Dprint(_L("[CSCPSession]-> NotifyAllStakeHoldersL() >>>")); |
|
1507 |
|
1508 if(aChange.Count() < 1) { |
|
1509 return KErrNone; |
|
1510 } |
|
1511 |
|
1512 RImplInfoPtrArray implArray; |
|
1513 CleanupClosePushL(implArray); |
|
1514 |
|
1515 CTC3rdPartyParamsEcomIF :: ListAllImplementationsL(implArray); |
|
1516 TInt numberOfPlugins = implArray.Count(); |
|
1517 |
|
1518 Dprint(_L("[CSCPSession]-> numberOfPlugins=%d"), numberOfPlugins); |
|
1519 for(TInt i = 0; i < numberOfPlugins; i++) { |
|
1520 CImplementationInformation& info = *implArray[i]; |
|
1521 TUid implementation = info.ImplementationUid(); |
|
1522 HBufC* text = HBufC :: NewMaxLC(info.OpaqueData().Length() ); |
|
1523 TPtr opaqueData(text->Des()); |
|
1524 opaqueData.Copy(info.OpaqueData()); |
|
1525 |
|
1526 TUint pluginUID; |
|
1527 TLex lex(* text); |
|
1528 lex.Val(pluginUID, EHex); |
|
1529 TUid id(TUid :: Uid((TInt)pluginUID)); |
|
1530 |
|
1531 if(TUint32(id.iUid) != aCallerID) { |
|
1532 CTC3rdPartyParamsEcomIF* plugin = CTC3rdPartyParamsEcomIF :: NewL(implementation); |
|
1533 CleanupStack :: PushL(plugin); |
|
1534 TRAPD(leaveCode, plugin->DeviceLockParamChangedL(aChange)); |
|
1535 CleanupStack :: PopAndDestroy(); // plugin |
|
1536 } |
|
1537 |
|
1538 CleanupStack :: PopAndDestroy(text); |
|
1539 } |
|
1540 |
|
1541 implArray.ResetAndDestroy(); |
|
1542 CleanupStack :: PopAndDestroy(&implArray); |
|
1543 Dprint(_L("[CSCPSession]-> NotifyAllStakeHoldersL() <<<")); |
|
1544 return KErrNone; |
|
1545 } |
|
1546 TInt CSCPSession :: HandleCleanupL(const RMessage2& aMessage) { |
|
1547 // Copy the client data into a local buffer |
|
1548 TInt32 lCount = aMessage.GetDesLength(1); |
|
1549 |
|
1550 /* // If the caller is not SCPEventHandler the deny access |
|
1551 if(aMessage.SecureId() != KSCPEvntHndlrUid) { |
|
1552 return KErrPermissionDenied; |
|
1553 }*/ |
|
1554 |
|
1555 // Atleast one application id has to be present in the received message (atleast 8 bytes) |
|
1556 if(lCount < sizeof(TInt32)) { |
|
1557 return KErrArgument; |
|
1558 } |
|
1559 |
|
1560 RArray<const TParamChange> lChangeArray; |
|
1561 CleanupClosePushL(lChangeArray); |
|
1562 |
|
1563 RPointerArray<HBufC8> lParamValArray; |
|
1564 CleanupClosePushL(lParamValArray); |
|
1565 |
|
1566 HBufC8* lBuffer = HBufC8 :: NewLC(lCount); |
|
1567 TPtr8 bufPtr = lBuffer->Des(); |
|
1568 aMessage.ReadL(1, bufPtr); |
|
1569 |
|
1570 TInt lStatus = KErrNone; |
|
1571 |
|
1572 TRAPD(lErr, lStatus = iServer.PerformCleanupL(lBuffer, lChangeArray, lParamValArray)); |
|
1573 |
|
1574 if(lErr != KErrNone) { |
|
1575 Dprint(_L("[CSCPSession]-> ERROR: SCPServer was unable to complete the operation lErr=%d"), lErr); |
|
1576 lParamValArray.ResetAndDestroy(); |
|
1577 User :: Leave(lErr); |
|
1578 } |
|
1579 |
|
1580 TInt32 lCallerID = aMessage.Identity().iUid; |
|
1581 aMessage.Complete(lStatus); |
|
1582 |
|
1583 Dprint(_L("[CSCPSession]-> Total parameters changed=%d "), lChangeArray.Count()); |
|
1584 if(lChangeArray.Count() > 0) { |
|
1585 TRAP(lErr, NotifyAllStakeHoldersL(lChangeArray, lCallerID)); |
|
1586 |
|
1587 if(lErr != KErrNone) { |
|
1588 Dprint(_L("[CSCPSession]-> ERROR: NotifyAllStakeHoldersL() could not complete, lErr=%d"), lErr); |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 lParamValArray.ResetAndDestroy(); |
|
1593 CleanupStack :: PopAndDestroy(3); // lParamIDArray lParamValArray lBuffer |
|
1594 return lStatus; |
|
1595 } |
|
1596 TInt CSCPSession :: HandleSetALPeriodL( const RMessage2& aMessage ) { |
|
1597 Dprint((_L("[CSCPSession]-> HandleSetParamMessageL() >>>"))); |
|
1598 TBool oldALState = EFalse; |
|
1599 TBool lNotifyChange = ETrue; |
|
1600 #ifndef __WINS__ // No need to check for lock setting changes in emulator |
|
1601 if ( ( (TSCPParameterID)aMessage.Int0() == ESCPAutolockPeriod ) || |
|
1602 ( (TSCPParameterID)aMessage.Int0() == ESCPMaxAutolockPeriod ) ) |
|
1603 { |
|
1604 oldALState = IsAutolockActive(); |
|
1605 } |
|
1606 #endif // __WINS__ |
|
1607 TPckgBuf<TInt> lALPeriod; |
|
1608 aMessage.ReadL(0, lALPeriod); |
|
1609 User :: LeaveIfError(iServer.SetAutolockPeriodL(lALPeriod())); |
|
1610 TBool completeRequest = ETrue; |
|
1611 #ifndef __WINS__ // No need to check for lock setting changes in emulator |
|
1612 TBool currentALState = IsAutolockActive(); |
|
1613 if ( ( !oldALState ) && ( currentALState ) ) |
|
1614 { |
|
1615 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): Enabling DOS lock") )); |
|
1616 SetDOSLockSettingL( ETrue, EFalse, aMessage ); |
|
1617 completeRequest = EFalse; |
|
1618 } |
|
1619 else if ( ( oldALState ) && ( !currentALState ) ) |
|
1620 { |
|
1621 if ( !IsSMSLockActiveL() ) |
|
1622 { |
|
1623 Dprint( (_L("CSCPSession::HandleSetParamMessageL():\ |
|
1624 Disabling DOS lock") )); |
|
1625 SetDOSLockSettingL( EFalse, EFalse, aMessage ); |
|
1626 completeRequest = EFalse; |
|
1627 } |
|
1628 else |
|
1629 { |
|
1630 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): SMS Lock active,\ |
|
1631 leaving DOS lock on") )); |
|
1632 } |
|
1633 } |
|
1634 else |
|
1635 { |
|
1636 Dprint( (_L("CSCPSession::HandleSetParamMessageL(): Autolock (Max.) period\ |
|
1637 changed, no lock change") )); |
|
1638 } |
|
1639 #endif // __WINS__ |
|
1640 if(completeRequest) { |
|
1641 Dprint(_L("[CSCPSession]-> aMessage.Complete()...")); |
|
1642 aMessage.Complete( KErrNone ); |
|
1643 } |
|
1644 else { |
|
1645 } |
|
1646 Dprint((_L("[CSCPSession]-> HandleSetParamMessageL() <<<"))); |
|
1647 return KErrNone; |
|
1648 } |
|
1649 |
|
1650 void CSCPSession :: NotifyChangeL( TInt aParamID, const TDesC8 aParamVal, TUint32 aCallerID ) { |
|
1651 RArray<const TParamChange> lChangeArray; |
|
1652 CleanupClosePushL(lChangeArray); |
|
1653 |
|
1654 const TParamChange lChange(aParamID, aParamVal); |
|
1655 TInt ret = lChangeArray.Append(lChange); |
|
1656 |
|
1657 if(KErrNone != ret) { |
|
1658 return; |
|
1659 } |
|
1660 |
|
1661 Dprint(_L("[CSCPSession]->INFO: Initiating notification to all the StakeHolders...")); |
|
1662 TRAPD(lErr, NotifyAllStakeHoldersL(lChangeArray, aCallerID)); |
|
1663 Dprint(_L("[CSCPSession]->INFO: Notification to all the StakeHolders complete...")); |
|
1664 CleanupStack :: PopAndDestroy(); //lChangeArray |
|
1665 } |