pkiutilities/SecModUI/inc/SecModUIModel.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:   Declaration of the CSecModUIModel class 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CSECMODUIMODEL_H
       
    20 #define CSECMODUIMODEL_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "SecModUI.h"
       
    24 #include <e32base.h>
       
    25 #include <bamdesca.h>
       
    26 #include <ct/rmpointerarray.h>
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KPinGIndex = 0; // PIN-G should be always first AO in the AO list.
       
    30 const TInt KMaxSettItemSize = 200;
       
    31 
       
    32 const TInt KPinGSettIndex = 0;
       
    33 const TInt KPinNrSettIndex = 1;
       
    34 
       
    35 const TUid KUidSecMod = { 0x101F8668 };
       
    36 
       
    37 // Panic strings
       
    38 _LIT(KPanicNullPointer, "SecModUI: invalid pointer");
       
    39 _LIT(KPanicIndexOutOfRange, "SecModUI: array indexed out of range");
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CUnifiedKeyStore;
       
    43 class MCTAuthenticationObject;
       
    44 class MCTAuthenticationObjectList;
       
    45 class CSecModUISyncWrapper;
       
    46 class CEikTextListBox;
       
    47 class MCTKeyStore;
       
    48 class MCTToken;
       
    49 class CEikonEnv;
       
    50 
       
    51 
       
    52 // DATA TYPES
       
    53 enum TSecModPanicCode
       
    54     {
       
    55     EPanicNullPointer,
       
    56     EPanicIndexOutOfRange
       
    57     };
       
    58 
       
    59 // FUNCTION PROTOTYPES
       
    60 GLREF_C void Panic( TInt aPanic );
       
    61 
       
    62 // CLASS DECLARATION
       
    63 
       
    64 /**
       
    65 *  class CSecModUIModel
       
    66 *  Model of the application
       
    67 *
       
    68 *  @lib SecModUI.lib
       
    69 *  @since Series 60 3.0
       
    70 */
       
    71 class CSecModUIModel : public CBase, public MSecModUI
       
    72     {
       
    73     public:  // Constructors and destructLoadTokenLabelsLor
       
    74         
       
    75         /**
       
    76         * Two-phased constructor.
       
    77         */        
       
    78         static CSecModUIModel* NewL();
       
    79                 
       
    80         /**
       
    81         * Destructor.
       
    82         */
       
    83         virtual ~CSecModUIModel();
       
    84 
       
    85     public: // New functions
       
    86         
       
    87         /**
       
    88         * Activates title to the title pane        
       
    89         * @param aTitle Title to be activated
       
    90         * @return void
       
    91         */
       
    92         void ActivateTitleL(const TDesC& aTitle) const;
       
    93         
       
    94         /**
       
    95         * Activates current tokens label to the title pane                
       
    96         * @return void
       
    97         */
       
    98         void ActivateTokenLabelToTitleL() const;
       
    99     
       
   100         /**
       
   101         * Initializes unified keystore        
       
   102         * @return Error value
       
   103         */
       
   104         TInt InitializeKeyStoreL();
       
   105         
       
   106         /**
       
   107         * Load labels of the tokens to the listbox        
       
   108         * @param aListBox Listbox
       
   109         * @return void
       
   110         */        
       
   111         void LoadTokenLabelsL(CEikTextListBox& aListBox);
       
   112         
       
   113         /**
       
   114         * Checks that does active token have also signing code(s)
       
   115         * @param aItemArray contains localised stings 
       
   116         * @return void
       
   117         */
       
   118         void CheckCodeViewStringsL(MDesCArray& aItemArray);
       
   119         
       
   120         /**
       
   121         * Opens and activates token        
       
   122         * @param aTokenIndex Index of the token to be opened.
       
   123         * @return void
       
   124         */
       
   125         void OpenTokenL(TInt aTokenIndex);
       
   126         
       
   127         /**
       
   128         * Opens authentication object view        
       
   129         * @param aIndex 0 is access code view
       
   130         *               1 is signing code view
       
   131         * @return void
       
   132         */
       
   133         void OpenAuthObjViewL(TInt aIndex);
       
   134         
       
   135         /**
       
   136         * Closes authentication object       
       
   137         * @param aIndex Index of the AO to be closed.
       
   138         * @return void
       
   139         */
       
   140         void CloseAuthObjL(TInt aIndex);
       
   141         
       
   142         /**
       
   143         * Loads PIN-NR labels to the listbox        
       
   144         * @param aListBox 
       
   145         * @param aShowBlockedNote If ETrue, shows code blocked if code is blocked.
       
   146         * @return void 
       
   147         */
       
   148         void LoadPinNRLabelsL(CEikTextListBox& aListBox, TBool aShowBlockedNote);
       
   149         
       
   150         /**
       
   151         * Loads items of the access code view list         
       
   152         * @param aListBox where items are appended.
       
   153         * @return void
       
   154         */
       
   155         void LoadPinGItemsL(CEikTextListBox& aListBox);
       
   156         
       
   157         /**
       
   158         * Writes AO status item to the descriptor        
       
   159         * @param aIndex Index of the authentication object
       
   160         * @param aItem Descriptor where status is written.
       
   161         * @param aShowBlockedNote If ETrue, shows code blocked if code is blocked.
       
   162         * @return void
       
   163         */
       
   164         void PINStatusItemL(
       
   165             TInt aIndex, TDes& aItem, TBool aShowBlockedNote) const;
       
   166         
       
   167         /**
       
   168         * Writes AO request status to the descriptor
       
   169         * @param aIndex Index of the authentication object
       
   170         * @param aItem Descriptor where status is written.
       
   171         * @return void
       
   172         */
       
   173         void PINRequestItemL(TInt aIndex, TDes& aItem) const;
       
   174         
       
   175         /**
       
   176         * Displays security module details dialog.        
       
   177         * @param aTokenIndex Index of the token, which details are shown.
       
   178         * @return void
       
   179         */
       
   180         void ViewSecModDetailsL(TInt aTokenIndex);
       
   181         
       
   182         /**
       
   183         * Displays details dialog of the active security module .                        
       
   184         * @return void
       
   185         */
       
   186         void ViewOpenedSecModDetailsL();
       
   187         
       
   188         /**
       
   189         * Deletes keystore        
       
   190         * @param aTokenIndex Index of the token to be deleted.
       
   191         * @return ETrue if keystore was deleted.
       
   192         */
       
   193         TBool DeleteKeyStoreL(TInt aTokenIndex);
       
   194         
       
   195         /**
       
   196         * Returns ETrue if token is deletable.
       
   197         * @param aTokenIndex Index of the token to be deleted.
       
   198         * @return ETrue / EFalse
       
   199         */
       
   200         TBool IsTokenDeletable(TInt aTokenIndex);
       
   201         
       
   202         /**
       
   203         * Launches change or unblock operation depending
       
   204         * of the status of the PIN-NR        
       
   205         * @param aIndex Index of the AO
       
   206         * @return ?description
       
   207         */
       
   208         void ChangeOrUnblockPinNrL(TInt aIndex);
       
   209         
       
   210         /**
       
   211         * Launches change or unblock operation depending
       
   212         * of the status of the PIN        
       
   213         * @param aIndex Index of the AO
       
   214         * @return ?description
       
   215         */
       
   216         void ChangeOrUnblockPinL(TInt aIndex);
       
   217         
       
   218         /**
       
   219         * Changes PIN-NR
       
   220         * @param aIndex Index of the AO
       
   221         * @return void
       
   222         */
       
   223         void ChangePinNrL(TInt aIndex);
       
   224         
       
   225         /**
       
   226         * Changes PIN
       
   227         * @param aIndex Index of the AO
       
   228         * @return void
       
   229         */
       
   230         void ChangePinL(TInt aIndex);
       
   231         
       
   232         /**
       
   233         * Unblocks PIN-NR
       
   234         * @param aIndex Index of the AO
       
   235         * @return void
       
   236         */
       
   237         void UnblockPinNrL(TInt aIndex);
       
   238         
       
   239         /**
       
   240         * Unblocks PIN
       
   241         * @param aIndex Index of the AO
       
   242         * @return void
       
   243         */
       
   244         void UnblockPinL(TInt aIndex);
       
   245         
       
   246         /**
       
   247         * Returns ETrue if PIN-NR is changeable.        
       
   248         * @param aIndex Index of the AO
       
   249         * @return ETrue / EFalse
       
   250         */
       
   251         TBool PinNrChangeable(TInt aIndex) const;
       
   252         
       
   253         /**
       
   254         * Returns ETrue if PIN is changeable.        
       
   255         * @param aIndex Index of the AO
       
   256         * @return ETrue / EFalse
       
   257         */
       
   258         TBool PinChangeable(TInt aIndex) const;
       
   259         
       
   260         /**
       
   261         * Returns ETrue if PIN-NR is unblockable.        
       
   262         * @param aIndex Index of the AO
       
   263         * @return ETrue / EFalse
       
   264         */
       
   265         TBool PinNrUnblockable(TInt aIndex) const;
       
   266         
       
   267         /**
       
   268         * Returns ETrue if PIN is unblockable.        
       
   269         * @param aIndex Index of the AO
       
   270         * @return ETrue / EFalse
       
   271         */
       
   272         TBool PinUnblockable(TInt aIndex) const;
       
   273         
       
   274         /**
       
   275         * Returns ETrue if PIN request can be disabled / enabled.        
       
   276         * @param aIndex Index of the AO
       
   277         * @return ETrue / EFalse
       
   278         */
       
   279         TBool PinRequestChangeable(TInt aIndex) const;
       
   280         
       
   281         /**
       
   282         * Returs ETrue if PIN is open.
       
   283         * @param aIndex Index of the AO
       
   284         * @return ?description
       
   285         */
       
   286         TBool PinOpen(TInt aIndex) const;
       
   287         
       
   288         /**
       
   289         * Disables / enables PIN depending on the status of the PIN.        
       
   290         * @param ?arg1 ?description
       
   291         * @return ?description
       
   292         */
       
   293         TInt ChangeCodeRequestL(TInt aIndex);
       
   294         
       
   295         /**
       
   296         * Shows confirmation query.        
       
   297         * @param aResourceId Id of the resource
       
   298         * @return Response of the user.
       
   299         */
       
   300         TInt ShowConfirmationQueryL(TInt aResourceId) const;
       
   301        
       
   302         /**
       
   303         * Shows confirmation note dialog.        
       
   304         * @param aResourceId Id of the resource
       
   305         * @return void
       
   306         */
       
   307         void ShowConfirmationNoteL(TInt aResourceId) const;
       
   308         
       
   309         /**
       
   310         * Shows information note dialog.        
       
   311         * @param aResourceId Id of the resource
       
   312         * @return void
       
   313         */
       
   314         void ShowInformationNoteL(TInt aResourceId, const TDesC& aString = KNullDesC) const;
       
   315         
       
   316         /**
       
   317         * Shows error note if needed.        
       
   318         * @param aError 
       
   319         * @return void
       
   320         */
       
   321         void ShowErrorNoteL(TInt aError) const;
       
   322         
       
   323         CSecModUISyncWrapper& Wrapper();            
       
   324         
       
   325         /**
       
   326          * Returns the number of security modules.
       
   327          */
       
   328         TInt SecurityModuleCount() const;
       
   329         
       
   330     private:
       
   331 
       
   332         /**
       
   333         * C++ default constructor.
       
   334         */        
       
   335         CSecModUIModel();
       
   336 
       
   337         /**
       
   338         * By default Symbian 2nd phase constructor is private.
       
   339         */
       
   340         void ConstructL();        
       
   341         
       
   342         void ResetAndDestroyCTObjects();
       
   343         
       
   344         void ResetAndDestroyAOs();
       
   345         
       
   346         void AddResourceFileL();
       
   347         
       
   348         void InitAuthObjectsL();
       
   349         
       
   350         void ListAuthObjectsL();
       
   351         
       
   352         void CreateSettingItem(const TDesC& aTitle, 
       
   353                                const TDesC& aValue,  
       
   354                                TDes& aItem) const;
       
   355         
       
   356         void AppendItemL(TDes& aMessage,
       
   357                          TInt aResItem, 
       
   358                          const TDesC& aValue, 
       
   359                          TInt aResNotDefined) const; 
       
   360          
       
   361         void AppendResourceL(TDes& aMessage, TInt aResource) const;
       
   362         
       
   363         void AppendResourceAndEnterL(TDes& aMessage, TInt aResource) const;
       
   364                         
       
   365         void AppendValueL(TDes& aMessage, 
       
   366                           const TDesC& aValue, 
       
   367                           TInt aResNotDefined) const;
       
   368         
       
   369         void AppendLocationL(TDes& aMessage, TUid aUid, TInt aItemRes=0) const;         
       
   370         
       
   371         void AppendPinNRsL( TDes& aMessage ) const;   
       
   372 
       
   373     private:    // Data
       
   374         // Resource file offsets		
       
   375 		TInt		iResourceFileOffset;
       
   376 		TInt        iResourceFileOffset2;
       
   377 		TInt        iResourceFileOffset3;
       
   378 		
       
   379 		CSecModUISyncWrapper* iWrapper; // owned             
       
   380 		
       
   381 		CEikonEnv* iEikEnv;
       
   382 		
       
   383 		/**
       
   384         * Crypto Token objects
       
   385         */
       
   386         CUnifiedKeyStore* iUnifiedKeyStore; // owned
       
   387         MCTKeyStore* iKeyStore; // not owned
       
   388         MCTAuthenticationObjectList*  iAOList; // owned, items not owned
       
   389         RMPointerArray<MCTAuthenticationObject> iAOArray; // items not owned		
       
   390 		                                         
       
   391         RMPointerArray<MCTKeyStore> iAOKeyStores; // items not owned       		                                         
       
   392     };
       
   393 
       
   394 #endif      // CSecModUIModel_H   
       
   395             
       
   396 // End of File