os/graphics/fbs/fontandbitmapserver/sfbs/SESSION.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/SESSION.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,604 @@
     1.4 +// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <fbs.h>
    1.20 +#include "fbsdefs.h"
    1.21 +#include "UTILS.H"
    1.22 +#include "FBSVER.H"
    1.23 +#include "FbsRalc.h"
    1.24 +#include "fbshelper.h"
    1.25 +#include "FbsMessage.H"
    1.26 +#include <graphics/fbsoogmmessage.h>
    1.27 +#include "OstTraceDefinitions.h"
    1.28 +#include "fbstrace.h"
    1.29 +#ifdef OST_TRACE_COMPILER_IN_USE
    1.30 +#include "SESSIONTraces.h"
    1.31 +#endif
    1.32 +
    1.33 +GLDEF_C void Panic(TFbsPanic aPanic)
    1.34 +	{
    1.35 +	_LIT(KFBSERVClientPanicCategory,"FBSCLI");
    1.36 +	User::Panic(KFBSERVClientPanicCategory,aPanic);
    1.37 +	}
    1.38 +
    1.39 +EXPORT_C TInt FbsStartup()
    1.40 +	{
    1.41 +	RChunk sharedchunk;
    1.42 +	TInt ret = sharedchunk.OpenGlobal(KFBSERVSharedChunkName,EFalse);
    1.43 +	if (ret == KErrNone)
    1.44 +		{
    1.45 +		sharedchunk.Close();
    1.46 +		return KErrNone;
    1.47 +		}
    1.48 +
    1.49 +	RProcess fbs;
    1.50 +	_LIT(KFBSERVServerExe,"z:\\sys\\bin\\fbserv.exe");
    1.51 +	ret = fbs.Create(KFBSERVServerExe,KNullDesC);
    1.52 +
    1.53 +	if (ret!=KErrNone)
    1.54 +		return ret;
    1.55 +	
    1.56 +  	
    1.57 +	TRequestStatus stat;
    1.58 +	fbs.Rendezvous(stat);
    1.59 +	if (stat!=KRequestPending)
    1.60 +		fbs.Kill(0);		// abort startup
    1.61 +	else
    1.62 +		fbs.Resume();	// logon OK - start the server
    1.63 +	User::WaitForRequest(stat);		// wait for start or death
    1.64 +	// we can't use the 'exit reason' if the server panicked as this
    1.65 +	// is the panic 'reason' and may be '0' which cannot be distinguished
    1.66 +	// from KErrNone
    1.67 +	ret=(fbs.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
    1.68 +	fbs.Close();
    1.69 +	return ret;
    1.70 +	}
    1.71 +
    1.72 +
    1.73 +//
    1.74 +// Fontbitmap server client side session
    1.75 +//
    1.76 +
    1.77 +/** 
    1.78 +@publishedAll 
    1.79 +@released
    1.80 +*/
    1.81 +EXPORT_C RFbsSession::RFbsSession():
    1.82 +	RSessionBase(),
    1.83 +	iConnections(0),
    1.84 +	iCallBack(),
    1.85 +	iSharedChunk(),
    1.86 +	iHelper(NULL),
    1.87 +	iRomFileAddrCache(NULL),
    1.88 +	iDecompressionBuffer(NULL),
    1.89 +	iScanLineBuffer(NULL),
    1.90 +	iSpare(NULL)
    1.91 +	{}
    1.92 +
    1.93 +/** Creates a session with the Font and Bitmap server.
    1.94 +@param aFileServer A fuly constructed file server session
    1.95 +@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
    1.96 +to create the session; otherwise another of the system-wide error codes. 
    1.97 +@publishedAll 
    1.98 +@released
    1.99 +*/
   1.100 +EXPORT_C TInt RFbsSession::Connect(RFs& aFileServer)
   1.101 +	{
   1.102 +    TInt ret = KErrNone;
   1.103 +	RFbsSession* thisptr = (RFbsSession*)Dll::Tls();
   1.104 +	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
   1.105 +	if(thisptr)
   1.106 +		{
   1.107 +		thisptr->iConnections++;
   1.108 +		FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);)
   1.109 +		}
   1.110 +	else
   1.111 +	    {
   1.112 +        ret = RFbsSession::DoAlloc(thisptr);
   1.113 +        if(ret!=KErrNone)
   1.114 +            {
   1.115 +            FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR, "! DoAlloc returned %d", ret);)
   1.116 +            }
   1.117 +        else
   1.118 +            {
   1.119 +            ret = thisptr->DoConnect(aFileServer);
   1.120 +            if(ret!=KErrNone)
   1.121 +                {
   1.122 +                FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR2, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);)
   1.123 +                }
   1.124 +            }
   1.125 +	    }
   1.126 +	
   1.127 +	FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);)
   1.128 +	return ret; 
   1.129 +	}
   1.130 +
   1.131 +/** Creates a session with the Font and Bitmap server.
   1.132 +@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
   1.133 +to create the session; otherwise another of the system-wide error codes. 
   1.134 +@publishedAll 
   1.135 +@released
   1.136 +*/
   1.137 +EXPORT_C TInt RFbsSession::Connect()
   1.138 +	{
   1.139 +    TInt ret = KErrNone;
   1.140 +	RFbsSession* thisptr = (RFbsSession*)Dll::Tls();
   1.141 +	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
   1.142 +	if(thisptr)
   1.143 +		{
   1.144 +		thisptr->iConnections++;
   1.145 +	    FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT2_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);)
   1.146 +		}
   1.147 +	else
   1.148 +	    {
   1.149 +        TInt ret = RFbsSession::DoAlloc(thisptr);
   1.150 +        if (ret!=KErrNone)
   1.151 +            {
   1.152 +            FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR, "! DoAlloc returned %d", ret);)
   1.153 +            goto end;
   1.154 +            }
   1.155 +            
   1.156 +        ret = thisptr->iFileServer.Connect();
   1.157 +        if(ret!=KErrNone)
   1.158 +            {
   1.159 +            thisptr->Disconnect();
   1.160 +            FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR2, "! this=0x%08x; RFs::Connect() returned %d", (TInt)thisptr, ret);)
   1.161 +            goto end;
   1.162 +            }
   1.163 +        
   1.164 +        ret = thisptr->DoConnect(thisptr->iFileServer);
   1.165 +        if(ret!=KErrNone)
   1.166 +            {
   1.167 +            FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR3, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);)
   1.168 +            }
   1.169 +	    }
   1.170 +end:
   1.171 +	FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);)
   1.172 +	return ret;
   1.173 +	}
   1.174 +
   1.175 +/** Closes the session with the Font and Bitmap server. 
   1.176 +@publishedAll 
   1.177 +@released
   1.178 +*/
   1.179 +EXPORT_C void RFbsSession::Disconnect()
   1.180 +	{
   1.181 +	RFbsSession* thisptr=(RFbsSession*)Dll::Tls();
   1.182 +    FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
   1.183 +	if(thisptr)
   1.184 +	    {
   1.185 +        TInt tempServerSessionHandle = thisptr->ServerSessionHandle();
   1.186 +        if(thisptr->iConnections>0)
   1.187 +            {
   1.188 +            thisptr->iCallBack.iPtr=NULL;
   1.189 +            thisptr->iCallBack.CallBack();
   1.190 +            // Destructor of CFbsSessionHelper may call SendCommand to cancel an
   1.191 +            // outstanding request, therefore destruction must be done before
   1.192 +            // iConnections is 0 to avoid an assertion going off.
   1.193 +            if(thisptr->iConnections==1)
   1.194 +                {
   1.195 +                delete thisptr->iHelper;
   1.196 +                }
   1.197 +            thisptr->iConnections--;
   1.198 +            }
   1.199 +        if(thisptr->iConnections==0)
   1.200 +            {
   1.201 +            thisptr->iSharedChunk.Close();
   1.202 +            thisptr->iLargeBitmapChunk.Close();
   1.203 +            // Call close on the iFileServer regardless of whether this session owns it: 
   1.204 +            // if we don't own it, close will do nothing if there are still open files, 
   1.205 +            // so always calling close introduces extra safety
   1.206 +            thisptr->iFileServer.Close();
   1.207 +            delete thisptr->iRomFileAddrCache; 
   1.208 +            delete thisptr->iScanLineBuffer;
   1.209 +            delete thisptr->iDecompressionBuffer;
   1.210 +            thisptr->Close();
   1.211 +            delete thisptr;
   1.212 +            Dll::FreeTls();	
   1.213 +            }
   1.214 +        FBS_OST(OstTraceExt3(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_DISCONNECT_INFO, "# Disconnected from session; this=0x%08x; iConnections=%d; iSSH=0x%08x", (TInt)thisptr, thisptr->iConnections, tempServerSessionHandle);)
   1.215 +	    }
   1.216 +	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_EXIT2, "< this=0x%08x;", (TUint)thisptr);)
   1.217 +	}
   1.218 +
   1.219 +/**  Gets the current Font and Bitmap server session.
   1.220 +@return  A pointer to the current session or NULL if Connect() has not been 
   1.221 +called yet. 
   1.222 +@publishedAll 
   1.223 +@released
   1.224 +*/
   1.225 +EXPORT_C RFbsSession* RFbsSession::GetSession()
   1.226 +    {
   1.227 +	return((RFbsSession*)Dll::Tls());
   1.228 +	}
   1.229 +
   1.230 +/** Triggers the most recently registered callback. This is mainly called by 
   1.231 +bitmaps when their twips size changes and when any FBSERV objects are closed 
   1.232 +to notify clients of a change that may affect their operation. 
   1.233 +@publishedAll 
   1.234 +@released
   1.235 +*/
   1.236 +EXPORT_C void RFbsSession::CallBack()
   1.237 +    {
   1.238 +	iCallBack.CallBack();
   1.239 +	iCallBack.iPtr=NULL;
   1.240 +	}
   1.241 +
   1.242 +void RFbsSession::SetCallBackPtr(TInt* aBitmapHandle)const
   1.243 +	{
   1.244 +	iCallBack.iPtr=aBitmapHandle;
   1.245 +	}
   1.246 +	
   1.247 +/** Sets the callback.
   1.248 +@param aCallBack callback object to be called by CallBack(). Only one may be 
   1.249 +in use at a time and subsequent calls will displace previous calls. 
   1.250 +@publishedAll 
   1.251 +@released
   1.252 +*/	
   1.253 +EXPORT_C void RFbsSession::SetCallBack(TCallBack aCallBack)
   1.254 +    {
   1.255 +	iCallBack=aCallBack;
   1.256 +	}
   1.257 +
   1.258 +/** Resets the callback. 
   1.259 +@publishedAll 
   1.260 +@released
   1.261 +*/	
   1.262 +EXPORT_C void RFbsSession::ResetCallBack()
   1.263 +	{
   1.264 +	TCallBack cb(NULL);
   1.265 +	iCallBack=cb;
   1.266 +	}
   1.267 +
   1.268 +/**  Returns the number of Font and Bitmap Server objects currently in 
   1.269 +use by this session.
   1.270 +@return The number of resources in use: bitmaps, fonts, typeface stores. 
   1.271 +@publishedAll 
   1.272 +@released
   1.273 +*/	
   1.274 +EXPORT_C TInt RFbsSession::ResourceCount()
   1.275 +    {
   1.276 +	return(SendCommand(EFbsMessResourceCount));
   1.277 +	}
   1.278 +
   1.279 +/** Utility function for passing commands to the server.
   1.280 +@param aMessage Integer code for the message to pass - see TFbsMessage.
   1.281 +@param aInt0 Parameter 0 for the message.
   1.282 +@param aInt1 Parameter 1 for the message.
   1.283 +@param aInt2 Parameter 2 for the message.
   1.284 +@param aInt3 Parameter 3 for the message.
   1.285 +@return Return code from RSessionBase::SendReceive(). 
   1.286 +@internalComponent
   1.287 +*/
   1.288 +EXPORT_C TInt RFbsSession::SendCommand(TInt aMessage,TInt aInt0,TInt aInt1,TInt aInt2,TInt aInt3) const
   1.289 +   {
   1.290 +	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
   1.291 +
   1.292 +	switch(aMessage)
   1.293 +		{
   1.294 +	case EFbsMessShutdown:
   1.295 +	case EFbsMessClose:
   1.296 +		SetCallBackPtr(aMessage==EFbsMessClose ? &aInt1 : 0);
   1.297 +		iCallBack.CallBack();
   1.298 +	default:
   1.299 +		break;
   1.300 +		}
   1.301 +
   1.302 +	TInt ret = SendReceive(aMessage, TIpcArgs(aInt0,aInt1,aInt2,aInt3));
   1.303 +
   1.304 +	return(ret);
   1.305 +	}
   1.306 +
   1.307 +TInt RFbsSession::SendCommand(TInt aMessage, const TIpcArgs& aArgs) const
   1.308 +	{
   1.309 +	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
   1.310 +	return SendReceive(aMessage,aArgs);
   1.311 +	}
   1.312 +
   1.313 +void RFbsSession::SendCommand(TInt aMessage, const TIpcArgs& aArgs, TRequestStatus &aStatus) const
   1.314 +	{
   1.315 +	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
   1.316 +	SendReceive(aMessage,aArgs,aStatus);
   1.317 +	}
   1.318 +	
   1.319 +/** Gets the current Font and Bitmap server version.
   1.320 +@return The current version of the server. 
   1.321 +@publishedAll 
   1.322 +@released
   1.323 +*/
   1.324 +EXPORT_C TVersion RFbsSession::Version()
   1.325 +	{
   1.326 +	TVersion v(KFbsMajorVersionNumber,KFbsMinorVersionNumber,KFbsBuildVersionNumber);
   1.327 +	return(v);
   1.328 +	}
   1.329 +
   1.330 +/** Gets the address of first location in the global shared heap containing 
   1.331 +fonts and bitmaps.
   1.332 +@return Pointer to the base of the shared heap. 
   1.333 +@publishedAll 
   1.334 +@released
   1.335 +*/	
   1.336 +EXPORT_C TUint8* RFbsSession::HeapBase() const
   1.337 +	{
   1.338 +	return(iSharedChunk.Base());
   1.339 +	}
   1.340 +
   1.341 +TBool RFbsSession::LookupBitmapInROM(const TDesC& aFilename, TAny*& aAddr)
   1.342 +	{
   1.343 +	aAddr = iRomFileAddrCache->Lookup(aFilename);
   1.344 +	if (aAddr)
   1.345 +		return ETrue;
   1.346 +	return EFalse;
   1.347 +   	}
   1.348 +
   1.349 +TInt RFbsSession::DoAlloc(RFbsSession*& aNewSession)
   1.350 +	{
   1.351 +	aNewSession = (RFbsSession*)User::Alloc(sizeof(RFbsSession));
   1.352 +	if(!aNewSession) 
   1.353 +		return KErrNoMemory;
   1.354 +	new(aNewSession) RFbsSession;
   1.355 +	aNewSession->iConnections = 1;
   1.356 +	TInt ret = Dll::SetTls(aNewSession);
   1.357 +	if(ret!=KErrNone)
   1.358 +		{
   1.359 +		delete aNewSession;
   1.360 +		aNewSession = NULL;
   1.361 +		}
   1.362 +	return ret;
   1.363 +	}
   1.364 +
   1.365 +/**  
   1.366 +Do actual connect as common to both Connect() and Connect(RFs& aFileServer). Store fully constructed
   1.367 +file server session to iSpare member variable
   1.368 +@see Connect()
   1.369 +@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
   1.370 +to create the session; otherwise another of the system-wide error codes. 
   1.371 +@internalComponent
   1.372 +*/
   1.373 +TInt RFbsSession::DoConnect(RFs& aFileServer)
   1.374 +	{
   1.375 +	//Allow this session to be accessed by other process to lead bitmap in server
   1.376 +	TInt ret = aFileServer.ShareProtected();
   1.377 +	if (ret!=KErrNone)
   1.378 +		{
   1.379 +		Disconnect();
   1.380 +		return ret;
   1.381 +		}
   1.382 +	iRomFileAddrCache = CFbsRalCache::New(4, aFileServer);
   1.383 +	if (!iRomFileAddrCache)
   1.384 +		{
   1.385 +		Disconnect();
   1.386 +		return KErrNoMemory;
   1.387 +		}
   1.388 +
   1.389 +	ret = CreateSession(KFBSERVGlobalThreadName,Version(),-1);
   1.390 +	if(ret!=KErrNone)
   1.391 +		{
   1.392 +		Disconnect();
   1.393 +		return ret;
   1.394 +		}
   1.395 +	const TInt serverAssignedHandle = SendReceive(EFbsMessInit);
   1.396 +	if(serverAssignedHandle <= 0)
   1.397 +		{
   1.398 +		Disconnect();
   1.399 +		return serverAssignedHandle;
   1.400 +		}
   1.401 +	ret = iSharedChunk.OpenGlobal(KFBSERVSharedChunkName,EFalse);
   1.402 +	if(ret!=KErrNone) 
   1.403 +		Panic(EFbsPanicChunkError);
   1.404 +	iHelper = new CFbsSessionHelper(*this);
   1.405 +	if (!iHelper)
   1.406 +		{
   1.407 +		Disconnect();
   1.408 +		return KErrNoMemory;
   1.409 +		}
   1.410 +	iHelper->iServerSessionHandle = serverAssignedHandle;
   1.411 +	
   1.412 +	ret = iLargeBitmapChunk.OpenGlobal(KFBSERVLargeChunkName,EFalse);
   1.413 +	if(ret!=KErrNone) 
   1.414 +		Panic(EFbsPanicChunkError);
   1.415 +	
   1.416 +	iSpare = (TUint32*)&aFileServer;
   1.417 +	
   1.418 +    FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_DOCONNECT_INFO, "# New FBS Session created; this=0x%08x; iSSH=0x%08x;", (TInt)this, serverAssignedHandle);)
   1.419 +	return KErrNone;
   1.420 +	}
   1.421 +	
   1.422 +/**  
   1.423 +Allocates the buffer for decoding compressed rom bitmaps.
   1.424 + 
   1.425 +Internal use only.
   1.426 +
   1.427 +@param 	aSize Minimum size of the buffer required.  
   1.428 +		If the buffer is too small an attempt to resize it will be made.
   1.429 +@return KErrNone if successful, 
   1.430 +		KErrNoMemory if the buffer was too small and could 
   1.431 +		not be expanded.
   1.432 +@publishedAll 
   1.433 +@released
   1.434 +*/
   1.435 +TInt RFbsSession::AllocScanLineBuffer(TInt aSize)
   1.436 +    {
   1.437 +	if (iScanLineBuffer && iScanLineBuffer->Des().MaxSize() >= aSize)
   1.438 +		{
   1.439 +		return KErrNone;
   1.440 +		}
   1.441 +
   1.442 +	HBufC8* newBuffer = HBufC8::New(aSize);
   1.443 +
   1.444 +	if (newBuffer)
   1.445 +		{
   1.446 +		delete iScanLineBuffer;
   1.447 +		iScanLineBuffer = newBuffer;
   1.448 +		return KErrNone;
   1.449 +		}
   1.450 +
   1.451 +	return KErrNoMemory;
   1.452 +	}
   1.453 +
   1.454 +/**  
   1.455 +Gets a reference to the buffer currently in use for decoding
   1.456 +compressed rom bitmaps. 
   1.457 +
   1.458 +Internal use only.
   1.459 +
   1.460 +@return  The buffer area currently in use,
   1.461 +@publishedAll 
   1.462 +@released
   1.463 +*/
   1.464 +HBufC8* RFbsSession::GetScanLineBuffer()
   1.465 +    {
   1.466 +	return iScanLineBuffer;
   1.467 +	}
   1.468 +
   1.469 +/**  
   1.470 +Gets a pointer to the buffer currently in use for decoding
   1.471 +compressed mask bitmaps. 
   1.472 +
   1.473 +Internal use only.
   1.474 +@param 	aSize Minimum size of the buffer required.  
   1.475 +		If the buffer is too small an attempt to resize it will be made.
   1.476 +@return  The buffer area currently in use or NULL if there is no memory.
   1.477 +@internalComponent 
   1.478 +*/
   1.479 +HBufC8* RFbsSession::GetDecompressionBuffer(TInt aSize)
   1.480 +	{
   1.481 +	if (iDecompressionBuffer)
   1.482 +		{
   1.483 +		if (iDecompressionBuffer->Des().MaxSize() < aSize)
   1.484 +			{
   1.485 +			HBufC8* tempBuffer = iDecompressionBuffer->ReAlloc(aSize);
   1.486 +			if (!tempBuffer)
   1.487 +				{
   1.488 +				return NULL;
   1.489 +				}
   1.490 +			iDecompressionBuffer = tempBuffer;
   1.491 +			}
   1.492 +		}
   1.493 +	else
   1.494 +		{
   1.495 +		iDecompressionBuffer = HBufC8::New(aSize);
   1.496 +		}
   1.497 +
   1.498 +	return iDecompressionBuffer;
   1.499 +	}
   1.500 +
   1.501 +/**  
   1.502 +Gets a pointer to an extra buffer for general use. 
   1.503 +
   1.504 +Internal use only.
   1.505 +@param 	aSize Minimum size of the buffer required.  
   1.506 +		If the buffer is too small an attempt to resize it will be made.
   1.507 +@return  The buffer area currently in use or NULL if there is no memory.
   1.508 +@internalComponent 
   1.509 +*/
   1.510 +HBufC8* RFbsSession::GetExtraBuffer(TInt aSize)
   1.511 +	{
   1.512 +	if (iHelper->iExtraBuffer)
   1.513 +		{
   1.514 +		if (iHelper->iExtraBuffer->Des().MaxSize() < aSize)
   1.515 +			{
   1.516 +			HBufC8* tempBuffer = iHelper->iExtraBuffer->ReAlloc(aSize);
   1.517 +			if (!tempBuffer)
   1.518 +				{
   1.519 +				return NULL;
   1.520 +				}
   1.521 +			iHelper->iExtraBuffer = tempBuffer;
   1.522 +			}
   1.523 +		}
   1.524 +	else
   1.525 +		{
   1.526 +		iHelper->iExtraBuffer = HBufC8::New(aSize);
   1.527 +		}
   1.528 +
   1.529 +	return iHelper->iExtraBuffer;
   1.530 +	}
   1.531 +
   1.532 +/**
   1.533 +Returns a handle assigned to this session by the server upon connection.
   1.534 +This method should be used instead of SessionHandle() when passing a session 
   1.535 +handle to FbServ APIs that require Session handles. 
   1.536 +@return A handle representing this session on the server. 
   1.537 +@pre The session has successfully connected to the server.
   1.538 + */
   1.539 +TInt RFbsSession::ServerSessionHandle() const
   1.540 +	{
   1.541 +	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
   1.542 +	return iHelper->iServerSessionHandle;
   1.543 +	}
   1.544 +
   1.545 +EXPORT_C TInt RFbsSession::GetGlyphCacheMetrics( TGlyphCacheMetrics& aGlyphCacheMetrics )
   1.546 +    {
   1.547 +    TPckgBuf<TGlyphCacheMetrics> metrics;
   1.548 +    TIpcArgs args( &metrics );
   1.549 +
   1.550 +    TInt ret = SendReceive( EFbsMessGetGlyphCacheMetrics, args );
   1.551 +    aGlyphCacheMetrics = metrics();
   1.552 +
   1.553 +    return ret;
   1.554 +    }
   1.555 +
   1.556 +/**
   1.557 + Perform the IPC to convey the desired OoGM action to the glyph atlas.
   1.558 +
   1.559 + @return KErrNone if IPC was successful. One of the system-wide error
   1.560 +         codes, as described for RSessionBase::SendReceive(), if not.
   1.561 +
   1.562 + @note The server-side platform security policy applied to this method is such that it is only useable by the GOoM framework.
   1.563 +
   1.564 + @param aOogmMessage. A reference to the class encapsulating the OoGM action required of the glyph atlas.
   1.565 +*/
   1.566 +EXPORT_C TInt RFbsSession::ConveyOogmMessage( TFbsOogmMessage& aOogmMessage )
   1.567 +    {
   1.568 +    TPckgBuf<TFbsOogmMessage> oogmMessage;
   1.569 +    oogmMessage() = aOogmMessage;
   1.570 +    TIpcArgs args( &oogmMessage );
   1.571 +
   1.572 +    return SendReceive( EFbsMessOogmNotification, args );
   1.573 +    }
   1.574 +
   1.575 +/**
   1.576 +Returns the current sizes of the FBServ default heap, the heap for large bitmaps, 
   1.577 +and the heap for small bitmaps.
   1.578 +
   1.579 +Not supported in release builds.
   1.580 +
   1.581 +@internalComponent
   1.582 +@test
   1.583 +@param aDefaultHeapSize A reference to an integer supplied by the caller. On return from this function, contains the size of the FBServ default heap.
   1.584 +@param aSmallBmpHeapSize A reference to an integer supplied by the caller. On return from this function, contains the size of the FBServ heap for small bitmaps
   1.585 +@param aBigBmpHeapSize A reference to an integer supplied by the caller. On return from this function, contains the size of the FBServ heap for large bitmaps
   1.586 +@return KErrNone or one of the system wide error codes in debug mode, or KErrNotSupported in release mode.
   1.587 +*/
   1.588 +#ifdef _DEBUG
   1.589 +EXPORT_C TInt RFbsSession::GetHeapSizes(TInt& aDefaultHeapSize, TInt& aSmallBmpHeapSize, TInt& aBigBmpHeapSize)
   1.590 + 	{
   1.591 + 	TPckgBuf<THeapSizes> data;
   1.592 + 	TIpcArgs args(&data);
   1.593 + 	TInt ret = SendReceive(EFbsMessGetHeapSizes, args);
   1.594 + 	if(ret == KErrNone)
   1.595 + 		{
   1.596 + 		aDefaultHeapSize = data().iDefault;
   1.597 + 		aSmallBmpHeapSize = data().iSmall;
   1.598 + 		aBigBmpHeapSize = data().iBig;
   1.599 + 		}
   1.600 + 	return ret;
   1.601 + 	}
   1.602 +#else
   1.603 +EXPORT_C TInt RFbsSession::GetHeapSizes(TInt&, TInt&, TInt&)
   1.604 +	{
   1.605 +	return KErrNotSupported;
   1.606 +	}
   1.607 +#endif