deviceencryption/DevEncUi/inc/DevEncUiEncryptionOperator.h
branchRCL_3
changeset 20 491b3ed49290
parent 19 95243422089a
child 21 65326cf895ed
equal deleted inserted replaced
19:95243422089a 20:491b3ed49290
     1 /*
       
     2 * Copyright (c) 2005 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:  Performs required preparations before encryption 
       
    15 *               operations can place.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef DEVENCUI_ENCRYPTIONOPERATOR_H_
       
    20 #define DEVENCUI_ENCRYPTIONOPERATOR_H_
       
    21 
       
    22 //INCLUDES
       
    23 
       
    24 //System includes
       
    25 #include <avkon.rsg>
       
    26 #include <e32base.h>
       
    27 #include <badesca.h> // for CDesCArrayFlat
       
    28 
       
    29 //User Includes
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CDevEncUiMemoryEntity;
       
    33 class CEikonEnv;
       
    34 class CAknViewAppUi;
       
    35 class CRepository;
       
    36 
       
    37 class CDevEncUiEncryptionOperator: public CBase
       
    38     {
       
    39     public:
       
    40     // Constructors and destructor
       
    41         static CDevEncUiEncryptionOperator* NewL( CEikonEnv& aEikonEnv,
       
    42                                                   CAknViewAppUi& aAppUi,
       
    43                                                   CRepository*& aCrSettings );
       
    44         static CDevEncUiEncryptionOperator* NewLC( CEikonEnv& aEikonEnv,
       
    45                                                    CAknViewAppUi& aAppUi,
       
    46                                                    CRepository*& aCrSettings );
       
    47         ~CDevEncUiEncryptionOperator();
       
    48 
       
    49     // Functions related to encryption
       
    50         void HandlePhoneMemEncryptRequestL( CDevEncUiMemoryEntity* aMem, CDevEncUiMemoryEntity* aPrimaryMem = NULL );
       
    51 
       
    52         void HandleMmcEncryptRequestL( CDevEncUiMemoryEntity* aMem,
       
    53                                        TInt aCommand );
       
    54 
       
    55         void HandleMmcDecryptRequestL( CDevEncUiMemoryEntity* aMem,
       
    56                                        TInt aCommand );
       
    57 
       
    58         void DestroyKeyQueryL( TBool aShowMmcNote );
       
    59         
       
    60         void BatteryStatusCallback();
       
    61 
       
    62         void SuggestMmcEncryptionL( CDevEncUiMemoryEntity* aMem );
       
    63 
       
    64         void SuggestMmcDecryptionL( CDevEncUiMemoryEntity* aMem );
       
    65 
       
    66         void SuggestMmcImportKeyL( CDevEncUiMemoryEntity* aMem,
       
    67                                    TBool aFirstAttempt );
       
    68         
       
    69         void ShowWrongKeyNoteL();
       
    70 
       
    71         /**
       
    72          * Displays an error note.
       
    73          * @param aResourceId the error text to display
       
    74          */
       
    75         void ErrorNoteL( TInt aResourceId,
       
    76                          TBool aWaitingNote = ETrue );
       
    77 
       
    78         /**
       
    79          * Displays an information note.
       
    80          * @param aResourceId the text to display
       
    81          */
       
    82         void InfoNoteL( TInt aResourceId,
       
    83                         TBool aWaitingNote = EFalse );
       
    84 
       
    85     private:
       
    86         CDevEncUiEncryptionOperator( CEikonEnv& aEikonEnv,
       
    87                                      CAknViewAppUi& aAppUi,
       
    88                                      CRepository*& aCrSettings );
       
    89 
       
    90         // Second-phase constructor
       
    91         void ConstructL();
       
    92 
       
    93         TBool PrepareEncryptionL();
       
    94 
       
    95         TBool PrepareDecryptionL();
       
    96 
       
    97         void SetPowerMenuStatusL( TBool aOpen );
       
    98 
       
    99         TBool MessageQueryL( TInt aResourceId,
       
   100                              TInt aSoftKeysId = R_AVKON_SOFTKEYS_OK_CANCEL );
       
   101 
       
   102         TBool QueryDialogL( TInt aResourceId,
       
   103                             TInt aSoftKeysId = R_AVKON_SOFTKEYS_OK_CANCEL );
       
   104 
       
   105         TBool DataQueryDialogL( TDes& aResult,
       
   106                                 TInt aPromptResourceId,
       
   107                                 TInt aMaxLength );
       
   108 
       
   109         /**
       
   110          * Displays a query dialog to let the user enter a password.
       
   111          * @param aPromptResourceId the prompt text to display
       
   112          * @param aPassword On return, contains the password
       
   113          * @return ETrue if the user entered a password, EFalse if
       
   114          *   the dialog was cancelled.
       
   115          */
       
   116         TBool PasswordQueryL( TInt aPromptResourceId,
       
   117                               TDes8& aPassword );
       
   118 
       
   119         /**
       
   120          * Checks if there's enough battery power to update.
       
   121          * @return ETrue if battery OK or charger connected
       
   122          */
       
   123         TBool CheckBatteryL();
       
   124 
       
   125         /**
       
   126          * Prompts the user for a key name and password, then creates
       
   127          * a pkcs#5 encrypted key using the common utility component.
       
   128          * @return ETrue if the key was created and saved successfully
       
   129          */
       
   130         TBool CreateAndSaveKeyL();
       
   131 
       
   132         /**
       
   133          * Lets the user select a key and enter a password, then loads
       
   134          * the specified key and takes it in use using the common utility
       
   135          * component.
       
   136          * @return ETrue if the key was loaded and set successfully
       
   137          */
       
   138         TBool LoadAndSetKeyL();
       
   139 
       
   140         /**
       
   141          * Creates a random key and sets it in the security driver.
       
   142          * @return ETrue if the key was created and set successfully
       
   143          */
       
   144         TBool CreateKeyL();
       
   145 
       
   146         /**
       
   147          * Resets the key in the security driver (fills with null chars).
       
   148          * Before destroying the key, a confirmation query is shown to
       
   149          * the user.
       
   150          */
       
   151         void DestroyKeyL();
       
   152 
       
   153         void RemountMmcL();
       
   154         
       
   155         TInt CheckMMCStatus();
       
   156 
       
   157         // For testing, remove
       
   158         void CheckNotesL();
       
   159         void CheckNotesWithHeaderL();
       
   160 
       
   161 
       
   162     // data
       
   163         /** Not owned */
       
   164         CEikonEnv& iEikEnv;
       
   165 
       
   166         /** Not owned */
       
   167         CAknViewAppUi& iAppUi;
       
   168         
       
   169         /** Owned */
       
   170         CDesCArrayFlat* iListQueryItemArray;
       
   171         
       
   172         /** Not owned */
       
   173         CRepository*& iCrSettings;
       
   174     };
       
   175 
       
   176 #endif /* DEVENCUI_ENCRYPTIONOPERATOR_H_ */
       
   177 
       
   178 // END OF FILE