os/graphics/fbs/fontandbitmapserver/sfbs/SESSION.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <fbs.h>
sl@0
    17
#include "fbsdefs.h"
sl@0
    18
#include "UTILS.H"
sl@0
    19
#include "FBSVER.H"
sl@0
    20
#include "FbsRalc.h"
sl@0
    21
#include "fbshelper.h"
sl@0
    22
#include "FbsMessage.H"
sl@0
    23
#include <graphics/fbsoogmmessage.h>
sl@0
    24
#include "OstTraceDefinitions.h"
sl@0
    25
#include "fbstrace.h"
sl@0
    26
#ifdef OST_TRACE_COMPILER_IN_USE
sl@0
    27
#include "SESSIONTraces.h"
sl@0
    28
#endif
sl@0
    29
sl@0
    30
GLDEF_C void Panic(TFbsPanic aPanic)
sl@0
    31
	{
sl@0
    32
	_LIT(KFBSERVClientPanicCategory,"FBSCLI");
sl@0
    33
	User::Panic(KFBSERVClientPanicCategory,aPanic);
sl@0
    34
	}
sl@0
    35
sl@0
    36
EXPORT_C TInt FbsStartup()
sl@0
    37
	{
sl@0
    38
	RChunk sharedchunk;
sl@0
    39
	TInt ret = sharedchunk.OpenGlobal(KFBSERVSharedChunkName,EFalse);
sl@0
    40
	if (ret == KErrNone)
sl@0
    41
		{
sl@0
    42
		sharedchunk.Close();
sl@0
    43
		return KErrNone;
sl@0
    44
		}
sl@0
    45
sl@0
    46
	RProcess fbs;
sl@0
    47
	_LIT(KFBSERVServerExe,"z:\\sys\\bin\\fbserv.exe");
sl@0
    48
	ret = fbs.Create(KFBSERVServerExe,KNullDesC);
sl@0
    49
sl@0
    50
	if (ret!=KErrNone)
sl@0
    51
		return ret;
sl@0
    52
	
sl@0
    53
  	
sl@0
    54
	TRequestStatus stat;
sl@0
    55
	fbs.Rendezvous(stat);
sl@0
    56
	if (stat!=KRequestPending)
sl@0
    57
		fbs.Kill(0);		// abort startup
sl@0
    58
	else
sl@0
    59
		fbs.Resume();	// logon OK - start the server
sl@0
    60
	User::WaitForRequest(stat);		// wait for start or death
sl@0
    61
	// we can't use the 'exit reason' if the server panicked as this
sl@0
    62
	// is the panic 'reason' and may be '0' which cannot be distinguished
sl@0
    63
	// from KErrNone
sl@0
    64
	ret=(fbs.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
sl@0
    65
	fbs.Close();
sl@0
    66
	return ret;
sl@0
    67
	}
sl@0
    68
sl@0
    69
sl@0
    70
//
sl@0
    71
// Fontbitmap server client side session
sl@0
    72
//
sl@0
    73
sl@0
    74
/** 
sl@0
    75
@publishedAll 
sl@0
    76
@released
sl@0
    77
*/
sl@0
    78
EXPORT_C RFbsSession::RFbsSession():
sl@0
    79
	RSessionBase(),
sl@0
    80
	iConnections(0),
sl@0
    81
	iCallBack(),
sl@0
    82
	iSharedChunk(),
sl@0
    83
	iHelper(NULL),
sl@0
    84
	iRomFileAddrCache(NULL),
sl@0
    85
	iDecompressionBuffer(NULL),
sl@0
    86
	iScanLineBuffer(NULL),
sl@0
    87
	iSpare(NULL)
sl@0
    88
	{}
sl@0
    89
sl@0
    90
/** Creates a session with the Font and Bitmap server.
sl@0
    91
@param aFileServer A fuly constructed file server session
sl@0
    92
@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
sl@0
    93
to create the session; otherwise another of the system-wide error codes. 
sl@0
    94
@publishedAll 
sl@0
    95
@released
sl@0
    96
*/
sl@0
    97
EXPORT_C TInt RFbsSession::Connect(RFs& aFileServer)
sl@0
    98
	{
sl@0
    99
    TInt ret = KErrNone;
sl@0
   100
	RFbsSession* thisptr = (RFbsSession*)Dll::Tls();
sl@0
   101
	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
sl@0
   102
	if(thisptr)
sl@0
   103
		{
sl@0
   104
		thisptr->iConnections++;
sl@0
   105
		FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);)
sl@0
   106
		}
sl@0
   107
	else
sl@0
   108
	    {
sl@0
   109
        ret = RFbsSession::DoAlloc(thisptr);
sl@0
   110
        if(ret!=KErrNone)
sl@0
   111
            {
sl@0
   112
            FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR, "! DoAlloc returned %d", ret);)
sl@0
   113
            }
sl@0
   114
        else
sl@0
   115
            {
sl@0
   116
            ret = thisptr->DoConnect(aFileServer);
sl@0
   117
            if(ret!=KErrNone)
sl@0
   118
                {
sl@0
   119
                FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT_ERROR2, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);)
sl@0
   120
                }
sl@0
   121
            }
sl@0
   122
	    }
sl@0
   123
	
sl@0
   124
	FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);)
sl@0
   125
	return ret; 
sl@0
   126
	}
sl@0
   127
sl@0
   128
/** Creates a session with the Font and Bitmap server.
sl@0
   129
@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
sl@0
   130
to create the session; otherwise another of the system-wide error codes. 
sl@0
   131
@publishedAll 
sl@0
   132
@released
sl@0
   133
*/
sl@0
   134
EXPORT_C TInt RFbsSession::Connect()
sl@0
   135
	{
sl@0
   136
    TInt ret = KErrNone;
sl@0
   137
	RFbsSession* thisptr = (RFbsSession*)Dll::Tls();
sl@0
   138
	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
sl@0
   139
	if(thisptr)
sl@0
   140
		{
sl@0
   141
		thisptr->iConnections++;
sl@0
   142
	    FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_CONNECT2_INFO, "# Connected to existing session; this=0x%08x; iConnections=%d;", (TInt)thisptr, thisptr->iConnections);)
sl@0
   143
		}
sl@0
   144
	else
sl@0
   145
	    {
sl@0
   146
        TInt ret = RFbsSession::DoAlloc(thisptr);
sl@0
   147
        if (ret!=KErrNone)
sl@0
   148
            {
sl@0
   149
            FBS_OST(OstTrace1(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR, "! DoAlloc returned %d", ret);)
sl@0
   150
            goto end;
sl@0
   151
            }
sl@0
   152
            
sl@0
   153
        ret = thisptr->iFileServer.Connect();
sl@0
   154
        if(ret!=KErrNone)
sl@0
   155
            {
sl@0
   156
            thisptr->Disconnect();
sl@0
   157
            FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR2, "! this=0x%08x; RFs::Connect() returned %d", (TInt)thisptr, ret);)
sl@0
   158
            goto end;
sl@0
   159
            }
sl@0
   160
        
sl@0
   161
        ret = thisptr->DoConnect(thisptr->iFileServer);
sl@0
   162
        if(ret!=KErrNone)
sl@0
   163
            {
sl@0
   164
            FBS_OST(OstTraceExt2(TRACE_ERROR, RFBSSESSION_CONNECT2_ERROR3, "! this=0x%08x; DoConnect returned %d", (TInt)thisptr, ret);)
sl@0
   165
            }
sl@0
   166
	    }
sl@0
   167
end:
sl@0
   168
	FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_CONNECT2_EXIT, "< this=0x%08x; ret=%d", (TUint)thisptr, ret);)
sl@0
   169
	return ret;
sl@0
   170
	}
sl@0
   171
sl@0
   172
/** Closes the session with the Font and Bitmap server. 
sl@0
   173
@publishedAll 
sl@0
   174
@released
sl@0
   175
*/
sl@0
   176
EXPORT_C void RFbsSession::Disconnect()
sl@0
   177
	{
sl@0
   178
	RFbsSession* thisptr=(RFbsSession*)Dll::Tls();
sl@0
   179
    FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_ENTRY, "> this=0x%08x;", (TUint)thisptr);)
sl@0
   180
	if(thisptr)
sl@0
   181
	    {
sl@0
   182
        TInt tempServerSessionHandle = thisptr->ServerSessionHandle();
sl@0
   183
        if(thisptr->iConnections>0)
sl@0
   184
            {
sl@0
   185
            thisptr->iCallBack.iPtr=NULL;
sl@0
   186
            thisptr->iCallBack.CallBack();
sl@0
   187
            // Destructor of CFbsSessionHelper may call SendCommand to cancel an
sl@0
   188
            // outstanding request, therefore destruction must be done before
sl@0
   189
            // iConnections is 0 to avoid an assertion going off.
sl@0
   190
            if(thisptr->iConnections==1)
sl@0
   191
                {
sl@0
   192
                delete thisptr->iHelper;
sl@0
   193
                }
sl@0
   194
            thisptr->iConnections--;
sl@0
   195
            }
sl@0
   196
        if(thisptr->iConnections==0)
sl@0
   197
            {
sl@0
   198
            thisptr->iSharedChunk.Close();
sl@0
   199
            thisptr->iLargeBitmapChunk.Close();
sl@0
   200
            // Call close on the iFileServer regardless of whether this session owns it: 
sl@0
   201
            // if we don't own it, close will do nothing if there are still open files, 
sl@0
   202
            // so always calling close introduces extra safety
sl@0
   203
            thisptr->iFileServer.Close();
sl@0
   204
            delete thisptr->iRomFileAddrCache; 
sl@0
   205
            delete thisptr->iScanLineBuffer;
sl@0
   206
            delete thisptr->iDecompressionBuffer;
sl@0
   207
            thisptr->Close();
sl@0
   208
            delete thisptr;
sl@0
   209
            Dll::FreeTls();	
sl@0
   210
            }
sl@0
   211
        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);)
sl@0
   212
	    }
sl@0
   213
	FBS_OST(OstTrace1(GRAPHICS_CONTROL_FUNCTIONS, RFBSSESSION_DISCONNECT_EXIT2, "< this=0x%08x;", (TUint)thisptr);)
sl@0
   214
	}
sl@0
   215
sl@0
   216
/**  Gets the current Font and Bitmap server session.
sl@0
   217
@return  A pointer to the current session or NULL if Connect() has not been 
sl@0
   218
called yet. 
sl@0
   219
@publishedAll 
sl@0
   220
@released
sl@0
   221
*/
sl@0
   222
EXPORT_C RFbsSession* RFbsSession::GetSession()
sl@0
   223
    {
sl@0
   224
	return((RFbsSession*)Dll::Tls());
sl@0
   225
	}
sl@0
   226
sl@0
   227
/** Triggers the most recently registered callback. This is mainly called by 
sl@0
   228
bitmaps when their twips size changes and when any FBSERV objects are closed 
sl@0
   229
to notify clients of a change that may affect their operation. 
sl@0
   230
@publishedAll 
sl@0
   231
@released
sl@0
   232
*/
sl@0
   233
EXPORT_C void RFbsSession::CallBack()
sl@0
   234
    {
sl@0
   235
	iCallBack.CallBack();
sl@0
   236
	iCallBack.iPtr=NULL;
sl@0
   237
	}
sl@0
   238
sl@0
   239
void RFbsSession::SetCallBackPtr(TInt* aBitmapHandle)const
sl@0
   240
	{
sl@0
   241
	iCallBack.iPtr=aBitmapHandle;
sl@0
   242
	}
sl@0
   243
	
sl@0
   244
/** Sets the callback.
sl@0
   245
@param aCallBack callback object to be called by CallBack(). Only one may be 
sl@0
   246
in use at a time and subsequent calls will displace previous calls. 
sl@0
   247
@publishedAll 
sl@0
   248
@released
sl@0
   249
*/	
sl@0
   250
EXPORT_C void RFbsSession::SetCallBack(TCallBack aCallBack)
sl@0
   251
    {
sl@0
   252
	iCallBack=aCallBack;
sl@0
   253
	}
sl@0
   254
sl@0
   255
/** Resets the callback. 
sl@0
   256
@publishedAll 
sl@0
   257
@released
sl@0
   258
*/	
sl@0
   259
EXPORT_C void RFbsSession::ResetCallBack()
sl@0
   260
	{
sl@0
   261
	TCallBack cb(NULL);
sl@0
   262
	iCallBack=cb;
sl@0
   263
	}
sl@0
   264
sl@0
   265
/**  Returns the number of Font and Bitmap Server objects currently in 
sl@0
   266
use by this session.
sl@0
   267
@return The number of resources in use: bitmaps, fonts, typeface stores. 
sl@0
   268
@publishedAll 
sl@0
   269
@released
sl@0
   270
*/	
sl@0
   271
EXPORT_C TInt RFbsSession::ResourceCount()
sl@0
   272
    {
sl@0
   273
	return(SendCommand(EFbsMessResourceCount));
sl@0
   274
	}
sl@0
   275
sl@0
   276
/** Utility function for passing commands to the server.
sl@0
   277
@param aMessage Integer code for the message to pass - see TFbsMessage.
sl@0
   278
@param aInt0 Parameter 0 for the message.
sl@0
   279
@param aInt1 Parameter 1 for the message.
sl@0
   280
@param aInt2 Parameter 2 for the message.
sl@0
   281
@param aInt3 Parameter 3 for the message.
sl@0
   282
@return Return code from RSessionBase::SendReceive(). 
sl@0
   283
@internalComponent
sl@0
   284
*/
sl@0
   285
EXPORT_C TInt RFbsSession::SendCommand(TInt aMessage,TInt aInt0,TInt aInt1,TInt aInt2,TInt aInt3) const
sl@0
   286
   {
sl@0
   287
	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
sl@0
   288
sl@0
   289
	switch(aMessage)
sl@0
   290
		{
sl@0
   291
	case EFbsMessShutdown:
sl@0
   292
	case EFbsMessClose:
sl@0
   293
		SetCallBackPtr(aMessage==EFbsMessClose ? &aInt1 : 0);
sl@0
   294
		iCallBack.CallBack();
sl@0
   295
	default:
sl@0
   296
		break;
sl@0
   297
		}
sl@0
   298
sl@0
   299
	TInt ret = SendReceive(aMessage, TIpcArgs(aInt0,aInt1,aInt2,aInt3));
sl@0
   300
sl@0
   301
	return(ret);
sl@0
   302
	}
sl@0
   303
sl@0
   304
TInt RFbsSession::SendCommand(TInt aMessage, const TIpcArgs& aArgs) const
sl@0
   305
	{
sl@0
   306
	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
sl@0
   307
	return SendReceive(aMessage,aArgs);
sl@0
   308
	}
sl@0
   309
sl@0
   310
void RFbsSession::SendCommand(TInt aMessage, const TIpcArgs& aArgs, TRequestStatus &aStatus) const
sl@0
   311
	{
sl@0
   312
	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
sl@0
   313
	SendReceive(aMessage,aArgs,aStatus);
sl@0
   314
	}
sl@0
   315
	
sl@0
   316
/** Gets the current Font and Bitmap server version.
sl@0
   317
@return The current version of the server. 
sl@0
   318
@publishedAll 
sl@0
   319
@released
sl@0
   320
*/
sl@0
   321
EXPORT_C TVersion RFbsSession::Version()
sl@0
   322
	{
sl@0
   323
	TVersion v(KFbsMajorVersionNumber,KFbsMinorVersionNumber,KFbsBuildVersionNumber);
sl@0
   324
	return(v);
sl@0
   325
	}
sl@0
   326
sl@0
   327
/** Gets the address of first location in the global shared heap containing 
sl@0
   328
fonts and bitmaps.
sl@0
   329
@return Pointer to the base of the shared heap. 
sl@0
   330
@publishedAll 
sl@0
   331
@released
sl@0
   332
*/	
sl@0
   333
EXPORT_C TUint8* RFbsSession::HeapBase() const
sl@0
   334
	{
sl@0
   335
	return(iSharedChunk.Base());
sl@0
   336
	}
sl@0
   337
sl@0
   338
TBool RFbsSession::LookupBitmapInROM(const TDesC& aFilename, TAny*& aAddr)
sl@0
   339
	{
sl@0
   340
	aAddr = iRomFileAddrCache->Lookup(aFilename);
sl@0
   341
	if (aAddr)
sl@0
   342
		return ETrue;
sl@0
   343
	return EFalse;
sl@0
   344
   	}
sl@0
   345
sl@0
   346
TInt RFbsSession::DoAlloc(RFbsSession*& aNewSession)
sl@0
   347
	{
sl@0
   348
	aNewSession = (RFbsSession*)User::Alloc(sizeof(RFbsSession));
sl@0
   349
	if(!aNewSession) 
sl@0
   350
		return KErrNoMemory;
sl@0
   351
	new(aNewSession) RFbsSession;
sl@0
   352
	aNewSession->iConnections = 1;
sl@0
   353
	TInt ret = Dll::SetTls(aNewSession);
sl@0
   354
	if(ret!=KErrNone)
sl@0
   355
		{
sl@0
   356
		delete aNewSession;
sl@0
   357
		aNewSession = NULL;
sl@0
   358
		}
sl@0
   359
	return ret;
sl@0
   360
	}
sl@0
   361
sl@0
   362
/**  
sl@0
   363
Do actual connect as common to both Connect() and Connect(RFs& aFileServer). Store fully constructed
sl@0
   364
file server session to iSpare member variable
sl@0
   365
@see Connect()
sl@0
   366
@return KErrNone, if successful; KErrNoMemory if there is not enough memory 
sl@0
   367
to create the session; otherwise another of the system-wide error codes. 
sl@0
   368
@internalComponent
sl@0
   369
*/
sl@0
   370
TInt RFbsSession::DoConnect(RFs& aFileServer)
sl@0
   371
	{
sl@0
   372
	//Allow this session to be accessed by other process to lead bitmap in server
sl@0
   373
	TInt ret = aFileServer.ShareProtected();
sl@0
   374
	if (ret!=KErrNone)
sl@0
   375
		{
sl@0
   376
		Disconnect();
sl@0
   377
		return ret;
sl@0
   378
		}
sl@0
   379
	iRomFileAddrCache = CFbsRalCache::New(4, aFileServer);
sl@0
   380
	if (!iRomFileAddrCache)
sl@0
   381
		{
sl@0
   382
		Disconnect();
sl@0
   383
		return KErrNoMemory;
sl@0
   384
		}
sl@0
   385
sl@0
   386
	ret = CreateSession(KFBSERVGlobalThreadName,Version(),-1);
sl@0
   387
	if(ret!=KErrNone)
sl@0
   388
		{
sl@0
   389
		Disconnect();
sl@0
   390
		return ret;
sl@0
   391
		}
sl@0
   392
	const TInt serverAssignedHandle = SendReceive(EFbsMessInit);
sl@0
   393
	if(serverAssignedHandle <= 0)
sl@0
   394
		{
sl@0
   395
		Disconnect();
sl@0
   396
		return serverAssignedHandle;
sl@0
   397
		}
sl@0
   398
	ret = iSharedChunk.OpenGlobal(KFBSERVSharedChunkName,EFalse);
sl@0
   399
	if(ret!=KErrNone) 
sl@0
   400
		Panic(EFbsPanicChunkError);
sl@0
   401
	iHelper = new CFbsSessionHelper(*this);
sl@0
   402
	if (!iHelper)
sl@0
   403
		{
sl@0
   404
		Disconnect();
sl@0
   405
		return KErrNoMemory;
sl@0
   406
		}
sl@0
   407
	iHelper->iServerSessionHandle = serverAssignedHandle;
sl@0
   408
	
sl@0
   409
	ret = iLargeBitmapChunk.OpenGlobal(KFBSERVLargeChunkName,EFalse);
sl@0
   410
	if(ret!=KErrNone) 
sl@0
   411
		Panic(EFbsPanicChunkError);
sl@0
   412
	
sl@0
   413
	iSpare = (TUint32*)&aFileServer;
sl@0
   414
	
sl@0
   415
    FBS_OST(OstTraceExt2(GRAPHICS_CONTROL_SEMANTICS, RFBSSESSION_DOCONNECT_INFO, "# New FBS Session created; this=0x%08x; iSSH=0x%08x;", (TInt)this, serverAssignedHandle);)
sl@0
   416
	return KErrNone;
sl@0
   417
	}
sl@0
   418
	
sl@0
   419
/**  
sl@0
   420
Allocates the buffer for decoding compressed rom bitmaps.
sl@0
   421
 
sl@0
   422
Internal use only.
sl@0
   423
sl@0
   424
@param 	aSize Minimum size of the buffer required.  
sl@0
   425
		If the buffer is too small an attempt to resize it will be made.
sl@0
   426
@return KErrNone if successful, 
sl@0
   427
		KErrNoMemory if the buffer was too small and could 
sl@0
   428
		not be expanded.
sl@0
   429
@publishedAll 
sl@0
   430
@released
sl@0
   431
*/
sl@0
   432
TInt RFbsSession::AllocScanLineBuffer(TInt aSize)
sl@0
   433
    {
sl@0
   434
	if (iScanLineBuffer && iScanLineBuffer->Des().MaxSize() >= aSize)
sl@0
   435
		{
sl@0
   436
		return KErrNone;
sl@0
   437
		}
sl@0
   438
sl@0
   439
	HBufC8* newBuffer = HBufC8::New(aSize);
sl@0
   440
sl@0
   441
	if (newBuffer)
sl@0
   442
		{
sl@0
   443
		delete iScanLineBuffer;
sl@0
   444
		iScanLineBuffer = newBuffer;
sl@0
   445
		return KErrNone;
sl@0
   446
		}
sl@0
   447
sl@0
   448
	return KErrNoMemory;
sl@0
   449
	}
sl@0
   450
sl@0
   451
/**  
sl@0
   452
Gets a reference to the buffer currently in use for decoding
sl@0
   453
compressed rom bitmaps. 
sl@0
   454
sl@0
   455
Internal use only.
sl@0
   456
sl@0
   457
@return  The buffer area currently in use,
sl@0
   458
@publishedAll 
sl@0
   459
@released
sl@0
   460
*/
sl@0
   461
HBufC8* RFbsSession::GetScanLineBuffer()
sl@0
   462
    {
sl@0
   463
	return iScanLineBuffer;
sl@0
   464
	}
sl@0
   465
sl@0
   466
/**  
sl@0
   467
Gets a pointer to the buffer currently in use for decoding
sl@0
   468
compressed mask bitmaps. 
sl@0
   469
sl@0
   470
Internal use only.
sl@0
   471
@param 	aSize Minimum size of the buffer required.  
sl@0
   472
		If the buffer is too small an attempt to resize it will be made.
sl@0
   473
@return  The buffer area currently in use or NULL if there is no memory.
sl@0
   474
@internalComponent 
sl@0
   475
*/
sl@0
   476
HBufC8* RFbsSession::GetDecompressionBuffer(TInt aSize)
sl@0
   477
	{
sl@0
   478
	if (iDecompressionBuffer)
sl@0
   479
		{
sl@0
   480
		if (iDecompressionBuffer->Des().MaxSize() < aSize)
sl@0
   481
			{
sl@0
   482
			HBufC8* tempBuffer = iDecompressionBuffer->ReAlloc(aSize);
sl@0
   483
			if (!tempBuffer)
sl@0
   484
				{
sl@0
   485
				return NULL;
sl@0
   486
				}
sl@0
   487
			iDecompressionBuffer = tempBuffer;
sl@0
   488
			}
sl@0
   489
		}
sl@0
   490
	else
sl@0
   491
		{
sl@0
   492
		iDecompressionBuffer = HBufC8::New(aSize);
sl@0
   493
		}
sl@0
   494
sl@0
   495
	return iDecompressionBuffer;
sl@0
   496
	}
sl@0
   497
sl@0
   498
/**  
sl@0
   499
Gets a pointer to an extra buffer for general use. 
sl@0
   500
sl@0
   501
Internal use only.
sl@0
   502
@param 	aSize Minimum size of the buffer required.  
sl@0
   503
		If the buffer is too small an attempt to resize it will be made.
sl@0
   504
@return  The buffer area currently in use or NULL if there is no memory.
sl@0
   505
@internalComponent 
sl@0
   506
*/
sl@0
   507
HBufC8* RFbsSession::GetExtraBuffer(TInt aSize)
sl@0
   508
	{
sl@0
   509
	if (iHelper->iExtraBuffer)
sl@0
   510
		{
sl@0
   511
		if (iHelper->iExtraBuffer->Des().MaxSize() < aSize)
sl@0
   512
			{
sl@0
   513
			HBufC8* tempBuffer = iHelper->iExtraBuffer->ReAlloc(aSize);
sl@0
   514
			if (!tempBuffer)
sl@0
   515
				{
sl@0
   516
				return NULL;
sl@0
   517
				}
sl@0
   518
			iHelper->iExtraBuffer = tempBuffer;
sl@0
   519
			}
sl@0
   520
		}
sl@0
   521
	else
sl@0
   522
		{
sl@0
   523
		iHelper->iExtraBuffer = HBufC8::New(aSize);
sl@0
   524
		}
sl@0
   525
sl@0
   526
	return iHelper->iExtraBuffer;
sl@0
   527
	}
sl@0
   528
sl@0
   529
/**
sl@0
   530
Returns a handle assigned to this session by the server upon connection.
sl@0
   531
This method should be used instead of SessionHandle() when passing a session 
sl@0
   532
handle to FbServ APIs that require Session handles. 
sl@0
   533
@return A handle representing this session on the server. 
sl@0
   534
@pre The session has successfully connected to the server.
sl@0
   535
 */
sl@0
   536
TInt RFbsSession::ServerSessionHandle() const
sl@0
   537
	{
sl@0
   538
	__ASSERT_ALWAYS(iConnections>0,Panic(EFbsPanicBadConnection));
sl@0
   539
	return iHelper->iServerSessionHandle;
sl@0
   540
	}
sl@0
   541
sl@0
   542
EXPORT_C TInt RFbsSession::GetGlyphCacheMetrics( TGlyphCacheMetrics& aGlyphCacheMetrics )
sl@0
   543
    {
sl@0
   544
    TPckgBuf<TGlyphCacheMetrics> metrics;
sl@0
   545
    TIpcArgs args( &metrics );
sl@0
   546
sl@0
   547
    TInt ret = SendReceive( EFbsMessGetGlyphCacheMetrics, args );
sl@0
   548
    aGlyphCacheMetrics = metrics();
sl@0
   549
sl@0
   550
    return ret;
sl@0
   551
    }
sl@0
   552
sl@0
   553
/**
sl@0
   554
 Perform the IPC to convey the desired OoGM action to the glyph atlas.
sl@0
   555
sl@0
   556
 @return KErrNone if IPC was successful. One of the system-wide error
sl@0
   557
         codes, as described for RSessionBase::SendReceive(), if not.
sl@0
   558
sl@0
   559
 @note The server-side platform security policy applied to this method is such that it is only useable by the GOoM framework.
sl@0
   560
sl@0
   561
 @param aOogmMessage. A reference to the class encapsulating the OoGM action required of the glyph atlas.
sl@0
   562
*/
sl@0
   563
EXPORT_C TInt RFbsSession::ConveyOogmMessage( TFbsOogmMessage& aOogmMessage )
sl@0
   564
    {
sl@0
   565
    TPckgBuf<TFbsOogmMessage> oogmMessage;
sl@0
   566
    oogmMessage() = aOogmMessage;
sl@0
   567
    TIpcArgs args( &oogmMessage );
sl@0
   568
sl@0
   569
    return SendReceive( EFbsMessOogmNotification, args );
sl@0
   570
    }
sl@0
   571
sl@0
   572
/**
sl@0
   573
Returns the current sizes of the FBServ default heap, the heap for large bitmaps, 
sl@0
   574
and the heap for small bitmaps.
sl@0
   575
sl@0
   576
Not supported in release builds.
sl@0
   577
sl@0
   578
@internalComponent
sl@0
   579
@test
sl@0
   580
@param aDefaultHeapSize A reference to an integer supplied by the caller. On return from this function, contains the size of the FBServ default heap.
sl@0
   581
@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
sl@0
   582
@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
sl@0
   583
@return KErrNone or one of the system wide error codes in debug mode, or KErrNotSupported in release mode.
sl@0
   584
*/
sl@0
   585
#ifdef _DEBUG
sl@0
   586
EXPORT_C TInt RFbsSession::GetHeapSizes(TInt& aDefaultHeapSize, TInt& aSmallBmpHeapSize, TInt& aBigBmpHeapSize)
sl@0
   587
 	{
sl@0
   588
 	TPckgBuf<THeapSizes> data;
sl@0
   589
 	TIpcArgs args(&data);
sl@0
   590
 	TInt ret = SendReceive(EFbsMessGetHeapSizes, args);
sl@0
   591
 	if(ret == KErrNone)
sl@0
   592
 		{
sl@0
   593
 		aDefaultHeapSize = data().iDefault;
sl@0
   594
 		aSmallBmpHeapSize = data().iSmall;
sl@0
   595
 		aBigBmpHeapSize = data().iBig;
sl@0
   596
 		}
sl@0
   597
 	return ret;
sl@0
   598
 	}
sl@0
   599
#else
sl@0
   600
EXPORT_C TInt RFbsSession::GetHeapSizes(TInt&, TInt&, TInt&)
sl@0
   601
	{
sl@0
   602
	return KErrNotSupported;
sl@0
   603
	}
sl@0
   604
#endif