fontservices/fontstore/tfs/T_IsolatedFontStore.cpp
changeset 0 1fb32624e06b
child 40 91ef7621b7fc
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "T_IsolatedFontStore.h"
       
    19 #include <graphics/openfontrasterizer.h>
       
    20 #include <graphics/openfontconstants.h>
       
    21 
       
    22 CTIsolatedFontStore::CTIsolatedFontStore()
       
    23 	{
       
    24 	}
       
    25 
       
    26 CTIsolatedFontStore::~CTIsolatedFontStore()
       
    27 	{
       
    28 	delete iFs;
       
    29 	if (iHeap)
       
    30 		iHeap->Close();
       
    31 	REComSession::FinalClose();
       
    32 	}
       
    33 
       
    34 CTIsolatedFontStore* CTIsolatedFontStore::NewLC()
       
    35 	{
       
    36 	CTIsolatedFontStore* self = new (ELeave)CTIsolatedFontStore();
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 CTIsolatedFontStore* CTIsolatedFontStore::NewL()
       
    43 	{
       
    44 	CTIsolatedFontStore* self=CTIsolatedFontStore::NewLC();
       
    45 	CleanupStack::Pop(); // self;
       
    46 	return self;
       
    47 	}
       
    48 
       
    49 void CTIsolatedFontStore::ConstructL()
       
    50 	{
       
    51 	iHeap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
       
    52 	iFs = CFontStore::NewL(iHeap);
       
    53 	}
       
    54 
       
    55 /**
       
    56 Load all available font rasterizers and install to the instance of CFontStore
       
    57 this class contains.
       
    58 
       
    59 @pre This function hasn't previously been called on this object
       
    60 @post All rasterizers located and successfully loaded will be available for use
       
    61  */
       
    62 void CTIsolatedFontStore::LoadRasterizersL()
       
    63 	{
       
    64 	RImplInfoPtrArray implementationArray;
       
    65 	TUid uid = {KUidOpenFontRasterizerPlunginInterface};
       
    66 
       
    67 	// get implementation list
       
    68 	ListImplementationsWithRetry(uid, implementationArray, EFalse);
       
    69 
       
    70 	const TInt availCount = implementationArray.Count();
       
    71 	for (TInt count=0; count < availCount; ++count)
       
    72 		{
       
    73 		const CImplementationInformation* info = implementationArray[count];
       
    74 		// Create & install a rasterizer
       
    75 		// ignore Leaves, as any necessary cleanup will have already been done through the cleanup stack
       
    76 		TRAP_IGNORE(SafeInstallOfRasterizerL(info->ImplementationUid()));
       
    77 		}
       
    78 	
       
    79 	// free memory
       
    80 	implementationArray.ResetAndDestroy();
       
    81 	}
       
    82 
       
    83 /**
       
    84 Helper function from CFbTop to List all available rasterizers.
       
    85 
       
    86 @param aInterfaceUid The UID of the ECOM plugin
       
    87 @param aImplementationArray An array to store the found plugins
       
    88 @param aRomOnly If ETrue only ROM plugins are returned, otherwise all drives are searched
       
    89 */
       
    90 void CTIsolatedFontStore::ListImplementationsWithRetry(TUid& aInterfaceUid, RImplInfoPtrArray &aImplementationArray, TBool aRomOnly)
       
    91 	{
       
    92 	// Making sure that no race situation arises between FBserv and Ecom
       
    93 	// If ECom is not ready, give it another chance and try again. if it still doesn't work 
       
    94 	// after the third try, then it just carries on quietly and fails... 
       
    95 	for (TInt ecomnotready =0; ecomnotready <3; ecomnotready++)
       
    96 		{
       
    97 		TInt ecomError = KErrNone;
       
    98 		if (aRomOnly)
       
    99 			{
       
   100 			TEComResolverParams resParams;
       
   101 			TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, resParams, KRomOnlyResolverUid, aImplementationArray));
       
   102 			}
       
   103 		else
       
   104 			{ // default resolver
       
   105 			TRAP(ecomError, REComSession::ListImplementationsL(aInterfaceUid, aImplementationArray));
       
   106 			}
       
   107 
       
   108 		if (!ecomError)
       
   109 			{
       
   110 			return;
       
   111 			}
       
   112 		else
       
   113 			{
       
   114 			User::After(0);
       
   115 			}
       
   116 		}
       
   117 	}
       
   118 
       
   119 /**
       
   120 Installs the rasterizer with the specified interface UID.
       
   121 
       
   122 @param aInterfaceImplUid The UID of the rasterizer to be installed.
       
   123 
       
   124 @see CFbTop::SafeInstallOfRasterizerL
       
   125  */
       
   126 void CTIsolatedFontStore::SafeInstallOfRasterizerL(TUid aInterfaceImplUid)
       
   127 	{
       
   128 	COpenFontRasterizer* rasterizer = COpenFontRasterizer::NewL(aInterfaceImplUid);
       
   129 	CleanupStack::PushL(rasterizer);
       
   130 	// Install it in the font store.
       
   131 	iFs->InstallRasterizerL(rasterizer);
       
   132 	CleanupStack::Pop(rasterizer);
       
   133 	}