diff -r 000000000000 -r 72b543305e3a email/mail/ViewerSrc/Msgmailcharactersethandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/email/mail/ViewerSrc/Msgmailcharactersethandler.cpp Thu Dec 17 08:44:11 2009 +0200 @@ -0,0 +1,272 @@ +/* +* 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: Character set handler +* +*/ + + + +// INCLUDE FILES +#include "Msgmailcharactersethandler.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +// CONSTANTS +enum TVariationFlag + { + EDefault, + EJapaneseVariant, + EChineseVariant + }; +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CMsgMailCharacterSetHandler::CMsgMailCharacterSetHandler +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CMsgMailCharacterSetHandler::CMsgMailCharacterSetHandler() + { + } + +// ----------------------------------------------------------------------------- +// CMsgMailCharacterSetHandler::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CMsgMailCharacterSetHandler::ConstructL() + { + if( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) + { + iVariationFlag = EJapaneseVariant; + } + else if( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) + { + iVariationFlag = EChineseVariant; + } + else + { + iVariationFlag = EDefault; + } + + iFirstFreeCommandId = 0; + AppendItemsToItemArrayL(); + } + +// ----------------------------------------------------------------------------- +// CMsgMailCharacterSetHandler::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CMsgMailCharacterSetHandler* CMsgMailCharacterSetHandler::NewL( + TInt aFirstFreeCommandId ) + { + CMsgMailCharacterSetHandler* self = new( + ELeave ) CMsgMailCharacterSetHandler; + + CleanupStack::PushL( self ); + self->ConstructL(); + self->iFirstFreeCommandId = aFirstFreeCommandId; + CleanupStack::Pop(); // self + return self; + } + + +// Destructor +CMsgMailCharacterSetHandler::~CMsgMailCharacterSetHandler() + { + iItems.Close(); + } + + +// ----------------------------------------------------------------------------- +// CMsgMailCharacterSetHandler::SetCharacterSetSubMenuItemsL +// Set filtered list of available characterset to menupane +// ----------------------------------------------------------------------------- +// +void CMsgMailCharacterSetHandler::SetCharacterSetSubMenuItemsL( + CEikMenuPane& aMenuPane, TUint aActiveCharacterSet) + { + for (TInt i=0; iFsSession(); + + CArrayFix* charSets = + CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC( fs ); + + for (TInt i=0; iCount(); i++) + { + const TUint identifier = (*charSets)[i].Identifier(); + if ( IsAcceptedCharacterSet( identifier ) ) + { + TData data; + data.iCommandId = i; + data.iCharacterSetId = identifier; + + HBufC* buf = NULL; + // China + if ( identifier == KCharacterSetIdentifierGb2312 ) + { + buf = StringLoader::LoadL(R_QTN_CHI_MAIL_SM_GB2312); + } + else if ( identifier == KCharacterSetIdentifierBig5 ) + { + buf = StringLoader::LoadL(R_QTN_CHI_MAIL_SM_BIG5); + } + // Japanice + else if ( identifier == KCharacterSetIdentifierIso2022Jp ) + { + buf = StringLoader::LoadL(R_QTN_JPN_MAIL_SM_CHARSET_ISO2022JP); + } + else if ( identifier == KCharacterSetIdentifierEucJpPacked ) + { + buf = StringLoader::LoadL(R_QTN_JPN_MAIL_SM_CHARSET_EUCJP); + } + else if ( identifier == KCharacterSetIdentifierShiftJis ) + { + buf = StringLoader::LoadL(R_QTN_JPN_MAIL_SM_CHARSET_SHIFTJIS); + } + else + { + // Ask name from charconv + CCnvCharacterSetConverter* charConv = + CCnvCharacterSetConverter::NewLC(); + HBufC8* name = charConv-> + ConvertCharacterSetIdentifierToStandardNameL( + identifier, fs); + if ( name ) + { + CleanupStack::PushL( name ); + // cleanupstack is not needed here since + // the code cannot leave before deleting this buffer + buf = HBufC::NewL( name->Length() ); // CSI: 35 # see comment above + buf->Des().Copy( *name ); + CleanupStack::PopAndDestroy(); // name + } + CleanupStack::PopAndDestroy(); // charConv + } + + if (!buf) + { + buf = KNullDesC().AllocL(); + } + data.iText.Copy(buf->Left(data.ENominalTextLength)); + delete buf; + buf = NULL; + + User::LeaveIfError( iItems.Append(data) ); + } + } + CleanupStack::PopAndDestroy(); // charSets + } + +// End of File