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