appinstaller/AppinstUi/Plugin/CommonUI/Src/CUICertificateDetailsDialog.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-2004 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:   This file contains the implementation of 
       
    15 *                CCUICertificateDetailsDialog class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 //#include <aknmessagequerydialog.h>
       
    22 //#include <StringLoader.h>
       
    23 #include <SWInstCommonUI.rsg>
       
    24 //#include <AknUtils.h>
       
    25 #include <hash.h>                  
       
    26 
       
    27 #include "CUICertificateDetailsDialog.h"
       
    28 #include "CUIDetailsDialog.h"
       
    29 
       
    30 using namespace SwiUI::CommonUI;
       
    31 
       
    32 // CONSTANTS
       
    33 _LIT( KNextLine, "\n" );
       
    34 _LIT( KNextNextLine, "\n\n" );
       
    35 _LIT( KHexFormat, "%02X" );
       
    36 const TInt KMaxLengthTextSerialNumberFormatting = 3;
       
    37 
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CCUICertificateDetailsDialog::CCUICertificateDetailsDialog
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CCUICertificateDetailsDialog::CCUICertificateDetailsDialog()
       
    48     {
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CCUICertificateDetailsDialog::ConstructL
       
    53 // Symbian 2nd phase constructor can leave.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CCUICertificateDetailsDialog::ConstructL()
       
    57     {
       
    58    
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CCUICertificateDetailsDialog::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CCUICertificateDetailsDialog* CCUICertificateDetailsDialog::NewL()
       
    67 
       
    68     {
       
    69     CCUICertificateDetailsDialog* self = new ( ELeave ) CCUICertificateDetailsDialog();
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop( self );
       
    73     return self; 
       
    74     }
       
    75 
       
    76 // Destructor
       
    77 CCUICertificateDetailsDialog::~CCUICertificateDetailsDialog()
       
    78     {
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CCUICertificateDetailsDialog::AddFieldLC
       
    83 // Adds a field (header and value) to the dialog.
       
    84 // (other items were commented in a header).
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CCUICertificateDetailsDialog::AddFieldLC( HBufC*& aMessage,
       
    88                                                TInt aHeaderResourceId,
       
    89                                                const TDesC& aValue )
       
    90     {
       
    91     /*
       
    92     HBufC* headerString = StringLoader::LoadLC( aHeaderResourceId );
       
    93     HBufC* newMessage;
       
    94     
       
    95     if ( aMessage->Length() > 0 )
       
    96         {
       
    97         newMessage = HBufC::NewL( headerString->Length() +
       
    98 	                          aValue.Length() +
       
    99                                   aMessage->Length() + 
       
   100                                   3 ); // \n\n, \n
       
   101         
       
   102         TPtr ptr( newMessage->Des() );
       
   103         ptr += *aMessage;        
       
   104         ptr += KNextNextLine;        
       
   105         ptr += *headerString;
       
   106         ptr += KNextLine;
       
   107         ptr += aValue;
       
   108         }
       
   109     else
       
   110         {
       
   111         newMessage = HBufC::NewL( headerString->Length() + aValue.Length() + 1 ); // \n
       
   112 
       
   113         TPtr ptr( newMessage->Des() );                
       
   114         ptr += *headerString;
       
   115         ptr += KNextLine;
       
   116         ptr += aValue;
       
   117         }
       
   118 
       
   119     CleanupStack::PopAndDestroy( headerString );
       
   120     CleanupStack::PopAndDestroy( aMessage );  
       
   121   
       
   122     aMessage = newMessage;    
       
   123     CleanupStack::PushL( aMessage );
       
   124     */  
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CCUICertificateDetailsDialog::ExecuteLD
       
   129 // Executes the dialog.
       
   130 // (other items were commented in a header).
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CCUICertificateDetailsDialog::ExecuteLD( const CCUICertificateInfo& aCertInfo )
       
   134     {
       
   135     /*
       
   136     CleanupStack::PushL( this );
       
   137     
       
   138     // Valid from
       
   139     HBufC* validFrom = DateToStringLC( aCertInfo.ValidFromL() );
       
   140 
       
   141     // Valid until
       
   142     HBufC* validTo = DateToStringLC( aCertInfo.ValidToL() );
       
   143     
       
   144     // Serial
       
   145     TPtrC8 serialPtr( aCertInfo.SerialNumberL() );
       
   146     HBufC* serial = HBufC::NewLC( serialPtr.Length() * 2 );
       
   147     TBuf<KMaxLengthTextSerialNumberFormatting> buf;
       
   148     
       
   149     for ( TInt index = 0; index < serialPtr.Length(); index++ )
       
   150         {
       
   151         buf.Format( KHexFormat, serialPtr[index] ); 
       
   152         serial->Des().Append( buf );
       
   153         }
       
   154 
       
   155     // Fingerprint   
       
   156     HBufC* fingerprint = HBufC::NewLC( aCertInfo.FingerprintL().Length() * 5 );
       
   157     DevideToBlocks( aCertInfo.FingerprintL(), fingerprint->Des() );
       
   158     
       
   159     // Fingerprint (MD5)
       
   160     HBufC* fingerprint_md = HBufC::NewLC( aCertInfo.FingerprintL().Length() * 5 );
       
   161     if ( aCertInfo.EncodingL() != KNullDesC8 )
       
   162         {
       
   163     	CMD5* md5 = CMD5::NewL();
       
   164         CleanupStack::PushL( md5 );
       
   165         DevideToBlocks( md5->Hash( aCertInfo.EncodingL() ), fingerprint_md->Des() );
       
   166         CleanupStack::PopAndDestroy( md5 );
       
   167         }
       
   168     
       
   169     HBufC* message = HBufC::NewLC( 0 );
       
   170 
       
   171     // Costruct the fields
       
   172     AddFieldLC( message, R_SWCOMMON_SEC_ISSUER, aCertInfo.IssuerNameL() ); 
       
   173     AddFieldLC( message, R_SWCOMMON_SEC_SUBJECT, aCertInfo.SubjectNameL() );
       
   174     AddFieldLC( message, R_SWCOMMON_SEC_VALID_FROM, *validFrom );
       
   175     AddFieldLC( message, R_SWCOMMON_SEC_VALID_UNTIL, *validTo );
       
   176     AddFieldLC( message, R_SWCOMMON_SEC_SERIAL, *serial );
       
   177     AddFieldLC( message, R_SWCOMMON_SEC_FINGERPRINT, *fingerprint );
       
   178     if ( fingerprint_md->Length() > 0 )
       
   179         {
       
   180     	AddFieldLC( message, R_SWCOMMON_SEC_FINGERPRINT_MD, *fingerprint_md );
       
   181         }
       
   182     
       
   183 
       
   184     // Create and show the message query dialog
       
   185     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *message );
       
   186     dlg->PrepareLC( R_SWCOMMON_SEC_DETAILS_DIALOG );
       
   187     dlg->RunLD();
       
   188 
       
   189     CleanupStack::PopAndDestroy( 7 );  // message, fingerprint_md, fingerprint, serial, validTo, validFrom
       
   190     */
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CCUICertificateDetailsDialog::DateToString
       
   195 // Converts date to local format.
       
   196 // (other items were commented in a header).
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 HBufC* CCUICertificateDetailsDialog::DateToStringLC( const TDateTime& aDate )
       
   200     {
       
   201     /*
       
   202     // Create date descriptors.
       
   203     // We use Avkon date format string to format the date into correct format.
       
   204     HBufC* dateFormatString = StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO );
       
   205     
       
   206     TBuf<30> timeString;    
       
   207     TTime time( aDate );
       
   208         
       
   209     time.FormatL( timeString, *dateFormatString );
       
   210     CleanupStack::PopAndDestroy( dateFormatString );   
       
   211     HBufC* tmp = timeString.AllocLC();
       
   212 
       
   213     TPtr ptr = tmp->Des();
       
   214     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
   215 
       
   216     return tmp;   
       
   217     */
       
   218     return NULL;
       
   219     }
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CCUICertificateDetailsDialog::DevideToBlocks
       
   223 // Devides input descriptor to blocks.
       
   224 // (other items were commented in a header).
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 void CCUICertificateDetailsDialog::DevideToBlocks( const TDesC8& aInput, TPtr aOutput )
       
   228     {
       
   229     const TInt KBlockLength = 2;    
       
   230     TInt blockIndex = 0;
       
   231     _LIT( KBlockSeparator, " " );
       
   232 
       
   233     for ( TInt index = 0 ; index < aInput.Length() ; index++ )
       
   234         {
       
   235         if ( blockIndex == KBlockLength )
       
   236             {
       
   237             aOutput.Append( KBlockSeparator );
       
   238             blockIndex = 0;
       
   239             }
       
   240         aOutput.AppendNumFixedWidthUC( (TUint)(aInput[index]), EHex, 2 );
       
   241         ++blockIndex;
       
   242         }
       
   243     }
       
   244 //  End of File