iaupdate/IAD/ui/src/iaupdatefwdetailsdialog.cpp
changeset 4 32704c33136d
child 18 3ba40be8e484
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2008-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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "iaupdatefwdetailsdialog.h"
       
    23 #include "iaupdatedialogutil.h"
       
    24 #include "iaupdatebasenode.h"
       
    25 #include "iaupdatefwnode.h"
       
    26 #include "iaupdatedebug.h"
       
    27 #include <iaupdate.rsg>
       
    28 
       
    29 #include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
       
    30 
       
    31 #include <StringLoader.h>
       
    32 
       
    33 // CONSTANTS
       
    34 const TInt KKiloByte = 1024;
       
    35 const TInt KMegaByte = 1024 * 1024;
       
    36 const TInt KMaxShownInKiloBytes = 10 * KMegaByte;
       
    37 
       
    38 
       
    39 /*******************************************************************************
       
    40  * class CIAUpdateDetailsDialog
       
    41  *******************************************************************************/
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CIAUpdateDetailsDialog::ShowDialogL
       
    46 // 
       
    47 // -----------------------------------------------------------------------------
       
    48 TBool CIAUpdateFwDetailsDialog::ShowDialogL( MIAUpdateFwNode* aFwNode )
       
    49 	{
       
    50 	CIAUpdateFwDetailsDialog* dialog = CIAUpdateFwDetailsDialog::NewL( aFwNode );
       
    51 	CleanupStack::PushL( dialog );
       
    52 
       
    53 	dialog->ShowDialogL();
       
    54 
       
    55 	CleanupStack::PopAndDestroy( dialog );
       
    56     
       
    57     return ETrue;
       
    58 	}
       
    59 
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CIAUpdateFwDetailsDialog::NewL
       
    63 //
       
    64 // -----------------------------------------------------------------------------
       
    65 CIAUpdateFwDetailsDialog* CIAUpdateFwDetailsDialog::NewL( MIAUpdateFwNode* aFwNode )
       
    66     {
       
    67     CIAUpdateFwDetailsDialog* self = new ( ELeave ) CIAUpdateFwDetailsDialog( aFwNode );
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL();
       
    70     CleanupStack::Pop( self );
       
    71 
       
    72     return self;
       
    73     }
       
    74 
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CIAUpdateFwDetailsDialog::CIAUpdateFwDetailsDialog
       
    78 // 
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CIAUpdateFwDetailsDialog::CIAUpdateFwDetailsDialog( MIAUpdateFwNode* aFwNode )
       
    82 	{
       
    83 	iFwNode = aFwNode;
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CIAUpdateFwDetailsDialog::ConstructL
       
    89 //
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CIAUpdateFwDetailsDialog::ConstructL()
       
    93     {
       
    94     TInt size = BufferSize();
       
    95  	iBuf = HBufC::NewL( size );
       
    96     } 
       
    97 
       
    98 
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // Destructor
       
   102 //
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 CIAUpdateFwDetailsDialog::~CIAUpdateFwDetailsDialog()
       
   106     {
       
   107     delete iBuf;
       
   108     }
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CIAUpdateFwDetailsDialog::BufferSize
       
   113 //
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 TInt CIAUpdateFwDetailsDialog::BufferSize()
       
   117     {
       
   118     const TInt KExtraSize = 512;
       
   119     
       
   120     TPtrC ptr1 = iFwNode->Base().Name();
       
   121     TPtrC ptr2 = iFwNode->Base().Description();
       
   122     
       
   123     TInt len = ptr1.Length() + ptr2.Length() + KExtraSize;
       
   124     
       
   125     return len;
       
   126     } 
       
   127 
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CIAUpdateFwDetailsDialog::ConstructTextL
       
   131 //
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CIAUpdateFwDetailsDialog::ConstructTextL()
       
   135     {
       
   136     _LIT(KNewLine, "\n");
       
   137 
       
   138     TPtr ptr = iBuf->Des();
       
   139  
       
   140     TInt contentSize =   iFwNode->Base().ContentSizeL();
       
   141      
       
   142     
       
   143     HBufC* hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_DESCRIPTION );
       
   144     ptr.Append( KOpeningBoldTag );
       
   145     ptr.Append( *hBuf );
       
   146     ptr.Append( KClosingBoldTag );
       
   147     CleanupStack::PopAndDestroy( hBuf );
       
   148     
       
   149     
       
   150     HBufC* description = StringLoader::LoadLC( R_IAUPDATE_FW_DESCRIPTION );
       
   151     ptr.Append( KNewLine );
       
   152     ptr.Append( *description );
       
   153     ptr.Append( KNewLine );
       
   154     ptr.Append( KNewLine );
       
   155     CleanupStack::PopAndDestroy( description );
       
   156     
       
   157     if ( iFwNode->FwVersion1().Length() > 0 )
       
   158         { 
       
   159         hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_VERSION );        
       
   160         ptr.Append( KOpeningBoldTag );
       
   161         ptr.Append( *hBuf );
       
   162         ptr.Append( KClosingBoldTag );
       
   163         CleanupStack::PopAndDestroy( hBuf );
       
   164 
       
   165         ptr.Append( KNewLine );
       
   166         ptr.Append( iFwNode->FwVersion1() );
       
   167         ptr.Append( KNewLine );
       
   168         ptr.Append( KNewLine );
       
   169         }
       
   170     
       
   171     
       
   172     if( contentSize > 0 && (iFwNode->FwType() == MIAUpdateFwNode::EFotaDp2) )
       
   173         {
       
   174         hBuf = StringLoader::LoadLC( R_IAUPDATE_DETAILS_DIALOG_FILE_SIZE );
       
   175         ptr.Append( KOpeningBoldTag );
       
   176         ptr.Append( *hBuf );
       
   177         ptr.Append( KClosingBoldTag );
       
   178         CleanupStack::PopAndDestroy( hBuf );
       
   179         
       
   180         ptr.Append( KNewLine );
       
   181         
       
   182         hBuf = FileSizeTextLC( contentSize );
       
   183 
       
   184         ptr.Append( *hBuf );
       
   185         CleanupStack::PopAndDestroy( hBuf );
       
   186         }
       
   187    
       
   188     } 
       
   189 
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CIAUpdateFwDetailsDialog::ShowDialogL
       
   193 // 
       
   194 // -----------------------------------------------------------------------------
       
   195 TBool CIAUpdateFwDetailsDialog::ShowDialogL()
       
   196 	{
       
   197 	ConstructTextL();
       
   198 	HBufC* firmwarename = iFwNode->Base().Name().AllocLC();
       
   199 	IAUpdateDialogUtil::ShowMessageQueryL( *firmwarename, *iBuf );
       
   200     CleanupStack::PopAndDestroy( firmwarename );
       
   201     return ETrue;
       
   202 	}
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CIAUpdateFwDetailsDialog::FileSizeTextLC
       
   207 // 
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 HBufC* CIAUpdateFwDetailsDialog::FileSizeTextLC( TInt aFileSize )
       
   211 	{
       
   212     TInt resourceId = 0;
       
   213 	TInt size = 0;
       
   214 	
       
   215 	if ( aFileSize >= KMaxShownInKiloBytes )
       
   216 	    {
       
   217 	    resourceId = R_IAUPDATE_DETAILS_DIALOG_SIZE_MEGABYTE;
       
   218 	    size = aFileSize / KMegaByte;
       
   219    	    if ( aFileSize % KMegaByte != 0 )
       
   220 	        {
       
   221 	        size++;
       
   222 	        }
       
   223 	    }
       
   224 	else
       
   225 	    {
       
   226 	    resourceId = R_IAUPDATE_DETAILS_DIALOG_SIZE_KILOBYTE;
       
   227 	    size = aFileSize / KKiloByte;
       
   228    	    if ( aFileSize % KKiloByte != 0 )
       
   229 	        {
       
   230 	        size++;
       
   231 	        }	
       
   232 	    }
       
   233 	    
       
   234 	HBufC* sizeAsString = StringLoader::LoadLC( resourceId, size );
       
   235 	TPtr ptr = sizeAsString->Des();
       
   236     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
   237     return sizeAsString;
       
   238 	}
       
   239 
       
   240 
       
   241    
       
   242 //  End of File