brandingserver/bsserver/cbsbrandhandler.cpp
changeset 0 e6b17d312c8b
child 2 89455bbf90d8
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006 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: CBSBrandHandler.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 
       
    21 #include "cbsbrandhandler.h"
       
    22 #include "bselementfactory.h"
       
    23 #include "debugtrace.h"
       
    24 #include "cbsstoragemanager.h"
       
    25 #include "cbsbitmap.h"
       
    26 #include "bsimportconstants.h"
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <utf.h>
       
    30 #include <s32file.h>
       
    31 
       
    32 void Panic(TInt aPanic)
       
    33     {
       
    34     _LIT( KPanic, "CBS" );
       
    35     User::Panic( KPanic, aPanic );
       
    36     }
       
    37 
       
    38 // Two-phased constructor.
       
    39 CBSBrandHandler* CBSBrandHandler::NewL( const TDesC& aApplicationId,
       
    40 									    const TDesC& aBrandId, 
       
    41 									    const TDesC& aDefaultBrandId, 
       
    42 									    TLanguage aLanguage,
       
    43 									    CBSSession* aSession,
       
    44 									    TInt aReserved )
       
    45     {
       
    46     CBSBrandHandler* self = new ( ELeave ) CBSBrandHandler( aLanguage, aReserved ) ;
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL( aApplicationId, aBrandId, aDefaultBrandId, aSession );
       
    49     CleanupStack::Pop( self );  //self
       
    50     return self;
       
    51     }
       
    52 
       
    53 // Symbian OS default constructor can leave.
       
    54 void CBSBrandHandler::ConstructL( const TDesC& aApplicationId,
       
    55 						 		  const TDesC& aBrandId,
       
    56 						 		  const TDesC& aDefaultBrandId,
       
    57 						 		  CBSSession* aSession )
       
    58     {
       
    59 	iApplicationId = aApplicationId.AllocL();
       
    60 	iBrandId = aBrandId.AllocL();
       
    61 	iDefaultBrandId = aDefaultBrandId.AllocL();
       
    62 	iSession = aSession;
       
    63 	
       
    64 	User::LeaveIfError( iFs.Connect() );
       
    65 	
       
    66 	iHandle = new(ELeave) RFile(); // CSI: 74 # this needs to be like this
       
    67 
       
    68 	isDefaultBrandUsed = ETrue;
       
    69 	iStorageManager = CBSStorageManager::NewL( iSession, KNullDesC );
       
    70     TInt err = -1;
       
    71     TRAP (err, iStorageManager->BrandHandleL( *iApplicationId,
       
    72                                    *iBrandId, iLanguage,
       
    73                                    *iHandle,
       
    74                                    iReserved ));
       
    75 
       
    76 
       
    77     if (err != KErrNone)
       
    78         {
       
    79 	iStorageManager->BrandHandleL( *iApplicationId,
       
    80                                            *iDefaultBrandId, iLanguage,
       
    81 								   *iHandle,
       
    82 								   iReserved );
       
    83         }
       
    84 	VerifyVersionL();
       
    85     }
       
    86 
       
    87 // Destructor
       
    88 CBSBrandHandler::~CBSBrandHandler()
       
    89     {
       
    90     delete iDefaultBrand;
       
    91     delete iApplicationId;
       
    92     delete iBrandId;
       
    93     delete iDefaultBrandId;
       
    94   	if( iHandle )
       
    95   		{
       
    96   		iHandle->Close();
       
    97 		delete iHandle;
       
    98 		iHandle = NULL;
       
    99   		}
       
   100 
       
   101     delete iStorageManager;
       
   102   
       
   103     iFs.Close();
       
   104     }
       
   105 
       
   106 // C++ default constructor can NOT contain any code, that
       
   107 // might leave.
       
   108 //
       
   109 CBSBrandHandler::CBSBrandHandler( TLanguage aLanguage,
       
   110 						 		  TInt aReserved )
       
   111 : iLanguage( aLanguage ), iReserved( aReserved)
       
   112 	{
       
   113 	}
       
   114 
       
   115 
       
   116 
       
   117 TInt CBSBrandHandler:: isBrandUpdateRequiredL ()
       
   118 {
       
   119 	TRACE( T_LIT( "isBrandUpdateRequired  entered"));
       
   120 	TInt updateRequired = -1;
       
   121 	if (isDefaultBrandUsed)
       
   122 		{
       
   123 		TRACE( T_LIT( "isBrandUpdateRequired  isDefaultBrandused is TRUE."));
       
   124 		/* default brand is used, so can check if the actual brand is installed by anychance or not */
       
   125 		updateRequired = iStorageManager->isActualBrandInstalledL (*iApplicationId, *iBrandId, iLanguage );
       
   126 		if (1 == updateRequired)
       
   127 			{
       
   128 				TRACE( T_LIT( "isBrandUpdateRequired  isDefaultBrandused returned 1, so update required, setting defaultbrand FALSE."));
       
   129 				isDefaultBrandUsed = EFalse;
       
   130 			}
       
   131 		}
       
   132 	TRACE( T_LIT( "isBrandUpdateRequired  isDefaultBrandused leaving.."));		
       
   133 	return updateRequired;
       
   134 }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CBSBrandHandler::SetDefaultBrandIdL()
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CBSBrandHandler::SetDefaultBrandIdL( const TDesC8& aBrandId )
       
   141     {
       
   142     HBufC* temp = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aBrandId );
       
   143     delete iDefaultBrand;
       
   144     iDefaultBrand = temp;
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CBSBrandHandler::GetTextL()
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 HBufC* CBSBrandHandler::GetTextL( const TDesC8& aId )
       
   152 	{
       
   153 	TRACE( T_LIT( "CBranding::GetTextL begin [%S]"), &aId);
       
   154 	
       
   155 	MBSElement* element = ReadElementLC( aId );
       
   156 
       
   157 	HBufC* returnValue = element->TextDataL().AllocL();
       
   158 
       
   159 	CleanupStack::PopAndDestroy(); // element
       
   160 	TRACE( T_LIT( "CBranding::GetTextL end") );
       
   161     return returnValue;
       
   162 	}
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CBSBrandHandler::GetBufferL()
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 HBufC8* CBSBrandHandler::GetBufferL( const TDesC8& aId )
       
   169 	{
       
   170 	TRACE( T_LIT( "CBSBrandHandler::GetBufferL begin") );
       
   171 	
       
   172 	MBSElement* element = ReadElementLC( aId );
       
   173 
       
   174 	HBufC8* returnValue = element->BufferDataL().AllocL();
       
   175 
       
   176 	CleanupStack::PopAndDestroy(); // element
       
   177 	TRACE( T_LIT( "CBSBrandHandler::GetBufferL end") );
       
   178     return returnValue;
       
   179 	}
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CBSBrandHandler::GetIntL()
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CBSBrandHandler::GetIntL( const TDesC8& aId )
       
   186 	{
       
   187     TRACE( T_LIT( "CBSBrandHandler::GetIntL begin") );
       
   188 	TInt value = 0;
       
   189 
       
   190 	MBSElement* element = ReadElementLC( aId );
       
   191 
       
   192 	value = element->IntDataL();
       
   193 
       
   194 	CleanupStack::PopAndDestroy(); // element
       
   195 
       
   196 	TRACE( T_LIT( "CBSBrandHandler::GetIntL end") );
       
   197     return value;
       
   198 	}
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CBSBrandHandler::GetFileL()
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CBSBrandHandler::GetFileL( const TDesC8& aId, RFile& aFile )
       
   205 	{
       
   206 	TRACE( T_LIT( "CBSBrandHandler::GetFileL begin aId[%S] "), &aId );
       
   207 	RFile file;
       
   208 	User::LeaveIfError( iFs.ShareProtected() );
       
   209 
       
   210 	if (iLanguage >= 100)
       
   211 		User::LeaveIfError (KErrNotFound);
       
   212 	HBufC* fileName = GetTextL( aId );
       
   213 
       
   214     TBuf<KLangBufLength> buffer;
       
   215 // append leading zero only if language code is <10.
       
   216     if ( 10 > iLanguage )
       
   217         {
       
   218     	buffer.AppendNum( KLeadingZero );
       
   219         }		
       
   220 
       
   221     buffer.AppendNum( iLanguage );
       
   222 
       
   223 	TInt err = -1;
       
   224 	TRAP (err, iStorageManager->FileElementHandleL( *iApplicationId,
       
   225 						     			 *iBrandId,
       
   226 						     			 *fileName,
       
   227 						     			 buffer,
       
   228 						     			 file ));
       
   229 
       
   230 	if (KErrNone != err)
       
   231 	    {
       
   232 		/* if the file is not found in the default brand also, then leave */
       
   233 	    iStorageManager->FileElementHandleL( *iApplicationId,
       
   234 	                                         *iDefaultBrandId,
       
   235 	                                         *fileName,
       
   236 	                                         buffer,
       
   237 	                                         file);
       
   238 
       
   239 		TRACE( T_LIT( "CBSBrandHandler::GetFileL found in default brand") );
       
   240 	    
       
   241 	    }
       
   242 
       
   243 	aFile = file;
       
   244     TRACE( T_LIT( "CBSBrandHandler::GetFileL end") );
       
   245 	}
       
   246 
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CBSBrandHandler::GetSeveralL()
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 MBSElement* CBSBrandHandler::GetSeveralL( RBSObjOwningPtrArray<HBufC8>& aIds )
       
   253 	{
       
   254 	MBSElement* returnValue = NULL;
       
   255 	TInt count = aIds.Count();
       
   256 	
       
   257 	RBSObjOwningPtrArray<MBSElement> listData;
       
   258 	CleanupClosePushL( listData );
       
   259 	for(TInt i = 0; i < count; i++ )
       
   260 		{
       
   261 		MBSElement* subElement = ReadElementLC( *aIds[ i ] );
       
   262 		listData.AppendL( subElement );
       
   263 		CleanupStack::Pop( subElement );
       
   264 		}
       
   265 	returnValue = BSElementFactory::CreateBSElementL( KNullDesC8,
       
   266 													  EBSList,
       
   267 													  listData );
       
   268 	CleanupStack::Pop(); // listData
       
   269 	return returnValue;
       
   270 	}
       
   271 
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CBSBrandHandler::GetStructureL()
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 MBSElement* CBSBrandHandler::GetStructureL( TDesC8& aId )
       
   278 	{
       
   279 	MBSElement* returnValue = NULL;
       
   280 
       
   281 	TRACE( T_LIT( "CBSBrandHandler::GetStructureL begin") );
       
   282 	
       
   283 	returnValue = ReadElementLC( aId );
       
   284 
       
   285 	CleanupStack::Pop(); // element
       
   286 
       
   287 	TRACE( T_LIT( "CBSBrandHandler::GetStructureL end") );
       
   288 
       
   289 	return returnValue;
       
   290 	}
       
   291 
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CBSBrandHandler::ReadElementLC()
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 MBSElement* CBSBrandHandler::ReadElementLC( const TDesC8& aId, TBool aForceDefault /*= EFalse*/ )
       
   298 	{
       
   299 	TRACE( T_LIT( "CBSBrandHandler::ReadElementLC begin aId"));
       
   300 
       
   301 	if( aForceDefault )
       
   302 		{
       
   303 		TRACE( T_LIT( "CBSBrandHandler::ReadElementLC default brand"));
       
   304 		iStorageManager->BrandHandleL( *iApplicationId,
       
   305 									   *iDefaultBrandId, iLanguage,
       
   306 									   *iHandle,
       
   307 									   iReserved );		
       
   308 		}
       
   309 	else
       
   310 		{
       
   311 		TInt err = -1;
       
   312 		TRAP (err, iStorageManager->BrandHandleL( *iApplicationId,
       
   313 									   *iBrandId, iLanguage,
       
   314 									   *iHandle,
       
   315 									   iReserved ));
       
   316 		if (KErrNone != err)
       
   317 			{
       
   318 			iStorageManager->BrandHandleL( *iApplicationId,
       
   319 										   *iDefaultBrandId, iLanguage,
       
   320 										   *iHandle,
       
   321 										   iReserved ); 	
       
   322 			}
       
   323 		}
       
   324 	
       
   325 	RFileReadStream stream;
       
   326 	stream.Attach( *iHandle );
       
   327 	CleanupClosePushL( stream );
       
   328 	
       
   329 	VerifyVersionL( stream );
       
   330 	
       
   331 	TInt count = stream.ReadInt16L();
       
   332 	
       
   333 	MBSElement* returnValue = NULL;
       
   334 
       
   335 	for( TInt i = 0; i < count; i++ )
       
   336 		{
       
   337 		TRAPD( err, returnValue = ReadStreamL( aId, stream ) );
       
   338 		
       
   339 		if( err == KErrEof )
       
   340 			{
       
   341 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC EOF!") );
       
   342 			// the id is not found in this file
       
   343 			User::Leave( KErrNotFound );
       
   344 			}
       
   345 		if( returnValue )
       
   346 			{
       
   347 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC ELEMENT FOUND.. at position %d"), i);
       
   348 			// we found what we are looking for
       
   349 			break;
       
   350 			}
       
   351 		}
       
   352 		
       
   353 	CleanupStack::PopAndDestroy( &stream ); // stream	
       
   354 	
       
   355 	TBool popElementFromCleanupStack( EFalse );
       
   356 	
       
   357 	/* If retur value is not found and if its read the actual brand, then try in default brand as well. aForceDefault will decide that. */
       
   358 	if( !returnValue && !aForceDefault)
       
   359 		{
       
   360 		TRACE( T_LIT( "CBSBrandHandler::ReadElementLC force default is true") );
       
   361 
       
   362 		// the element was not found
       
   363 		// try the default brand if it's not the same as wanted brand
       
   364 		if( 0 != iBrandId->Compare( *iDefaultBrandId ) )
       
   365 			{
       
   366 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC calling READELEMENTLC again") );
       
   367 
       
   368 			/* Call ReadElementLC wiht aForceDefault set to TRUE */
       
   369 			returnValue = ReadElementLC( aId, ETrue );
       
   370 
       
   371 			if ( returnValue )
       
   372 			    {
       
   373 				TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS FOUND!!!") );
       
   374 			    popElementFromCleanupStack = ETrue;
       
   375 			    }
       
   376 			else
       
   377 				{
       
   378 				TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS NOT FOUND!!!") );
       
   379 				CleanupStack :: Pop (returnValue);
       
   380 				}
       
   381 			}
       
   382 		if( !returnValue )
       
   383 			{
       
   384 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE not FOUND LEAVING WITH -1 !!!") );
       
   385 			User::Leave( KErrNotFound );			
       
   386 			}
       
   387 		}
       
   388 	
       
   389 	CleanupClosePushL( *returnValue );
       
   390     // since we make one function call to ReadElementLC in case the default 
       
   391 	// brand id is used to retrieved the element, we have to pop one returnValue
       
   392 	// pointer from CleanupStack (otherwise we have two identical pointers on 
       
   393 	// the stack!!!)
       
   394 	if ( popElementFromCleanupStack )
       
   395    		{
       
   396    	 	CleanupStack::Pop( returnValue );
       
   397     	}
       
   398 	
       
   399 	TRACE( T_LIT( "CBSBrandHandler::ReadElementLC end ") );
       
   400 	return returnValue;
       
   401 	}
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // CBSBrandHandler::VerifyVersionL()
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 void CBSBrandHandler::VerifyVersionL( RFileReadStream& aStream )
       
   408 	{
       
   409 	TInt version = aStream.ReadInt16L();
       
   410 	if( version != iReserved )
       
   411 		{
       
   412 		User::Leave( KErrArgument );
       
   413 		}
       
   414 	}
       
   415 
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CBSBrandHandler::VerifyVersionL()
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 void CBSBrandHandler::VerifyVersionL()
       
   422 	{
       
   423 	if( !iHandle )
       
   424 		{
       
   425 		User::Leave( KErrNotReady );
       
   426 		}
       
   427 	RFileReadStream stream;
       
   428 	stream.Attach( *iHandle );
       
   429 	CleanupClosePushL( stream );
       
   430 	
       
   431 	VerifyVersionL( stream );
       
   432 	
       
   433 	CleanupStack::PopAndDestroy(); // stream
       
   434 	}
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 // CBSBrandHandler::ReadStreamL()
       
   438 // -----------------------------------------------------------------------------
       
   439 //
       
   440 MBSElement* CBSBrandHandler::ReadStreamL( const TDesC8& aId, RFileReadStream& aStream,
       
   441 										  TBool aAllowEmptyId /* = EFalse */ )
       
   442 	{
       
   443 	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL BEGIN"));
       
   444 	TBSElementType type = (TBSElementType)aStream.ReadInt16L();
       
   445 	MBSElement* returnValue = NULL;
       
   446 	
       
   447 	TInt idSize = aStream.ReadInt16L();
       
   448 	
       
   449 	HBufC8* elementId = HBufC8::NewLC( idSize );
       
   450 	TPtr8 elementIdPtr = elementId->Des();
       
   451 
       
   452 	if( idSize == 0 && aAllowEmptyId )
       
   453 		{
       
   454 		// we don't read empty ID
       
   455 		}
       
   456 	else
       
   457 		{
       
   458 		aStream.ReadL( elementIdPtr, idSize );
       
   459         elementIdPtr.SetLength( idSize );// Set length
       
   460 		}
       
   461 	
       
   462 
       
   463 	TBool match = EFalse;
       
   464 	if( aAllowEmptyId || ( 0 == elementIdPtr.Compare( aId ) ) )
       
   465 		{
       
   466 		match = ETrue;
       
   467 		}
       
   468 		
       
   469     TPtrC8 idPtrC( *elementId );// idPtrC creation moved here so it will be updated correctly.
       
   470 	if( elementId->Length() == 0 )
       
   471 		{
       
   472 		CleanupStack::PopAndDestroy( elementId );
       
   473 		elementId = NULL;
       
   474 		idPtrC.Set( KNullDesC8 );
       
   475 		}
       
   476 
       
   477 	switch( type )
       
   478 		{
       
   479 		case EBSInt:
       
   480 			{
       
   481 			TInt intData = aStream.ReadInt16L();
       
   482 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type INT"));
       
   483 			if( match )
       
   484 				{
       
   485                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   486                 // This method cannot leave after this line
       
   487 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   488 																  EBSInt,
       
   489 																  intData ); 
       
   490 				}
       
   491 			break;
       
   492 			}		
       
   493 		case EBSText:
       
   494 		case EBSFile: // flow through
       
   495 			{
       
   496 			TInt textSize = aStream.ReadInt16L();
       
   497 			HBufC* textData = HBufC::NewLC( textSize );
       
   498 
       
   499 			TPtr textPtr = textData->Des();
       
   500 			aStream.ReadL( textPtr, textSize );
       
   501 
       
   502 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type TEXT/ FILE"));
       
   503 			if( match )
       
   504 				{
       
   505                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   506                 // This method cannot leave after this line
       
   507 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   508 																  type,
       
   509 																  *textData ); 
       
   510 				}
       
   511 
       
   512 			CleanupStack::PopAndDestroy( textData );
       
   513 			break;
       
   514 			}
       
   515 		case EBSList:
       
   516 			{
       
   517 			RBSObjOwningPtrArray<MBSElement> listData;
       
   518 			CleanupClosePushL( listData );
       
   519 			TInt count = aStream.ReadInt16L();
       
   520 			
       
   521 			for( TInt i = 0; i < count; i++ )
       
   522 				{
       
   523 				MBSElement* subElement = ReadStreamL( KNullDesC8, aStream, ETrue );
       
   524 				CleanupDeletePushL( subElement );
       
   525 				listData.AppendL( subElement );
       
   526 				CleanupStack::Pop(); // subElement
       
   527 				}
       
   528 				
       
   529 			if( match )
       
   530 				{
       
   531                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   532                 // This method cannot leave after this line
       
   533 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   534 																  EBSList,
       
   535 																  listData ); 
       
   536 				}
       
   537 			CleanupStack::Pop(); // listData
       
   538 			break;
       
   539 			}
       
   540 		case EBSBuffer:
       
   541 			{
       
   542 			TInt bufferSize = aStream.ReadInt16L();
       
   543 			HBufC8* buffeData = HBufC8::NewLC( bufferSize );
       
   544 
       
   545 			TPtr8 bufferPtr = buffeData->Des();
       
   546 			aStream.ReadL( bufferPtr, bufferSize );
       
   547 
       
   548 			if( match )
       
   549 				{
       
   550                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   551                 // This method cannot leave after this line				
       
   552 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   553 																  EBSBuffer,
       
   554 																  *buffeData ); 
       
   555 				}
       
   556 
       
   557 			CleanupStack::PopAndDestroy( buffeData );
       
   558 			break;
       
   559 			}
       
   560 		case EBSBitmap:
       
   561 			{
       
   562 			TInt length = aStream.ReadInt16L();
       
   563 			HBufC8* fileId = HBufC8::NewLC( length );
       
   564 			
       
   565 			TPtr8 fileIdPtr = fileId->Des();
       
   566 			aStream.ReadL( fileIdPtr, length );
       
   567 			
       
   568 			TInt bitmapId = aStream.ReadInt16L();
       
   569 			TInt maskId = aStream.ReadInt16L();
       
   570 			TInt skinId = aStream.ReadInt16L();
       
   571 			TInt skinMaskId = aStream.ReadInt16L();
       
   572 
       
   573 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type BITMAP .. bitmap ID is [%d]"), bitmapId);
       
   574 			if( match )
       
   575 				{
       
   576 				CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId,
       
   577 													  maskId,
       
   578 													  skinId,
       
   579 													  skinMaskId,
       
   580 													  fileIdPtr );
       
   581 
       
   582                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   583                 // This method cannot leave after this line
       
   584 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   585 																  EBSBitmap,
       
   586 																  bitmap ); 
       
   587 				CleanupStack::Pop( bitmap ); 
       
   588 				}
       
   589 		    CleanupStack::PopAndDestroy( fileId ); 
       
   590 
       
   591 			break;
       
   592 			}
       
   593 		default:
       
   594 			{
       
   595 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type DEFAULT : corrupt"));
       
   596 			User::Leave( KErrCorrupt );
       
   597 			break;
       
   598 			}
       
   599 		}
       
   600 
       
   601 	if( elementId )
       
   602 		{
       
   603 		CleanupStack::PopAndDestroy( elementId );
       
   604 		}
       
   605 
       
   606 	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL END"));
       
   607 	return returnValue;
       
   608 	}
       
   609 
       
   610 //  END OF FILE
       
   611