136 // |
137 // |
137 // |
138 // |
138 // Status : Approved |
139 // Status : Approved |
139 // ---------------------------------------------------------------------------- |
140 // ---------------------------------------------------------------------------- |
140 // |
141 // |
141 CSCPParamObject* CSCPTimestampPlugin::HandleEvent( TInt aID, CSCPParamObject& aParam ) |
142 void CSCPTimestampPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam ) |
142 { |
143 { |
143 Dprint ( ( _L( "CSCPTimestampPlugin::HandleEvent()" ) ) ); |
144 Dprint ( ( _L( "CSCPTimestampPlugin::HandleEvent()" ) ) ); |
144 |
|
145 CSCPParamObject* retParams = NULL; |
|
146 |
145 |
147 // Get our current functional configuration |
146 // Get our current functional configuration |
148 if ( iEventHandler->GetParameters().Get( |
147 if ( iEventHandler->GetParameters().Get( |
149 RTerminalControl3rdPartySession::EPasscodeExpiration, iExpiration ) != KErrNone ) |
148 RTerminalControl3rdPartySession::EPasscodeExpiration, iExpiration ) != KErrNone ) |
150 { |
149 { |
163 if ( iEventHandler->GetParameters().Get( |
162 if ( iEventHandler->GetParameters().Get( |
164 RTerminalControl3rdPartySession::EPasscodeMaxAttempts, iMaxAttempts ) != KErrNone ) |
163 RTerminalControl3rdPartySession::EPasscodeMaxAttempts, iMaxAttempts ) != KErrNone ) |
165 { |
164 { |
166 iMaxAttempts = 0; |
165 iMaxAttempts = 0; |
167 } |
166 } |
168 |
167 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iExpiration :%d, iExpiration :%d, iMinTolerance :%d, iMaxAttempts :%d"), iExpiration,iMinInterval,iMinTolerance,iMaxAttempts ) ); |
169 if ( !iResOpen ) |
168 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): aID is :%d"), aID) ); |
170 { |
|
171 // Load the resource file containing the localized texts |
|
172 TInt ret = GetResource(); |
|
173 if ( ret == KErrNone ) |
|
174 { |
|
175 iResOpen = ETrue; |
|
176 } |
|
177 // We'll continue without the resource if required |
|
178 } |
|
179 |
|
180 switch ( aID ) |
169 switch ( aID ) |
181 { |
170 { |
182 case ( KSCPEventPasswordChangeQuery ): |
171 case ( KSCPEventPasswordChangeQuery ): |
183 { |
172 { |
184 if ( iMinInterval > 0 ) |
173 if ( iMinInterval > 0 ) |
185 { |
174 { |
186 // Ignore errors, the plugin will stay silent on error |
175 // Ignore errors, the plugin will stay silent on error |
187 TRAP_IGNORE( IsChangeAllowedL( aParam, retParams ) ); |
176 TRAP_IGNORE( IsChangeAllowedL( aParam, aOutParam ) ); |
188 } |
177 } |
189 break; |
178 break; |
190 } |
179 } |
191 |
180 |
192 case ( KSCPEventConfigurationQuery ): |
181 case ( KSCPEventConfigurationQuery ): |
194 |
183 |
195 TInt paramID; |
184 TInt paramID; |
196 |
185 |
197 if ( aParam.Get( KSCPParamID, paramID ) == KErrNone ) |
186 if ( aParam.Get( KSCPParamID, paramID ) == KErrNone ) |
198 { |
187 { |
199 ConfigurationQuery( paramID, aParam, retParams ); |
188 ConfigurationQuery( paramID, aParam, aOutParam ); |
200 } |
189 } |
201 |
190 |
202 break; |
191 break; |
203 } |
192 } |
204 |
193 |
205 case ( KSCPEventPasswordChanged ): |
194 case ( KSCPEventPasswordChanged ): |
206 { |
195 { |
207 PasswordChanged( aParam, retParams ); |
196 PasswordChanged( aParam, aOutParam ); |
208 break; |
197 break; |
209 } |
198 } |
210 |
199 |
211 case ( KSCPEventAuthenticationAttempted ): |
200 case ( KSCPEventAuthenticationAttempted ): |
212 { |
201 { |
213 TInt authStatus; |
202 TInt authStatus; |
214 if ( aParam.Get( KSCPParamStatus, authStatus ) == KErrNone ) // Ignore errors |
203 if ( aParam.Get( KSCPParamStatus, authStatus ) == KErrNone ) // Ignore errors |
215 { |
204 { |
216 TBool isSuccess = ( authStatus == KErrNone ); |
205 TBool isSuccess = ( authStatus == KErrNone ); |
217 // No return value required in any case |
206 // No return value required in any case |
218 AuthenticationAttempt( isSuccess, aParam, retParams ); |
207 AuthenticationAttempt( isSuccess, aParam, aOutParam ); |
219 } |
208 } |
220 |
209 |
221 break; |
210 break; |
222 } |
211 } |
223 |
212 |
309 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() Error, new interval will start in passwordChanged") )); |
297 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL() Error, new interval will start in passwordChanged") )); |
310 } |
298 } |
311 |
299 |
312 if ( ret == KErrSCPCodeChangeNotAllowed ) |
300 if ( ret == KErrSCPCodeChangeNotAllowed ) |
313 { |
301 { |
314 // Code change is not allowed, send the info back to the user |
302 Dprint ( ( _L( "EDeviceLockMinChangeTolerance Failed" ) ) ); |
315 aRetParams = CSCPParamObject::NewL(); |
303 aRetParams.AddtoFailedPolices(EDeviceLockMinChangeTolerance); |
316 |
304 aRetParams.Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed ); |
317 aRetParams->Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed ); |
305 } |
318 aRetParams->Set( KSCPParamAction, KSCPActionShowUI ); |
|
319 aRetParams->Set( KSCPParamUIMode, KSCPUINote ); |
|
320 aRetParams->Set( KSCPParamNoteIcon, KSCPUINoteError ); |
|
321 |
|
322 HBufC16* resText = NULL; |
|
323 HBufC16* formatBuf = NULL; |
|
324 |
|
325 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinInterval : %d"), iMinInterval ) ); |
|
326 Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinTolerance : %d"), iMinTolerance ) ); |
|
327 if ( iMinInterval > 1 ) |
|
328 { |
|
329 if ( iMinTolerance >1 ) |
|
330 { |
|
331 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance >= 1") )); |
|
332 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_DAY ); |
|
333 } |
|
334 else |
|
335 { |
|
336 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance !>= 1") )); |
|
337 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_HOURS ); |
|
338 } |
|
339 } |
|
340 else |
|
341 if ( iMinTolerance > 1 ) |
|
342 { |
|
343 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance >= 1") )); |
|
344 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_TIMES ); |
|
345 } |
|
346 else |
|
347 { |
|
348 Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance !>= 1") )); |
|
349 resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_ONES ); |
|
350 } |
|
351 |
|
352 CleanupStack::PushL( resText ); |
|
353 |
|
354 formatBuf = HBufC::NewL( resText->Length() + KSCPMaxMinChangeValueLen ); |
|
355 |
|
356 TPtr16 bufDes = formatBuf->Des(); |
|
357 |
|
358 if ( iMinInterval > 1 ) |
|
359 { |
|
360 if ( iMinTolerance > 1 ) |
|
361 { |
|
362 bufDes.Format( resText->Des(), iMinTolerance , iMinInterval ); |
|
363 } |
|
364 else |
|
365 { |
|
366 bufDes.Format( resText->Des(), iMinInterval ); |
|
367 } |
|
368 } |
|
369 else |
|
370 if ( iMinTolerance > 1 ) |
|
371 { |
|
372 bufDes.Format( resText->Des(), iMinTolerance ); |
|
373 } |
|
374 else |
|
375 { |
|
376 bufDes.Format( resText->Des() ); |
|
377 } |
|
378 |
|
379 aRetParams->Set( KSCPParamPromptText, bufDes ); |
|
380 |
|
381 delete formatBuf; |
|
382 |
|
383 CleanupStack::PopAndDestroy( resText ); |
|
384 } |
|
385 |
|
386 // No need to write configuration changes |
|
387 } |
306 } |
388 |
307 |
389 |
308 |
390 // ---------------------------------------------------------------------------- |
309 // ---------------------------------------------------------------------------- |
391 // CSCPTimestampPlugin::PasswordChanged() |
310 // CSCPTimestampPlugin::PasswordChanged() |
392 // |
311 // |
393 // |
312 // |
394 // Status : Approved |
313 // Status : Approved |
395 // ---------------------------------------------------------------------------- |
314 // ---------------------------------------------------------------------------- |
396 // |
315 // |
397 void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject*& aRetParams ) |
316 void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject& aRetParams ) |
398 { |
317 { |
399 (void)aParam; |
318 (void)aParam; |
400 (void)aRetParams; |
319 |
401 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged()") )); |
320 Dprint( (_L("CSCPTimestampPlugin::PasswordChanged()") )); |
402 TInt err = ReadConfiguration(); |
321 TInt err = ReadConfiguration(); |
403 if ( err == KErrNone ) |
322 if ( err == KErrNone ) |
404 { |
323 { |
405 // Check if immediate expiration is set |
324 // Check if immediate expiration is set |
475 // |
394 // |
476 // |
395 // |
477 // Status : Approved |
396 // Status : Approved |
478 // ---------------------------------------------------------------------------- |
397 // ---------------------------------------------------------------------------- |
479 // |
398 // |
480 void CSCPTimestampPlugin::AuthenticationAttempt( TBool aIsSuccessful, |
399 void CSCPTimestampPlugin :: AuthenticationAttempt( TBool aIsSuccessful, |
481 CSCPParamObject& aParam, |
400 CSCPParamObject& aParam, |
482 CSCPParamObject*& aRetParams ) |
401 CSCPParamObject& aRetParams ) |
483 { |
402 { |
|
403 Dprint( (_L("CSCPTimestampPlugin::AuthenticationAttempt") )); |
484 if ( ReadConfiguration() != KErrNone ) |
404 if ( ReadConfiguration() != KErrNone ) |
485 { |
405 { |
486 return; |
406 return; |
487 } |
407 } |
488 |
408 |
489 // Check if immediate expiration is set |
409 // Check if immediate expiration is set |
490 TInt expireNow = 0; |
410 TInt expireNow = 0; |
491 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
411 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
492 |
412 Dprint( ( _L( "CSCPPatternPlugin::AuthenticationAttempt(): expireNow = %d"), expireNow ) ); |
493 if ( ( iExpiration == 0 ) && ( iMaxAttempts == 0) && ( expireNow == 0 ) ) |
413 if ( ( iExpiration == 0 ) && ( iMaxAttempts == 0) && ( expireNow == 0 ) ) |
494 { |
414 { |
495 return; // We have no interest in this call |
415 return; // We have no interest in this call |
496 } |
416 } |
497 |
417 |
508 iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors |
428 iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors |
509 failedCount++; |
429 failedCount++; |
510 |
430 |
511 if ( failedCount == iMaxAttempts - 1 ) |
431 if ( failedCount == iMaxAttempts - 1 ) |
512 { |
432 { |
513 // Warn the user. Only one attempt left. There's no use handling the error |
433 Dprint ( ( _L( "EDeviceLockAllowedMaxAtempts Failed" ) ) ); |
514 // so we'll just stay silent at this point on failure. |
434 aRetParams.AddtoFailedPolices(EDeviceLockAllowedMaxAtempts); |
515 TRAP_IGNORE( |
|
516 HBufC16* resText = NULL; |
|
517 resText = LoadResourceL( R_SET_SEC_CODE_WARNING_ATTEMPTS_LEFT ); |
|
518 FormatResourceString(*resText); |
|
519 CleanupStack::PushL( resText ); |
|
520 |
|
521 TPtr16 bufDes = resText->Des(); |
|
522 |
|
523 CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC(); |
|
524 |
|
525 TRequestStatus status; |
|
526 note->ShowConfirmationQueryL(status, |
|
527 bufDes, |
|
528 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
529 R_QGN_NOTE_WARNING_ANIM ); |
|
530 User::WaitForRequest( status ); |
|
531 |
|
532 CleanupStack::PopAndDestroy( note ); |
|
533 |
|
534 CleanupStack::PopAndDestroy( resText ); |
|
535 ); |
|
536 } |
435 } |
537 else if ( failedCount >= iMaxAttempts ) |
436 else if ( failedCount >= iMaxAttempts ) |
538 { |
437 { |
539 // Try to wipe the device |
438 // Try to wipe the device |
540 TRAPD( err, WipeDeviceL( aRetParams ) ); |
439 TRAPD( err, WipeDeviceL( aRetParams ) ); |
|
440 |
541 if ( err != KErrNone ) |
441 if ( err != KErrNone ) |
542 { |
442 { |
543 Dprint( ( _L( "CSCPPatternPlugin::\ |
443 Dprint( ( _L( "CSCPPatternPlugin::\ |
544 AuthenticationAttempt(): Wipe FAILED :%d"), err ) ); |
444 AuthenticationAttempt(): Wipe FAILED :%d"), err ) ); |
545 } |
445 } |
559 // |
459 // |
560 // Status : Approved |
460 // Status : Approved |
561 // ---------------------------------------------------------------------------- |
461 // ---------------------------------------------------------------------------- |
562 // |
462 // |
563 void CSCPTimestampPlugin::SuccessfulAuthenticationL( CSCPParamObject& aParam, |
463 void CSCPTimestampPlugin::SuccessfulAuthenticationL( CSCPParamObject& aParam, |
564 CSCPParamObject*& aRetParams ) |
464 CSCPParamObject& aRetParams ) |
565 { |
465 { |
|
466 Dprint( (_L("CSCPTimestampPlugin::IsAfter()..enter") )); |
566 // Reset the failed attempts -counter |
467 // Reset the failed attempts -counter |
567 if ( iMaxAttempts > 0 ) |
468 if ( iMaxAttempts > 0 ) |
568 { |
469 { |
569 iConfiguration->Set( KSCPFailedAttempts, 0 ); |
470 iConfiguration->Set( KSCPFailedAttempts, 0 ); |
570 } |
471 } |
574 aParam.Get( KSCPParamContext, context ); // ignore errors |
475 aParam.Get( KSCPParamContext, context ); // ignore errors |
575 |
476 |
576 // Check if immediate expiration is set |
477 // Check if immediate expiration is set |
577 TInt expireNow = 0; |
478 TInt expireNow = 0; |
578 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
479 iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors |
579 |
480 Dprint( ( _L( "CSCPPatternPlugin::SuccessfulAuthenticationL(): expireNow = %d, iExpiration =%d"), expireNow,iExpiration ) ); |
580 // Check if the code should be changed now |
481 // Check if the code should be changed now |
581 if ( ( context != KSCPContextChangePsw ) && |
482 if ( ( context != KSCPContextChangePsw ) && |
582 ( ( iExpiration > 0 ) || ( expireNow ) ) ) |
483 ( ( iExpiration > 0 ) || ( expireNow ) ) ) |
583 { |
484 { |
584 if ( ( IsAfter( KSCPLastChangeTime, iExpiration, KSCPTypeDays ) == KSCPIsAfter ) || |
485 if ( ( IsAfter( KSCPLastChangeTime, iExpiration, KSCPTypeDays ) == KSCPIsAfter ) || |
585 ( expireNow ) ) |
486 ( expireNow ) ) |
586 { |
487 { |
587 // Force password change |
488 Dprint ( ( _L( "EDeviceLockPasscodeExpiration Failed" ) ) ); |
588 |
489 aRetParams.AddtoFailedPolices(EDeviceLockPasscodeExpiration); |
589 HBufC16* resText = NULL; |
490 aRetParams.Set( KSCPParamStatus, KErrSCPInvalidCode ); |
590 TRAPD( err, resText = LoadResourceL( R_SET_SEC_CODE_AGING ) ); |
491 } |
591 FormatResourceString(*resText); |
492 } |
592 if (err == KErrNone) // If this fails, go on anyway to signal the psw change |
493 Dprint( (_L("CSCPTimestampPlugin::IsAfter()..exit") )); |
593 { |
494 } |
594 TPtr16 bufDes = resText->Des(); |
495 |
595 TRequestStatus userResponse; |
|
596 |
|
597 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
598 TRAP_IGNORE( |
|
599 note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
|
600 note->ShowNoteL(userResponse, EAknGlobalWarningNote, |
|
601 bufDes); |
|
602 ); |
|
603 |
|
604 // Wait for the User Response |
|
605 User::WaitForRequest(userResponse); |
|
606 CleanupStack::PopAndDestroy(note); |
|
607 |
|
608 delete resText; |
|
609 } |
|
610 |
|
611 // Refill the parameters to inform the client that the password |
|
612 // should be changed. |
|
613 aRetParams = CSCPParamObject::NewL(); |
|
614 aRetParams->Set( KSCPParamAction, KSCPActionForceChange ); |
|
615 } |
|
616 } |
|
617 } |
|
618 |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
496 // ---------------------------------------------------------------------------- |
621 // CSCPTimestampPlugin::IsAfter() |
497 // CSCPTimestampPlugin::IsAfter() |
622 // |
498 // |
623 // |
499 // |
624 // Status : Approved |
500 // Status : Approved |
631 TTime curTime; |
507 TTime curTime; |
632 curTime.UniversalTime(); |
508 curTime.UniversalTime(); |
633 |
509 |
634 TBuf<KSCPMaxInt64Length> savedTimeBuf; |
510 TBuf<KSCPMaxInt64Length> savedTimeBuf; |
635 TInt64 savedTime; |
511 TInt64 savedTime; |
|
512 Dprint( ( _L( "CSCPPatternPlugin::IsAfter: aConfID value is :%d"), aConfID ) ); |
636 ret = iConfiguration->Get( aConfID, savedTimeBuf ); |
513 ret = iConfiguration->Get( aConfID, savedTimeBuf ); |
637 if ( ret == KErrNone ) |
514 if ( ret == KErrNone ) |
638 { |
515 { |
639 Dprint( (_L("CSCPTimestampPlugin::IsAfter() iConfiguration->Get == KErrNone") )); |
516 Dprint( (_L("CSCPTimestampPlugin::IsAfter() iConfiguration->Get == KErrNone") )); |
640 TLex lex( savedTimeBuf ); |
517 TLex lex( savedTimeBuf ); |
693 // Status : Approved |
570 // Status : Approved |
694 // ---------------------------------------------------------------------------- |
571 // ---------------------------------------------------------------------------- |
695 // |
572 // |
696 void CSCPTimestampPlugin::ConfigurationQuery( TInt aParamID, |
573 void CSCPTimestampPlugin::ConfigurationQuery( TInt aParamID, |
697 CSCPParamObject& aParam, |
574 CSCPParamObject& aParam, |
698 CSCPParamObject*& aRetParams ) |
575 CSCPParamObject& aRetParams ) |
699 { |
576 { |
700 // First check if this is our ID |
577 // First check if this is our ID |
701 if ( ( aParamID == RTerminalControl3rdPartySession::EPasscodeExpiration ) || |
578 if ( ( aParamID == RTerminalControl3rdPartySession::EPasscodeExpiration ) || |
702 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeTolerance ) || |
579 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeTolerance ) || |
703 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeInterval ) || |
580 ( aParamID == RTerminalControl3rdPartySession::EPasscodeMinChangeInterval ) || |
808 else |
685 else |
809 { |
686 { |
810 // Something wrong, and this is our parameter. Signal an error |
687 // Something wrong, and this is our parameter. Signal an error |
811 ret = KErrArgument; |
688 ret = KErrArgument; |
812 } |
689 } |
813 |
690 |
814 TRAPD( err, aRetParams = CSCPParamObject::NewL() ); |
691 aRetParams.Set( KSCPParamStatus, ret ); |
815 if ( err == KErrNone ) // If we can't create a paramObject, there's nothing we can do |
692 |
816 { |
693 if ( setPrivateStorage ) |
817 aRetParams->Set( KSCPParamStatus, ret ); |
694 { |
818 if ( setPrivateStorage ) |
695 aRetParams.Set( KSCPParamStorage, KSCPStoragePrivate ); |
819 { |
696 } |
820 aRetParams->Set( KSCPParamStorage, KSCPStoragePrivate ); |
697 } |
821 } |
698 } |
822 } |
|
823 } |
|
824 } |
|
825 |
|
826 |
|
827 |
699 |
828 // ---------------------------------------------------------------------------- |
700 // ---------------------------------------------------------------------------- |
829 // CSCPTimestampPlugin::WipeDeviceL() |
701 // CSCPTimestampPlugin::WipeDeviceL() |
830 // |
702 // |
831 // |
703 // |
832 // Status : Approved |
704 // Status : Approved |
833 // ---------------------------------------------------------------------------- |
705 // ---------------------------------------------------------------------------- |
834 // |
706 // |
835 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject*& aRetParams ) |
707 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject& aRetParams ) |
836 { |
708 { |
837 (void)aRetParams; |
|
838 |
|
839 // First try to format other local drives than C: |
709 // First try to format other local drives than C: |
840 RRfsClient rfsClient; |
710 RRfsClient rfsClient; |
841 |
711 |
842 TInt ret = rfsClient.Connect(); |
712 TInt ret = rfsClient.Connect(); |
843 |
713 |
888 //Loop through all drives except phonem memory drive |
758 //Loop through all drives except phonem memory drive |
889 for (TInt i(0); i<driveListLen; ++i) |
759 for (TInt i(0); i<driveListLen; ++i) |
890 { |
760 { |
891 if (driveList[i]) |
761 if (driveList[i]) |
892 { |
762 { |
893 driveNumber = TDriveNumber(i); |
763 driveNumber = TDriveNumber(i); |
894 if (phoneMemoryDrive != driveNumber) |
764 if (phoneMemoryDrive != driveNumber) |
895 { |
765 { |
896 TBuf<KSCPFormatScriptMaxLen> formatScript; |
766 TBuf<KSCPFormatScriptMaxLen> formatScript; |
897 TChar driveLetter; |
767 TChar driveLetter; |
898 RFs::DriveToChar(i,driveLetter); |
768 RFs::DriveToChar(i,driveLetter); |
899 formatScript.Format(KSCPFormatScript, (TUint)driveLetter ); |
769 formatScript.Format(KSCPFormatScript, (TUint)driveLetter ); |
900 Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL(): Formatting %c:"), driveLetter ) ); |
770 ret = rfsClient.RunScriptInDescriptor(formatScript); |
901 |
771 } |
902 ret = rfsClient.RunScriptInDescriptor(formatScript); |
|
903 |
|
904 if ( ret != KErrNone ) |
|
905 { |
|
906 Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL():\ |
|
907 FAILED to format %c: %d"), driveLetter, ret ) ); |
|
908 } |
|
909 } |
|
910 } |
772 } |
911 } |
773 } |
912 |
774 |
913 CleanupStack::PopAndDestroy(); |
775 CleanupStack::PopAndDestroy(); |
914 #endif //RD_MULTIPLE_DRIVE |
776 #endif //RD_MULTIPLE_DRIVE |
1029 } |
891 } |
1030 |
892 |
1031 return ret; |
893 return ret; |
1032 } |
894 } |
1033 |
895 |
1034 |
|
1035 |
|
1036 // ---------------------------------------------------------------------------- |
|
1037 // CSCPTimestampPlugin::GetResource |
|
1038 // GetResource |
|
1039 // |
|
1040 // Status : Approved |
|
1041 // ---------------------------------------------------------------------------- |
|
1042 // |
|
1043 |
|
1044 TInt CSCPTimestampPlugin::GetResource() |
|
1045 { |
|
1046 Dprint( (_L("CSCPTimestampPlugin::GetResource()") )); |
|
1047 // The resource has to be loaded manually since this is not an application. |
|
1048 |
|
1049 // Build the resource file name and localize it |
|
1050 TFileName resourceFile; |
|
1051 resourceFile.Append( KDriveZ ); |
|
1052 resourceFile.Append( KSCPTimestampPluginResFilename ); |
|
1053 BaflUtils::NearestLanguageFile( *iFsSession, resourceFile ); |
|
1054 |
|
1055 TRAPD( err, iResFile.OpenL( *iFsSession, resourceFile ) ); |
|
1056 |
|
1057 if ( err == KErrNone ) |
|
1058 { |
|
1059 TRAP( err, iResFile.ConfirmSignatureL() ); |
|
1060 } |
|
1061 |
|
1062 return err; |
|
1063 } |
|
1064 |
|
1065 |
|
1066 // ---------------------------------------------------------------------------- |
|
1067 // CSCPTimestampPlugin::LoadResourceLC |
|
1068 // |
|
1069 // |
|
1070 // Status : Approved |
|
1071 // ---------------------------------------------------------------------------- |
|
1072 // |
|
1073 HBufC16* CSCPTimestampPlugin::LoadResourceL( TInt aResId ) |
|
1074 { |
|
1075 if ( !iResOpen ) |
|
1076 { |
|
1077 User::Leave( KErrNotReady ); |
|
1078 } |
|
1079 |
|
1080 Dprint( (_L("CSCPTimestampPlugin::LoadResourceL()") )); |
|
1081 |
|
1082 // Load the actual resource |
|
1083 HBufC8* readBuffer = iResFile.AllocReadLC( aResId ); |
|
1084 |
|
1085 // As we are expecting HBufC16 |
|
1086 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(), |
|
1087 ( readBuffer->Length() + 1 ) >> 1 ); |
|
1088 |
|
1089 HBufC16* textBuffer = HBufC16::NewL( ptrReadBuffer.Length() ); |
|
1090 |
|
1091 *textBuffer = ptrReadBuffer; |
|
1092 |
|
1093 FormatResourceString(*textBuffer); |
|
1094 CleanupStack::PopAndDestroy( readBuffer ); |
|
1095 |
|
1096 return textBuffer; |
|
1097 } |
|
1098 |
|
1099 // ---------------------------------------------------------------------------- |
|
1100 // CSCPTimestampPlugin::FormatResourceString |
|
1101 // The buffer that is passed is formatted to have only %i as a format specifier instead of %N or %0N etc. |
|
1102 // |
|
1103 // Status : Approved |
|
1104 // ---------------------------------------------------------------------------- |
|
1105 // |
|
1106 void CSCPTimestampPlugin::FormatResourceString(HBufC16 &aResStr) |
|
1107 { |
|
1108 TInt pos = 0; |
|
1109 TInt flag = 0; |
|
1110 TPtr16 bufPtr = aResStr.Des(); |
|
1111 _LIT (mess1, "%N"); |
|
1112 _LIT (mess2, "%i"); |
|
1113 _LIT (mess3, "%0N"); |
|
1114 _LIT (mess4, "%1N"); |
|
1115 |
|
1116 while ((pos = bufPtr.Find(mess1)) !=KErrNotFound) |
|
1117 { |
|
1118 bufPtr.Replace(pos,2,mess2); |
|
1119 flag = 1; |
|
1120 break; |
|
1121 } |
|
1122 |
|
1123 if(flag == 0) |
|
1124 { |
|
1125 while ((pos = bufPtr.Find(mess3)) != KErrNotFound) |
|
1126 { |
|
1127 bufPtr.Replace(pos,3,mess2); |
|
1128 } |
|
1129 |
|
1130 while ((pos = bufPtr.Find(mess4)) != KErrNotFound) |
|
1131 { |
|
1132 bufPtr.Replace(pos,3,mess2); |
|
1133 } |
|
1134 } |
|
1135 } |
|
1136 |
|
1137 // End of File |
896 // End of File |