sl@0: /* sl@0: * Copyright (c) 1995-2010 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: #include "T_IsolatedFontStore.h" sl@0: #include sl@0: #include sl@0: sl@0: CTIsolatedFontStore::CTIsolatedFontStore():iIsHeapOwner(ETrue) sl@0: { sl@0: } sl@0: sl@0: CTIsolatedFontStore::CTIsolatedFontStore(RHeap* aHeap):iIsHeapOwner(EFalse),iHeap(aHeap) sl@0: { sl@0: } sl@0: sl@0: CTIsolatedFontStore::~CTIsolatedFontStore() sl@0: { sl@0: delete iFs; sl@0: if (iIsHeapOwner && iHeap) sl@0: { sl@0: iHeap->Close(); sl@0: } sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: CTIsolatedFontStore* CTIsolatedFontStore::NewLC() sl@0: { sl@0: CTIsolatedFontStore* self = new (ELeave)CTIsolatedFontStore(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: CTIsolatedFontStore* CTIsolatedFontStore::NewL() sl@0: { sl@0: CTIsolatedFontStore* self=CTIsolatedFontStore::NewLC(); sl@0: CleanupStack::Pop(); // self; sl@0: return self; sl@0: } sl@0: sl@0: CTIsolatedFontStore* CTIsolatedFontStore::NewLC(RHeap * aHeap) sl@0: { sl@0: CTIsolatedFontStore* self = new (ELeave)CTIsolatedFontStore(aHeap); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: CTIsolatedFontStore* CTIsolatedFontStore::NewL(RHeap * aHeap) sl@0: { sl@0: CTIsolatedFontStore* self=CTIsolatedFontStore::NewLC(aHeap); sl@0: CleanupStack::Pop(); // self; sl@0: return self; sl@0: } sl@0: sl@0: void CTIsolatedFontStore::ConstructL() sl@0: { sl@0: if(iIsHeapOwner) sl@0: { sl@0: iHeap = UserHeap::ChunkHeap(NULL,0x10000,0x10000); sl@0: } sl@0: iFs = CFontStore::NewL(iHeap); sl@0: } sl@0: sl@0: /** sl@0: Load all available font rasterizers and install to the instance of CFontStore sl@0: this class contains. sl@0: sl@0: @pre This function hasn't previously been called on this object sl@0: @post All rasterizers located and successfully loaded will be available for use sl@0: */ sl@0: void CTIsolatedFontStore::LoadRasterizersL() sl@0: { sl@0: RImplInfoPtrArray implementationArray; sl@0: TUid uid = {KUidOpenFontRasterizerPlunginInterface}; sl@0: sl@0: // get implementation list sl@0: ListImplementationsWithRetry(uid, implementationArray, EFalse); sl@0: sl@0: const TInt availCount = implementationArray.Count(); sl@0: for (TInt count=0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = implementationArray[count]; sl@0: // Create & install a rasterizer sl@0: // ignore Leaves, as any necessary cleanup will have already been done through the cleanup stack sl@0: TRAP_IGNORE(SafeInstallOfRasterizerL(info->ImplementationUid())); sl@0: } sl@0: sl@0: // free memory sl@0: implementationArray.ResetAndDestroy(); sl@0: } sl@0: sl@0: /** sl@0: Helper function from CFbTop to List all available rasterizers. sl@0: sl@0: @param aInterfaceUid The UID of the ECOM plugin sl@0: @param aImplementationArray An array to store the found plugins sl@0: @param aRomOnly If ETrue only ROM plugins are returned, otherwise all drives are searched sl@0: */ sl@0: void CTIsolatedFontStore::ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly) sl@0: { sl@0: // Making sure that no race situation arises between FBserv and Ecom sl@0: // If ECom is not ready, give it another chance and try again. if it still doesn't work sl@0: // after the third try, then it just carries on quietly and fails... sl@0: for (TInt ecomnotready =0; ecomnotready <3; ecomnotready++) sl@0: { sl@0: TInt ecomError = KErrNone; sl@0: if (aRomOnly) sl@0: { sl@0: TEComResolverParams resParams; sl@0: TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, resParams, KRomOnlyResolverUid, aImplementationArray)); sl@0: } sl@0: else sl@0: { // default resolver sl@0: TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, aImplementationArray)); sl@0: } sl@0: sl@0: if (!ecomError) sl@0: { sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: User::After(0); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Installs the rasterizer with the specified interface UID. sl@0: sl@0: @param aInterfaceImplUid The UID of the rasterizer to be installed. sl@0: sl@0: @see CFbTop::SafeInstallOfRasterizerL sl@0: */ sl@0: void CTIsolatedFontStore::SafeInstallOfRasterizerL(TUid aInterfaceImplUid) sl@0: { sl@0: COpenFontRasterizer* rasterizer = COpenFontRasterizer::NewL(aInterfaceImplUid); sl@0: CleanupStack::PushL(rasterizer); sl@0: // Install it in the font store. sl@0: iFs->InstallRasterizerL(rasterizer); sl@0: CleanupStack::Pop(rasterizer); sl@0: }