pushmtm/MtmUiSrc/PushMessageInfoDialog.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:  Member definitions of CPushMessageInfoDialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 
       
    22 #include "PushMessageInfoDialog.h"
       
    23 #include "PushMtmUiDef.h"
       
    24 #include "PushMtmUiPanic.h"
       
    25 #include "PushMtmUtil.h"
       
    26 #include "PushMtmLog.h"
       
    27 #include <push/CSIPushMsgEntry.h>
       
    28 #include <push/CSLPushMsgEntry.h>
       
    29 #include <push/CUnknownPushMsgEntry.h>
       
    30 #include <PushMtmUi.rsg>
       
    31 #include <AknLists.h>
       
    32 #include <msvapi.h>
       
    33 #include <e32math.h>
       
    34 #include <StringLoader.h>
       
    35 #include <AVKON.RSG>
       
    36 #include <bldvariant.hrh>
       
    37 #include <FeatMgr.h>
       
    38 #include <data_caging_path_literals.hrh>
       
    39 #include <f32file.h>
       
    40 #include <AknUtils.h>
       
    41 #include <AknBidiTextUtils.h>
       
    42 
       
    43 // CONSTANTS
       
    44 
       
    45 LOCAL_D const TInt KNoResource = 0;
       
    46 LOCAL_D const TInt KArrayGranularity = 16;
       
    47 LOCAL_D const TReal KReal1024 = 1024.0;
       
    48 _LIT( KTab, "\t" );
       
    49 _LIT( KSpace, " " );
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CPushMessageInfoDialog::CPushMessageInfoDialog
       
    56 // ---------------------------------------------------------
       
    57 //
       
    58 CPushMessageInfoDialog::CPushMessageInfoDialog()
       
    59 :   CAknPopupList(),
       
    60     iResourceLoader( *iCoeEnv )
       
    61     {
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CPushMessageInfoDialog::~CPushMessageInfoDialog
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 CPushMessageInfoDialog::~CPushMessageInfoDialog()
       
    69     {
       
    70     iSecondColumnFont = 0;
       
    71     iResourceLoader.Close();
       
    72     delete iListBox;
       
    73     delete iListBoxModel;
       
    74     FeatureManager::UnInitializeLib();
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // CPushMessageInfoDialog::ExecuteLD
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 void CPushMessageInfoDialog::ExecuteLD( CMsvSession& aMsvSession, TMsvId aId )
       
    82     {
       
    83     ConstructL( aMsvSession, aId );
       
    84     CAknPopupList::ExecuteLD();
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // CPushMessageInfoDialog::ConstructL
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void CPushMessageInfoDialog::ConstructL( CMsvSession& aMsvSession, TMsvId aId )
       
    92     {
       
    93     PUSHLOG_ENTERFN("CPushMessageInfoDialog::ConstructL");
       
    94 
       
    95     __ASSERT_DEBUG( !iListBox &&
       
    96                     !iListBoxModel,
       
    97                     UiPanic( EPushMtmUiPanAlreadyInitialized ) );
       
    98 
       
    99     FeatureManager::InitializeLibL();
       
   100 
       
   101     // Add resource file.
       
   102     TParse* fileParser = new (ELeave) TParse;
       
   103     // Unnecessary to call CleanupStack::PushL( fileParser );
       
   104     fileParser->Set( KPushMtmUiResourceFileAndDrive, &KDC_MTM_RESOURCE_DIR, NULL );
       
   105     iResourceFile = fileParser->FullName();
       
   106     PUSHLOG_WRITE_FORMAT(" iResourceFile: <%S>",&iResourceFile);
       
   107     delete fileParser;
       
   108     fileParser = NULL;
       
   109     iResourceLoader.OpenL( iResourceFile );
       
   110     PUSHLOG_WRITE(" iResourceFile opened");
       
   111 
       
   112     // Construct list box's model first
       
   113     // This list box will be used by an CAknPopupList object.
       
   114     __ASSERT_DEBUG( !iListBoxModel && !iListBox,
       
   115                     UiPanic( EPushMtmUiPanAlreadyInitialized ) );
       
   116    	iListBoxModel = new (ELeave) CDesCArrayFlat( KArrayGranularity );
       
   117     // Construct list box.
       
   118     iListBox = new (ELeave) CAknSingleHeadingPopupMenuStyleListBox;
       
   119 
       
   120     // ========================================================
       
   121     // Layout info of CAknSingleHeadingPopupMenuStyleListBox
       
   122     TAknTextLineLayout textLayout =
       
   123         AknLayout::List_pane_texts__menu_single_heading__Line_2(0);
       
   124 
       
   125     // Font of the second column of the given list box
       
   126     iSecondColumnFont = AknLayoutUtils::FontFromId( textLayout.FontId() );
       
   127 
       
   128     // Line width of the second column of the given list box
       
   129     TInt itemCount = 0; // No need to set
       
   130     TInt titleVisible = 1; // known value (we always have title)
       
   131     TRect main_pane = iAvkonAppUi->ClientRect();
       
   132 
       
   133     TAknLayoutRect popup_menu_graphic_window;
       
   134     popup_menu_graphic_window.LayoutRect( main_pane,
       
   135         AknLayout::popup_menu_graphic_window(itemCount) );
       
   136 
       
   137     TAknLayoutRect menu_heading_pane;
       
   138     menu_heading_pane.LayoutRect( popup_menu_graphic_window.Rect(),
       
   139         AknLayout::list_menu_heading_pane(titleVisible, itemCount) );
       
   140 
       
   141     TAknLayoutRect list_item;
       
   142     list_item.LayoutRect( menu_heading_pane.Rect(),
       
   143         AknLayout::list_single_heading_popup_menu_pane(itemCount) );
       
   144 
       
   145     TAknLayoutText text;
       
   146     text.LayoutText( list_item.Rect(), textLayout );
       
   147 
       
   148     iSecondColumnWidth = text.TextRect().Width();
       
   149     // ========================================================
       
   150 
       
   151     // Add items to the list.
       
   152     AddMessageInfoItemsL( aMsvSession, aId );
       
   153 
       
   154     CAknPopupList::ConstructL( iListBox,
       
   155                                R_AVKON_SOFTKEYS_OK_EMPTY__OK,
       
   156                                AknPopupLayouts::EMenuGraphicHeadingWindow );
       
   157 
       
   158 	iListBox->ConstructL( this, EAknListBoxViewerFlags );
       
   159 	iListBox->CreateScrollBarFrameL( ETrue );
       
   160 	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL
       
   161         ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   162 
       
   163     CTextListBoxModel* listBoxModel = iListBox->Model();
       
   164 	listBoxModel->SetItemTextArray( iListBoxModel );
       
   165 	listBoxModel->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   166 
       
   167     // Get title text of popup list
       
   168     HBufC* title = iCoeEnv->AllocReadResourceLC( R_PUSHMID_TITLE );
       
   169     PUSHLOG_WRITE(" R_PUSHMID_TITLE read");
       
   170     SetTitleL( *title );
       
   171     CleanupStack::PopAndDestroy( title ); // title
       
   172 
       
   173     PUSHLOG_LEAVEFN("CPushMessageInfoDialog::ConstructL");
       
   174 	}
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // CPushMessageInfoDialog::AddMessageInfoItemL
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 void CPushMessageInfoDialog::AddMessageInfoItemL( TInt aHeaderResourceId,
       
   181                                                   const TDesC& aText ) const
       
   182     {
       
   183     __ASSERT_DEBUG( iListBoxModel, UiPanic( EPushMtmUiPanNotInitialized ) );
       
   184 
       
   185     // Make some necessary conversion.
       
   186     HBufC* paramTextCopy = aText.AllocLC();
       
   187     TPtr paramTextCopyPtr = paramTextCopy->Des();
       
   188     // Remove tabs, because of the list box...
       
   189     AknTextUtils::StripCharacters( paramTextCopyPtr, KAknStripListControlChars );
       
   190     // Number conversion
       
   191     if ( paramTextCopyPtr.Length() > 0 )
       
   192         {
       
   193         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( paramTextCopyPtr );
       
   194         }
       
   195 
       
   196     HBufC* header = ( aHeaderResourceId == KNoResource ?
       
   197         KNullDesC().AllocLC() :
       
   198         iCoeEnv->AllocReadResourceLC( aHeaderResourceId ) );
       
   199 
       
   200     CArrayFix<TPtrC>* wrappedArray =
       
   201         new ( ELeave ) CArrayFixFlat<TPtrC>( KArrayGranularity );
       
   202     CleanupStack::PushL( wrappedArray );
       
   203 
       
   204     AknTextUtils::WrapToArrayL
       
   205                                 ( paramTextCopyPtr, iSecondColumnWidth,
       
   206                                   *iSecondColumnFont, *wrappedArray );
       
   207     // visual is directly not used, but wrappedArray points to it
       
   208 
       
   209     // Add the lines in wrappedArray to the list
       
   210     const TInt lines = wrappedArray->Count();
       
   211     for ( TInt loop = 0; loop < lines; ++loop )
       
   212         {
       
   213         TPtrC current = ( *wrappedArray )[loop];
       
   214         // Allocate a buffer for the new list box item text
       
   215         // (including header, separator and wrapped text)
       
   216         HBufC* currentFormattedLine = HBufC::NewLC
       
   217             ( ((loop==0) ? header->Length() : /*KSpace().Length()*/1) +
       
   218               /*KTab().Length()*/1 + current.Length() );
       
   219         TPtr currentFormattedLinePtr = currentFormattedLine->Des(); // writeable
       
   220 
       
   221         if ( loop == 0 )
       
   222             { currentFormattedLinePtr.Copy( *header ); }
       
   223         else
       
   224             { currentFormattedLinePtr.Copy( KSpace ); }
       
   225 
       
   226         currentFormattedLinePtr.Append( KTab );
       
   227         currentFormattedLinePtr.Append( current );
       
   228         iListBoxModel->AppendL( currentFormattedLinePtr );
       
   229 
       
   230         CleanupStack::PopAndDestroy( currentFormattedLine ); // currentFormattedLine
       
   231         }
       
   232 
       
   233     CleanupStack::PopAndDestroy( 1, wrappedArray ); //  wrappedArray
       
   234     CleanupStack::PopAndDestroy( 2, paramTextCopy ); // header, paramTextCopy
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------
       
   238 // CPushMessageInfoDialog::ConvertUniversalToHomeTime
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 TTime CPushMessageInfoDialog::ConvertUniversalToHomeTime
       
   242                               ( const TTime& aUniversalTime ) const
       
   243     {
       
   244     TTime time( aUniversalTime );   // time stores UTC time.
       
   245 
       
   246     TLocale locale;
       
   247     TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() );
       
   248     // Add locale's universal time offset to universal time.
       
   249     time += universalTimeOffset;    // time stores Local Time.
       
   250 
       
   251     // If home daylight saving in effect, add one hour offset.
       
   252     if ( locale.QueryHomeHasDaylightSavingOn() )
       
   253           {
       
   254           TTimeIntervalHours daylightSaving(1);
       
   255           time += daylightSaving;   // Now it is Home Time.
       
   256           }
       
   257 
       
   258 #ifdef __TEST_LOG__
       
   259         // The following section will call LEAVEable functions, but
       
   260         // they are only for logging purposes.
       
   261         _LIT( KDateFormat, "%E%D%X%N%Y %1 %2 %3" );
       
   262         _LIT( KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B" );
       
   263         TBuf<32> dateHolder;
       
   264         TBuf<32> timeHolder;
       
   265         aUniversalTime.FormatL( dateHolder, KDateFormat );
       
   266         aUniversalTime.FormatL( timeHolder, KTimeFormat );
       
   267         PUSHLOG_WRITE_FORMAT(" UTC date: <%S>",&dateHolder);
       
   268         PUSHLOG_WRITE_FORMAT(" UTC time: <%S>",&timeHolder);
       
   269         time.FormatL( dateHolder, KDateFormat );
       
   270         time.FormatL( timeHolder, KTimeFormat );
       
   271         PUSHLOG_WRITE_FORMAT(" Home date: <%S>",&dateHolder);
       
   272         PUSHLOG_WRITE_FORMAT(" Home time: <%S>",&timeHolder);
       
   273 #endif // __TEST_LOG__
       
   274 
       
   275     return time; // Home Time.
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------
       
   279 // CPushMessageInfoDialog::AddMessageInfoItemsL
       
   280 // ---------------------------------------------------------
       
   281 //
       
   282 void CPushMessageInfoDialog::AddMessageInfoItemsL( CMsvSession& aMsvSession,
       
   283                                                    TMsvId aId ) const
       
   284     {
       
   285     PUSHLOG_ENTERFN("CPushMessageInfoDialog::AddMessageInfoItemsL");
       
   286 
       
   287     TMsvEntry tEntry;
       
   288     TMsvId dummyService;
       
   289     User::LeaveIfError( aMsvSession.GetEntry( aId, dummyService, tEntry ) );
       
   290     PUSHLOG_WRITE(" Entry got");
       
   291     __ASSERT_DEBUG
       
   292         ( tEntry.iMtm == KUidMtmWapPush, UiPanic( EPushMtmUiPanBadType ) );
       
   293 
       
   294     // Construct model.
       
   295     CPushMsgEntryBase* msg = NULL;
       
   296     const TInt32 bioType( tEntry.iBioType );
       
   297     if ( bioType == KUidWapPushMsgSI.iUid )
       
   298         {
       
   299         msg = CSIPushMsgEntry::NewL();
       
   300         PUSHLOG_WRITE(" SI");
       
   301         }
       
   302 #ifdef __SERIES60_PUSH_SL
       
   303     else if ( bioType == KUidWapPushMsgSL.iUid )
       
   304         {
       
   305         msg = CSLPushMsgEntry::NewL();
       
   306         PUSHLOG_WRITE(" SL");
       
   307         }
       
   308 #endif // __SERIES60_PUSH_SL
       
   309 #ifdef __SERIES60_PUSH_SP
       
   310     else if ( bioType == KUidWapPushMsgUnknown.iUid )
       
   311         {
       
   312         msg = CUnknownPushMsgEntry::NewL();
       
   313         PUSHLOG_WRITE(" Unknown");
       
   314         }
       
   315 #endif // __SERIES60_PUSH_SP
       
   316     else
       
   317         {
       
   318         PUSHLOG_WRITE(" Bad message type");
       
   319         User::Leave( KErrNotSupported );
       
   320         }
       
   321 
       
   322     CleanupStack::PushL( msg );
       
   323     msg->RetrieveL( aMsvSession, tEntry.Id() );
       
   324     PUSHLOG_WRITE(" RetreiveL OK");
       
   325 
       
   326     // ************************************************************************
       
   327     // Information item: From (push initiator).
       
   328     // This can be MSISDN number, URL, etc.
       
   329     // ************************************************************************
       
   330     TPtrC8 from8( msg->From() );
       
   331     if ( from8.Length() )
       
   332         {
       
   333         // Copy the 8-bit text into a 16-bit one and convert the string to
       
   334         // decoded form.
       
   335         HBufC* from16 = HBufC::NewMaxLC( from8.Length() );
       
   336         from16->Des().Copy( from8 );
       
   337 
       
   338         HBufC* convertedFrom =
       
   339             CPushMtmUtil::ConvertUriToDisplayFormL( *from16 );
       
   340         CleanupStack::PushL( convertedFrom );
       
   341         //
       
   342         AddMessageInfoItemL( R_PUSHMID_FROM, *convertedFrom );
       
   343         PUSHLOG_WRITE(" From added");
       
   344         //
       
   345         CleanupStack::PopAndDestroy( 2, from16 ); // convertedFrom, from16
       
   346         }
       
   347 
       
   348     // ************************************************************************
       
   349     // Information item: Address/URL (SI and SL specific).
       
   350     // ************************************************************************
       
   351     if ( msg->PushMsgType() == KUidWapPushMsgSI.iUid )
       
   352         {
       
   353         CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, msg );
       
   354         const TPtrC url = si->Url();
       
   355         if ( url.Length() )
       
   356             {
       
   357             //
       
   358             HBufC* convertedUrl =
       
   359                 CPushMtmUtil::ConvertUriToDisplayFormL( url );
       
   360             CleanupStack::PushL( convertedUrl );
       
   361             //
       
   362             AddMessageInfoItemL( R_PUSHMID_URL, *convertedUrl );
       
   363             PUSHLOG_WRITE(" URL added");
       
   364             //
       
   365             CleanupStack::PopAndDestroy( convertedUrl );
       
   366             }
       
   367         }
       
   368 #ifdef __SERIES60_PUSH_SL
       
   369     else if ( msg->PushMsgType() == KUidWapPushMsgSL.iUid )
       
   370         {
       
   371         CSLPushMsgEntry* sl = STATIC_CAST( CSLPushMsgEntry*, msg );
       
   372         const TPtrC url = sl->Url();
       
   373         if ( url.Length() )
       
   374             {
       
   375             //
       
   376             HBufC* convertedUrl =
       
   377                 CPushMtmUtil::ConvertUriToDisplayFormL( url );
       
   378             CleanupStack::PushL( convertedUrl );
       
   379             //
       
   380             AddMessageInfoItemL( R_PUSHMID_URL, sl->Url() );
       
   381             PUSHLOG_WRITE(" URL added");
       
   382             //
       
   383             CleanupStack::PopAndDestroy( convertedUrl );
       
   384             }
       
   385         }
       
   386 #endif // __SERIES60_PUSH_SL
       
   387 
       
   388     // ************************************************************************
       
   389     // Information item: Message body/text (SI specific).
       
   390     // ************************************************************************
       
   391     if ( msg->PushMsgType() == KUidWapPushMsgSI.iUid )
       
   392         {
       
   393         CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, msg );
       
   394         if ( si->Text().Length() )
       
   395             {
       
   396             TPtrC siText = si->Text();
       
   397             PUSHLOG_WRITE_FORMAT(" SI text: <%S>",&siText);
       
   398             AddMessageInfoItemL( R_PUSHMID_BODY, siText );
       
   399             PUSHLOG_WRITE(" SI text added");
       
   400             }
       
   401         }
       
   402 
       
   403     // ************************************************************************
       
   404     // Information item: Type.
       
   405     // ************************************************************************
       
   406     HBufC* value = iCoeEnv->AllocReadResourceLC( R_PUSHMID_TYPE_STR );
       
   407     AddMessageInfoItemL( R_PUSHMID_TYPE, *value );
       
   408     CleanupStack::PopAndDestroy( value ); // value
       
   409     PUSHLOG_WRITE(" Msg. type added");
       
   410 
       
   411 #ifdef __SERIES60_PUSH_SP
       
   412     // ************************************************************************
       
   413     // Information item: Content type (SP specific)
       
   414     // ************************************************************************
       
   415     if ( msg->PushMsgType() == KUidWapPushMsgUnknown.iUid )
       
   416         {
       
   417         CUnknownPushMsgEntry* sp = STATIC_CAST( CUnknownPushMsgEntry*, msg );
       
   418         TPtrC contType = sp->ContentType();
       
   419         if ( contType.Length() )
       
   420             {
       
   421             AddMessageInfoItemL( R_PUSHMID_CONTENT_TYPE, contType );
       
   422             PUSHLOG_WRITE(" Content type added ");
       
   423             }
       
   424         }
       
   425 #endif // __SERIES60_PUSH_SP
       
   426 
       
   427     TBuf<32> time;
       
   428     TBuf<32> date;
       
   429     HBufC* dateFormatString =
       
   430                 iCoeEnv->AllocReadResourceLC( R_QTN_DATE_USUAL_WITH_ZERO );
       
   431     HBufC* timeFormatString =
       
   432                 iCoeEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
       
   433 
       
   434     // ************************************************************************
       
   435     // SI specific information item: creation time and date.
       
   436     // ************************************************************************
       
   437     if ( msg->PushMsgType() == KUidWapPushMsgSI.iUid )
       
   438         {
       
   439         CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, msg );
       
   440         const TTime created( si->Created() );
       
   441         // Check if created time was set.
       
   442         if ( created != Time::NullTTime() )
       
   443             {
       
   444             // OK. this attribute was set. Render it to the user.
       
   445             TTime creLocal = ConvertUniversalToHomeTime( created );
       
   446             creLocal.FormatL( time, *timeFormatString );
       
   447             creLocal.FormatL( date, *dateFormatString );
       
   448             AddMessageInfoItemL( R_PUSHMID_CREATED, time );
       
   449             AddMessageInfoItemL( KNoResource, date );
       
   450             PUSHLOG_WRITE(" Created added");
       
   451             }
       
   452         }
       
   453 
       
   454     // ************************************************************************
       
   455     // Information item: Arrival time and date.
       
   456     // ************************************************************************
       
   457     const TTime arrivalTime( msg->ReceivedDate() );
       
   458     // Arrival time is always set by the wappush framework. Render it to the user.
       
   459     TTime arrLocal = ConvertUniversalToHomeTime( arrivalTime );
       
   460     arrLocal.FormatL( time, *timeFormatString );
       
   461     arrLocal.FormatL( date, *dateFormatString );
       
   462     AddMessageInfoItemL( R_PUSHMID_RCVD, time );
       
   463     AddMessageInfoItemL( KNoResource, date );
       
   464     PUSHLOG_WRITE(" Received added");
       
   465 
       
   466     // ************************************************************************
       
   467     // SI specific information item: expiration time and date.
       
   468     // ************************************************************************
       
   469     if ( msg->PushMsgType() == KUidWapPushMsgSI.iUid )
       
   470         {
       
   471         CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, msg );
       
   472         const TTime expires( si->Expires() );
       
   473         // Check expiration if expiration time was set.
       
   474         if ( expires != Time::NullTTime() )
       
   475             {
       
   476             TTime expLocal = ConvertUniversalToHomeTime( expires );
       
   477             expLocal.FormatL( time, *timeFormatString );
       
   478             expLocal.FormatL( date, *dateFormatString );
       
   479             AddMessageInfoItemL( R_PUSHMID_EXPIRES, time );
       
   480             AddMessageInfoItemL( KNoResource, date );
       
   481             PUSHLOG_WRITE(" Expires added");
       
   482             }
       
   483         }
       
   484 
       
   485     CleanupStack::PopAndDestroy( 2, dateFormatString );
       
   486     // timeFormatString, dateFormatString
       
   487 
       
   488     // ************************************************************************
       
   489     // Information item: Size.
       
   490     // Convert the message size given in bytes into kilobytes. Round the
       
   491     // value up, if necessary.
       
   492     // ************************************************************************
       
   493     TReal messageSize( 0 );
       
   494     if ( msg->PushMsgType() == KUidWapPushMsgSI.iUid )
       
   495         {
       
   496         CSIPushMsgEntry* si = STATIC_CAST( CSIPushMsgEntry*, msg );
       
   497         messageSize = (TReal)si->Text().Size() / KReal1024;
       
   498         }
       
   499 #ifdef __SERIES60_PUSH_SL
       
   500     else if ( msg->PushMsgType() == KUidWapPushMsgSL.iUid )
       
   501         {
       
   502         CSLPushMsgEntry* sl = STATIC_CAST( CSLPushMsgEntry*, msg );
       
   503         messageSize = (TReal)sl->Url().Size() / KReal1024;
       
   504         }
       
   505 #endif // __SERIES60_PUSH_SL
       
   506 #ifdef __SERIES60_PUSH_SP
       
   507     else if ( msg->PushMsgType() == KUidWapPushMsgUnknown.iUid )
       
   508         {
       
   509         CUnknownPushMsgEntry* sp = STATIC_CAST( CUnknownPushMsgEntry*, msg );
       
   510         messageSize = (TReal)sp->MessageData().Size() / KReal1024;
       
   511         }
       
   512 #endif // __SERIES60_PUSH_SP
       
   513     TInt32 messageSizeInt;
       
   514     User::LeaveIfError( Math::Int( messageSizeInt, messageSize ) );
       
   515     TReal fraction;
       
   516     User::LeaveIfError( Math::Frac( fraction, messageSize ) );
       
   517     if ( fraction )
       
   518         {
       
   519         ++messageSizeInt;
       
   520         }
       
   521     HBufC* size =
       
   522         StringLoader::LoadLC( R_QTN_SIZE_KB, messageSizeInt, iCoeEnv );
       
   523     // From avkon.loc:
       
   524     // #define qtn_size_kb " %N kB"
       
   525     // We don't need white spaces at the beginning of the size string, so
       
   526     // remove them:
       
   527     size->Des().Trim();
       
   528     AddMessageInfoItemL( R_PUSHMID_SIZE, *size );
       
   529     PUSHLOG_WRITE(" Size added");
       
   530     CleanupStack::PopAndDestroy( size ); // size
       
   531 
       
   532     CleanupStack::PopAndDestroy( msg ); // msg
       
   533 
       
   534     PUSHLOG_LEAVEFN("CPushMessageInfoDialog::AddMessageInfoItemsL");
       
   535     }
       
   536 
       
   537 // End of file.