terminalsecurity/SCP/SCPTimestampPlugin/src/SCPUserInf.cpp
branchRCL_3
changeset 26 19bba8228ff0
child 27 5cc2995847ea
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
       
     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: CSCPUserInf implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "SCPUserInf.h"
       
    19 #include <SCPTimestampPluginLang.rsg>
       
    20 
       
    21 #include <AknGlobalNote.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include "SCPDebug.h"
       
    24 
       
    25 #include <hal.h>
       
    26 // For wipe
       
    27 #include <starterclient.h>
       
    28 #include <syslangutil.h>
       
    29 #include <rfsClient.h>
       
    30 #include "DMUtilClient.h"
       
    31 CSCPUserInf::CSCPUserInf() :
       
    32     CActive(EPriorityStandard) // Standard priority
       
    33     {
       
    34     }
       
    35 
       
    36 CSCPUserInf* CSCPUserInf::NewLC()
       
    37     {
       
    38     CSCPUserInf* self = new (ELeave) CSCPUserInf();
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL();
       
    41     return self;
       
    42     }
       
    43 
       
    44 CSCPUserInf* CSCPUserInf::NewL()
       
    45     {
       
    46     CSCPUserInf* self = CSCPUserInf::NewLC();
       
    47     CleanupStack::Pop(); // self;
       
    48     return self;
       
    49     }
       
    50 
       
    51 void CSCPUserInf::ConstructL()
       
    52     {
       
    53     //User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
       
    54     Dprint( (_L("CSCPUserInf::ConstructL()") ));
       
    55     CActiveScheduler::Add(this); // Add to scheduler
       
    56     }
       
    57 
       
    58 CSCPUserInf::~CSCPUserInf()
       
    59     {
       
    60     Cancel(); // Cancel any request, if outstanding
       
    61     //iTimer.Close(); // Destroy the RTimer object
       
    62     // Delete instance variables if any
       
    63 	if (idispText)
       
    64     delete idispText;
       
    65     }
       
    66 
       
    67 void CSCPUserInf::DoCancel()
       
    68     {
       
    69     //iTimer.Cancel();
       
    70     }
       
    71 
       
    72 void CSCPUserInf::StartL(TDesC& aString)
       
    73     {
       
    74 	idispText = HBufC16::NewL( aString.Length() );
       
    75     idispText->Des().Append(aString);
       
    76     Cancel(); // Cancel any request, just to be sure
       
    77     iState = EGlobalConf;
       
    78     Dprint( (_L("CSCPUserInf::StartL()") ));
       
    79     TRequestStatus* aStatus = &iStatus;
       
    80     User::RequestComplete(aStatus, KErrNone);
       
    81     SetActive(); // Tell scheduler a request is active
       
    82     }
       
    83 	
       
    84 void CSCPUserInf::DoRfsL()
       
    85 	{
       
    86 	Cancel(); // Cancel any request, just to be sure
       
    87     iState = ERfs;
       
    88     Dprint( (_L("CSCPUserInf::DoRfsL()") ));
       
    89     TRequestStatus* aStatus = &iStatus;
       
    90     User::RequestComplete(aStatus, KErrNone);
       
    91 	// This will give the control back to SecUi
       
    92     SetActive(); // Tell scheduler a request is active
       
    93     }
       
    94 
       
    95 void CSCPUserInf::RunL()
       
    96     {
       
    97 	
       
    98     Dprint( (_L("CSCPUserInf::RunL()") ));
       
    99 	if (iState == EGlobalConf)
       
   100 	{
       
   101 	Dprint( (_L("CSCPUserInf::EGlobalConf") ));
       
   102     TRAP_IGNORE(                                            
       
   103 		TRequestStatus status;
       
   104 		    TPtr16 bufDes = idispText->Des();                    
       
   105 		CAknGlobalNote* lInfoNote = CAknGlobalNote :: NewLC();
       
   106 		lInfoNote->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY__OK);
       
   107 		lInfoNote->SetAnimation(R_QGN_NOTE_WARNING_ANIM);
       
   108 		lInfoNote->ShowNoteL(status, EAknGlobalInformationNote, bufDes);
       
   109 		lInfoNote->SetPriority(ECoeWinPriorityAlwaysAtFront + 1);
       
   110 		    User::WaitForRequest( status );
       
   111 		CleanupStack::PopAndDestroy(1); // note
       
   112 			);
       
   113 	}
       
   114 	else if (iState == ERfs)
       
   115 	{
       
   116 	Dprint( (_L("CSCPUserInf::ERfs") ));
       
   117     // Mark MMC card to be formatted also in bootup
       
   118 	RDMUtil util;
       
   119 	if ( util.Connect() == KErrNone )
       
   120 	    {        
       
   121         TInt err = util.MarkMMCWipe();
       
   122 		Dprint( (_L("CSCPUserInf::rfsClient.markmmc for wipe") ));
       
   123         if( err != KErrNone )
       
   124         	{
       
   125         	// even if not successfull we try to reset as much as possible -> continue
       
   126         	Dprint( ( _L( "CSCPUserInf::WipeDeviceL(): FAILED to mark MMC wipe: %d"), err ) );        	
       
   127         	}    
       
   128         util.Close();
       
   129 	    }	
       
   130 	
       
   131 	// In case of deep level RFS, set the default language code
       
   132 	// here, before RFS reboot.
       
   133 	
       
   134 	TInt language( 0 );
       
   135 	Dprint( (_L("CSCPUserInf::Language") ));
       
   136 	// If default language is not found, we reset anyway
       
   137 	if ( SysLangUtil::GetDefaultLanguage( language ) == KErrNone )
       
   138 	{
       
   139 	HAL::Set( HALData::ELanguageIndex, language );
       
   140 	Dprint( (_L("CSCPUserInf::HAL,set") ));
       
   141 	}
       
   142 
       
   143     // Reboot with RFS reason  
       
   144     Dprint( (_L("CSCPUserInf::rfsClient.Reboot with RFS reason") ));
       
   145 	RStarterSession startersession;
       
   146 	if( startersession.Connect() == KErrNone )
       
   147 		{
       
   148 		startersession.Reset( RStarterSession::EDeepRFSReset );
       
   149 		Dprint( (_L("CSCPUserInf::rfsClient.starter reset") ));
       
   150 		startersession.Close();
       
   151 		}
       
   152     
       
   153     TInt ret;	
       
   154     if ( ret != KErrNone )
       
   155 		{
       
   156 		Dprint( ( _L( "CSCPUserInf::WipeDeviceL(): Rfs FAILED: %d"), ret ) );
       
   157 		}  
       
   158 	Dprint( (_L("CSCPUserInf::out of ERfs") ));
       
   159 	}	
       
   160     }
       
   161 	
       
   162 TInt CSCPUserInf::RunError(TInt /*aError */)
       
   163     {
       
   164     return KErrNone;
       
   165     }