graphics/fntstore/src/T_GraphicsFntstoreAPIServer.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 /*
       
     2 * Copyright (c) 2005-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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "T_GraphicsFntstoreAPIServer.h"
       
    19 #include "T_DataAlgStyle.h"
       
    20 #include "T_DataFontStore.h"
       
    21 #include "T_DataBitmapFont.h"
       
    22 #include "T_DataOpenFontGlyphData.h"
       
    23 #include "T_DataOpenFontRasterizerContext.h"
       
    24 
       
    25 //	EPOC Includes
       
    26 #include <rsshared.h>
       
    27 
       
    28 /**
       
    29  * @enum Constant Literals used.
       
    30  */
       
    31 /*@{*/
       
    32 // Graphics Fntstore API
       
    33 
       
    34 _LIT(KTAlgStyle,						"TAlgStyle");
       
    35 _LIT(KCFontStore,						"CFontStore");
       
    36 _LIT(KCBitmapFont,						"CBitmapFont");
       
    37 _LIT(KTOpenFontGlyphData,				"TOpenFontGlyphData");
       
    38 _LIT(KCOpenFontRasterizerContext,		"COpenFontRasterizerContext");
       
    39 /*@}*/
       
    40 
       
    41 
       
    42 inline CDataWrapper* CT_GraphicsFntstoreAPIServer::CT_GraphicsFntstoreAPIBlock::CreateDataL( const TDesC& aData )
       
    43 	{
       
    44 	CDataWrapper*	wrapper = NULL;
       
    45 
       
    46 	if (aData == KCFontStore)
       
    47 		{
       
    48 		wrapper = CT_DataFontStore::NewL();
       
    49 		}
       
    50 	else if (aData == KCBitmapFont)
       
    51 		{
       
    52 		wrapper = CT_DataBitmapFont::NewL();
       
    53 		}
       
    54 	else if (aData == KTAlgStyle)
       
    55 		{
       
    56 		wrapper = CT_DataAlgStyle::NewL();
       
    57 		}
       
    58 	else if (aData == KTOpenFontGlyphData)
       
    59 		{
       
    60 		wrapper = CT_DataOpenFontGlyphData::NewL();
       
    61 		}
       
    62 	else if (aData == KCOpenFontRasterizerContext)
       
    63 		{
       
    64 		wrapper = CT_DataOpenFontRasterizerContext::NewL();
       
    65 		}
       
    66 	
       
    67 	return wrapper;
       
    68 	}
       
    69 
       
    70 CT_GraphicsFntstoreAPIServer* CT_GraphicsFntstoreAPIServer::NewL()
       
    71 /**
       
    72  * @return - Instance of the test server
       
    73  * Same code for Secure and non-secure variants
       
    74  * Called inside the MainL() function to create and start the
       
    75  * CTestServer derived server.
       
    76  */
       
    77 	{
       
    78 	CT_GraphicsFntstoreAPIServer*	server = new (ELeave) CT_GraphicsFntstoreAPIServer();
       
    79 	CleanupStack::PushL(server);
       
    80 	// CServer base class call
       
    81 	server->ConstructL();		/*Parsing the server name from the file name*/
       
    82 	CleanupStack::Pop(server);
       
    83 	return server;
       
    84 	}
       
    85 
       
    86 
       
    87 TInt LoadDrivers()
       
    88 	{
       
    89 #ifdef __WINS__
       
    90 	#define KPDDName _L("ECDRV")
       
    91 	#define KLDDName _L("ECOMM")
       
    92 #else
       
    93 	#define KPDDName _L("EUART1")
       
    94 	#define KLDDName _L("ECOMM")
       
    95 #endif
       
    96 	TInt rerr = KErrNone;
       
    97 
       
    98 	rerr = StartC32();
       
    99 	if( rerr!=KErrNone && rerr!=KErrAlreadyExists )
       
   100 		{
       
   101 		return rerr;
       
   102 		}
       
   103 
       
   104 	rerr = User::LoadPhysicalDevice(KPDDName);
       
   105 	if(rerr != KErrNone && rerr != KErrAlreadyExists)
       
   106 		{
       
   107 		return rerr;
       
   108 		}
       
   109 	rerr = User::LoadLogicalDevice(KLDDName);
       
   110 	if(rerr != KErrNone && rerr != KErrAlreadyExists)
       
   111 		{
       
   112 		return rerr;
       
   113 		}
       
   114 	return KErrNone;
       
   115 	}
       
   116 
       
   117 LOCAL_C void MainL()
       
   118 /**
       
   119  * Secure variant
       
   120  * Much simpler, uses the new Rendezvous() call to sync with the client
       
   121  */
       
   122 	{
       
   123 #if (defined __DATA_CAGING__)
       
   124 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   125 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
   126 #endif
       
   127 	CActiveScheduler*	sched=NULL;
       
   128 	sched=new(ELeave) CActiveScheduler;
       
   129 	CActiveScheduler::Install(sched);
       
   130 	CT_GraphicsFntstoreAPIServer*	server = NULL;
       
   131 	// Create the CTestServer derived server
       
   132 	TRAPD(err,server = CT_GraphicsFntstoreAPIServer::NewL());
       
   133 	if(!err)
       
   134 		{
       
   135 		// Sync with the client and enter the active scheduler
       
   136 		RProcess::Rendezvous(KErrNone);
       
   137 		sched->Start();
       
   138 		}
       
   139 	delete server;
       
   140 	delete sched;
       
   141 	}
       
   142 
       
   143 GLDEF_C TInt E32Main()
       
   144 /**
       
   145  * @return - Standard Epoc error code on process exit
       
   146  * Secure variant only
       
   147  * Process entry point. Called by client using RProcess API
       
   148  */
       
   149 	{
       
   150 	TInt rerr = LoadDrivers();
       
   151 	if( rerr != KErrNone )
       
   152 		{
       
   153 		return rerr;
       
   154 		}
       
   155 
       
   156 	__UHEAP_MARK;
       
   157 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   158 	if(cleanup == NULL)
       
   159 		{
       
   160 		return KErrNoMemory;
       
   161 		}
       
   162 #if (defined TRAP_IGNORE)
       
   163 	TRAP_IGNORE(MainL());
       
   164 #else
       
   165 	TRAPD(err,MainL());
       
   166 #endif
       
   167 	delete cleanup;
       
   168 	__UHEAP_MARKEND;
       
   169 	return KErrNone;
       
   170 	}