diff -r ebe688cedc25 -r 7fdbb852d323 messagingappbase/mce/src/MceDeliveryReportAdapter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingappbase/mce/src/MceDeliveryReportAdapter.cpp Wed Sep 01 12:31:54 2010 +0100 @@ -0,0 +1,294 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This class formats data from engine to listbox +* +*/ + + + +// INCLUDE FILES +#include +#include +#include // TextUtils +#include + +#include +#include + +#include "MceDeliveryReportAdapter.h" +#include "MceLogEngine.h" +#include "MceUtils.h" + +// security data caging +#include +#include + +// CONSTANTS +const TInt KTinyBufferLength = 5; +const TInt KSmallBufferLength = 30; +const TInt KMediumBufferLength = 128; +const TInt KLargeBufferLength = 256; +const TInt KInitConcItem = 0; +const TInt KFirstConcItemPos = 0; +const TInt KSecondConcItemPos = 2; +const TInt KConcItemLength = 1; +const TInt KPhoneNumberMaxLen = 48; +const TInt KListBoxCellId = 1; + +// LOCAL CONSTANTS AND MACROS + +_LIT( KMceDirAndFile,"mcelogeng.rSC" ); + +_LIT(KSmsEventType, "0\t"); +_LIT(KMmsEventType, "1\t"); +_LIT(KTab, "\t"); + +#ifdef RD_MSG_NAVIPANE_IMPROVEMENT +_LIT( KSeparator, " " ); +#else +_LIT( KSeparator, " - " ); +#endif // RD_MSG_NAVIPANE_IMPROVEMENT +// ================= MEMBER FUNCTIONS ======================= + + +// Two-phased constructor. +CMceDeliveryReportAdapter* CMceDeliveryReportAdapter::NewL + ( CMceLogEngine* aModel, + CEikFormattedCellListBox *aListBox ) + { + CMceDeliveryReportAdapter* self = new( ELeave ) CMceDeliveryReportAdapter( aModel, aListBox ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// C++ default constructor can NOT contain any code that +// might leave. +// +CMceDeliveryReportAdapter::CMceDeliveryReportAdapter( CMceLogEngine* aModel, + CEikFormattedCellListBox *aListBox ) + : iModel( aModel ), + iResourceLoader( *CCoeEnv::Static() ), + iListBox( aListBox ) + { + TTime universal; + TTime home; + + universal.UniversalTime(); + home.HomeTime(); + TInt err = home.MinutesFrom( universal, iInterval ); + + if( err ) + { + iInterval = 0; + } + } + +// Symbian OS default constructor can leave. +void CMceDeliveryReportAdapter::ConstructL() + { + // security data caging + TParse fp; + fp.Set( KMceDirAndFile, &KDC_APP_RESOURCE_DIR , NULL ); + TFileName filename = fp.FullName(); + + iResourceLoader.OpenL( filename ); + CEikonEnv* env = CEikonEnv::Static(); + + iBuffer = HBufC::NewL( KLargeBufferLength ); + iTimeText = HBufC::NewL( KMediumBufferLength ); + iPendingText = env->AllocReadResourceL( R_MCE_LOG_ENG_PENDING_TEXT ); + iRead = env->AllocReadResourceL( R_MCE_LOG_ENG_READ_TEXT ); + iFailedText = env->AllocReadResourceL( R_MCE_LOG_ENG_FAILED_TEXT ); + iDeliveredText = env->AllocReadResourceL( R_MCE_LOG_ENG_DELIVERED_TEXT ); + iTimeFormat = env->AllocReadResourceL( R_QTN_TIME_USUAL_WITH_ZERO ); + +#ifdef RD_MSG_NAVIPANE_IMPROVEMENT + iTimeDateFormat = env->AllocReadResourceL( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO ); +#else + iTimeDateFormat = env->AllocReadResourceL( R_QTN_DATE_SHORT_WITH_ZERO ); +#endif // RD_MSG_NAVIPANE_IMPROVEMENT + + iModel->GetStandardStrings( iFailed, iPending ); + + iConcItems = new( ELeave ) CArrayFixFlat( 1 ); + iConcItems->AppendL( KInitConcItem ); + iConcItems->AppendL( KInitConcItem ); + + iConcText = StringLoader::LoadL( R_MCE_LOG_ENG_CONCATENATED_TEXT, + *iConcItems ); + + // CenRep key KCRUidNumberGrouping / KNumberGrouping is used to check if + // number grouping is supported + if( AknLayoutUtils::LayoutMirrored() || MceUtils::NumberGroupingEnabled() ) + { + iNumberGrouping = CPNGNumberGrouping::NewL( KPhoneNumberMaxLen ); + } + } + + +// Destructor +CMceDeliveryReportAdapter::~CMceDeliveryReportAdapter() + { + delete iBuffer; + delete iPendingText; + delete iFailedText; + delete iDeliveredText; + delete iTimeFormat; + delete iTimeDateFormat; + delete iTimeText; + delete iConcItems; + delete iConcText; + delete iRead; + iResourceLoader.Close(); + + delete iNumberGrouping; + } + + +// from MDesCArray +TInt CMceDeliveryReportAdapter::MdcaCount () const + { + return iModel->Count(); + } + +// from MDesCArray +TPtrC16 CMceDeliveryReportAdapter::MdcaPoint( TInt aIndex ) const + { + TPtr des = iBuffer->Des(); + /// Double Graphics Style " \t\t