Update contrib.
2 * Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_IsolatedFontStore.h"
19 #include <graphics/openfontrasterizer.h>
20 #include <graphics/openfontconstants.h>
22 CTIsolatedFontStore::CTIsolatedFontStore():iIsHeapOwner(ETrue)
26 CTIsolatedFontStore::CTIsolatedFontStore(RHeap* aHeap):iIsHeapOwner(EFalse),iHeap(aHeap)
30 CTIsolatedFontStore::~CTIsolatedFontStore()
33 if (iIsHeapOwner && iHeap)
37 REComSession::FinalClose();
40 CTIsolatedFontStore* CTIsolatedFontStore::NewLC()
42 CTIsolatedFontStore* self = new (ELeave)CTIsolatedFontStore();
43 CleanupStack::PushL(self);
48 CTIsolatedFontStore* CTIsolatedFontStore::NewL()
50 CTIsolatedFontStore* self=CTIsolatedFontStore::NewLC();
51 CleanupStack::Pop(); // self;
55 CTIsolatedFontStore* CTIsolatedFontStore::NewLC(RHeap * aHeap)
57 CTIsolatedFontStore* self = new (ELeave)CTIsolatedFontStore(aHeap);
58 CleanupStack::PushL(self);
63 CTIsolatedFontStore* CTIsolatedFontStore::NewL(RHeap * aHeap)
65 CTIsolatedFontStore* self=CTIsolatedFontStore::NewLC(aHeap);
66 CleanupStack::Pop(); // self;
70 void CTIsolatedFontStore::ConstructL()
74 iHeap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
76 iFs = CFontStore::NewL(iHeap);
80 Load all available font rasterizers and install to the instance of CFontStore
83 @pre This function hasn't previously been called on this object
84 @post All rasterizers located and successfully loaded will be available for use
86 void CTIsolatedFontStore::LoadRasterizersL()
88 RImplInfoPtrArray implementationArray;
89 TUid uid = {KUidOpenFontRasterizerPlunginInterface};
91 // get implementation list
92 ListImplementationsWithRetry(uid, implementationArray, EFalse);
94 const TInt availCount = implementationArray.Count();
95 for (TInt count=0; count < availCount; ++count)
97 const CImplementationInformation* info = implementationArray[count];
98 // Create & install a rasterizer
99 // ignore Leaves, as any necessary cleanup will have already been done through the cleanup stack
100 TRAP_IGNORE(SafeInstallOfRasterizerL(info->ImplementationUid()));
104 implementationArray.ResetAndDestroy();
108 Helper function from CFbTop to List all available rasterizers.
110 @param aInterfaceUid The UID of the ECOM plugin
111 @param aImplementationArray An array to store the found plugins
112 @param aRomOnly If ETrue only ROM plugins are returned, otherwise all drives are searched
114 void CTIsolatedFontStore::ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly)
116 // Making sure that no race situation arises between FBserv and Ecom
117 // If ECom is not ready, give it another chance and try again. if it still doesn't work
118 // after the third try, then it just carries on quietly and fails...
119 for (TInt ecomnotready =0; ecomnotready <3; ecomnotready++)
121 TInt ecomError = KErrNone;
124 TEComResolverParams resParams;
125 TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, resParams, KRomOnlyResolverUid, aImplementationArray));
128 { // default resolver
129 TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, aImplementationArray));
144 Installs the rasterizer with the specified interface UID.
146 @param aInterfaceImplUid The UID of the rasterizer to be installed.
148 @see CFbTop::SafeInstallOfRasterizerL
150 void CTIsolatedFontStore::SafeInstallOfRasterizerL(TUid aInterfaceImplUid)
152 COpenFontRasterizer* rasterizer = COpenFontRasterizer::NewL(aInterfaceImplUid);
153 CleanupStack::PushL(rasterizer);
154 // Install it in the font store.
155 iFs->InstallRasterizerL(rasterizer);
156 CleanupStack::Pop(rasterizer);