pkiutilities/CertmanUi/INC/CertmanuiCertificateHelper.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003-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 CCertManUICertificateHelper class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef  CERTMANUICERTIFICATEHELPER_H
       
    20 #define  CERTMANUICERTIFICATEHELPER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <pkixcertchain.h>          // for validation
       
    24 #include <e32std.h>
       
    25 #include "CertmanuiKeeper.h"
       
    26 #include "CertmanuiCommon.h"
       
    27 // FORWARD DECLARATIONS
       
    28 
       
    29 class CCertManUIKeeper;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 
       
    34 /**
       
    35 *
       
    36 */
       
    37 NONSHARABLE_CLASS( CCertManUICertificateHelper )
       
    38     {
       
    39     public:
       
    40         CCertManUICertificateHelper( CCertManUIKeeper& aKeeper );
       
    41 
       
    42         ~CCertManUICertificateHelper();
       
    43 
       
    44        /**
       
    45         * If CertLabel, Issuer and Owner length is over 80 characters, cut it down to 80
       
    46         * Returns the cut certificate field.
       
    47         */
       
    48         TPtrC CutCertificateField(TPtrC aField);
       
    49 
       
    50        /**
       
    51         * Check whether certificate is deletable
       
    52         * @param aIndex Index to certificate array
       
    53         * @param aIsCA Flag whether CA/User certificate is in use
       
    54         * @return ETrue if certificate is deletable
       
    55         */
       
    56         TBool IsCertificateDeletable(TInt aIndex, TInt aType)const;
       
    57 
       
    58        /**
       
    59         * Check whether one marked certificate is deletable
       
    60         * @param aListbox Pointer to active view's listbox
       
    61         * @param aIsCA Flag whether CA/User certificate is in use
       
    62         * @return ETrue if certificate is deletable
       
    63         */
       
    64         TBool IsOneMarkedCertificateDeletable(CEikColumnListBox* aListBox,
       
    65                                                 TInt aType) const;
       
    66 
       
    67        /**
       
    68         * Creates the whole of certificate details view
       
    69         * Appends strings from both resources and CertManAPI to one
       
    70         * message body text and displays it.
       
    71         */
       
    72         void MessageQueryViewDetailsL( TInt aIndex, TInt aType,
       
    73                                         CEikonEnv* aEikonEnv );
       
    74 
       
    75        /**
       
    76         * Checks if the certificate is corrupted
       
    77         * Checks the validity period of the certificate
       
    78         */
       
    79         void ValidateCertificateL(
       
    80             TInt aIndex, CCertificate* aDetails, const CCTCertInfo& aCertInfo, TInt aType);
       
    81 
       
    82        /**
       
    83         * Reads line from resources
       
    84         */
       
    85         void DetailsResourceL(HBufC& aMessage, TInt aResourceOne);
       
    86 
       
    87        /**
       
    88         * Deletes either certificate in focus if there are no marked items,
       
    89         * or deletes the marked items
       
    90         * Shows read-only information notes if certificates are not deletable
       
    91         * Returns ETrue if at least one certificate is deleted
       
    92         */
       
    93         TBool ConfirmationQueryDeleteCertL(TInt aType,
       
    94                                        CEikColumnListBox* aListBox);
       
    95 
       
    96        /**
       
    97         * Handle markable list command. Does nothing
       
    98         * if listbox is not markable or empty.
       
    99         */
       
   100         void HandleMarkableListCommandL( TInt aCommand, CEikColumnListBox* aListBox);
       
   101 
       
   102        /**
       
   103         * Displays Delete yes/no confirmation notes
       
   104         */
       
   105         TInt DisplayConfirmationLD(HBufC* aString);
       
   106 
       
   107        /**
       
   108         * Moves one key from one store to another
       
   109         */
       
   110         void MoveKeyL( const TCTKeyAttributeFilter& aFilter,
       
   111                        const TUid aSourceStore,
       
   112                        const TUid aTargetStore );
       
   113 
       
   114        /**
       
   115         * Moves one certificate from one store to another
       
   116         */
       
   117         void MoveCertL( CCTCertInfo& aEntry, TInt aPosition,
       
   118                         CEikColumnListBox* aListBox,
       
   119                         const TUid aSourceStore,
       
   120                         const TUid aTargetStore );
       
   121 
       
   122     private:
       
   123        /**
       
   124         * Appends a field that has string from resources and string from CertManAPI
       
   125         * to the details view message body
       
   126         */
       
   127         void DetailsFieldDynamicL(HBufC& aMessage, TPtrC aValue,
       
   128                                   TInt aResourceOne, TInt aResourceTwo);
       
   129 
       
   130        /**
       
   131         * Appends a field that has two strings from resources
       
   132         * to the details view message body
       
   133         */
       
   134         void DetailsFieldResourceL(HBufC& aMessage, TInt aResourceOne, TInt aResourceTwo);
       
   135 
       
   136        /**
       
   137         * Devides string to four characters blocks
       
   138         * and delimits them with space.
       
   139         * @param aInput String to devide
       
   140         * @param aOutput Descriptor where result is appended
       
   141         * @return void
       
   142         */
       
   143         void DevideToBlocks( const TDesC8& aInput, TPtr aOutput );
       
   144 
       
   145        /**
       
   146         * Displays the warning note for corrupted/expired/not yet valid certificate
       
   147         */
       
   148         void DisplayWarningNoteLD(HBufC* aString);
       
   149 
       
   150        /**
       
   151         * Checks if the X509 certificate is corrupted and the validity period of
       
   152         * the certificate. Display only one warning note, in the following order:
       
   153         * 1) Expired/Not yet valid
       
   154         * 2) Corrupted
       
   155         * 3) Not trusted
       
   156         * @param aDetails
       
   157         * @return
       
   158         */
       
   159         CArrayFixFlat<TValidationError>* ValidateX509CertificateL( CX509Certificate* aDetails );
       
   160 
       
   161        /**
       
   162         * Reads dynamic text from CertManAPI, if the string is empty
       
   163         * put a not defined text from the resource in its place
       
   164         */
       
   165         void DetailsDynamicL(HBufC& aMessage, TPtrC aValue, TInt aResourceOne);
       
   166 
       
   167        /**
       
   168         * Gets the certificate name (or No label/No subject) for the Confirmation note
       
   169         */
       
   170         TInt DeleteSingleItemQueryL(CCTCertInfo& aEntry);
       
   171 
       
   172        /**
       
   173         * Deletes one item from CertManAPI and from listbox
       
   174         */
       
   175         void DeleteSingleItemL(CCTCertInfo& aEntry,
       
   176                                TInt aPosition,
       
   177                                CEikColumnListBox* aListBox,
       
   178                                TInt aType);
       
   179 
       
   180        /**
       
   181         * Gets the certificate name (or No label/No subject) for the read-only note
       
   182         */
       
   183         void ReadOnlySingleItemNoteL(CCTCertInfo& aEntry);
       
   184 
       
   185 
       
   186        /**
       
   187         * Displays read-only information notes
       
   188         */
       
   189         void DisplayNoteLD(HBufC* aString);
       
   190 
       
   191        /**
       
   192         * Check if Disk space goes below critical level if allocating
       
   193         * more disk space.
       
   194         * @param aShowErrorNote If ETrue, a warning note is shown.
       
   195         * @param aBytesToWrite Amount of disk space to be allocated (use an
       
   196         * estimate if exact amount is not known).
       
   197         * @return ETrue if allocation would go below critical level.
       
   198         */
       
   199         static TBool FFSSpaceBelowCriticalLevelL
       
   200             ( TBool aShowErrorNote, TInt aBytesToWrite = 0 );
       
   201 
       
   202        /**
       
   203         * Returns usage of key
       
   204         * @param aCertEntry Certificate in handling.
       
   205         * @param aKeyLocation Where is key is being stored
       
   206         */
       
   207 
       
   208         TKeyUsagePKCS15 GetKeyUsageAndLocationL(CCTCertInfo* aCertEntry, TUid* aKeyLocation);
       
   209 
       
   210        /**
       
   211         * Set certificate/key location info to certificate details view
       
   212         * @param aMessage Certificate details string
       
   213         * @param aCertificate flag whether handling certificate or key
       
   214         * @param aLocUid The location UID of cert/key
       
   215         */
       
   216         void SetLocationInfoL(HBufC& aMessage, TBool aCertificate, TUid* aLocUid);
       
   217 
       
   218         /**
       
   219          * Helper function for MessageQueryViewDetailsL() member. Fills in
       
   220          * message body text for certificate details dialog.
       
   221          * @param aIndex Certificate index, from MessageQueryViewDetailsL().
       
   222          * @param aType Certificate type, from MessageQueryViewDetailsL().
       
   223          * @param aEikonEnv Pointer to EIKON environment, from MessageQueryViewDetailsL().
       
   224          * @param aMessage Message body text to be filled in.
       
   225          */
       
   226         void CreateMessageBodyTextL(TInt aIndex, TInt aType, CEikonEnv* aEikonEnv,
       
   227                 HBufC& aMessage);
       
   228 
       
   229     private:  //Data
       
   230 
       
   231         CCertManUIKeeper&   iKeeper;
       
   232 
       
   233     };
       
   234 
       
   235 #endif //   CERTMANUICERTIFICATEHELPER_H
       
   236 
       
   237 // End of File