sl@0: /* sl@0: * Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: _LIT(KLitNameOfResourceFileForBuiltInCharacterSets, "z:\\resource\\charconv\\BUILTIN.RSC"); sl@0: _LIT(KLitRscExtension, ".RSC"); sl@0: sl@0: sl@0: // CCnvCharacterSetNames sl@0: sl@0: EXPORT_C CCnvCharacterSetNames* CCnvCharacterSetNames::NewL(RFs& aFileServerSession, const TArray& aArrayOfCharacterSetsAvailable) sl@0: /** Allocates and constructs a localised list of character set encoding names. sl@0: sl@0: @param aFileServerSession A connected session with the file server. sl@0: @param aArrayOfCharacterSetsAvailable The array of character sets available sl@0: on the phone. This can be created using CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL() sl@0: or CreateArrayOfCharacterSetsAvailableLC(). sl@0: @return Pointer to the newly created object. */ sl@0: { sl@0: CCnvCharacterSetNames* arrayOfNamedCharacterSets=NewLC(aFileServerSession, aArrayOfCharacterSetsAvailable); sl@0: CleanupStack::Pop(arrayOfNamedCharacterSets); sl@0: return arrayOfNamedCharacterSets; sl@0: } sl@0: sl@0: sl@0: EXPORT_C CCnvCharacterSetNames* CCnvCharacterSetNames::NewLC(RFs& aFileServerSession, const TArray& aArrayOfCharacterSetsAvailable) sl@0: /** Allocates and constructs a localised list of character set encoding names. sl@0: Puts a pointer to the object on the cleanup stack. sl@0: sl@0: @param aFileServerSession A connected session with the file server. sl@0: @param aArrayOfCharacterSetsAvailable The array of character sets available sl@0: on the phone. This can be created using CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL() sl@0: or CreateArrayOfCharacterSetsAvailableLC(). sl@0: @return Pointer to the newly created object. */ sl@0: { sl@0: CCnvCharacterSetNames* arrayOfNamedCharacterSets=new(ELeave) CCnvCharacterSetNames; sl@0: CleanupStack::PushL(arrayOfNamedCharacterSets); sl@0: arrayOfNamedCharacterSets->ConstructL(aFileServerSession, aArrayOfCharacterSetsAvailable); sl@0: return arrayOfNamedCharacterSets; sl@0: } sl@0: sl@0: EXPORT_C CCnvCharacterSetNames::~CCnvCharacterSetNames() sl@0: /** Deletes the array of named plug-ins owned by the object prior to its destruction. */ sl@0: { sl@0: delete iNamedPlugins; sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt CCnvCharacterSetNames::IndexOfIdentifier(TUint aIdentifier) const sl@0: /** Gets the index into the sorted list of the character set identifier specified. sl@0: sl@0: @param aIdentifier The character set identifier. This must not be zero, or sl@0: a panic occurs. sl@0: @return The index into the list of the character set identifier, or KErrNotFound sl@0: if the identifier does not exist in the list. */ sl@0: { sl@0: return iNamedPlugins->IndexOfUid(TUid::Uid(aIdentifier)); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TUint CCnvCharacterSetNames::IdentifierAtIndex(TInt aIndex) const sl@0: /** Gets the character set identifier at the specified index into the list. sl@0: sl@0: @param aIndex The index into the list. Must be within the bounds of the array, sl@0: or a panic occurs. sl@0: @return The character set identifier at the specified index. */ sl@0: { sl@0: return iNamedPlugins->UidAtIndex(aIndex).iUid; sl@0: } sl@0: sl@0: CCnvCharacterSetNames::CCnvCharacterSetNames() sl@0: :iNamedPlugins(NULL) sl@0: { sl@0: } sl@0: sl@0: void CCnvCharacterSetNames::DestroyResourceFileArray(TAny* aArrayOfCharconvResourceFiles) sl@0: { sl@0: RArray& arrayOfCharconvResourceFiles=*STATIC_CAST(RArray*, aArrayOfCharconvResourceFiles); sl@0: for (TInt i=arrayOfCharconvResourceFiles.Count()-1; i>=0; --i) sl@0: { sl@0: const CBaNamedPlugins::TResourceFile& resourceFile=arrayOfCharconvResourceFiles[i]; sl@0: delete resourceFile.iFullFileName; sl@0: delete resourceFile.iIdentifier; sl@0: } sl@0: arrayOfCharconvResourceFiles.Close(); sl@0: } sl@0: sl@0: void CCnvCharacterSetNames::ConstructL(RFs& aFileServerSession, const TArray& aArrayOfCharacterSetsAvailable) sl@0: { sl@0: RArray arrayOfCharconvResourceFiles; sl@0: CleanupStack::PushL(TCleanupItem(DestroyResourceFileArray, &arrayOfCharconvResourceFiles)); sl@0: TParse* parser=new(ELeave) TParse; sl@0: CleanupStack::PushL(parser); sl@0: CBaNamedPlugins::TResourceFile resourceFile; sl@0: resourceFile.iFullFileName=KLitNameOfResourceFileForBuiltInCharacterSets().AllocLC(); sl@0: resourceFile.iIdentifier=NULL; sl@0: resourceFile.iUid=KNullUid; sl@0: resourceFile.iFormat=CBaNamedPlugins::TResourceFile::EFormatArrayOfUidNamePairs; sl@0: User::LeaveIfError(arrayOfCharconvResourceFiles.Append(resourceFile)); sl@0: CleanupStack::Pop(resourceFile.iFullFileName); sl@0: for (TInt i=aArrayOfCharacterSetsAvailable.Count()-1; i>=0; --i) sl@0: { sl@0: const CCnvCharacterSetConverter::SCharacterSet& characterSet=aArrayOfCharacterSetsAvailable[i]; sl@0: if (characterSet.NameIsFileName()) sl@0: { sl@0: const TPtrC fileNameOfCharacterSetPlugIn(characterSet.Name()); sl@0: User::LeaveIfError(parser->SetNoWild(KLitRscExtension, &fileNameOfCharacterSetPlugIn, NULL)); sl@0: CBaNamedPlugins::TResourceFile resourceFile; sl@0: resourceFile.iFullFileName=parser->FullName().AllocLC(); sl@0: resourceFile.iIdentifier=NULL; sl@0: resourceFile.iUid=TUid::Uid(characterSet.Identifier()); sl@0: resourceFile.iFormat=CBaNamedPlugins::TResourceFile::EFormatTbuf; sl@0: User::LeaveIfError(arrayOfCharconvResourceFiles.Append(resourceFile)); sl@0: CleanupStack::Pop(resourceFile.iFullFileName); sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(parser); sl@0: CBaNamedPlugins::CParameters* const parameters=CBaNamedPlugins::CParameters::NewLC(aFileServerSession, arrayOfCharconvResourceFiles.Array()); sl@0: iNamedPlugins=CBaNamedPlugins::NewL(*parameters); sl@0: CleanupStack::PopAndDestroy(2, &arrayOfCharconvResourceFiles); sl@0: } sl@0: sl@0: TInt CCnvCharacterSetNames::MdcaCount() const sl@0: { sl@0: return iNamedPlugins->MdcaCount(); sl@0: } sl@0: sl@0: TPtrC CCnvCharacterSetNames::MdcaPoint(TInt aIndex) const sl@0: { sl@0: return iNamedPlugins->MdcaPoint(aIndex); sl@0: } sl@0: