brandingserver/bsserver/cbsbrandhandler.cpp
changeset 46 860cd8a5168c
parent 35 085f765766a0
equal deleted inserted replaced
35:085f765766a0 46:860cd8a5168c
     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 	CleanupStack :: PushL (fileName);
       
   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 	CleanupStack :: PopAndDestroy (fileName);
       
   245 
       
   246 	aFile = file;
       
   247     TRACE( T_LIT( "CBSBrandHandler::GetFileL end") );
       
   248 	}
       
   249 
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CBSBrandHandler::GetSeveralL()
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 MBSElement* CBSBrandHandler::GetSeveralL( RBSObjOwningPtrArray<HBufC8>& aIds )
       
   256 	{
       
   257 	MBSElement* returnValue = NULL;
       
   258 	TInt count = aIds.Count();
       
   259 	
       
   260 	RBSObjOwningPtrArray<MBSElement> listData;
       
   261 	CleanupClosePushL( listData );
       
   262 	for(TInt i = 0; i < count; i++ )
       
   263 		{
       
   264 		MBSElement* subElement = ReadElementLC( *aIds[ i ] );
       
   265 		listData.AppendL( subElement );
       
   266 		CleanupStack::Pop( subElement );
       
   267 		}
       
   268 	returnValue = BSElementFactory::CreateBSElementL( KNullDesC8,
       
   269 													  EBSList,
       
   270 													  listData );
       
   271 	CleanupStack::Pop(); // listData
       
   272 	return returnValue;
       
   273 	}
       
   274 
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CBSBrandHandler::GetStructureL()
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 MBSElement* CBSBrandHandler::GetStructureL( TDesC8& aId )
       
   281 	{
       
   282 	MBSElement* returnValue = NULL;
       
   283 
       
   284 	TRACE( T_LIT( "CBSBrandHandler::GetStructureL begin") );
       
   285 	
       
   286 	returnValue = ReadElementLC( aId );
       
   287 
       
   288 	CleanupStack::Pop(); // element
       
   289 
       
   290 	TRACE( T_LIT( "CBSBrandHandler::GetStructureL end") );
       
   291 
       
   292 	return returnValue;
       
   293 	}
       
   294 
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CBSBrandHandler::ReadElementLC()
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 MBSElement* CBSBrandHandler::ReadElementLC( const TDesC8& aId, TBool aForceDefault /*= EFalse*/ )
       
   301 	{
       
   302 	TRACE( T_LIT( "CBSBrandHandler::ReadElementLC begin aId"));
       
   303 
       
   304 	if( aForceDefault )
       
   305 		{
       
   306 		TRACE( T_LIT( "CBSBrandHandler::ReadElementLC default brand"));
       
   307 		iStorageManager->BrandHandleL( *iApplicationId,
       
   308 									   *iDefaultBrandId, iLanguage,
       
   309 									   *iHandle,
       
   310 									   iReserved );		
       
   311 		}
       
   312 	else
       
   313 		{
       
   314 		TInt err = -1;
       
   315 		TRAP (err, iStorageManager->BrandHandleL( *iApplicationId,
       
   316 									   *iBrandId, iLanguage,
       
   317 									   *iHandle,
       
   318 									   iReserved ));
       
   319 		if (KErrNone != err)
       
   320 			{
       
   321 			iStorageManager->BrandHandleL( *iApplicationId,
       
   322 										   *iDefaultBrandId, iLanguage,
       
   323 										   *iHandle,
       
   324 										   iReserved ); 	
       
   325 			}
       
   326 		}
       
   327 	
       
   328 	RFileReadStream stream;
       
   329 	stream.Attach( *iHandle );
       
   330 	CleanupClosePushL( stream );
       
   331 	
       
   332 	VerifyVersionL( stream );
       
   333 	
       
   334 	TInt count = stream.ReadInt16L();
       
   335 	
       
   336 	MBSElement* returnValue = NULL;
       
   337 
       
   338 	for( TInt i = 0; i < count; i++ )
       
   339 		{
       
   340 		TRAPD( err, returnValue = ReadStreamL( aId, stream ) );
       
   341 		
       
   342 		if( err == KErrEof )
       
   343 			{
       
   344 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC EOF!") );
       
   345 			// the id is not found in this file
       
   346 			User::Leave( KErrNotFound );
       
   347 			}
       
   348 		if( returnValue )
       
   349 			{
       
   350 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC ELEMENT FOUND.. at position %d"), i);
       
   351 			// we found what we are looking for
       
   352 			break;
       
   353 			}
       
   354 		}
       
   355 		
       
   356 	CleanupStack::PopAndDestroy( &stream ); // stream	
       
   357 	
       
   358 	TBool popElementFromCleanupStack( EFalse );
       
   359 	
       
   360 	/* If retur value is not found and if its read the actual brand, then try in default brand as well. aForceDefault will decide that. */
       
   361 	if( !returnValue && !aForceDefault)
       
   362 		{
       
   363 		TRACE( T_LIT( "CBSBrandHandler::ReadElementLC force default is true") );
       
   364 
       
   365 		// the element was not found
       
   366 		// try the default brand if it's not the same as wanted brand
       
   367 		if( 0 != iBrandId->Compare( *iDefaultBrandId ) )
       
   368 			{
       
   369 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC calling READELEMENTLC again") );
       
   370 
       
   371 			/* Call ReadElementLC wiht aForceDefault set to TRUE */
       
   372 			returnValue = ReadElementLC( aId, ETrue );
       
   373 
       
   374 			if ( returnValue )
       
   375 			    {
       
   376 				TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS FOUND!!!") );
       
   377 			    popElementFromCleanupStack = ETrue;
       
   378 			    }
       
   379 			else
       
   380 				{
       
   381 				TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE IS NOT FOUND!!!") );
       
   382 				CleanupStack :: Pop (returnValue);
       
   383 				}
       
   384 			}
       
   385 		if( !returnValue )
       
   386 			{
       
   387 			TRACE( T_LIT( "CBSBrandHandler::ReadElementLC VALUE not FOUND LEAVING WITH -1 !!!") );
       
   388 			User::Leave( KErrNotFound );			
       
   389 			}
       
   390 		}
       
   391 	
       
   392 	CleanupClosePushL( *returnValue );
       
   393     // since we make one function call to ReadElementLC in case the default 
       
   394 	// brand id is used to retrieved the element, we have to pop one returnValue
       
   395 	// pointer from CleanupStack (otherwise we have two identical pointers on 
       
   396 	// the stack!!!)
       
   397 	if ( popElementFromCleanupStack )
       
   398    		{
       
   399    	 	CleanupStack::Pop( returnValue );
       
   400     	}
       
   401 	
       
   402 	TRACE( T_LIT( "CBSBrandHandler::ReadElementLC end ") );
       
   403 	return returnValue;
       
   404 	}
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CBSBrandHandler::VerifyVersionL()
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 void CBSBrandHandler::VerifyVersionL( RFileReadStream& aStream )
       
   411 	{
       
   412 	TInt version = aStream.ReadInt16L();
       
   413 	if( version != iReserved )
       
   414 		{
       
   415 		User::Leave( KErrArgument );
       
   416 		}
       
   417 	}
       
   418 
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CBSBrandHandler::VerifyVersionL()
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 void CBSBrandHandler::VerifyVersionL()
       
   425 	{
       
   426 	if( !iHandle )
       
   427 		{
       
   428 		User::Leave( KErrNotReady );
       
   429 		}
       
   430 	RFileReadStream stream;
       
   431 	stream.Attach( *iHandle );
       
   432 	CleanupClosePushL( stream );
       
   433 	
       
   434 	VerifyVersionL( stream );
       
   435 	
       
   436 	CleanupStack::PopAndDestroy(); // stream
       
   437 	}
       
   438 
       
   439 // -----------------------------------------------------------------------------
       
   440 // CBSBrandHandler::ReadStreamL()
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 MBSElement* CBSBrandHandler::ReadStreamL( const TDesC8& aId, RFileReadStream& aStream,
       
   444 										  TBool aAllowEmptyId /* = EFalse */ )
       
   445 	{
       
   446 	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL BEGIN"));
       
   447 	TBSElementType type = (TBSElementType)aStream.ReadInt16L();
       
   448 	MBSElement* returnValue = NULL;
       
   449 	
       
   450 	TInt idSize = aStream.ReadInt16L();
       
   451 	
       
   452 	HBufC8* elementId = HBufC8::NewLC( idSize );
       
   453 	TPtr8 elementIdPtr = elementId->Des();
       
   454 
       
   455 	if( idSize == 0 && aAllowEmptyId )
       
   456 		{
       
   457 		// we don't read empty ID
       
   458 		}
       
   459 	else
       
   460 		{
       
   461 		aStream.ReadL( elementIdPtr, idSize );
       
   462         elementIdPtr.SetLength( idSize );// Set length
       
   463 		}
       
   464 	
       
   465 
       
   466 	TBool match = EFalse;
       
   467 	if( aAllowEmptyId || ( 0 == elementIdPtr.Compare( aId ) ) )
       
   468 		{
       
   469 		match = ETrue;
       
   470 		}
       
   471 		
       
   472     TPtrC8 idPtrC( *elementId );// idPtrC creation moved here so it will be updated correctly.
       
   473 	if( elementId->Length() == 0 )
       
   474 		{
       
   475 		CleanupStack::PopAndDestroy( elementId );
       
   476 		elementId = NULL;
       
   477 		idPtrC.Set( KNullDesC8 );
       
   478 		}
       
   479 
       
   480 	switch( type )
       
   481 		{
       
   482 		case EBSInt:
       
   483 			{
       
   484 			TInt intData = aStream.ReadInt16L();
       
   485 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type INT"));
       
   486 			if( match )
       
   487 				{
       
   488                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   489                 // This method cannot leave after this line
       
   490 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   491 																  EBSInt,
       
   492 																  intData ); 
       
   493 				}
       
   494 			break;
       
   495 			}		
       
   496 		case EBSText:
       
   497 		case EBSFile: // flow through
       
   498 			{
       
   499 			TInt textSize = aStream.ReadInt16L();
       
   500 			HBufC* textData = HBufC::NewLC( textSize );
       
   501 
       
   502 			TPtr textPtr = textData->Des();
       
   503 			aStream.ReadL( textPtr, textSize );
       
   504 
       
   505 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type TEXT/ FILE"));
       
   506 			if( match )
       
   507 				{
       
   508                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   509                 // This method cannot leave after this line
       
   510 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   511 																  type,
       
   512 																  *textData ); 
       
   513 				}
       
   514 
       
   515 			CleanupStack::PopAndDestroy( textData );
       
   516 			break;
       
   517 			}
       
   518 		case EBSList:
       
   519 			{
       
   520 			RBSObjOwningPtrArray<MBSElement> listData;
       
   521 			CleanupClosePushL( listData );
       
   522 			TInt count = aStream.ReadInt16L();
       
   523 			
       
   524 			for( TInt i = 0; i < count; i++ )
       
   525 				{
       
   526 				MBSElement* subElement = ReadStreamL( KNullDesC8, aStream, ETrue );
       
   527 				CleanupDeletePushL( subElement );
       
   528 				listData.AppendL( subElement );
       
   529 				CleanupStack::Pop(); // subElement
       
   530 				}
       
   531 				
       
   532 			if( match )
       
   533 				{
       
   534                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   535                 // This method cannot leave after this line
       
   536 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   537 																  EBSList,
       
   538 																  listData ); 
       
   539 				}
       
   540 			CleanupStack::Pop(); // listData
       
   541 			break;
       
   542 			}
       
   543 		case EBSBuffer:
       
   544 			{
       
   545 			TInt bufferSize = aStream.ReadInt16L();
       
   546 			HBufC8* buffeData = HBufC8::NewLC( bufferSize );
       
   547 
       
   548 			TPtr8 bufferPtr = buffeData->Des();
       
   549 			aStream.ReadL( bufferPtr, bufferSize );
       
   550 
       
   551 			if( match )
       
   552 				{
       
   553                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   554                 // This method cannot leave after this line				
       
   555 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   556 																  EBSBuffer,
       
   557 																  *buffeData ); 
       
   558 				}
       
   559 
       
   560 			CleanupStack::PopAndDestroy( buffeData );
       
   561 			break;
       
   562 			}
       
   563 		case EBSBitmap:
       
   564 			{
       
   565 			TInt length = aStream.ReadInt16L();
       
   566 			HBufC8* fileId = HBufC8::NewLC( length );
       
   567 			
       
   568 			TPtr8 fileIdPtr = fileId->Des();
       
   569 			aStream.ReadL( fileIdPtr, length );
       
   570 			
       
   571 			TInt bitmapId = aStream.ReadInt16L();
       
   572 			TInt maskId = aStream.ReadInt16L();
       
   573 			TInt skinId = aStream.ReadInt16L();
       
   574 			TInt skinMaskId = aStream.ReadInt16L();
       
   575 
       
   576 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type BITMAP .. bitmap ID is [%d]"), bitmapId);
       
   577 			if( match )
       
   578 				{
       
   579 				CBSBitmap* bitmap = CBSBitmap::NewLC( bitmapId,
       
   580 													  maskId,
       
   581 													  skinId,
       
   582 													  skinMaskId,
       
   583 													  fileIdPtr );
       
   584 
       
   585                 // Codescanner warning: neglected to put variable on cleanup stack (id:35)
       
   586                 // This method cannot leave after this line
       
   587 				returnValue = BSElementFactory::CreateBSElementL( idPtrC, // CSI: 35 # See above
       
   588 																  EBSBitmap,
       
   589 																  bitmap ); 
       
   590 				CleanupStack::Pop( bitmap ); 
       
   591 				}
       
   592 		    CleanupStack::PopAndDestroy( fileId ); 
       
   593 
       
   594 			break;
       
   595 			}
       
   596 		default:
       
   597 			{
       
   598 			TRACE( T_LIT( "CBSBrandHandler::ReadStreamL type DEFAULT : corrupt"));
       
   599 			User::Leave( KErrCorrupt );
       
   600 			break;
       
   601 			}
       
   602 		}
       
   603 
       
   604 	if( elementId )
       
   605 		{
       
   606 		CleanupStack::PopAndDestroy( elementId );
       
   607 		}
       
   608 
       
   609 	TRACE( T_LIT( "CBSBrandHandler::ReadStreamL END"));
       
   610 	return returnValue;
       
   611 	}
       
   612 
       
   613 //  END OF FILE
       
   614