19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <e32base.h> |
20 #include <e32base.h> |
21 #include <e32std.h> |
21 #include <e32std.h> |
22 #include <ecom/implementationproxy.h> |
22 #include <ecom/implementationproxy.h> |
23 #include <SCPParamObject.h> |
23 #include <SCPParamObject.h> |
24 #include <SCPTimestampPluginLang.rsg> |
24 #include <SCPServerInterface.h> |
|
25 #include <scptimestamppluginlang.rsg> |
25 #include "SCP_IDs.h" |
26 #include "SCP_IDs.h" |
26 #include <bautils.h> |
27 #include <bautils.h> |
27 #include <hal.h> |
28 #include <hal.h> |
28 #include <AknGlobalNote.h> |
29 #include <AknGlobalNote.h> |
|
30 #include <AknGlobalConfirmationQuery.h> |
29 // For wipe |
31 // For wipe |
30 //#include <StarterClient.h> |
32 #include <starterclient.h> |
31 //#include <sysutil.h> |
33 #include <sysutil.h> |
32 //#include <SysLangUtil.h> |
34 #include <syslangutil.h> |
33 //#include <rfsClient.h> |
35 #include <rfsClient.h> |
34 //#include "DMUtilClient.h" |
36 #include "DMUtilClient.h" |
35 |
37 |
36 #include "SCPTimestampPlugin.h" |
38 #include "SCPTimestampPlugin.h" |
37 #include <featmgr.h> |
39 #include <featmgr.h> |
38 //#ifdef RD_MULTIPLE_DRIVE |
40 #ifdef RD_MULTIPLE_DRIVE |
39 //#include <DriveInfo.h> |
41 #include <driveinfo.h> |
40 //#include <PathInfo.h> |
42 #include <pathinfo.h> |
41 //#include <f32file.h> |
43 #include <f32file.h> |
42 //#endif //RD_MULTIPLE_DRIVEs |
44 #endif //RD_MULTIPLE_DRIVEs |
43 // CONSTANTS |
45 // CONSTANTS |
44 |
46 |
45 // ============================= LOCAL FUNCTIONS ============================= |
47 // ============================= LOCAL FUNCTIONS ============================= |
46 |
48 |
47 |
49 |
138 // |
137 // |
139 // |
138 // |
140 // Status : Approved |
139 // Status : Approved |
141 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
142 // |
141 // |
143 CSCPParamObject* CSCPTimestampPlugin::HandleEvent( TInt aID, CSCPParamObject& aParam ) |
142 void CSCPTimestampPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam ) |
144 { |
143 { |
145 Dprint ( ( _L( "CSCPTimestampPlugin::HandleEvent()" ) ) ); |
144 Dprint ( ( _L( "CSCPTimestampPlugin::HandleEvent()" ) ) ); |
146 |
|
147 CSCPParamObject* retParams = NULL; |
|
148 |
145 |
149 // Get our current functional configuration |
146 // Get our current functional configuration |
150 if ( iEventHandler->GetParameters().Get( |
147 if ( iEventHandler->GetParameters().Get( |
151 RTerminalControl3rdPartySession::EPasscodeExpiration, iExpiration ) != KErrNone ) |
148 RTerminalControl3rdPartySession::EPasscodeExpiration, iExpiration ) != KErrNone ) |
152 { |
149 { |
165 if ( iEventHandler->GetParameters().Get( |
162 if ( iEventHandler->GetParameters().Get( |
166 RTerminalControl3rdPartySession::EPasscodeMaxAttempts, iMaxAttempts ) != KErrNone ) |
163 RTerminalControl3rdPartySession::EPasscodeMaxAttempts, iMaxAttempts ) != KErrNone ) |
167 { |
164 { |
168 iMaxAttempts = 0; |
165 iMaxAttempts = 0; |
169 } |
166 } |
170 |
167 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iExpiration :%d, iExpiration :%d, iMinTolerance :%d, iMaxAttempts :%d"), iExpiration,iMinInterval,iMinTolerance,iMaxAttempts ) ); |
171 if ( !iResOpen ) |
168 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): aID is :%d"), aID) ); |
172 { |
|
173 // Load the resource file containing the localized texts |
|
174 TInt ret = GetResource(); |
|
175 if ( ret == KErrNone ) |
|
176 { |
|
177 iResOpen = ETrue; |
|
178 } |
|
179 // We'll continue without the resource if required |
|
180 } |
|
181 |
|
182 switch ( aID ) |
169 switch ( aID ) |
183 { |
170 { |
184 case ( KSCPEventPasswordChangeQuery ): |
171 case ( KSCPEventPasswordChangeQuery ): |
185 { |
172 { |
186 if ( iMinInterval > 0 ) |
173 if ( iMinInterval > 0 ) |
187 { |
174 { |
188 // Ignore errors, the plugin will stay silent on error |
175 // Ignore errors, the plugin will stay silent on error |
189 TRAP_IGNORE( IsChangeAllowedL( aParam, retParams ) ); |
176 TRAP_IGNORE( IsChangeAllowedL( aParam, aOutParam ) ); |
190 } |
177 } |
191 break; |
178 break; |
192 } |
179 } |
193 |
180 |
194 case ( KSCPEventConfigurationQuery ): |
181 case ( KSCPEventConfigurationQuery ): |
196 |
183 |
197 TInt paramID; |
184 TInt paramID; |
198 |
185 |
199 if ( aParam.Get( KSCPParamID, paramID ) == KErrNone ) |
186 if ( aParam.Get( KSCPParamID, paramID ) == KErrNone ) |
200 { |
187 { |
201 ConfigurationQuery( paramID, aParam, retParams ); |
188 ConfigurationQuery( paramID, aParam, aOutParam ); |
202 } |
189 } |
203 |
190 |
204 break; |
191 break; |
205 } |
192 } |
206 |
193 |
207 case ( KSCPEventPasswordChanged ): |
194 case ( KSCPEventPasswordChanged ): |
208 { |
195 { |
209 PasswordChanged( aParam, retParams ); |
196 PasswordChanged( aParam, aOutParam ); |
210 break; |
197 break; |
211 } |
198 } |
212 |
199 |
213 case ( KSCPEventAuthenticationAttempted ): |
200 case ( KSCPEventAuthenticationAttempted ): |
214 { |
201 { |
215 TInt authStatus; |
202 TInt authStatus; |
216 if ( aParam.Get( KSCPParamStatus, authStatus ) == KErrNone ) // Ignore errors |
203 if ( aParam.Get( KSCPParamStatus, authStatus ) == KErrNone ) // Ignore errors |
217 { |
204 { |
218 TBool isSuccess = ( authStatus == KErrNone ); |
205 TBool isSuccess = ( authStatus == KErrNone ); |
219 // No return value required in any case |
206 // No return value required in any case |
220 AuthenticationAttempt( isSuccess, aParam, retParams ); |
207 AuthenticationAttempt( isSuccess, aParam, aOutParam ); |
221 } |
208 } |
222 |
209 |
223 break; |
210 break; |
224 } |
211 } |
225 |
212 |
295 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() KSCPIsNotAfter") )); |
281 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() KSCPIsNotAfter") )); |
296 TInt tolerance = 0; |
282 TInt tolerance = 0; |
297 iConfiguration->Get( KSCPUsedTolerance, tolerance ); // ignore errors |
283 iConfiguration->Get( KSCPUsedTolerance, tolerance ); // ignore errors |
298 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): tolerance get: %d"), tolerance ) ); |
284 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): tolerance get: %d"), tolerance ) ); |
299 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinTolerance : %d"), iMinTolerance ) ); |
285 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinTolerance : %d"), iMinTolerance ) ); |
300 |
286 if ( tolerance >= iMinTolerance ) |
301 if ( iMinTolerance > 0 && tolerance >= iMinTolerance ) |
|
302 { |
287 { |
303 ret = KErrSCPCodeChangeNotAllowed; |
288 ret = KErrSCPCodeChangeNotAllowed; |
304 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() KErrSCPCodeChangeNotAllowed") )); |
289 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() KErrSCPCodeChangeNotAllowed") )); |
305 } |
290 } |
306 |
291 |
312 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() Error, new interval will start in passwordChanged") )); |
297 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() Error, new interval will start in passwordChanged") )); |
313 } |
298 } |
314 |
299 |
315 if ( ret == KErrSCPCodeChangeNotAllowed ) |
300 if ( ret == KErrSCPCodeChangeNotAllowed ) |
316 { |
301 { |
317 // Code change is not allowed, send the info back to the user |
302 Dprint ( ( _L( "EDeviceLockMinChangeTolerance Failed" ) ) ); |
318 aRetParams = CSCPParamObject::NewL(); |
303 aRetParams.AddtoFailedPolices(EDeviceLockMinChangeTolerance); |
319 |
304 aRetParams.Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed ); |
320 aRetParams->Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed ); |
305 } |
321 aRetParams->Set( KSCPParamAction, KSCPActionShowUI ); |
|
322 aRetParams->Set( KSCPParamUIMode, KSCPUINote ); |
|
323 aRetParams->Set( KSCPParamNoteIcon, KSCPUINoteError ); |
|
324 |
|
325 HBufC16* resText = NULL; |
|
326 HBufC16* formatBuf = NULL; |
|
327 |
|
328 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinInterval : %d"), iMinInterval ) ); |
|
329 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinTolerance : %d"), iMinTolerance ) ); |
|
330 if ( iMinInterval > 1 ) |
|
331 { |
|
332 if ( iMinTolerance >1 ) |
|
333 { |
|
334 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance >= 1") )); |
|
335 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_DAY ); |
|
336 } |
|
337 else |
|
338 { |
|
339 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance !>= 1") )); |
|
340 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_HOURS ); |
|
341 } |
|
342 } |
|
343 else |
|
344 if ( iMinTolerance > 1 ) |
|
345 { |
|
346 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance >= 1") )); |
|
347 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_TIMES ); |
|
348 } |
|
349 else |
|
350 { |
|
351 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance !>= 1") )); |
|
352 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_ONES ); |
|
353 } |
|
354 |
|
355 CleanupStack::PushL( resText ); |
|
356 |
|
357 formatBuf = HBufC::NewL( resText->Length() + KSCPMaxMinChangeValueLen ); |
|
358 |
|
359 TPtr16 bufDes = formatBuf->Des(); |
|
360 |
|
361 if ( iMinInterval > 1 ) |
|
362 { |
|
363 if ( iMinTolerance > 1 ) |
|
364 { |
|
365 bufDes.Format( resText->Des(), iMinTolerance , iMinInterval ); |
|
366 } |
|
367 else |
|
368 { |
|
369 bufDes.Format( resText->Des(), iMinInterval ); |
|
370 } |
|
371 } |
|
372 else |
|
373 if ( iMinTolerance > 1 ) |
|
374 { |
|
375 bufDes.Format( resText->Des(), iMinTolerance ); |
|
376 } |
|
377 else |
|
378 { |
|
379 bufDes.Format( resText->Des() ); |
|
380 } |
|
381 |
|
382 aRetParams->Set( KSCPParamPromptText, bufDes ); |
|
383 |
|
384 delete formatBuf; |
|
385 |
|
386 CleanupStack::PopAndDestroy( resText ); |
|
387 } |
|
388 |
|
389 // No need to write configuration changes |
|
390 } |
306 } |
391 |
307 |
392 |
308 |
393 // ---------------------------------------------------------------------------- |
309 // ---------------------------------------------------------------------------- |
394 // CSCPTimestampPlugin::PasswordChanged() |
310 // CSCPTimestampPlugin::PasswordChanged() |
395 // |
311 // |
396 // |
312 // |
397 // Status : Approved |
313 // Status : Approved |
398 // ---------------------------------------------------------------------------- |
314 // ---------------------------------------------------------------------------- |
399 // |
315 // |
400 void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject*& aRetParams ) |
316 void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject& aRetParams ) |
401 { |
317 { |
402 (void)aParam; |
318 (void)aParam; |
403 (void)aRetParams; |
319 |
404 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged()") )); |
320 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged()") )); |
405 TInt err = ReadConfiguration(); |
321 TInt err = ReadConfiguration(); |
406 if ( err == KErrNone ) |
322 if ( err == KErrNone ) |
407 { |
323 { |
408 // Check if immediate expiration is set |
324 // Check if immediate expiration is set |
424 |
340 |
425 if ( iExpiration > 0 ) |
341 if ( iExpiration > 0 ) |
426 { |
342 { |
427 // Set the last time the password was changed, for expiration |
343 // Set the last time the password was changed, for expiration |
428 iConfiguration->Set( KSCPLastChangeTime, timeBuf ); |
344 iConfiguration->Set( KSCPLastChangeTime, timeBuf ); |
429 } |
345 } |
430 |
|
431 Dprint( ( _L( "CSCPPatternPlugin::PasswordChanged(): iMinInterval: %d"), iMinInterval ) ); |
346 Dprint( ( _L( "CSCPPatternPlugin::PasswordChanged(): iMinInterval: %d"), iMinInterval ) ); |
432 |
347 if ( iMinInterval > 0 ) |
433 if ( iMinInterval > 0 && iMinTolerance > 0) { |
348 { |
434 TInt ret = IsAfter( KSCPIntervalStartTime, iMinInterval, KSCPTypeHours ); |
349 TInt ret = IsAfter( KSCPIntervalStartTime, iMinInterval, KSCPTypeHours ); |
435 |
|
436 if ( ret == KSCPIsAfter ) |
350 if ( ret == KSCPIsAfter ) |
437 { |
351 { |
438 // Interval exceeded, start a new interval from here |
352 // Interval exceeded, start a new interval from here |
439 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged() KSCPIsAfter") )); |
353 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged() KSCPIsAfter") )); |
440 iConfiguration->Set( KSCPIntervalStartTime, timeBuf ); |
354 iConfiguration->Set( KSCPIntervalStartTime, timeBuf ); |
485 // |
394 // |
486 // |
395 // |
487 // Status : Approved |
396 // Status : Approved |
488 // ---------------------------------------------------------------------------- |
397 // ---------------------------------------------------------------------------- |
489 // |
398 // |
490 void CSCPTimestampPlugin::AuthenticationAttempt( TBool aIsSuccessful, |
399 void CSCPTimestampPlugin :: AuthenticationAttempt( TBool aIsSuccessful, |
491 CSCPParamObject& aParam, |
400 CSCPParamObject& aParam, |
492 CSCPParamObject*& aRetParams ) |
401 CSCPParamObject& aRetParams ) |
493 { |
402 { |
|
403 Dprint( (_L("CSCPTimestampPlugin::AuthenticationAttempt") )); |
494 if ( ReadConfiguration() != KErrNone ) |
404 if ( ReadConfiguration() != KErrNone ) |
495 { |
405 { |
496 return; |
406 return; |
497 } |
407 } |
498 Dprint( (_L("CSCPTimestampPlugin::AuthenticationAttempt()") )); |
|
499 |
408 |
500 // Check if immediate expiration is set |
409 // Check if immediate expiration is set |
501 TInt expireNow = 0; |
410 TInt expireNow = 0; |
502 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
411 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
503 |
412 Dprint( ( _L( "CSCPPatternPlugin::AuthenticationAttempt(): expireNow = %d"), expireNow ) ); |
504 if ( ( iExpiration == 0 ) && ( iMaxAttempts == 0) && ( expireNow == 0 ) ) |
413 if ( ( iExpiration == 0 ) && ( iMaxAttempts == 0) && ( expireNow == 0 ) ) |
505 { |
414 { |
506 return; // We have no interest in this call |
415 return; // We have no interest in this call |
507 } |
416 } |
508 |
417 |
513 else |
422 else |
514 { |
423 { |
515 // Failed authentication attempt |
424 // Failed authentication attempt |
516 if ( iMaxAttempts > 0 ) |
425 if ( iMaxAttempts > 0 ) |
517 { |
426 { |
518 Dprint( (_L("CSCPTimestampPlugin::iMaxAttempts > 0") )); |
|
519 TInt failedCount = 0; |
427 TInt failedCount = 0; |
520 iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors |
428 iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors |
521 failedCount++; |
429 failedCount++; |
522 |
430 |
523 if ( failedCount == iMaxAttempts - 1 ) |
431 if ( failedCount == iMaxAttempts - 1 ) |
524 { |
432 { |
525 // Warn the user. Only one attempt left. There's no use handling the error |
433 Dprint ( ( _L( "EDeviceLockAllowedMaxAtempts Failed" ) ) ); |
526 // so we'll just stay silent at this point on failure. |
434 aRetParams.AddtoFailedPolices(EDeviceLockAllowedMaxAtempts); |
527 Dprint( (_L("CSCPTimestampPlugin::One Attempt Left") )); |
|
528 HBufC16* resText = NULL; |
|
529 resText = LoadResourceL( R_SET_SEC_CODE_WARNING_ATTEMPTS_LEFT ); |
|
530 FormatResourceString(*resText); |
|
531 // Call the dialog from an ActiveObj framework so that we could give control back to secui |
|
532 Dprint( (_L("CSCPTimestampPlugin::start actv obj for dialog") )); |
|
533 iUserInfo->StartL(*resText); |
|
534 } |
435 } |
535 else if ( failedCount >= iMaxAttempts ) |
436 else if ( failedCount >= iMaxAttempts ) |
536 { |
437 { |
537 // Try to wipe the device |
438 // Try to wipe the device |
538 TRAPD( err, WipeDeviceL( aRetParams ) ); |
439 TRAPD( err, WipeDeviceL( aRetParams ) ); |
|
440 |
539 if ( err != KErrNone ) |
441 if ( err != KErrNone ) |
540 { |
442 { |
541 Dprint( ( _L( "CSCPPatternPlugin::\ |
443 Dprint( ( _L( "CSCPPatternPlugin::\ |
542 AuthenticationAttempt(): Wipe FAILED :%d"), err ) ); |
444 AuthenticationAttempt(): Wipe FAILED :%d"), err ) ); |
543 } |
445 } |
557 // |
459 // |
558 // Status : Approved |
460 // Status : Approved |
559 // ---------------------------------------------------------------------------- |
461 // ---------------------------------------------------------------------------- |
560 // |
462 // |
561 void CSCPTimestampPlugin::SuccessfulAuthenticationL( CSCPParamObject& aParam, |
463 void CSCPTimestampPlugin::SuccessfulAuthenticationL( CSCPParamObject& aParam, |
562 CSCPParamObject*& aRetParams ) |
464 CSCPParamObject& aRetParams ) |
563 { |
465 { |
|
466 Dprint( (_L("CSCPTimestampPlugin::IsAfter()..enter") )); |
564 // Reset the failed attempts -counter |
467 // Reset the failed attempts -counter |
565 if ( iMaxAttempts > 0 ) |
468 if ( iMaxAttempts > 0 ) |
566 { |
469 { |
567 iConfiguration->Set( KSCPFailedAttempts, 0 ); |
470 iConfiguration->Set( KSCPFailedAttempts, 0 ); |
568 } |
471 } |
572 aParam.Get( KSCPParamContext, context ); // ignore errors |
475 aParam.Get( KSCPParamContext, context ); // ignore errors |
573 |
476 |
574 // Check if immediate expiration is set |
477 // Check if immediate expiration is set |
575 TInt expireNow = 0; |
478 TInt expireNow = 0; |
576 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
479 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
577 |
480 Dprint( ( _L( "CSCPPatternPlugin::SuccessfulAuthenticationL(): expireNow = %d, iExpiration =%d"), expireNow,iExpiration ) ); |
578 // Check if the code should be changed now |
481 // Check if the code should be changed now |
579 if ( ( context != KSCPContextChangePsw ) && |
482 if ( ( context != KSCPContextChangePsw ) && |
580 ( ( iExpiration > 0 ) || ( expireNow ) ) ) |
483 ( ( iExpiration > 0 ) || ( expireNow ) ) ) |
581 { |
484 { |
582 if ( ( IsAfter( KSCPLastChangeTime, iExpiration, KSCPTypeDays ) == KSCPIsAfter ) || |
485 if ( ( IsAfter( KSCPLastChangeTime, iExpiration, KSCPTypeDays ) == KSCPIsAfter ) || |
583 ( expireNow ) ) |
486 ( expireNow ) ) |
584 { |
487 { |
585 // Refill the parameters to inform the client that the password |
488 Dprint ( ( _L( "EDeviceLockPasscodeExpiration Failed" ) ) ); |
586 // should be changed. |
489 aRetParams.AddtoFailedPolices(EDeviceLockPasscodeExpiration); |
587 aRetParams = CSCPParamObject::NewL(); |
490 aRetParams.Set( KSCPParamStatus, KErrSCPInvalidCode ); |
588 aRetParams->Set( KSCPParamAction, KSCPActionForceChange ); |
491 } |
589 } |
492 } |
590 } |
493 Dprint( (_L("CSCPTimestampPlugin::IsAfter()..exit") )); |
591 } |
494 } |
592 |
495 |
593 |
|
594 // ---------------------------------------------------------------------------- |
496 // ---------------------------------------------------------------------------- |
595 // CSCPTimestampPlugin::IsAfter() |
497 // CSCPTimestampPlugin::IsAfter() |
596 // |
498 // |
597 // |
499 // |
598 // Status : Approved |
500 // Status : Approved |
605 TTime curTime; |
507 TTime curTime; |
606 curTime.UniversalTime(); |
508 curTime.UniversalTime(); |
607 |
509 |
608 TBuf<KSCPMaxInt64Length> savedTimeBuf; |
510 TBuf<KSCPMaxInt64Length> savedTimeBuf; |
609 TInt64 savedTime; |
511 TInt64 savedTime; |
|
512 Dprint( ( _L( "CSCPPatternPlugin::IsAfter: aConfID value is :%d"), aConfID ) ); |
610 ret = iConfiguration->Get( aConfID, savedTimeBuf ); |
513 ret = iConfiguration->Get( aConfID, savedTimeBuf ); |
611 if ( ret == KErrNone ) |
514 if ( ret == KErrNone ) |
612 { |
515 { |
613 Dprint( (_L("CSCPTimestampPlugin::IsAfter() iConfiguration->Get == KErrNone") )); |
516 Dprint( (_L("CSCPTimestampPlugin::IsAfter() iConfiguration->Get == KErrNone") )); |
614 TLex lex( savedTimeBuf ); |
517 TLex lex( savedTimeBuf ); |
667 // Status : Approved |
570 // Status : Approved |
668 // ---------------------------------------------------------------------------- |
571 // ---------------------------------------------------------------------------- |
669 // |
572 // |
670 void CSCPTimestampPlugin::ConfigurationQuery( TInt aParamID, |
573 void CSCPTimestampPlugin::ConfigurationQuery( TInt aParamID, |
671 CSCPParamObject& aParam, |
574 CSCPParamObject& aParam, |
672 CSCPParamObject*& aRetParams ) |
575 CSCPParamObject& aRetParams ) |
673 { |
576 { |
674 // First check if this is our ID |
577 // First check if this is our ID |
675 if ( ( aParamID == RTerminalControl3rdPartySession::EPasscodeExpiration ) || |
578 if ( ( aParamID == RTerminalControl3rdPartySession::EPasscodeExpiration ) || |
676 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeTolerance ) || |
579 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeTolerance ) || |
677 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeInterval ) || |
580 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeInterval ) || |
782 else |
685 else |
783 { |
686 { |
784 // Something wrong, and this is our parameter. Signal an error |
687 // Something wrong, and this is our parameter. Signal an error |
785 ret = KErrArgument; |
688 ret = KErrArgument; |
786 } |
689 } |
787 |
690 |
788 TRAPD( err, aRetParams = CSCPParamObject::NewL() ); |
691 aRetParams.Set( KSCPParamStatus, ret ); |
789 if ( err == KErrNone ) // If we can't create a paramObject, there's nothing we can do |
692 |
790 { |
693 if ( setPrivateStorage ) |
791 aRetParams->Set( KSCPParamStatus, ret ); |
694 { |
792 if ( setPrivateStorage ) |
695 aRetParams.Set( KSCPParamStorage, KSCPStoragePrivate ); |
793 { |
696 } |
794 aRetParams->Set( KSCPParamStorage, KSCPStoragePrivate ); |
697 } |
795 } |
698 } |
796 } |
|
797 } |
|
798 } |
|
799 |
|
800 |
|
801 |
699 |
802 // ---------------------------------------------------------------------------- |
700 // ---------------------------------------------------------------------------- |
803 // CSCPTimestampPlugin::WipeDeviceL() |
701 // CSCPTimestampPlugin::WipeDeviceL() |
804 // |
702 // |
805 // |
703 // |
806 // Status : Approved |
704 // Status : Approved |
807 // ---------------------------------------------------------------------------- |
705 // ---------------------------------------------------------------------------- |
808 // |
706 // |
809 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject*& aRetParams ) |
707 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject& aRetParams ) |
810 { |
708 { |
811 (void)aRetParams; |
|
812 |
|
813 Dprint( (_L("CSCPTimestampPlugin::WipeDeviceL") )); |
|
814 iUserInfo->DoRfsL(); |
|
815 /* |
|
816 // First try to format other local drives than C: |
709 // First try to format other local drives than C: |
817 RRfsClient rfsClient; |
710 RRfsClient rfsClient; |
818 |
711 |
819 TInt ret = rfsClient.Connect(); |
712 TInt ret = rfsClient.Connect(); |
820 |
713 |
865 //Loop through all drives except phonem memory drive |
758 //Loop through all drives except phonem memory drive |
866 for (TInt i(0); i<driveListLen; ++i) |
759 for (TInt i(0); i<driveListLen; ++i) |
867 { |
760 { |
868 if (driveList[i]) |
761 if (driveList[i]) |
869 { |
762 { |
870 driveNumber = TDriveNumber(i); |
763 driveNumber = TDriveNumber(i); |
871 if (phoneMemoryDrive != driveNumber) |
764 if (phoneMemoryDrive != driveNumber) |
872 { |
765 { |
873 TBuf<KSCPFormatScriptMaxLen> formatScript; |
766 TBuf<KSCPFormatScriptMaxLen> formatScript; |
874 TChar driveLetter; |
767 TChar driveLetter; |
875 RFs::DriveToChar(i,driveLetter); |
768 RFs::DriveToChar(i,driveLetter); |
876 formatScript.Format(KSCPFormatScript, (TUint)driveLetter ); |
769 formatScript.Format(KSCPFormatScript, (TUint)driveLetter ); |
877 Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL(): Formatting %c:"), driveLetter ) ); |
770 ret = rfsClient.RunScriptInDescriptor(formatScript); |
878 |
771 } |
879 ret = rfsClient.RunScriptInDescriptor(formatScript); |
|
880 |
|
881 if ( ret != KErrNone ) |
|
882 { |
|
883 Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL():\ |
|
884 FAILED to format %c: %d"), driveLetter, ret ) ); |
|
885 } |
|
886 } |
|
887 } |
772 } |
888 } |
773 } |
889 |
774 |
890 CleanupStack::PopAndDestroy(); |
775 CleanupStack::PopAndDestroy(); |
891 #endif //RD_MULTIPLE_DRIVE |
776 #endif //RD_MULTIPLE_DRIVE |
1007 } |
891 } |
1008 |
892 |
1009 return ret; |
893 return ret; |
1010 } |
894 } |
1011 |
895 |
1012 |
|
1013 |
|
1014 // ---------------------------------------------------------------------------- |
|
1015 // CSCPTimestampPlugin::GetResource |
|
1016 // GetResource |
|
1017 // |
|
1018 // Status : Approved |
|
1019 // ---------------------------------------------------------------------------- |
|
1020 // |
|
1021 |
|
1022 TInt CSCPTimestampPlugin::GetResource() |
|
1023 { |
|
1024 Dprint( (_L("CSCPTimestampPlugin::GetResource()") )); |
|
1025 // The resource has to be loaded manually since this is not an application. |
|
1026 |
|
1027 // Build the resource file name and localize it |
|
1028 TFileName resourceFile; |
|
1029 resourceFile.Append( KDriveZ ); |
|
1030 resourceFile.Append( KSCPTimestampPluginResFilename ); |
|
1031 BaflUtils::NearestLanguageFile( *iFsSession, resourceFile ); |
|
1032 |
|
1033 TRAPD( err, iResFile.OpenL( *iFsSession, resourceFile ) ); |
|
1034 |
|
1035 if ( err == KErrNone ) |
|
1036 { |
|
1037 TRAP( err, iResFile.ConfirmSignatureL() ); |
|
1038 } |
|
1039 |
|
1040 return err; |
|
1041 } |
|
1042 |
|
1043 |
|
1044 // ---------------------------------------------------------------------------- |
|
1045 // CSCPTimestampPlugin::LoadResourceLC |
|
1046 // |
|
1047 // |
|
1048 // Status : Approved |
|
1049 // ---------------------------------------------------------------------------- |
|
1050 // |
|
1051 HBufC16* CSCPTimestampPlugin::LoadResourceL( TInt aResId ) |
|
1052 { |
|
1053 if ( !iResOpen ) |
|
1054 { |
|
1055 User::Leave( KErrNotReady ); |
|
1056 } |
|
1057 |
|
1058 Dprint( (_L("CSCPTimestampPlugin::LoadResourceL()") )); |
|
1059 |
|
1060 // Load the actual resource |
|
1061 HBufC8* readBuffer = iResFile.AllocReadLC( aResId ); |
|
1062 |
|
1063 // As we are expecting HBufC16 |
|
1064 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(), |
|
1065 ( readBuffer->Length() + 1 ) >> 1 ); |
|
1066 |
|
1067 HBufC16* textBuffer = HBufC16::NewL( ptrReadBuffer.Length() ); |
|
1068 |
|
1069 *textBuffer = ptrReadBuffer; |
|
1070 |
|
1071 FormatResourceString(*textBuffer); |
|
1072 CleanupStack::PopAndDestroy( readBuffer ); |
|
1073 |
|
1074 return textBuffer; |
|
1075 } |
|
1076 |
|
1077 // ---------------------------------------------------------------------------- |
|
1078 // CSCPTimestampPlugin::FormatResourceString |
|
1079 // The buffer that is passed is formatted to have only %i as a format specifier instead of %N or %0N etc. |
|
1080 // |
|
1081 // Status : Approved |
|
1082 // ---------------------------------------------------------------------------- |
|
1083 // |
|
1084 void CSCPTimestampPlugin::FormatResourceString(HBufC16 &aResStr) |
|
1085 { |
|
1086 TInt pos = 0; |
|
1087 TInt flag = 0; |
|
1088 TPtr16 bufPtr = aResStr.Des(); |
|
1089 _LIT (mess1, "%N"); |
|
1090 _LIT (mess2, "%i"); |
|
1091 _LIT (mess3, "%0N"); |
|
1092 _LIT (mess4, "%1N"); |
|
1093 |
|
1094 while ((pos = bufPtr.Find(mess1)) !=KErrNotFound) |
|
1095 { |
|
1096 bufPtr.Replace(pos,2,mess2); |
|
1097 flag = 1; |
|
1098 break; |
|
1099 } |
|
1100 |
|
1101 if(flag == 0) |
|
1102 { |
|
1103 while ((pos = bufPtr.Find(mess3)) != KErrNotFound) |
|
1104 { |
|
1105 bufPtr.Replace(pos,3,mess2); |
|
1106 } |
|
1107 |
|
1108 while ((pos = bufPtr.Find(mess4)) != KErrNotFound) |
|
1109 { |
|
1110 bufPtr.Replace(pos,3,mess2); |
|
1111 } |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 // End of File |
896 // End of File |