diff -r 000000000000 -r f979ecb2b13e meetingui/meetingrequestviewers/src/CMRStringFormatter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/meetingui/meetingrequestviewers/src/CMRStringFormatter.cpp Tue Feb 02 10:12:19 2010 +0200 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2005 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: Implementation for meeting request string formatter +* +*/ + + + + +// INCLUDE FILES +#include "CMRStringFormatter.h" +#include "MRViewersPanic.h" +#include // CCoeEnv +#include // StringLoader +#include // resouce identifiers +#include +#include // Calendar entry API V2 +#include + +// CONSTANTS +/// Unnamed namespace for local definitions +namespace { + +const TInt KMaxDateTimeTextLength = 100; + +_LIT( KPanicMsg, "~CMRStringFormatter" ); + +void Panic( TPanicCode aReason ) + { + User::Panic( KPanicMsg, aReason ); + } + +} // namespace + + +// ============================ MEMBER FUNCTIONS =============================== + +CMRStringFormatter* CMRStringFormatter::NewL( CCoeEnv& aCoeEnv ) + { + CMRStringFormatter* self = new( ELeave ) CMRStringFormatter( aCoeEnv ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +CMRStringFormatter::~CMRStringFormatter() + { + delete iDateFormat; + delete iTimeFormat; + } + +// ----------------------------------------------------------------------------- +// CMRStringFormatter::CMRStringFormatter +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CMRStringFormatter::CMRStringFormatter( CCoeEnv& aCoeEnv ) : iCoeEnv( aCoeEnv ) + { + } + +// ----------------------------------------------------------------------------- +// CMRStringFormatter::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CMRStringFormatter::ConstructL() + { + iDateFormat = StringLoader::LoadL( R_QTN_DATE_USUAL_WITH_ZERO, &iCoeEnv ); + iTimeFormat = StringLoader::LoadL( R_QTN_TIME_USUAL, &iCoeEnv ); + } + +HBufC* CMRStringFormatter::DateStringLC( const TCalTime& aTime ) const + { + return DateStringLC( aTime.TimeLocalL() ); + } + +HBufC* CMRStringFormatter::DateStringLC( const TTime& aTime ) const + { + TBuf tmpString; + aTime.FormatL( tmpString, *iDateFormat ); + return tmpString.AllocLC(); + } + +HBufC* CMRStringFormatter::TimeStringLC( const TCalTime& aTime ) const + { + return TimeStringLC( aTime.TimeLocalL() ); + } + +HBufC* CMRStringFormatter::TimeStringLC( const TTime& aTime ) const + { + TBuf tmpString; + aTime.FormatL( tmpString, *iTimeFormat ); + return tmpString.AllocLC(); + } + +HBufC* CMRStringFormatter::WhenStringLC( + const TCalTime& aStartTime, + const TCalTime& aEndTime ) const + { + TBuf tmpWhenStartDate; + TBuf tmpWhenStartTime; + TBuf tmpWhendEndTime; + + // use local time in ui + TTime whenStartTime = aStartTime.TimeLocalL(); + TTime whenEndTime = aEndTime.TimeLocalL(); + + whenStartTime.FormatL( tmpWhenStartDate, *iDateFormat ); + whenStartTime.FormatL( tmpWhenStartTime, *iTimeFormat ); + whenEndTime.FormatL( tmpWhendEndTime, *iTimeFormat ); + + CDesCArrayFlat* timeStrings = new( ELeave ) CDesCArrayFlat( 3 ); + CleanupStack::PushL( timeStrings ); + + timeStrings->AppendL( tmpWhenStartDate ); + timeStrings->AppendL( tmpWhenStartTime ); + timeStrings->AppendL( tmpWhendEndTime ); + HBufC* string = StringLoader::LoadL( R_QTN_MAIL_MTG_TIME_DATA, + *timeStrings, + &iCoeEnv ); + CleanupStack::PopAndDestroy( timeStrings ); + CleanupStack::PushL( string ); + return string; + } + +// End of File +