graphicsapitest/graphicssvs/bitgdi/src/T_GraphicsBitgdiAPIServer.cpp
changeset 103 2717213c588a
parent 98 bf7481649c98
child 116 171fae344dd4
child 121 d72fc2aace31
child 187 9f66f99ee56f
equal deleted inserted replaced
98:bf7481649c98 103:2717213c588a
     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 "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_GraphicsBitgdiAPIServer.h"
       
    19 #include "T_DataBitmapUtil.h"
       
    20 #include "T_DataFbsBitmap.h"
       
    21 #include "T_DataWsBitmap.h"
       
    22 #include "T_DataFbsBitmapDevice.h"
       
    23 #include "T_DataFbsScreenDevice.h"
       
    24 #include "T_DataAlgStyle.h"
       
    25 #include "T_DataFbsBitGc.h"
       
    26 #include "T_DataFbsSession.h"
       
    27 #include "T_DataWsSession.h"
       
    28 #include "T_DataPalette.h"
       
    29 #include "T_DataPolygonFiller.h"
       
    30 #include "T_DataFbsFont.h"
       
    31 #include "T_DataFbsTypefaceStore.h"
       
    32 #include "T_DataWsScreenDevice.h"
       
    33 #include "T_DataFbsBitGcBitmap.h"
       
    34 #include "T_DataFbsBitGcFont.h"
       
    35 #include "T_DataLinkedTypefaceSpecification.h"
       
    36 
       
    37 //	EPOC Includes
       
    38 #include <rsshared.h>
       
    39 
       
    40 /**
       
    41  * @enum Constant Literals used.
       
    42  */
       
    43 /*@{*/
       
    44 // Graphics BITGDI API
       
    45 _LIT(KDataFbsBitGc,				"CFbsBitGc");
       
    46 _LIT(KDataPolygonFiller,       	"CPolygonFiller");
       
    47 
       
    48 //from T_FBServAPI
       
    49 _LIT(KRFbsSessionData, 			"RFbsSession");
       
    50 _LIT(KCFbsFontData, 			"CFbsFont");
       
    51 _LIT(KCFbsBitmapData, 			"CFbsBitmap");
       
    52 _LIT(KCWsBitmapData, 			"CWsBitmap");
       
    53 _LIT(KTBitmapUtilData, 			"TBitmapUtil");
       
    54 _LIT(KCFbsTypefaceStoreData,	"CFbsTypefaceStore");
       
    55 _LIT(KCFbsColor256BitmapUtil,	"CFbsColor256BitmapUtil");
       
    56 _LIT(KCPalette,					"CPalette");
       
    57 _LIT(KCFbsBitmapDevice,			"CFbsBitmapDevice");
       
    58 _LIT(KCFbsScreenDevice,			"CFbsScreenDevice");
       
    59 _LIT(KTAlgStyle,				"TAlgStyle");
       
    60 _LIT(KTMeasureTextInput,		"TMeasureTextInput");
       
    61 _LIT(KTMeasureTextOutput,		"TMeasureTextOutput");
       
    62 _LIT(KRWsSession,				"RWsSession");
       
    63 _LIT(KCWsScreenDevice,			"CWsScreenDevice");
       
    64 _LIT(KCFbsBitGcBitmap,			"CFbsBitGcBitmap");
       
    65 _LIT(KCFbsBitGcFont,			"CFbsBitGcFont");
       
    66 
       
    67 //from T_GraphicsFntstoreAPI
       
    68 _LIT(KCLinkedTypefaceSpecification,	"CLinkedTypefaceSpecification");
       
    69 
       
    70 /*@}*/
       
    71 
       
    72 
       
    73 inline CDataWrapper* CT_GraphicsBitgdiAPIServer::CT_GraphicsBitgdiAPIBlock::CreateDataL( const TDesC& aData )
       
    74 	{
       
    75 	CDataWrapper*	wrapper = NULL;
       
    76 
       
    77 	if ( aData==KRFbsSessionData )
       
    78 		{
       
    79 		wrapper=CT_DataFbsSession::NewL();
       
    80 		}
       
    81 	else if ( aData==KCFbsScreenDevice )
       
    82 		{
       
    83 		wrapper=CT_DataFbsScreenDevice::NewL();
       
    84 		}
       
    85 	else if ( aData==KDataFbsBitGc )
       
    86 		{
       
    87 		wrapper=CT_DataFbsBitGc::NewL();
       
    88 		}
       
    89 	else if ( aData==KCPalette )
       
    90 		{
       
    91 		wrapper=CT_DataPalette::NewL();
       
    92 		}
       
    93 	else if (aData==KDataPolygonFiller)
       
    94 		{
       
    95 		wrapper=CT_DataPolygonFiller::NewL();
       
    96 		}
       
    97 	else if (aData == KCFbsFontData)
       
    98         {
       
    99 		wrapper=CT_DataFbsFont::NewL();
       
   100         }
       
   101 	else if (aData==KCFbsBitmapData)
       
   102 		{
       
   103 		wrapper=CT_DataFbsBitmap::NewL();
       
   104 		}
       
   105 	else if (aData==KCWsBitmapData)
       
   106 		{
       
   107 		wrapper=CT_DataWsBitmap::NewL();
       
   108 		}
       
   109 	else if (aData==KRWsSession)
       
   110 		{
       
   111 		wrapper=CT_DataWsSession::NewL();
       
   112 		}
       
   113 	else if (aData==KCFbsTypefaceStoreData)
       
   114 		{
       
   115 		wrapper=CT_DataFbsTypefaceStore::NewL();
       
   116 		}
       
   117 	else if (aData==KCWsScreenDevice)
       
   118 		{
       
   119 		wrapper=CT_DataWsScreenDevice::NewL();
       
   120 		}
       
   121 	else if (aData==KCFbsBitmapDevice)
       
   122 		{
       
   123 		wrapper=CT_DataFbsBitmapDevice::NewL();
       
   124 		}
       
   125 	else if (aData==KCFbsBitGcBitmap)
       
   126 		{
       
   127 		wrapper=CT_DataFbsBitGcBitmap::NewL();
       
   128 		}
       
   129 	else if (aData==KCFbsBitGcFont)
       
   130 		{
       
   131 		wrapper=CT_DataFbsBitGcFont::NewL();
       
   132 		}
       
   133 	// from fontstore
       
   134 	else if (aData==KTAlgStyle)
       
   135 		{
       
   136 		wrapper=CT_DataAlgStyle::NewL();
       
   137 		}	
       
   138 	else if (aData==KCLinkedTypefaceSpecification)
       
   139 		{
       
   140 		wrapper=CT_DataLinkedTypefaceSpecification::NewL();
       
   141 		}
       
   142 	return wrapper;
       
   143 	}
       
   144 
       
   145 CT_GraphicsBitgdiAPIServer* CT_GraphicsBitgdiAPIServer::NewL()
       
   146 /**
       
   147  * @return - Instance of the test server
       
   148  * Same code for Secure and non-secure variants
       
   149  * Called inside the MainL() function to create and start the
       
   150  * CTestServer derived server.
       
   151  */
       
   152 	{
       
   153 	CT_GraphicsBitgdiAPIServer*	server = new (ELeave) CT_GraphicsBitgdiAPIServer();
       
   154 	CleanupStack::PushL(server);
       
   155 	// CServer base class call
       
   156 	server->ConstructL();		/*Parsing the server name from the file name*/
       
   157 	CleanupStack::Pop(server);
       
   158 	return server;
       
   159 	}
       
   160 
       
   161 
       
   162 TInt LoadDrivers()
       
   163 	{
       
   164 #ifdef __WINS__
       
   165 	#define KPDDName _L("ECDRV")
       
   166 	#define KLDDName _L("ECOMM")
       
   167 #else
       
   168 	#define KPDDName _L("EUART1")
       
   169 	#define KLDDName _L("ECOMM")
       
   170 #endif
       
   171 	TInt rerr = KErrNone;
       
   172 
       
   173 	rerr = StartC32();
       
   174 	if( rerr!=KErrNone && rerr!=KErrAlreadyExists )
       
   175 		{
       
   176 		return rerr;
       
   177 		}
       
   178 
       
   179 	rerr = User::LoadPhysicalDevice(KPDDName);
       
   180 	if(rerr != KErrNone && rerr != KErrAlreadyExists)
       
   181 		{
       
   182 		return rerr;
       
   183 		}
       
   184 	rerr = User::LoadLogicalDevice(KLDDName);
       
   185 	if(rerr != KErrNone && rerr != KErrAlreadyExists)
       
   186 		{
       
   187 		return rerr;
       
   188 		}
       
   189 	return KErrNone;
       
   190 	}
       
   191 
       
   192 LOCAL_C void MainL()
       
   193 /**
       
   194  * Secure variant
       
   195  * Much simpler, uses the new Rendezvous() call to sync with the client
       
   196  */
       
   197 	{
       
   198 #if (defined __DATA_CAGING__)
       
   199 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   200 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
   201 #endif
       
   202 	CActiveScheduler*	sched=NULL;
       
   203 	sched=new(ELeave) CActiveScheduler;
       
   204 	CActiveScheduler::Install(sched);
       
   205 	CT_GraphicsBitgdiAPIServer*	server = NULL;
       
   206 	// Create the CTestServer derived server
       
   207 	TRAPD(err,server = CT_GraphicsBitgdiAPIServer::NewL());
       
   208 	if(!err)
       
   209 		{
       
   210 		// Sync with the client and enter the active scheduler
       
   211 		RProcess::Rendezvous(KErrNone);
       
   212 		sched->Start();
       
   213 		}
       
   214 	delete server;
       
   215 	delete sched;
       
   216 	}
       
   217 
       
   218 GLDEF_C TInt E32Main()
       
   219 /**
       
   220  * @return - Standard Epoc error code on process exit
       
   221  * Secure variant only
       
   222  * Process entry point. Called by client using RProcess API
       
   223  */
       
   224 	{
       
   225 	TInt rerr = LoadDrivers();
       
   226 	if( rerr != KErrNone )
       
   227 		{
       
   228 		return rerr;
       
   229 		}
       
   230 
       
   231 	__UHEAP_MARK;
       
   232 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   233 	if(cleanup == NULL)
       
   234 		{
       
   235 		return KErrNoMemory;
       
   236 		}
       
   237 #if (defined TRAP_IGNORE)
       
   238 	TRAP_IGNORE(MainL());
       
   239 #else
       
   240 	TRAPD(err,MainL());
       
   241 #endif
       
   242 	delete cleanup;
       
   243 	__UHEAP_MARKEND;
       
   244 	return KErrNone;
       
   245 	}