common/tools/ats/smoketest/graphics/fbserv/src/T_DataFbsBitmap.cpp
changeset 833 6ffc235847d0
child 872 17498133d9ad
equal deleted inserted replaced
832:9b2bf01d4d36 833:6ffc235847d0
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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 "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @test
       
    20 @internalComponent
       
    21 v
       
    22 This contains CT_DataFbsBitmap
       
    23 */
       
    24 
       
    25 //	User includes
       
    26 #include "T_DataFbsBitmap.h"
       
    27 #include "T_GraphicsUtil.h"
       
    28 
       
    29 
       
    30 /*@{*/
       
    31 ///	Parameters
       
    32 _LIT(KAlways,								"always");
       
    33 _LIT(KBitmapId,								"bitmap_id");
       
    34 _LIT(KBuffLength,							"buff_length");
       
    35 _LIT(KDitherOffsetX,						"dither_offset_x");
       
    36 _LIT(KDitherOffsetY,						"dither_offset_y");
       
    37 _LIT(KExpectedBool,							"expected_bool");
       
    38 _LIT(KExpectedInt,							"expected_int");
       
    39 _LIT(KFbsBitmapName,						"fbs_bitmap_name");
       
    40 _LIT(KFileName,								"file_name");
       
    41 _LIT(KFileOffset,							"file_offset");
       
    42 _LIT(KHeight,								"height");
       
    43 _LIT(KHandle,								"handle");
       
    44 _LIT(KWidth,								"width");
       
    45 _LIT(KLength,								"length");
       
    46 _LIT(KNullExpected,							"null_expected");
       
    47 _LIT(KDevice,								"device");
       
    48 _LIT(KNumberOfSources,						"number_of_sources");
       
    49 _LIT(KPixels,								"pixels");
       
    50 _LIT(KPointX,								"point_x");
       
    51 _LIT(KPointY,								"point_y");
       
    52 _LIT(KRectTlX,								"rect_tl_x");
       
    53 _LIT(KRectTlY,								"rect_tl_y");
       
    54 _LIT(KRectBrX,								"rect_br_x");
       
    55 _LIT(KRectBrY,								"rect_br_y");
       
    56 _LIT(KScanLineCoord,						"scan_line_coord");
       
    57 _LIT(KSourceFileName0,						"source_file_name_0"); // we don't need more than 3 sources for our test anyway.
       
    58 _LIT(KSourceFileName1,						"source_file_name_1"); // So that this solution is ok
       
    59 _LIT(KSourceFileName2,						"source_file_name_2");
       
    60 _LIT(KSourceBitmapId0,						"source_bitmap_id_0");
       
    61 _LIT(KSourceBitmapId1,						"source_bitmap_id_1");
       
    62 _LIT(KSourceBitmapId2,						"source_bitmap_id_2");
       
    63 _LIT(KShareIfLoaded,						"share_if_loaded");
       
    64 _LIT(KTwips,								"twips");
       
    65 _LIT(KUseDitherOffset,						"use_dither_offset");
       
    66 _LIT(KUseRFile,								"use_rfile");
       
    67 _LIT(KUseClosedRFile,						"use_closed_rfile");
       
    68 _LIT(KUseClosedStream,						"use_closed_stream");
       
    69 _LIT(KUseRequestStatus,						"use_request_status");
       
    70 _LIT(KUid,									"uid");
       
    71 _LIT(KPalette,								"palette");
       
    72 _LIT(KModifiable,							"modifiable");
       
    73 _LIT(KEntries,								"entries");
       
    74 _LIT(KRed,									"red");
       
    75 _LIT(KGreen,								"green");
       
    76 _LIT(KBlue,									"blue");
       
    77 _LIT(KDisplayMode,							"displaymode");
       
    78 _LIT(KBitmapfileCompressionScheme,			"bitmap_compression_scheme");
       
    79 
       
    80 ///	Commands
       
    81 _LIT(KCmdDisown,								"disown");
       
    82 _LIT(KCmdNew,								"new");
       
    83 _LIT(KCmdDestructor,						"~");
       
    84 _LIT(KCmdCompress,							"Compress");
       
    85 _LIT(KCmdCompressInBackground,				"CompressInBackground");
       
    86 _LIT(KCmdCreate,							"Create");
       
    87 _LIT(KCmdCreateHardwareBitmap,				"CreateHardwareBitmap");
       
    88 _LIT(KCmdDataAddress,						"DataAddress");
       
    89 _LIT(KCmdDataStride,						"DataStride");
       
    90 _LIT(KCmdDisplayMode,						"DisplayMode");
       
    91 _LIT(KCmdDuplicate,							"Duplicate");
       
    92 _LIT(KCmdExternalizeL,						"ExternalizeL");
       
    93 _LIT(KCmdExternalizeRectangleL,				"ExternalizeRectangleL");
       
    94 _LIT(KCmdGetPalette,						"GetPalette");
       
    95 _LIT(KCmdGetPixel,							"GetPixel");
       
    96 _LIT(KCmdGetScanLine,						"GetScanLine");
       
    97 _LIT(KCmdGetVerticalScanLine,				"GetVerticalScanLine");
       
    98 _LIT(KCmdHandle,							"Handle");
       
    99 _LIT(KCmdHardwareBitmapHandle,				"HardwareBitmapHandle");
       
   100 _LIT(KCmdHeader,							"Header");
       
   101 _LIT(KCmdHorizontalPixelsToTwips,			"HorizontalPixelsToTwips");
       
   102 _LIT(KCmdHorizontalTwipsToPixels,			"HorizontalTwipsToPixels");
       
   103 _LIT(KCmdInitialDisplayMode,				"InitialDisplayMode");
       
   104 _LIT(KCmdInternalizeL,						"InternalizeL");
       
   105 _LIT(KCmdIsCompressedInRAM,					"IsCompressedInRAM");
       
   106 _LIT(KCmdIsFileInRom,						"IsFileInRom");
       
   107 _LIT(KCmdIsLargeBitmap,						"IsLargeBitmap");
       
   108 _LIT(KCmdIsMonochrome,						"IsMonochrome");
       
   109 _LIT(KCmdIsRomBitmap,						"IsRomBitmap");
       
   110 _LIT(KCmdLoad,								"Load");
       
   111 _LIT(KCmdLoadAndCompress,					"LoadAndCompress");
       
   112 _LIT(KCmdLockHeap,							"LockHeap");
       
   113 _LIT(KCmdLockHeapLC,						"LockHeapLC");
       
   114 _LIT(KCmdPaletteAttributes,					"PaletteAttributes");
       
   115 _LIT(KCmdReset,								"Reset");
       
   116 _LIT(KCmdResize,							"Resize");
       
   117 _LIT(KCmdSave,								"Save");
       
   118 _LIT(KCmdScanLineLength,					"ScanLineLength");
       
   119 _LIT(KCmdSetDisplayMode,					"SetDisplayMode");
       
   120 _LIT(KCmdSetPalette,						"SetPalette");
       
   121 _LIT(KCmdSetRomBitmapL,						"SetRomBitmapL");
       
   122 _LIT(KCmdSetScanLine,						"SetScanLine");
       
   123 _LIT(KCmdSetSizeInTwips,					"SetSizeInTwips");
       
   124 _LIT(KCmdSizeInPixels,						"SizeInPixels");
       
   125 _LIT(KCmdSizeInTwips,						"SizeInTwips");
       
   126 _LIT(KCmdStoreL,							"StoreL");
       
   127 _LIT(KCmdSwapWidthAndHeight,				"SwapWidthAndHeight");
       
   128 _LIT(KCmdUnlockHeap,						"UnlockHeap");
       
   129 _LIT(KCmdVerticalPixelsToTwips,				"VerticalPixelsToTwips");
       
   130 _LIT(KCmdVerticalTwipsToPixels,				"VerticalTwipsToPixels");
       
   131 
       
   132 //??	SetRomBitmapL
       
   133 //	Begin
       
   134 //	End
       
   135 //	GetDecompressionBuffer
       
   136 //	GetAllBitmapHandles
       
   137 /*@}*/
       
   138 
       
   139 /**
       
   140 * Two phase constructor
       
   141 */
       
   142 CT_DataFbsBitmap* CT_DataFbsBitmap::NewL()
       
   143 	{
       
   144 	CT_DataFbsBitmap* ret = new (ELeave) CT_DataFbsBitmap();
       
   145 	CleanupStack::PushL(ret);
       
   146 	ret->ConstructL();
       
   147 	CleanupStack::Pop(ret);
       
   148 	return ret;
       
   149 	}
       
   150 
       
   151 /**
       
   152 * Protected constructor. First phase construction
       
   153 */
       
   154 CT_DataFbsBitmap::CT_DataFbsBitmap()
       
   155 :	CDataWrapperBase()
       
   156 ,	iFbsBitmap(NULL)
       
   157 ,	iDisplayMode(ENone)
       
   158 ,	iPopWhenUnlocking(EFalse)
       
   159 ,	iCompressFailed(EFalse)
       
   160 ,	iActiveCompressInBackground(NULL)
       
   161 	{
       
   162 	}
       
   163 
       
   164 /**
       
   165 * Protected constructor. Second phase construction
       
   166 */
       
   167 void CT_DataFbsBitmap::ConstructL()
       
   168 	{
       
   169 	iActiveCompressInBackground=CActiveCallback::NewL(*this);
       
   170 	}
       
   171 
       
   172 /**
       
   173 * Destructor.
       
   174 */
       
   175 CT_DataFbsBitmap::~CT_DataFbsBitmap()
       
   176 	{
       
   177 	DestroyData();
       
   178 	delete iActiveCompressInBackground;
       
   179 	iActiveCompressInBackground=NULL;
       
   180 	}
       
   181 
       
   182 /**
       
   183 * Contains cleanup implementation
       
   184 */
       
   185 void CT_DataFbsBitmap::DestroyData()
       
   186 	{
       
   187 	delete iFbsBitmap;
       
   188 	iFbsBitmap=NULL;
       
   189 	}
       
   190 
       
   191 /**
       
   192 * Return a pointer to the object that the data wraps
       
   193 *
       
   194 * @return pointer to the object that the data wraps
       
   195 */
       
   196 TAny* CT_DataFbsBitmap::GetObject()
       
   197 	{
       
   198 	return iFbsBitmap;
       
   199 	}
       
   200 
       
   201 void CT_DataFbsBitmap::SetObjectL(TAny* aAny)
       
   202     {
       
   203     DestroyData();
       
   204     iFbsBitmap=static_cast<CFbsBitmap*> (aAny);
       
   205     }
       
   206 
       
   207 void CT_DataFbsBitmap::DisownObjectL()
       
   208 	{
       
   209 	iFbsBitmap=NULL;
       
   210 	}
       
   211 
       
   212 CFbsBitmap* CT_DataFbsBitmap::GetFbsBitmap() const
       
   213 	{
       
   214 	return iFbsBitmap;
       
   215 	}
       
   216 
       
   217 /**
       
   218 * Process a command read from the ini file
       
   219 *
       
   220 * @param aDataWrapper	test step requiring command to be processed
       
   221 * @param aCommand	the command to process
       
   222 * @param aSection		the entry in the ini file requiring the command to be processed
       
   223 *
       
   224 * @return ETrue if the command is processed
       
   225 */
       
   226 TBool CT_DataFbsBitmap::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
   227 	{
       
   228 	TBool	retVal = ETrue;
       
   229 
       
   230 	if (aCommand == KCmdNew)
       
   231 		{
       
   232 		DoCmdNewL();
       
   233 		}
       
   234 	else if (aCommand == KCmdDestructor)
       
   235 		{
       
   236 		DoCmdDestructor();
       
   237 		}
       
   238 	else if (aCommand == KCmdCompress)
       
   239 		{
       
   240 		DoCmdCompress(aSection);
       
   241 		}
       
   242 	else if (aCommand == KCmdCompressInBackground)
       
   243 		{
       
   244 		DoCmdCompressInBackground(aSection, aAsyncErrorIndex);
       
   245 		}
       
   246 	else if (aCommand == KCmdCreate)
       
   247 		{
       
   248 		DoCmdCreate(aSection);
       
   249 		}
       
   250 	else if (aCommand == KCmdCreateHardwareBitmap)
       
   251 		{
       
   252 		DoCmdCreateHardwareBitmap(aSection);
       
   253 		}
       
   254 	else if (aCommand == KCmdDataAddress)
       
   255 		{
       
   256 		DoCmdDataAddress(aSection);
       
   257 		}
       
   258 	else if (aCommand == KCmdDataStride)
       
   259 		{
       
   260 		DoCmdDataStride(aSection);
       
   261 		}
       
   262 	else if (aCommand == KCmdDisplayMode)
       
   263 		{
       
   264 		DoCmdDisplayMode(aSection);
       
   265 		}
       
   266 	else if (aCommand == KCmdDuplicate)
       
   267 		{
       
   268 		DoCmdDuplicateL(aSection);
       
   269 		}
       
   270 	else if (aCommand == KCmdExternalizeL)
       
   271 		{
       
   272 		DoCmdExternalizeL(aSection);
       
   273 		}
       
   274 	else if (aCommand == KCmdExternalizeRectangleL)
       
   275 		{
       
   276 		DoCmdExternalizeRectangleL(aSection);
       
   277 		}
       
   278 	else if (aCommand == KCmdGetPalette)
       
   279 		{
       
   280 		DoCmdGetPaletteL(aSection);
       
   281 		}
       
   282 	else if (aCommand == KCmdGetPixel)
       
   283 		{
       
   284 		DoCmdGetPixel(aSection);
       
   285 		}
       
   286 	else if (aCommand == KCmdGetScanLine)
       
   287 		{
       
   288 		DoCmdGetScanLineL(aSection);
       
   289 		}
       
   290 	else if (aCommand == KCmdGetVerticalScanLine)
       
   291 		{
       
   292 		DoCmdGetVerticalScanLineL(aSection);
       
   293 		}
       
   294 	else if (aCommand == KCmdHandle)
       
   295 		{
       
   296 		DoCmdHandle(aSection);
       
   297 		}
       
   298 	else if (aCommand == KCmdHardwareBitmapHandle)
       
   299 		{
       
   300 		DoCmdHardwareBitmapHandle(aSection);
       
   301 		}
       
   302 	else if (aCommand == KCmdHeader)
       
   303 		{
       
   304 		DoCmdHeader();
       
   305 		}
       
   306 	else if (aCommand == KCmdHorizontalPixelsToTwips)
       
   307 		{
       
   308 		DoCmdHorizontalPixelsToTwips(aSection);
       
   309 		}
       
   310 	else if (aCommand == KCmdHorizontalTwipsToPixels)
       
   311 		{
       
   312 		DoCmdHorizontalTwipsToPixels(aSection);
       
   313 		}
       
   314 	else if (aCommand == KCmdInitialDisplayMode)
       
   315 		{
       
   316 		DoCmdInitialDisplayMode(aSection);
       
   317 		}
       
   318 	else if (aCommand == KCmdInternalizeL)
       
   319 		{
       
   320 		DoCmdInternalizeL(aSection);
       
   321 		}
       
   322 	else if (aCommand == KCmdIsCompressedInRAM)
       
   323 		{
       
   324 		DoCmdIsCompressedInRAM(aSection);
       
   325 		}
       
   326 	else if (aCommand == KCmdIsFileInRom)
       
   327 		{
       
   328 		DoCmdIsFileInRom(aSection);
       
   329 		}
       
   330 	else if (aCommand == KCmdIsLargeBitmap)
       
   331 		{
       
   332 		DoCmdIsLargeBitmap(aSection);
       
   333 		}
       
   334 	else if (aCommand == KCmdIsMonochrome)
       
   335 		{
       
   336 		DoCmdIsMonochrome(aSection);
       
   337 		}
       
   338 	else if (aCommand == KCmdIsRomBitmap)
       
   339 		{
       
   340 		DoCmdIsRomBitmap(aSection);
       
   341 		}
       
   342 	else if (aCommand == KCmdLoad)
       
   343 		{
       
   344 		DoCmdLoadL(aSection);
       
   345 		}
       
   346 	else if (aCommand == KCmdLoadAndCompress)
       
   347 		{
       
   348 		DoCmdLoadAndCompressL(aSection);
       
   349 		}
       
   350 	else if (aCommand == KCmdLockHeap)
       
   351 		{
       
   352 		DoCmdLockHeap(aSection);
       
   353 		}
       
   354 	else if (aCommand == KCmdLockHeapLC)
       
   355 		{
       
   356 		DoCmdLockHeapLC(aSection);
       
   357 		}
       
   358 	else if (aCommand == KCmdPaletteAttributes)
       
   359 		{
       
   360 		DoCmdPaletteAttributes(aSection);
       
   361 		}
       
   362 	else if (aCommand == KCmdReset)
       
   363 		{
       
   364 		DoCmdReset();
       
   365 		}
       
   366 	else if (aCommand == KCmdResize)
       
   367 		{
       
   368 		DoCmdResize(aSection);
       
   369 		}
       
   370 	else if (aCommand == KCmdSave)
       
   371 		{
       
   372 		DoCmdSave(aSection);
       
   373 		}
       
   374 	else if (aCommand == KCmdScanLineLength)
       
   375 		{
       
   376 		DoCmdScanLineLength(aSection);
       
   377 		}
       
   378 	else if (aCommand == KCmdSetDisplayMode)
       
   379 		{
       
   380 		DoCmdSetDisplayMode(aSection);
       
   381 		}
       
   382 	else if (aCommand == KCmdSetPalette)
       
   383 		{
       
   384 		DoCmdSetPaletteL(aSection);
       
   385 		}
       
   386 	else if (aCommand == KCmdSetRomBitmapL)
       
   387 		{
       
   388 		DoCmdSetRomBitmapL(aSection);
       
   389 		}
       
   390 	else if (aCommand == KCmdSetScanLine)
       
   391 		{
       
   392 		DoCmdSetScanLineL(aSection);
       
   393 		}
       
   394 	else if (aCommand == KCmdSetSizeInTwips)
       
   395 		{
       
   396 		DoCmdSetSizeInTwipsL(aSection);
       
   397 		}
       
   398 	else if (aCommand == KCmdSizeInPixels)
       
   399 		{
       
   400 		DoCmdSizeInPixels(aSection);
       
   401 		}
       
   402 	else if (aCommand == KCmdSizeInTwips)
       
   403 		{
       
   404 		DoCmdSizeInTwips(aSection);
       
   405 		}
       
   406 	else if (aCommand == KCmdStoreL)
       
   407 		{
       
   408 		DoCmdStoreL(aSection);
       
   409 		}
       
   410 	else if (aCommand == KCmdSwapWidthAndHeight)
       
   411 		{
       
   412 		DoCmdSwapWidthAndHeight();
       
   413 		}
       
   414 	else if (aCommand == KCmdUnlockHeap)
       
   415 		{
       
   416 		DoCmdUnlockHeapL(aSection);
       
   417 		}
       
   418 	else if (aCommand == KCmdVerticalPixelsToTwips)
       
   419 		{
       
   420 		DoCmdVerticalPixelsToTwips(aSection);
       
   421 		}
       
   422 	else if (aCommand == KCmdVerticalTwipsToPixels)
       
   423 		{
       
   424 		DoCmdVerticalTwipsToPixels(aSection);
       
   425 		}
       
   426 	else if (aCommand == KCmdDisown)
       
   427    {
       
   428    DisownObjectL();
       
   429    }
       
   430 	else
       
   431 		{
       
   432 		retVal=EFalse;
       
   433 		}
       
   434 
       
   435 	return retVal;
       
   436 	}
       
   437 
       
   438 
       
   439 /** Creates new CFbsBitmap class instance */
       
   440 void CT_DataFbsBitmap::DoCmdNewL()
       
   441 	{
       
   442 	INFO_PRINTF1(_L("Creates new CFbsBitmap class instance"));
       
   443 
       
   444 	// cleanup if already created
       
   445     DestroyData();
       
   446 	iFbsBitmap=new (ELeave) CFbsBitmap();
       
   447 	}
       
   448 
       
   449 /** Calls static CFbsBitmap destructor */
       
   450 void CT_DataFbsBitmap::DoCmdDestructor()
       
   451 	{
       
   452 	DestroyData();
       
   453 	}
       
   454 
       
   455 /** Calls CFbsBitmap::Compress() */
       
   456 void CT_DataFbsBitmap::DoCmdCompress(const TDesC& aSection)
       
   457 	{
       
   458 	INFO_PRINTF1(_L("Calls CFbsBitmap::Compress()"));
       
   459 
       
   460 	TInt							err=KErrNone;
       
   461 	TBitmapfileCompressionScheme	compressionScheme;
       
   462 	if ( CT_GraphicsUtil::ReadBitmapfileCompressionScheme(*this, aSection, KBitmapfileCompressionScheme(), compressionScheme) )
       
   463 		{
       
   464 		err=GetFbsBitmap()->Compress(compressionScheme);
       
   465 		}
       
   466 	else
       
   467 		{
       
   468 		// call Compress()
       
   469 		err=GetFbsBitmap()->Compress();
       
   470 		}
       
   471 	// check error code
       
   472 	if ( err!=KErrNone )
       
   473 		{
       
   474 		ERR_PRINTF2(_L("Compress error: %d"), err);
       
   475 		SetError(err);
       
   476 		iCompressFailed = ETrue;
       
   477 		}
       
   478 	else
       
   479 	    {
       
   480 	    iCompressFailed = EFalse;
       
   481 	    };
       
   482 	}
       
   483 
       
   484 /** Calls CFbsBitmap::CompressInBackground() */
       
   485 void CT_DataFbsBitmap::DoCmdCompressInBackground(const TDesC& aSection, const TInt aAsyncErrorIndex)
       
   486 	{
       
   487 	INFO_PRINTF1(_L("Calls CFbsBitmap::CompressInBackground()"));
       
   488 
       
   489 	// get a flag if to use requset status from parameters
       
   490 	TBool	useRequestStatus = EFalse;
       
   491 	GetBoolFromConfig(aSection, KUseRequestStatus(), useRequestStatus);
       
   492 
       
   493 	TBitmapfileCompressionScheme	compressionScheme;
       
   494 	TBool							hasCompressionScheme=CT_GraphicsUtil::ReadBitmapfileCompressionScheme(*this, aSection, KBitmapfileCompressionScheme(), compressionScheme);
       
   495 
       
   496 	// call CompressInBackground()
       
   497 	if ( useRequestStatus )
       
   498 		{
       
   499 		if ( hasCompressionScheme )
       
   500 			{
       
   501 			GetFbsBitmap()->CompressInBackground(iActiveCompressInBackground->iStatus, compressionScheme);
       
   502 			}
       
   503 		else
       
   504 			{
       
   505 			GetFbsBitmap()->CompressInBackground(iActiveCompressInBackground->iStatus);
       
   506 			}
       
   507 		iActiveCompressInBackground->Activate(aAsyncErrorIndex);
       
   508 		IncOutstanding();
       
   509 		}
       
   510 	else
       
   511 		{
       
   512 		TInt	err = KErrNone;
       
   513 
       
   514 		if ( hasCompressionScheme )
       
   515 			{
       
   516 			err=GetFbsBitmap()->CompressInBackground(compressionScheme);
       
   517 			}
       
   518 		else
       
   519 			{
       
   520 			err=GetFbsBitmap()->CompressInBackground();
       
   521 			}
       
   522 
       
   523 		// check error code
       
   524 		if ( err != KErrNone )
       
   525 			{
       
   526 			ERR_PRINTF2(_L("Compress in background error: %d"), err);
       
   527 			SetError(err);
       
   528 			iCompressFailed = ETrue;
       
   529 			}
       
   530 		else
       
   531 		    {
       
   532 		    iCompressFailed = EFalse;
       
   533 		    }
       
   534 		}
       
   535 	}
       
   536 
       
   537 /** Calls CFbsBitmap::Create() */
       
   538 void CT_DataFbsBitmap::DoCmdCreate(const TDesC& aSection)
       
   539 	{
       
   540 	INFO_PRINTF1(_L("Calls CFbsBitmap::Create()"));
       
   541 
       
   542 	// get size height from parameters
       
   543 	TInt	height;
       
   544 	if(!GetIntFromConfig(aSection, KHeight(), height))
       
   545 		{
       
   546 		ERR_PRINTF2(_L("No %S"), &KHeight());
       
   547 		SetBlockResult(EFail);
       
   548 		}
       
   549 
       
   550 	// get size width from parameters
       
   551 	TInt	width;
       
   552 	if(!GetIntFromConfig(aSection, KWidth(), width))
       
   553 		{
       
   554 		ERR_PRINTF2(_L("No %S"), &KWidth());
       
   555 		SetBlockResult(EFail);
       
   556 		}
       
   557 
       
   558 	// get display mode from parameters
       
   559 
       
   560 	TDisplayMode	displayMode;
       
   561 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
   562 		{
       
   563 		ERR_PRINTF1(_L("No display mode"));
       
   564 		SetBlockResult(EFail);
       
   565 		}
       
   566 	else
       
   567 		{
       
   568 		// call Create()
       
   569 		TInt	err = GetFbsBitmap()->Create(TSize(width, height), displayMode);
       
   570 
       
   571 		// check error code
       
   572 		if (err != KErrNone)
       
   573 			{
       
   574 			ERR_PRINTF2(_L("Creation error: %d"), err);
       
   575 			SetError(err);
       
   576 			}
       
   577 		}
       
   578 	}
       
   579 
       
   580 /** Calls CFbsBitmap::CreateHardwareBitmap() */
       
   581 void CT_DataFbsBitmap::DoCmdCreateHardwareBitmap(const TDesC& aSection)
       
   582 	{
       
   583 	INFO_PRINTF1(_L("Calls CFbsBitmap::CreateHardwareBitmap()"));
       
   584 
       
   585 	// get size height from parameters
       
   586 	TInt	height;
       
   587 	if(!GetIntFromConfig(aSection, KHeight(), height))
       
   588 		{
       
   589 		ERR_PRINTF2(_L("No %S"), &KHeight());
       
   590 		SetBlockResult(EFail);
       
   591 		}
       
   592 
       
   593 	// get size width from parameters
       
   594 	TInt	width;
       
   595 	if(!GetIntFromConfig(aSection, KWidth(), width))
       
   596 		{
       
   597 		ERR_PRINTF2(_L("No %S"), &KWidth());
       
   598 		SetBlockResult(EFail);
       
   599 		}
       
   600 
       
   601 	// get display mode from parameters
       
   602 	TDisplayMode	displayMode;
       
   603 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
   604 		{
       
   605 		ERR_PRINTF1(_L("No display mode"));
       
   606 		SetBlockResult(EFail);
       
   607 		}
       
   608 
       
   609 	// get application uid from parameters
       
   610 	TInt	uidInt;
       
   611 	if(!GetIntFromConfig(aSection, KUid(), uidInt))
       
   612 		{
       
   613 		ERR_PRINTF2(_L("No %S"), &KUid());
       
   614 		SetBlockResult(EFail);
       
   615 		}
       
   616 
       
   617 	// call Create()
       
   618 	TInt	err = GetFbsBitmap()->CreateHardwareBitmap(TSize(width, height), displayMode, TUid::Uid(uidInt));
       
   619 
       
   620 	// check error code
       
   621 	if ( err != KErrNone )
       
   622 		{
       
   623 		ERR_PRINTF2(_L("Hardware bitmap creation error: %d"), err);
       
   624 		SetError(err);
       
   625 		}
       
   626 	}
       
   627 
       
   628 /** Calls CFbsBitmap::DataAddress() locking and unlocking heap by defined in parameters means */
       
   629 void CT_DataFbsBitmap::DoCmdDataAddress(const TDesC& aSection)
       
   630 	{
       
   631 	// call DataAddress()
       
   632 	TUint32*	address=GetFbsBitmap()->DataAddress();
       
   633 	INFO_PRINTF2(_L("DataAddress %d"), address);
       
   634 
       
   635 	// validate returned value if needed
       
   636 	TInt	expectedValue;
       
   637 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
   638 		{
       
   639 		if (expectedValue != (TInt)address)
       
   640 			{
       
   641 			ERR_PRINTF1(_L("The returned value is not as expected"));
       
   642 			SetBlockResult(EFail);
       
   643 			}
       
   644 		}
       
   645 	}
       
   646 
       
   647 /** Calls CFbsBitmap::DataStride() */
       
   648 void CT_DataFbsBitmap::DoCmdDataStride(const TDesC& aSection)
       
   649 	{
       
   650 	INFO_PRINTF1(_L("Calls CFbsBitmap::DataStride()"));
       
   651 	
       
   652 	// call DataStride()
       
   653 	TInt value = GetFbsBitmap()->DataStride();
       
   654 	INFO_PRINTF2(_L("Data stride: %d"), value);
       
   655 
       
   656 	// validate returned value if needed
       
   657 	TInt expectedValue;
       
   658 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
   659 		{
       
   660 		if (expectedValue != value)
       
   661 			{
       
   662 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, value);
       
   663 			SetBlockResult(EFail);
       
   664 			}
       
   665 		}
       
   666 
       
   667 	// check the value is not NULL
       
   668 	if (value <= 0)
       
   669 		{
       
   670 		ERR_PRINTF2(_L("The data stride is not expected zero or less, value: %d"), value);
       
   671 		SetBlockResult(EFail);
       
   672 		}
       
   673 	}
       
   674 
       
   675 /** Checks CFbsBitmap::DisplayMode() value */
       
   676 void CT_DataFbsBitmap::DoCmdDisplayMode(const TDesC& aSection)
       
   677 	{
       
   678 	INFO_PRINTF1(_L("Checks CFbsBitmap::DisplayMode() value"));
       
   679 
       
   680 	// call DisplayMode()
       
   681 	iDisplayMode=GetFbsBitmap()->DisplayMode();
       
   682 	INFO_PRINTF2(_L("Display Mode %d"), iDisplayMode);
       
   683 
       
   684 	// get display mode from parameters
       
   685 	TDisplayMode	expectedValue;
       
   686 	if ( CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), expectedValue) )
       
   687 		{
       
   688 		// check value against NULL
       
   689 		if ( iDisplayMode!=expectedValue )
       
   690 			{
       
   691 			ERR_PRINTF3(_L("The value is not as expected! expected: %d, actual: %d"), expectedValue, iDisplayMode);
       
   692 			SetBlockResult(EFail);
       
   693 			}
       
   694 		}
       
   695 	}
       
   696 
       
   697 /** Calls CFbsBitmap::Duplicate() */
       
   698 void CT_DataFbsBitmap::DoCmdDuplicateL(const TDesC& aSection)
       
   699 	{
       
   700 	INFO_PRINTF1(_L("Calls CFbsBitmap::Duplicate()"));
       
   701 	TInt	handle=GetHandle();
       
   702 	TPtrC	objectName;
       
   703 	if ( GetStringFromConfig(aSection, KFbsBitmapName(), objectName) )
       
   704 		{
       
   705 		CDataWrapperBase*	wrapper=static_cast<CDataWrapperBase*>(GetDataWrapperL(objectName));
       
   706 		handle=wrapper->GetHandle();
       
   707 		}
       
   708 	else
       
   709 		{
       
   710 		GetIntFromConfig(aSection, KHandle(), handle);
       
   711 		}
       
   712 
       
   713 	// call Duplicate()
       
   714 	TInt	err = GetFbsBitmap()->Duplicate(handle);
       
   715 	if (err != KErrNone)
       
   716 		{
       
   717 		ERR_PRINTF2(_L("Duplicate error: %d"), err);
       
   718 		SetError(err);
       
   719 		}
       
   720 	}
       
   721 
       
   722 /** Calls CFbsBitmap::ExternalizeL() */
       
   723 void CT_DataFbsBitmap::DoCmdExternalizeL(const TDesC& aSection)
       
   724 	{
       
   725 	INFO_PRINTF1(_L("Calls CFbsBitmap::ExternalizeL()"));
       
   726 	ExternalizeImplL(aSection, TRect(), EFalse);
       
   727 	}
       
   728 
       
   729 /** Calls CFbsBitmap::ExternalizeRectangleL() */
       
   730 void CT_DataFbsBitmap::DoCmdExternalizeRectangleL(const TDesC& aSection)
       
   731 	{
       
   732 	INFO_PRINTF1(_L("Calls CFbsBitmap::ExternalizeRectangleL()"));
       
   733 
       
   734 	// get rectangle top left x-coordinate from parameters
       
   735 	TInt	tlx;
       
   736 	if(!GetIntFromConfig(aSection, KRectTlX(), tlx))
       
   737 		{
       
   738 		ERR_PRINTF2(_L("No %S"), &KRectTlX());
       
   739 		SetBlockResult(EFail);
       
   740 		}
       
   741 
       
   742 	// get rectangle top left x-coordinate from parameters
       
   743 	TInt	tly;
       
   744 	if(!GetIntFromConfig(aSection, KRectTlY(), tly))
       
   745 		{
       
   746 		ERR_PRINTF2(_L("No %S"), &KRectTlY());
       
   747 		SetBlockResult(EFail);
       
   748 		}
       
   749 
       
   750 	// get rectangle top left x-coordinate from parameters
       
   751 	TInt	brx;
       
   752 	if(!GetIntFromConfig(aSection, KRectBrX(), brx))
       
   753 		{
       
   754 		ERR_PRINTF2(_L("No %S"), &KRectBrX());
       
   755 		SetBlockResult(EFail);
       
   756 		}
       
   757 
       
   758 	// get rectangle top left x-coordinate from parameters
       
   759 	TInt	bry;
       
   760 	if(!GetIntFromConfig(aSection, KRectBrY(), bry))
       
   761 		{
       
   762 		ERR_PRINTF2(_L("No %S"), &KRectBrY());
       
   763 		SetBlockResult(EFail);
       
   764 		}
       
   765 
       
   766 	ExternalizeImplL(aSection, TRect(tlx, tly, brx, bry), ETrue);
       
   767 	}
       
   768 
       
   769 /** Calls CFbsBitmap::GetPalette() */
       
   770 void CT_DataFbsBitmap::DoCmdGetPaletteL(const TDesC& aSection)
       
   771 	{
       
   772 	// call GetPalette()
       
   773 	CPalette*	palette = NULL;
       
   774 	TInt		err = GetFbsBitmap()->GetPalette(palette);
       
   775 	INFO_PRINTF2(_L("Calls CFbsBitmap::GetPalette() %d"), palette);
       
   776 
       
   777 	// check error code
       
   778 	if (err != KErrNone)
       
   779 		{
       
   780 		ERR_PRINTF2(_L("GetPalette error: %d"), err);
       
   781 		SetError(err);
       
   782 		}
       
   783 	else
       
   784 		{
       
   785 		//	Verify palette
       
   786 		CPalette*	expectedPalette = NULL;
       
   787 
       
   788 		if ( CT_GraphicsUtil::GetPaletteL(*this, aSection, KPalette(), expectedPalette) )
       
   789 			{
       
   790 			if ( palette != expectedPalette )
       
   791 				{
       
   792 				ERR_PRINTF3(_L("GetPalette palette %d not the expected palette %d"), palette, expectedPalette);
       
   793 				SetBlockResult(EFail);
       
   794 				}
       
   795 			}
       
   796 		}
       
   797 	}
       
   798 
       
   799 /** Calls CFbsBitmap::GetPixel() */
       
   800 void CT_DataFbsBitmap::DoCmdGetPixel(const TDesC& aSection)
       
   801 	{
       
   802 	INFO_PRINTF1(_L("Calls CFbsBitmap::GetPixel()"));
       
   803 
       
   804 	// get point x-coordinate from parameters
       
   805 	TInt	pointX;
       
   806 	if(!GetIntFromConfig(aSection, KPointX(), pointX))
       
   807 		{
       
   808 		ERR_PRINTF2(_L("No %S"), &KPointX());
       
   809 		SetBlockResult(EFail);
       
   810 		}
       
   811 
       
   812 	// get point y-coordinate from parameters
       
   813 	TInt	pointY;
       
   814 	if(!GetIntFromConfig(aSection, KPointY(), pointY))
       
   815 		{
       
   816 		ERR_PRINTF2(_L("No %S"), &KPointY());
       
   817 		SetBlockResult(EFail);
       
   818 		}
       
   819 
       
   820 	// call GetPixel()
       
   821 	TRgb	color;
       
   822 	GetFbsBitmap()->GetPixel(color, TPoint(pointX, pointY));
       
   823 
       
   824 	INFO_PRINTF2(_L("Red    %d"), color.Red());
       
   825 	INFO_PRINTF2(_L("Green  %d"), color.Green());
       
   826 	INFO_PRINTF2(_L("Blue   %d"), color.Blue());
       
   827 
       
   828 	TInt	actual;
       
   829 	TInt	expected;
       
   830 
       
   831 	if(GetIntFromConfig(aSection, KRed(), expected))
       
   832 		{
       
   833 		actual=color.Red();
       
   834 		if ( expected != actual )
       
   835 			{
       
   836 			ERR_PRINTF3(_L("Expected Red %d does not match actual %d"), expected, actual);
       
   837 			SetBlockResult(EFail);
       
   838 			}
       
   839 		}
       
   840 
       
   841 	if(GetIntFromConfig(aSection, KGreen(), expected))
       
   842 		{
       
   843 		actual=color.Green();
       
   844 		if ( expected != actual )
       
   845 			{
       
   846 			ERR_PRINTF3(_L("Expected Green %d does not match actual %d"), expected, actual);
       
   847 			SetBlockResult(EFail);
       
   848 			}
       
   849 		}
       
   850 	
       
   851 	if(GetIntFromConfig(aSection, KBlue(), expected))
       
   852 		{
       
   853 		actual=color.Blue();
       
   854 		if ( expected != actual )
       
   855 			{
       
   856 			ERR_PRINTF3(_L("Expected Blue %d does not match actual %d"), expected, actual);
       
   857 			SetBlockResult(EFail);
       
   858 			}
       
   859 		}
       
   860 	}
       
   861 
       
   862 /** Calls CFbsBitmap::GetScanLine() */
       
   863 void CT_DataFbsBitmap::DoCmdGetScanLineL(const TDesC& aSection)
       
   864 	{
       
   865 	INFO_PRINTF1(_L("Calls CFbsBitmap::GetScanLine()"));
       
   866 	TBool								dataOk=ETrue;
       
   867 
       
   868 	// get point x coordinate from parameters
       
   869 	TInt	pointX = 0;
       
   870 	if(!GetIntFromConfig(aSection, KPointX(), pointX))
       
   871 		{
       
   872 		ERR_PRINTF2(_L("No %S"), &KPointX());
       
   873 		SetBlockResult(EFail);
       
   874 		dataOk=EFalse;
       
   875 		}
       
   876 
       
   877 	// get point y coordinate from parameters
       
   878 	TInt	pointY = 0;
       
   879 	if(!GetIntFromConfig(aSection, KPointY(), pointY))
       
   880 		{
       
   881 		ERR_PRINTF2(_L("No %S"), &KPointY());
       
   882 		SetBlockResult(EFail);
       
   883 		dataOk=EFalse;
       
   884 		}
       
   885 
       
   886 	// get length from parameters
       
   887 	TInt	length = 0;
       
   888 	if(!GetIntFromConfig(aSection, KLength(), length))
       
   889 		{
       
   890 		ERR_PRINTF2(_L("No %S"), &KLength());
       
   891 		SetBlockResult(EFail);
       
   892 		dataOk=EFalse;
       
   893 		}
       
   894 
       
   895 	// get buffer length from parameters
       
   896 	TInt	buffLength = 0;
       
   897 	if(!GetIntFromConfig(aSection, KBuffLength(), buffLength))
       
   898 		{
       
   899 		ERR_PRINTF2(_L("No %S"), &KBuffLength());
       
   900 		SetBlockResult(EFail);
       
   901 		dataOk=EFalse;
       
   902 		}
       
   903 
       
   904 	// get display mode from parameters
       
   905 	TDisplayMode	displayMode;
       
   906 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
   907 		{
       
   908 		ERR_PRINTF1(_L("No display mode"));
       
   909 		SetBlockResult(EFail);
       
   910 		dataOk=EFalse;
       
   911 		}
       
   912 
       
   913 	if ( dataOk )
       
   914 		{
       
   915 		// call GetScanLine()
       
   916 		TUint8*	buffer = new (ELeave) TUint8[buffLength];
       
   917 		TPtr8	scanline(buffer, buffLength, buffLength);
       
   918 
       
   919 		GetFbsBitmap()->GetScanLine(scanline, TPoint(pointX, pointY), length, displayMode);
       
   920 
       
   921 		delete [] buffer;
       
   922 		}
       
   923 	}
       
   924 
       
   925 /** Calls CFbsBitmap::GetVerticalScanLine() */
       
   926 void CT_DataFbsBitmap::DoCmdGetVerticalScanLineL(const TDesC& aSection)
       
   927 	{
       
   928 	INFO_PRINTF1(_L("Calls CFbsBitmap::GetVerticalScanLine()"));
       
   929 	TBool								dataOk=ETrue;
       
   930 
       
   931 	// get point x coordinate from parameters
       
   932 	TInt	pointX = 0;
       
   933 	if(!GetIntFromConfig(aSection, KPointX(), pointX))
       
   934 		{
       
   935 		ERR_PRINTF2(_L("No %S"), &KPointX());
       
   936 		SetBlockResult(EFail);
       
   937 		dataOk=EFalse;
       
   938 		}
       
   939 
       
   940 	// get if to use dither offset flag from parameters
       
   941 	TBool	useDitherOffset = EFalse;
       
   942 	if(!GetBoolFromConfig(aSection, KUseDitherOffset(), useDitherOffset))
       
   943 		{
       
   944 		ERR_PRINTF2(_L("No %S"), &KUseDitherOffset());
       
   945 		SetBlockResult(EFail);
       
   946 		dataOk=EFalse;
       
   947 		}
       
   948 
       
   949 	// get dither offset x coordinate from parameters
       
   950 	TInt	ditherOffsetX = 0;
       
   951 	if(useDitherOffset && !GetIntFromConfig(aSection, KDitherOffsetX(), ditherOffsetX))
       
   952 		{
       
   953 		ERR_PRINTF2(_L("No %S"), &KDitherOffsetX());
       
   954 		SetBlockResult(EFail);
       
   955 		dataOk=EFalse;
       
   956 		}
       
   957 
       
   958 	// get dither offset y coordinate from parameters
       
   959 	TInt	ditherOffsetY = 0;
       
   960 	if(useDitherOffset && !GetIntFromConfig(aSection, KDitherOffsetY(), ditherOffsetY))
       
   961 		{
       
   962 		ERR_PRINTF2(_L("No %S"), &KDitherOffsetY());
       
   963 		SetBlockResult(EFail);
       
   964 		dataOk=EFalse;
       
   965 		}
       
   966 
       
   967 	// get buffer length from parameters
       
   968 	TInt	buffLength = 0;
       
   969 	if(!GetIntFromConfig(aSection, KBuffLength(), buffLength))
       
   970 		{
       
   971 		ERR_PRINTF2(_L("No %S"), &KBuffLength());
       
   972 		SetBlockResult(EFail);
       
   973 		dataOk=EFalse;
       
   974 		}
       
   975 
       
   976 	// get display mode from parameters
       
   977 	TDisplayMode	displayMode;
       
   978 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
   979 		{
       
   980 		ERR_PRINTF1(_L("No display mode"));
       
   981 		SetBlockResult(EFail);
       
   982 		dataOk=EFalse;
       
   983 		}
       
   984 
       
   985 	if ( dataOk )
       
   986 		{
       
   987 		// call GetVerticalScanLine()
       
   988 		TUint8*	buffer = new (ELeave) TUint8[buffLength];
       
   989 		TPtr8 	scanline(buffer, buffLength, buffLength);
       
   990 
       
   991 		if (useDitherOffset)
       
   992 			{
       
   993 			GetFbsBitmap()->GetVerticalScanLine(scanline, pointX, displayMode);
       
   994 			}
       
   995 		else
       
   996 			{
       
   997 			GetFbsBitmap()->GetVerticalScanLine(scanline, pointX, TPoint(ditherOffsetX, ditherOffsetY), displayMode);
       
   998 			}
       
   999 
       
  1000 		delete [] buffer;
       
  1001 		}
       
  1002 	}
       
  1003 
       
  1004 /** Calls CFbsBitmap::Handle() */
       
  1005 void CT_DataFbsBitmap::DoCmdHandle(const TDesC& aSection)
       
  1006 	{
       
  1007 	
       
  1008 	// call Handle()
       
  1009 	TInt	handle=GetFbsBitmap()->Handle();
       
  1010 	INFO_PRINTF2(_L("Calls CFbsBitmap::Handle() %d"), handle);
       
  1011 	SetHandle(handle);
       
  1012 
       
  1013 	// validate returned value if needed
       
  1014 	TInt	expectedValue;
       
  1015 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
  1016 		{
       
  1017 		if (expectedValue != handle)
       
  1018 			{
       
  1019 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, handle);
       
  1020 			SetBlockResult(EFail);
       
  1021 			}
       
  1022 		}
       
  1023 	}
       
  1024 
       
  1025 /** Checks CFbsBitmap::HardwareBitmapHandle() */
       
  1026 void CT_DataFbsBitmap::DoCmdHardwareBitmapHandle(const TDesC& aSection)
       
  1027 	{
       
  1028 	// call HardwareBitmapHandle()
       
  1029 	TInt	handle=GetFbsBitmap()->HardwareBitmapHandle();
       
  1030 	INFO_PRINTF2(_L("CFbsBitmap::HardwareBitmapHandle() %d"), handle);
       
  1031 	SetHandle(handle);
       
  1032 
       
  1033 	// get if null expected flag from parameters
       
  1034 	TBool	nullExpected = EFalse;
       
  1035 	if ( GetBoolFromConfig(aSection, KNullExpected(), nullExpected) )
       
  1036 		{
       
  1037 		// check value againts NULL
       
  1038 		if ( (handle == NULL) != nullExpected )
       
  1039 			{
       
  1040 			ERR_PRINTF2(_L("The value is not as expected! value: %d"), handle);
       
  1041 			SetBlockResult(EFail);
       
  1042 			}
       
  1043 		}
       
  1044 	}
       
  1045 
       
  1046 /** Calls CFbsBitmap::Header() */
       
  1047 void CT_DataFbsBitmap::DoCmdHeader()
       
  1048 	{
       
  1049 	INFO_PRINTF1(_L("Calls CFbsBitmap::Header()"));
       
  1050 
       
  1051 	// call Header()
       
  1052 	SEpocBitmapHeader	header=GetFbsBitmap()->Header();
       
  1053 	INFO_PRINTF2(_L("Header iBitmapSize     &d"), header.iBitmapSize);
       
  1054 	INFO_PRINTF2(_L("Header iBitsPerPixel   &d"), header.iBitsPerPixel);
       
  1055 	INFO_PRINTF2(_L("Header iColor          &d"), header.iColor);
       
  1056 	INFO_PRINTF2(_L("Header iCompression    &d"), header.iCompression);
       
  1057 	INFO_PRINTF2(_L("Header iPaletteEntries &d"), header.iPaletteEntries);
       
  1058 	INFO_PRINTF3(_L("Header iSizeInPixels   &d %d"), header.iSizeInPixels.iWidth, header.iSizeInPixels.iHeight);
       
  1059 	INFO_PRINTF3(_L("Header iSizeInTwips    &d %d"), header.iSizeInTwips.iWidth, header.iSizeInTwips.iHeight);
       
  1060 	INFO_PRINTF2(_L("Header iStructSize     &d"), header.iStructSize);
       
  1061 	}
       
  1062 
       
  1063 /** Calls CFbsBitmap::HorizontalPixelsToTwips() */
       
  1064 void CT_DataFbsBitmap::DoCmdHorizontalPixelsToTwips(const TDesC& aSection)
       
  1065 	{
       
  1066 	INFO_PRINTF1(_L("Calls CFbsBitmap::HorizontalPixelsToTwips()"));
       
  1067 
       
  1068 	// get pixels from parameters
       
  1069 	TInt	pixels;
       
  1070 	if(!GetIntFromConfig(aSection, KPixels(), pixels))
       
  1071 		{
       
  1072 		ERR_PRINTF2(_L("No %S"), &KPixels());
       
  1073 		SetBlockResult(EFail);
       
  1074 		}
       
  1075 
       
  1076 	// call HorizontalPixelsToTwips()
       
  1077 	TInt	value = GetFbsBitmap()->HorizontalPixelsToTwips(pixels);
       
  1078 	INFO_PRINTF2(_L("Twips: %d"), value);
       
  1079 
       
  1080 	// validate returned value if needed
       
  1081 	TInt	expectedValue;
       
  1082 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
  1083 		{
       
  1084 		if (expectedValue != value)
       
  1085 			{
       
  1086 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, value);
       
  1087 			SetBlockResult(EFail);
       
  1088 			}
       
  1089 		}
       
  1090 	}
       
  1091 
       
  1092 /** Calls CFbsBitmap::HorizontalTwipsToPixels() */
       
  1093 void CT_DataFbsBitmap::DoCmdHorizontalTwipsToPixels(const TDesC& aSection)
       
  1094 	{
       
  1095 	INFO_PRINTF1(_L("Calls CFbsBitmap::HorizontalTwipsToPixels()"));
       
  1096 
       
  1097 	// get twips from parameters
       
  1098 	TInt	twips;
       
  1099 	if(!GetIntFromConfig(aSection, KTwips(), twips))
       
  1100 		{
       
  1101 		ERR_PRINTF2(_L("No %S"), &KTwips());
       
  1102 		SetBlockResult(EFail);
       
  1103 		}
       
  1104 
       
  1105 	// call HorizontalTwipsToPixels()
       
  1106 	TInt	value = GetFbsBitmap()->HorizontalTwipsToPixels(twips);
       
  1107 	INFO_PRINTF2(_L("Pixels: %d"), value);
       
  1108 
       
  1109 	// validate returned value if needed
       
  1110 	TInt	expectedValue;
       
  1111 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
  1112 		{
       
  1113 		if (expectedValue != value)
       
  1114 			{
       
  1115 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, value);
       
  1116 			SetBlockResult(EFail);
       
  1117 			}
       
  1118 		}
       
  1119 	}
       
  1120 
       
  1121 /** Checks CFbsBitmap::InitialDisplayMode() value */
       
  1122 void CT_DataFbsBitmap::DoCmdInitialDisplayMode(const TDesC& aSection)
       
  1123 	{
       
  1124 	INFO_PRINTF1(_L("Checks CFbsBitmap::InitialDisplayMode() value"));
       
  1125 
       
  1126 	// call InitialDisplayMode()
       
  1127 	TInt	actualValue = GetFbsBitmap()->InitialDisplayMode();
       
  1128 	INFO_PRINTF2(_L("Initial Display Mode %d"), actualValue);
       
  1129 
       
  1130 	// get display mode from parameters
       
  1131 	TDisplayMode	expectedValue;
       
  1132 	if ( CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), expectedValue) )
       
  1133 		{
       
  1134 		// check value againts NULL
       
  1135 		if (actualValue != expectedValue)
       
  1136 			{
       
  1137 			ERR_PRINTF3(_L("The value is not as expected! expecyed: %d, actual: %d"), expectedValue, actualValue);
       
  1138 			SetBlockResult(EFail);
       
  1139 			}
       
  1140 		}
       
  1141 	}
       
  1142 
       
  1143 /** Calls CFbsBitmap::InternalizeL() */
       
  1144 void CT_DataFbsBitmap::DoCmdInternalizeL(const TDesC& aSection)
       
  1145 	{
       
  1146 	INFO_PRINTF1(_L("Calls CFbsBitmap::InternalizeL()"));
       
  1147 
       
  1148 	// get file name from parameters
       
  1149 	TPtrC	fileName;
       
  1150 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  1151 		{
       
  1152 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  1153 		SetBlockResult(EFail);
       
  1154 		}
       
  1155 
       
  1156 	// get a flag if to use closed stream from parameters
       
  1157 	TBool	useClosedStream = EFalse;
       
  1158 	if(!GetBoolFromConfig(aSection, KUseClosedStream(), useClosedStream))
       
  1159 		{
       
  1160 		ERR_PRINTF2(_L("No %S"), &KUseClosedStream());
       
  1161 		SetBlockResult(EFail);
       
  1162 		}
       
  1163 
       
  1164 	// ReadStore creation
       
  1165 	CDirectFileStore*	readstore = CDirectFileStore::OpenL(FileServer(), fileName, EFileStream | EFileRead);
       
  1166 	CleanupStack::PushL(readstore);
       
  1167 	TInt				popCount=1;
       
  1168 	TStreamId			headerid = readstore->Root();
       
  1169 	RStoreReadStream	readstrm;
       
  1170 
       
  1171 	// close stream if defined by parameters
       
  1172 	if (!useClosedStream)
       
  1173 		{
       
  1174 		readstrm.OpenL(*readstore, headerid);
       
  1175 		CleanupClosePushL(readstrm);
       
  1176 		popCount=2;
       
  1177 		}
       
  1178 
       
  1179 	// call InternalizeL()
       
  1180 	TRAPD(err, GetFbsBitmap()->InternalizeL(readstrm));
       
  1181 	if (err != KErrNone)
       
  1182 		{
       
  1183 		ERR_PRINTF2(_L("Internalize error: %d"), err);
       
  1184 		SetError(err);
       
  1185 		}
       
  1186 
       
  1187 	// cleanup
       
  1188 	CleanupStack::PopAndDestroy(popCount, readstore);
       
  1189 	}
       
  1190 
       
  1191 /** Calls CFbsBitmap::IsCompressedInRAM() to check againt expected value */
       
  1192 void CT_DataFbsBitmap::DoCmdIsCompressedInRAM(const TDesC& aSection)
       
  1193 	{
       
  1194 	// call IsCompressedInRAM() to get actual value
       
  1195 	TBool	actualValue = GetFbsBitmap()->IsCompressedInRAM();
       
  1196 	INFO_PRINTF2(_L("CFbsBitmap::IsCompressedInRAM() %d"), actualValue);
       
  1197 
       
  1198 	// get expected value from parameters
       
  1199 	TBool	expectedValue = EFalse;
       
  1200 	if ( GetBoolFromConfig(aSection, KExpectedBool(), expectedValue) )
       
  1201 		{
       
  1202 		if (actualValue != expectedValue)
       
  1203 			{
       
  1204 			ERR_PRINTF3(_L("Expected value doesn't match to actual! expected: %d, actual: %d"), expectedValue, actualValue);
       
  1205 			if (!iCompressFailed)
       
  1206 			    {
       
  1207 			    SetBlockResult(EFail);
       
  1208 			    };
       
  1209 			}
       
  1210 		}
       
  1211 	}
       
  1212 
       
  1213 /** Calls CFbsBitmap::IsFileInRom() and check against expectation */
       
  1214 void CT_DataFbsBitmap::DoCmdIsFileInRom(const TDesC& aSection)
       
  1215 	{
       
  1216 	INFO_PRINTF1(_L("Calls CFbsBitmap::IsFileInRom() and check against expectation"));
       
  1217 
       
  1218 	// get file name from parameters
       
  1219 
       
  1220 	TPtrC	fileName;
       
  1221 	if ( !GetStringFromConfig(aSection, KFileName(), fileName) )
       
  1222 		{
       
  1223 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  1224 		SetBlockResult(EFail);
       
  1225 		}
       
  1226 
       
  1227 	// get flag if use RFile instance in Save() call from parameters
       
  1228 	TBool	useRFile = EFalse;
       
  1229 	GetBoolFromConfig(aSection, KUseRFile(), useRFile);
       
  1230 
       
  1231 	TInt		err = KErrNone;
       
  1232 	TBool		isFileInRom = EFalse;
       
  1233 	TUint32*	addressInRom = NULL;
       
  1234 	if (useRFile)
       
  1235 		{
       
  1236 		// open rfile
       
  1237 		RFile file;
       
  1238 		err = file.Open(FileServer(), fileName, EFileShareReadersOnly);
       
  1239 
       
  1240 		// check if failed to open file
       
  1241 		if ( err != KErrNone )
       
  1242 			{
       
  1243 			ERR_PRINTF2(_L("File open error: %d"), err);
       
  1244 			SetBlockResult(EFail);
       
  1245 			}
       
  1246 		else
       
  1247 			{
       
  1248 			// call IsFileInRom()
       
  1249 			isFileInRom = CFbsBitmap::IsFileInRom(file, addressInRom);
       
  1250 
       
  1251 			// close rfile
       
  1252 			file.Close();
       
  1253 			}
       
  1254 		}
       
  1255 	else
       
  1256 		{
       
  1257 		isFileInRom = CFbsBitmap::IsFileInRom(fileName, addressInRom);
       
  1258 		}
       
  1259 
       
  1260 	// get expected value if is in ROM from parameters
       
  1261 	TBool	expectedIsFileInRom = EFalse;
       
  1262 	if ( GetBoolFromConfig(aSection, KExpectedBool(), expectedIsFileInRom) )
       
  1263 		{
       
  1264 		// check the expectation
       
  1265 		if (expectedIsFileInRom != isFileInRom)
       
  1266 			{
       
  1267 			ERR_PRINTF3(_L("The value is not as expected! expected: %d, actual: %d"), expectedIsFileInRom, isFileInRom);
       
  1268 			SetBlockResult(EFail);
       
  1269 			}
       
  1270 		}
       
  1271 
       
  1272 	// check that address is not null if in rom
       
  1273 	if ( isFileInRom && addressInRom == NULL )
       
  1274 		{
       
  1275 		ERR_PRINTF1(_L("The file is in ROM but returned address is NULL"));
       
  1276 		SetBlockResult(EFail);
       
  1277 		}
       
  1278 	}
       
  1279 
       
  1280 /** Calls CFbsBitmap::IsLargeBitmap() */
       
  1281 void CT_DataFbsBitmap::DoCmdIsLargeBitmap(const TDesC& aSection)
       
  1282 	{
       
  1283 	// call IsLargeBitmap()
       
  1284 	TBool	value = GetFbsBitmap()->IsLargeBitmap();
       
  1285 	INFO_PRINTF2(_L("Is large bitmap: %d"), value);
       
  1286 	
       
  1287 	// validate returned value if needed
       
  1288 	TBool	expectedBool;
       
  1289 	if(GetIntFromConfig(aSection, KExpectedBool(), expectedBool))
       
  1290 		{
       
  1291 		if (expectedBool != value)
       
  1292 			{
       
  1293 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedBool, value);
       
  1294 			SetBlockResult(EFail);
       
  1295 			}
       
  1296 		}
       
  1297 	}
       
  1298 
       
  1299 /** Calls CFbsBitmap::IsMonochrome() */
       
  1300 void CT_DataFbsBitmap::DoCmdIsMonochrome(const TDesC& aSection)
       
  1301 	{
       
  1302 
       
  1303 	// call IsMonochrome()
       
  1304 	TBool	value = GetFbsBitmap()->IsMonochrome();
       
  1305 	INFO_PRINTF2(_L("Is monochrome: %d"), value);
       
  1306 
       
  1307 	// validate returned value if needed
       
  1308 	TBool	expectedBool;
       
  1309 	if(GetIntFromConfig(aSection, KExpectedBool(), expectedBool))
       
  1310 		{
       
  1311 		if (expectedBool != value)
       
  1312 			{
       
  1313 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedBool, value);
       
  1314 			SetBlockResult(EFail);
       
  1315 			}
       
  1316 		}
       
  1317 	}
       
  1318 
       
  1319 /** Calls CFbsBitmap::IsRomBitmap() and check against expectation */
       
  1320 void CT_DataFbsBitmap::DoCmdIsRomBitmap(const TDesC& aSection)
       
  1321 	{
       
  1322 	// call IsRomBitmap()
       
  1323 	TBool	actualValue = GetFbsBitmap()->IsRomBitmap();
       
  1324 	INFO_PRINTF2(_L("CFbsBitmap::IsRomBitmap() %d"), actualValue);
       
  1325 
       
  1326 	// get expected value if is in ROM from parameters
       
  1327 	TBool	expectedIsRomBitmap = EFalse;
       
  1328 	if ( GetBoolFromConfig(aSection, KExpectedBool(), expectedIsRomBitmap) )
       
  1329 		{
       
  1330 		// check the expectation
       
  1331 		if (expectedIsRomBitmap != actualValue)
       
  1332 			{
       
  1333 			ERR_PRINTF3(_L("The value is not as expected! expected: %d, actual: %d"), expectedIsRomBitmap, actualValue);
       
  1334 			SetBlockResult(EFail);
       
  1335 			}
       
  1336 		}
       
  1337 	}
       
  1338 
       
  1339 /** CFbsBitmap::Load() Call */
       
  1340 void CT_DataFbsBitmap::DoCmdLoadL(const TDesC& aSection)
       
  1341 	{
       
  1342 	INFO_PRINTF1(_L("CFbsBitmap::Load() Call"));
       
  1343 	LoadOrLoadAndCompressL(aSection, EFalse);
       
  1344 	}
       
  1345 
       
  1346 /** CFbsBitmap::LoadAndCompress() Call */
       
  1347 void CT_DataFbsBitmap::DoCmdLoadAndCompressL(const TDesC& aSection)
       
  1348 	{
       
  1349 	INFO_PRINTF1(_L("CFbsBitmap::LoadAndCompress() Call"));
       
  1350 	LoadOrLoadAndCompressL(aSection, ETrue);
       
  1351 	}
       
  1352 
       
  1353 /** Calls static CFbsBitmap destructor */
       
  1354 void CT_DataFbsBitmap::DoCmdLockHeap(const TDesC& aSection)
       
  1355 	{
       
  1356 	TBool	always=EFalse;
       
  1357 	GetBoolFromConfig(aSection, KAlways(), always);
       
  1358 	GetFbsBitmap()->LockHeap(always);
       
  1359 	}
       
  1360 
       
  1361 /** Calls static CFbsBitmap destructor */
       
  1362 void CT_DataFbsBitmap::DoCmdLockHeapLC(const TDesC& aSection)
       
  1363 	{
       
  1364 	TBool	always=EFalse;
       
  1365 	GetBoolFromConfig(aSection, KAlways(), always);
       
  1366 
       
  1367 	GetFbsBitmap()->LockHeapLC(always);
       
  1368 	iPopWhenUnlocking=ETrue;
       
  1369 	}
       
  1370 
       
  1371 /** Calls CFbsBitmap::PaletteAttributes() */
       
  1372 void CT_DataFbsBitmap::DoCmdPaletteAttributes(const TDesC& aSection)
       
  1373 	{
       
  1374 	INFO_PRINTF1(_L("Calls CFbsBitmap::PaletteAttributes()"));
       
  1375 
       
  1376 	// call PaletteAttributes()
       
  1377 	TBool	modifiable;
       
  1378 	TInt	entries;
       
  1379 	GetFbsBitmap()->PaletteAttributes(modifiable, entries);
       
  1380 
       
  1381 	INFO_PRINTF3(_L("Modifiable: %d, Number of entries: %d"), modifiable, entries);
       
  1382 
       
  1383 	// validate returned value if needed
       
  1384 	TBool	expectedModifiable;
       
  1385 	if(GetBoolFromConfig(aSection, KModifiable(), expectedModifiable))
       
  1386 		{
       
  1387 		if (expectedModifiable != modifiable)
       
  1388 			{
       
  1389 			ERR_PRINTF3(_L("The returned modifaiable value is not as expected, expected: %d, actual: %d"), expectedModifiable, modifiable);
       
  1390 			SetBlockResult(EFail);
       
  1391 			}
       
  1392 		}
       
  1393 
       
  1394 	// validate returned value if needed
       
  1395 	TBool	expectedEntries;
       
  1396 	if(GetIntFromConfig(aSection, KEntries(), expectedEntries))
       
  1397 		{
       
  1398 		if (expectedEntries != entries)
       
  1399 			{
       
  1400 			ERR_PRINTF3(_L("The returned modifaiable value is not as expected, expected: %d, actual: %d"), expectedEntries, entries);
       
  1401 			SetBlockResult(EFail);
       
  1402 			}
       
  1403 		}
       
  1404 	}
       
  1405 
       
  1406 /** Calls CFbsBitmap::Reset() */
       
  1407 void CT_DataFbsBitmap::DoCmdReset()
       
  1408 	{
       
  1409 	INFO_PRINTF1(_L("Calls CFbsBitmap::Reset()"));
       
  1410 
       
  1411 	// call Reset()
       
  1412 	GetFbsBitmap()->Reset();
       
  1413 	}
       
  1414 
       
  1415 /** Calls CFbsBitmap::Resize() */
       
  1416 void CT_DataFbsBitmap::DoCmdResize(const TDesC& aSection)
       
  1417 	{
       
  1418 	INFO_PRINTF1(_L("Calls CFbsBitmap::Resize()"));
       
  1419 
       
  1420 	// get size height from parameters
       
  1421 	TInt	height;
       
  1422 	if(!GetIntFromConfig(aSection, KHeight(), height))
       
  1423 		{
       
  1424 		ERR_PRINTF2(_L("No %S"), &KHeight());
       
  1425 		SetBlockResult(EFail);
       
  1426 		}
       
  1427 
       
  1428 	// get size width from parameters
       
  1429 	TInt	width;
       
  1430 	if(!GetIntFromConfig(aSection, KWidth(), width))
       
  1431 		{
       
  1432 		ERR_PRINTF2(_L("No %S"), &KWidth());
       
  1433 		SetBlockResult(EFail);
       
  1434 		}
       
  1435 
       
  1436 	// call Resize()
       
  1437 	TInt	err = GetFbsBitmap()->Resize(TSize(width, height));
       
  1438 
       
  1439 	// check error code
       
  1440 	if (err != KErrNone)
       
  1441 		{
       
  1442 		ERR_PRINTF2(_L("Resize error: %d"), err);
       
  1443 		SetError(err);
       
  1444 		}
       
  1445 	}
       
  1446 
       
  1447 /** Calls CFbsBitmap::Save() */
       
  1448 void CT_DataFbsBitmap::DoCmdSave(const TDesC& aSection)
       
  1449 	{
       
  1450 	INFO_PRINTF1(_L("Calls CFbsBitmap::Save()"));
       
  1451 
       
  1452 	// get file name from parameters
       
  1453 	TPtrC	fileName;
       
  1454 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  1455 		{
       
  1456 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  1457 		SetBlockResult(EFail);
       
  1458 		}
       
  1459 
       
  1460 	// get flag if use RFile instance in Save() call from parameters
       
  1461 	TBool	useRFile = EFalse;
       
  1462 	if(!GetBoolFromConfig(aSection, KUseRFile(), useRFile))
       
  1463 		{
       
  1464 		ERR_PRINTF2(_L("No %S"), &KUseRFile());
       
  1465 		SetBlockResult(EFail);
       
  1466 		}
       
  1467 
       
  1468 	// get flag if use RFile instance in Load() call from parameters
       
  1469 	TBool	useClosedRFile = EFalse;
       
  1470 	if(GetBoolFromConfig(aSection, KUseClosedRFile(), useClosedRFile))
       
  1471 		{
       
  1472 		if (useClosedRFile && !useRFile)
       
  1473 			{
       
  1474 			ERR_PRINTF3(_L("Cannot use %S parameter if %S is not set to TRUE"), &KUseClosedRFile(), &KUseRFile());
       
  1475 			SetBlockResult(EFail);
       
  1476 			}
       
  1477 		}
       
  1478 
       
  1479 	TInt	err = KErrNone;
       
  1480 	if (useRFile)
       
  1481 		{
       
  1482 		// required to allow file handle to be adopted by another process
       
  1483 		FileServer().ShareProtected();
       
  1484 
       
  1485 		// open or create rfile
       
  1486 		RFile	file;
       
  1487 
       
  1488 		if (!useClosedRFile)
       
  1489 			{
       
  1490 			err = file.Open(FileServer(), fileName, EFileWrite);
       
  1491 
       
  1492 			if (err == KErrNotFound)
       
  1493 				{
       
  1494 				err = file.Create(FileServer(), fileName, EFileWrite);
       
  1495 
       
  1496 				// check if failed to create file
       
  1497 				if (err != KErrNone)
       
  1498 					{
       
  1499 					ERR_PRINTF2(_L("File create error: %d"), err);
       
  1500 					SetBlockResult(EFail);
       
  1501 					}
       
  1502 				}
       
  1503 			else if (err != KErrNone)
       
  1504 				{
       
  1505 				// if failed to open file
       
  1506 				ERR_PRINTF2(_L("File open error: %d"), err);
       
  1507 				SetBlockResult(EFail);
       
  1508 				}
       
  1509 			}
       
  1510 
       
  1511 		// call Save()
       
  1512 		err = GetFbsBitmap()->Save(file);
       
  1513 
       
  1514 		// close rfile
       
  1515 		file.Close();
       
  1516 		}
       
  1517 	else
       
  1518 		{
       
  1519 		err = GetFbsBitmap()->Save(fileName);
       
  1520 		}
       
  1521 
       
  1522 	// check error code
       
  1523 	if (err != KErrNone)
       
  1524 		{
       
  1525 		ERR_PRINTF2(_L("Save error: %d"), err);
       
  1526 		SetError(err);
       
  1527 		}
       
  1528 	}
       
  1529 
       
  1530 /** Calls CFbsBitmap::ScanLineLength() */
       
  1531 void CT_DataFbsBitmap::DoCmdScanLineLength(const TDesC& aSection)
       
  1532 	{
       
  1533 	INFO_PRINTF1(_L("Calls CFbsBitmap::ScanLineLength()"));
       
  1534 
       
  1535 	// get length from parameters
       
  1536 	TInt length = 0;
       
  1537 	if(!GetIntFromConfig(aSection, KLength(), length))
       
  1538 		{
       
  1539 		ERR_PRINTF2(_L("No %S"), &KLength());
       
  1540 		SetBlockResult(EFail);
       
  1541 		}
       
  1542 
       
  1543 	// get display mode from parameters
       
  1544 	TDisplayMode	displayMode;
       
  1545 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
  1546 		{
       
  1547 		ERR_PRINTF1(_L("No display mode"));
       
  1548 		SetBlockResult(EFail);
       
  1549 		}
       
  1550 	else
       
  1551 		{
       
  1552 		TInt actualValue = CFbsBitmap::ScanLineLength(length, displayMode);
       
  1553 		INFO_PRINTF2(_L("CFbsBitmap::ScanLineLength() %d"), actualValue);
       
  1554 	
       
  1555 		TInt expectedValue = 0;
       
  1556 		if ( GetIntFromConfig(aSection, KExpectedInt(), expectedValue) )
       
  1557 			{
       
  1558 			if (actualValue != expectedValue)
       
  1559 				{
       
  1560 				ERR_PRINTF3(_L("Expected value doesn't match to actual! expected: %d, actual: %d"), expectedValue, actualValue);
       
  1561 				SetBlockResult(EFail);
       
  1562 				}
       
  1563 			}
       
  1564 		}
       
  1565 	}
       
  1566 
       
  1567 /** Calls CFbsBitmap::SetDisplayMode() */
       
  1568 void CT_DataFbsBitmap::DoCmdSetDisplayMode(const TDesC& aSection)
       
  1569 	{
       
  1570 	INFO_PRINTF1(_L("Calls CFbsBitmap::SetDisplayMode()"));
       
  1571 
       
  1572 	// get display mode from parameters
       
  1573 	TDisplayMode	displayMode;
       
  1574 	if ( !CT_GraphicsUtil::ReadDisplayMode(*this, aSection, KDisplayMode(), displayMode) )
       
  1575 		{
       
  1576 		ERR_PRINTF1(_L("No display mode"));
       
  1577 		SetBlockResult(EFail);
       
  1578 		}
       
  1579 	else
       
  1580 		{
       
  1581 		// call SetDisplayMode()
       
  1582 		TInt	err = GetFbsBitmap()->SetDisplayMode(displayMode);
       
  1583 
       
  1584 		// check error code
       
  1585 		if (err != KErrNone)
       
  1586 			{
       
  1587 			ERR_PRINTF2(_L("Set display mode error: %d"), err);
       
  1588 			SetError(err);
       
  1589 			}
       
  1590 		}
       
  1591 	}
       
  1592 
       
  1593 /** Calls CFbsBitmap::SetPalette() by previously created palette */
       
  1594 void CT_DataFbsBitmap::DoCmdSetPaletteL(const TDesC& aSection)
       
  1595 	{
       
  1596 	INFO_PRINTF1(_L("Calls CFbsBitmap::SetPalette() by previously created palette"));
       
  1597 
       
  1598 	// get CPalette object passed as a parameter
       
  1599 	CPalette*	palette = NULL;
       
  1600 
       
  1601 	CT_GraphicsUtil::GetPaletteL(*this, aSection, KPalette(), palette);
       
  1602 
       
  1603 	// call SetPalette()
       
  1604 	GetFbsBitmap()->SetPalette(palette);
       
  1605 	}
       
  1606 
       
  1607 /** Calls CFbsBitmap::SetRomBitmapL() by another bitmap */
       
  1608 void CT_DataFbsBitmap::DoCmdSetRomBitmapL(const TDesC& aSection)
       
  1609 	{
       
  1610 	INFO_PRINTF1(_L("Calls CFbsBitmap::SetRomBitmapL() by another bitmap"));
       
  1611 
       
  1612 	// get fbsBitmap passed as a parameter
       
  1613 	CFbsBitmap*		otherFbsBitmap=NULL;
       
  1614 
       
  1615 	CT_GraphicsUtil::GetFbsBitmapL(*this, aSection, KFbsBitmapName(), otherFbsBitmap);
       
  1616 
       
  1617 	// get romPointer. If the bitmap is ROM bitmap then Handle() returns ROM pointer
       
  1618 	CBitwiseBitmap*	bitmapRomAddress=NULL;
       
  1619 	if ( otherFbsBitmap!=NULL )
       
  1620 		{
       
  1621 		bitmapRomAddress=REINTERPRET_CAST(CBitwiseBitmap*, otherFbsBitmap->Handle());
       
  1622 		}
       
  1623 
       
  1624 	// call SetRomBitmapL()
       
  1625 	TInt	bitmapSizeInBytes=0;
       
  1626 	TRAPD(err, GetFbsBitmap()->SetRomBitmapL(bitmapRomAddress, bitmapSizeInBytes));
       
  1627 
       
  1628 	// check error code
       
  1629 	if (err != KErrNone)
       
  1630 		{
       
  1631 		ERR_PRINTF2(_L("Set ROM bitmap error: %d"), err);
       
  1632 		SetError(err);
       
  1633 		}
       
  1634 	}
       
  1635 
       
  1636 /** Calls CFbsBitmap::SetScanLine() */
       
  1637 void CT_DataFbsBitmap::DoCmdSetScanLineL(const TDesC& aSection)
       
  1638 	{
       
  1639 	INFO_PRINTF1(_L("Calls CFbsBitmap::SetScanLine()"));
       
  1640 
       
  1641 	// get scanline coordinate from parameters
       
  1642 	TInt	coordinate = 0;
       
  1643 	if(!GetIntFromConfig(aSection, KScanLineCoord(), coordinate))
       
  1644 		{
       
  1645 		ERR_PRINTF2(_L("No %S"), &KScanLineCoord());
       
  1646 		SetBlockResult(EFail);
       
  1647 		}
       
  1648 
       
  1649 	// get file name from parameters
       
  1650 	TPtrC	fileName;
       
  1651 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  1652 		{
       
  1653 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  1654 		SetBlockResult(EFail);
       
  1655 		}
       
  1656 
       
  1657 	// open file
       
  1658 	RFile	file;
       
  1659 	User::LeaveIfError(file.Open(FileServer(), fileName, EFileRead | EFileShareAny));
       
  1660 	CleanupClosePushL(file);
       
  1661 
       
  1662 	// get size
       
  1663 	TInt	size = 0;
       
  1664 	User::LeaveIfError(file.Size(size));
       
  1665 
       
  1666 	// read file
       
  1667     HBufC8*	fileDataBuff = HBufC8::NewLC(size);
       
  1668     TPtr8	fileData = fileDataBuff->Des();
       
  1669 
       
  1670 	User::LeaveIfError(file.Read(fileData));
       
  1671 
       
  1672 	GetFbsBitmap()->SetScanLine(fileData, coordinate);
       
  1673 
       
  1674     CleanupStack::PopAndDestroy(2, &file);  // fileDataBuff, file
       
  1675 	}
       
  1676 
       
  1677 /** Calls CFbsBitmap::SetSizeInTwips() by size parameter */
       
  1678 void CT_DataFbsBitmap::DoCmdSetSizeInTwipsL(const TDesC& aSection)
       
  1679 	{
       
  1680 	INFO_PRINTF1(_L("Calls CFbsBitmap::SetSizeInTwips()"));
       
  1681 
       
  1682 	// get if to NULL device pointer flag from parameters
       
  1683 	TPtrC	device;
       
  1684 	if ( GetStringFromConfig(aSection, KDevice(), device) )
       
  1685 		{
       
  1686 		CFbsBitmapDevice*	bitmapDevice=static_cast<CFbsBitmapDevice*>(GetDataObjectL(device));
       
  1687 		GetFbsBitmap()->SetSizeInTwips(bitmapDevice);
       
  1688 		}
       
  1689 	else
       
  1690 		{
       
  1691 		// get size height from parameters
       
  1692 		TInt	height;
       
  1693 		if(!GetIntFromConfig(aSection, KHeight(), height))
       
  1694 			{
       
  1695 			ERR_PRINTF2(_L("No %S"), &KHeight());
       
  1696 			SetBlockResult(EFail);
       
  1697 			}
       
  1698 
       
  1699 		// get size width from parameters
       
  1700 		TInt	width;
       
  1701 		if(!GetIntFromConfig(aSection, KWidth(), width))
       
  1702 			{
       
  1703 			ERR_PRINTF2(_L("No %S"), &KWidth());
       
  1704 			SetBlockResult(EFail);
       
  1705 			}
       
  1706 
       
  1707 		// call SetSizeInTwips()
       
  1708 		GetFbsBitmap()->SetSizeInTwips(TSize(width, height));
       
  1709 		}
       
  1710 	}
       
  1711 
       
  1712 /** Calls CFbsBitmap::SizeInPixels() and checks the size */
       
  1713 void CT_DataFbsBitmap::DoCmdSizeInPixels(const TDesC& aSection)
       
  1714 	{
       
  1715 	// call SizeInTwips()
       
  1716 	TSize	actualSize = GetFbsBitmap()->SizeInPixels();
       
  1717 	INFO_PRINTF3(_L("CFbsBitmap::SizeInPixels() height %d, width %d"), actualSize.iHeight, actualSize.iWidth);
       
  1718 
       
  1719 	// get size height from parameters
       
  1720 	TInt	height;
       
  1721 	if ( GetIntFromConfig(aSection, KHeight(), height) )
       
  1722 		{
       
  1723 		if ( actualSize.iHeight != height )
       
  1724 			{
       
  1725 			ERR_PRINTF3(_L("Height mismatch expected: %d, actual: %d"), height, actualSize.iHeight);
       
  1726 			SetBlockResult(EFail);
       
  1727 			}
       
  1728 		}
       
  1729 
       
  1730 	// get size width from parameters
       
  1731 	TInt	width;
       
  1732 	if ( GetIntFromConfig(aSection, KWidth(), width) )
       
  1733 		{
       
  1734 		// check that value is as expected
       
  1735 		if ( actualSize.iWidth != width )
       
  1736 			{
       
  1737 			ERR_PRINTF3(_L("Width mismatch expected: %d, actual: %d"), width, actualSize.iWidth);
       
  1738 			SetBlockResult(EFail);
       
  1739 			}
       
  1740 		}
       
  1741 	}
       
  1742 
       
  1743 /** Calls CFbsBitmap::SizeInTwips() and compares the result with expected */
       
  1744 void CT_DataFbsBitmap::DoCmdSizeInTwips(const TDesC& aSection)
       
  1745 	{
       
  1746 	// call SizeInTwips()
       
  1747 	TSize	actualSize = GetFbsBitmap()->SizeInTwips();
       
  1748 	INFO_PRINTF3(_L("CFbsBitmap::SizeInTwips() height %d, width %d"), actualSize.iHeight, actualSize.iWidth);
       
  1749 
       
  1750 	// get size height from parameters
       
  1751 	TInt	height;
       
  1752 	if ( GetIntFromConfig(aSection, KHeight(), height) )
       
  1753 		{
       
  1754 		if ( actualSize.iHeight != height )
       
  1755 			{
       
  1756 			ERR_PRINTF3(_L("Height mismatch expected: %d, actual: %d"), height, actualSize.iHeight);
       
  1757 			SetBlockResult(EFail);
       
  1758 			}
       
  1759 		}
       
  1760 
       
  1761 	// get size width from parameters
       
  1762 	TInt	width;
       
  1763 	if ( GetIntFromConfig(aSection, KWidth(), width) )
       
  1764 		{
       
  1765 		// check that value is as expected
       
  1766 		if ( actualSize.iWidth != width )
       
  1767 			{
       
  1768 			ERR_PRINTF3(_L("Width mismatch expected: %d, actual: %d"), width, actualSize.iWidth);
       
  1769 			SetBlockResult(EFail);
       
  1770 			}
       
  1771 		}
       
  1772 	}
       
  1773 
       
  1774 /** Calls CFbsBitmap::StoreL() */
       
  1775 void CT_DataFbsBitmap::DoCmdStoreL(const TDesC& aSection)
       
  1776 	{
       
  1777 	INFO_PRINTF1(_L("Calls CFbsBitmap::StoreL()"));
       
  1778 
       
  1779 	TInt	numberOfFiles = 0;
       
  1780 	TInt	numberOfBitmapIds = 0;
       
  1781 	TPtrC	sourceFileName1;
       
  1782 	TPtrC	sourceFileName2;
       
  1783 	TInt	sourceBitmapId0 = -1;
       
  1784 	TInt	sourceBitmapId1 = -1;
       
  1785 	TInt	sourceBitmapId2 = -1;
       
  1786 
       
  1787 	// get file name from parameters
       
  1788 	TPtrC	fileName;
       
  1789 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  1790 		{
       
  1791 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  1792 		SetBlockResult(EFail);
       
  1793 		}
       
  1794 
       
  1795 	// get flag if use RFile instance in Save() call from parameters
       
  1796 	TBool	useRFile = EFalse;
       
  1797 	if(!GetBoolFromConfig(aSection, KUseRFile(), useRFile))
       
  1798 		{
       
  1799 		ERR_PRINTF2(_L("No %S"), &KUseRFile());
       
  1800 		SetBlockResult(EFail);
       
  1801 		}
       
  1802 
       
  1803 	// get flag if use RFile instance in Load() call from parameters
       
  1804 	TBool	useClosedRFile = EFalse;
       
  1805 	if(GetBoolFromConfig(aSection, KUseClosedRFile(), useClosedRFile))
       
  1806 		{
       
  1807 		if (useClosedRFile && !useRFile)
       
  1808 			{
       
  1809 			ERR_PRINTF3(_L("Cannot use %S parameter if %S is not set to TRUE"), &KUseClosedRFile(), &KUseRFile());
       
  1810 			SetBlockResult(EFail);
       
  1811 			}
       
  1812 		}
       
  1813 
       
  1814 	// get up to 3 source file names from parameters
       
  1815 	TPtrC	sourceFileName0;
       
  1816 	if (GetStringFromConfig(aSection, KSourceFileName0(), sourceFileName0))
       
  1817 		{
       
  1818 		numberOfFiles++;
       
  1819 		if (GetStringFromConfig(aSection, KSourceFileName1(), sourceFileName1))
       
  1820 			{
       
  1821 			numberOfFiles++;
       
  1822 			if (GetStringFromConfig(aSection, KSourceFileName2(), sourceFileName2))
       
  1823 				{
       
  1824 				numberOfFiles++;
       
  1825 				}
       
  1826 			}
       
  1827 		}
       
  1828 
       
  1829 	// get up to 3 source bitmap ids from parameters
       
  1830 	if (GetIntFromConfig(aSection, KSourceBitmapId0(), sourceBitmapId0))
       
  1831 		{
       
  1832 		numberOfBitmapIds++;
       
  1833 		if (GetIntFromConfig(aSection, KSourceBitmapId1(), sourceBitmapId1))
       
  1834 			{
       
  1835 			numberOfBitmapIds++;
       
  1836 			if (GetIntFromConfig(aSection, KSourceBitmapId2(), sourceBitmapId2))
       
  1837 				{
       
  1838 				numberOfBitmapIds++;
       
  1839 				}
       
  1840 			}
       
  1841 		}
       
  1842 
       
  1843 	// get number of sources argument from parameters
       
  1844 	TInt	numberOfSources;
       
  1845 	if(!GetIntFromConfig(aSection, KNumberOfSources(), numberOfSources))
       
  1846 		{
       
  1847 		ERR_PRINTF2(_L("No %S"), &KNumberOfSources());
       
  1848 		SetBlockResult(EFail);
       
  1849 		}
       
  1850 
       
  1851 	// create array of file names
       
  1852  	TFileName** sourceFiles = new (ELeave) TFileName*[numberOfFiles];
       
  1853  	CleanupStack::PushL(sourceFiles);
       
  1854 	if (numberOfFiles > 0) sourceFiles[0] = new (ELeave) TFileName(sourceFileName0);
       
  1855 	if (numberOfFiles > 1) sourceFiles[1] = new (ELeave) TFileName(sourceFileName1);
       
  1856 	if (numberOfFiles > 2) sourceFiles[2] = new (ELeave) TFileName(sourceFileName2);
       
  1857 
       
  1858 	// create array of bitmap ids
       
  1859 	TInt32* bitmapIds = new (ELeave) TInt32[numberOfBitmapIds];
       
  1860 	CleanupStack::PushL(bitmapIds);
       
  1861 
       
  1862 	if (numberOfBitmapIds > 0) bitmapIds[0] = sourceBitmapId0;
       
  1863 	if (numberOfBitmapIds > 1) bitmapIds[1] = sourceBitmapId1;
       
  1864 	if (numberOfBitmapIds > 2) bitmapIds[2] = sourceBitmapId2;
       
  1865 
       
  1866 	TInt err = KErrNone;
       
  1867 	if (useRFile)
       
  1868 		{
       
  1869 		// required to allow file handle to be adopted by another process
       
  1870 		FileServer().ShareProtected();
       
  1871 
       
  1872 		// open rfile
       
  1873 		TBool	openSuccess = EFalse;
       
  1874 
       
  1875 		RFile file;
       
  1876 		err = file.Open(FileServer(), fileName, EFileWrite);
       
  1877 
       
  1878 		// check if ok, if not fount => try to create new file
       
  1879 		if (err == KErrNone)
       
  1880 			{
       
  1881 			openSuccess = ETrue;
       
  1882 			}
       
  1883 		else if (err == KErrNotFound)
       
  1884 			{
       
  1885 			INFO_PRINTF1(_L("File doesn't exist, trying to create it."));
       
  1886 
       
  1887 			err = file.Create(FileServer(), fileName, EFileWrite);
       
  1888 
       
  1889 			// check if failed to create file
       
  1890 			if (err == KErrNone)
       
  1891 				{
       
  1892 				openSuccess = ETrue;
       
  1893 				}
       
  1894 			else
       
  1895 				{
       
  1896 				ERR_PRINTF2(_L("File create error: %d"), err);
       
  1897 				SetBlockResult(EFail);
       
  1898 				}
       
  1899 			}
       
  1900 		else
       
  1901 			{
       
  1902 			ERR_PRINTF2(_L("File open error: %d"), err);
       
  1903 			SetBlockResult(EFail);
       
  1904 			}
       
  1905 
       
  1906 		// if ok => do store
       
  1907 		if (openSuccess)
       
  1908 			{
       
  1909 			// if we use invalid RFile handle in our test
       
  1910 			if (useClosedRFile)
       
  1911 				{
       
  1912 				file.Close();
       
  1913 				}
       
  1914 
       
  1915 			// call StoreL()
       
  1916 			TRAP(err, CFbsBitmap::StoreL(file, numberOfSources, (const TDesC**) sourceFiles, bitmapIds));
       
  1917 
       
  1918 			// check error code
       
  1919 			if (err != KErrNone)
       
  1920 				{
       
  1921 				ERR_PRINTF2(_L("Store error: %d"), err);
       
  1922 				SetError(err);
       
  1923 				}
       
  1924 
       
  1925 			// close rfile
       
  1926 			file.Close();
       
  1927 			}
       
  1928 		}
       
  1929 	else
       
  1930 		{
       
  1931 		// call StoreL()
       
  1932 		TRAP(err, CFbsBitmap::StoreL(fileName, numberOfSources, (const TDesC**) sourceFiles, bitmapIds));
       
  1933 
       
  1934 		// check error code
       
  1935 		if (err != KErrNone)
       
  1936 			{
       
  1937 			ERR_PRINTF2(_L("Store error: %d"), err);
       
  1938 			SetError(err);
       
  1939 			}
       
  1940 		}
       
  1941 
       
  1942  	// Iterate over the file name pointer array and cleanup
       
  1943  	for (TInt i = 0; i < numberOfFiles; ++i)
       
  1944  		{
       
  1945 		delete sourceFiles[i];
       
  1946    		}
       
  1947 
       
  1948  	// Cleanup the arrays allocated on the heap
       
  1949  	CleanupStack::PopAndDestroy(2, sourceFiles);
       
  1950 	}
       
  1951 
       
  1952 /** Calls CFbsBitmap::SwapWidthAndHeight() */
       
  1953 void CT_DataFbsBitmap::DoCmdSwapWidthAndHeight()
       
  1954 	{
       
  1955 	INFO_PRINTF1(_L("Calls CFbsBitmap::SwapWidthAndHeight()"));
       
  1956 
       
  1957 	// call SwapWidthAndHeight()
       
  1958 	TInt	err = GetFbsBitmap()->SwapWidthAndHeight();
       
  1959 
       
  1960 	// check error code
       
  1961 	if (err != KErrNone)
       
  1962 		{
       
  1963 		ERR_PRINTF2(_L("Swap width and height error: %d"), err);
       
  1964 		SetError(err);
       
  1965 		}
       
  1966 	}
       
  1967 
       
  1968 /** Calls static CFbsBitmap destructor */
       
  1969 void CT_DataFbsBitmap::DoCmdUnlockHeapL(const TDesC& aSection)
       
  1970 	{
       
  1971 
       
  1972 	CFbsBitmap*	bitmap=NULL;
       
  1973 	if ( CT_GraphicsUtil::GetFbsBitmapL(*this, aSection, KFbsBitmapName(), bitmap) )
       
  1974 		{
       
  1975 		CFbsBitmap::UnlockHeap(bitmap);
       
  1976 		}
       
  1977 	else
       
  1978 		{
       
  1979 		TBool	always=EFalse;
       
  1980 		GetBoolFromConfig(aSection, KAlways(), always);
       
  1981 
       
  1982 		GetFbsBitmap()->UnlockHeap(always);
       
  1983 		}
       
  1984 
       
  1985 	if ( iPopWhenUnlocking )
       
  1986 		{
       
  1987 		iPopWhenUnlocking=EFalse;
       
  1988 		CleanupStack::Pop();
       
  1989 		}
       
  1990 	}
       
  1991 
       
  1992 /** Calls CFbsBitmap::VerticalPixelsToTwips() */
       
  1993 void CT_DataFbsBitmap::DoCmdVerticalPixelsToTwips(const TDesC& aSection)
       
  1994 	{
       
  1995 	INFO_PRINTF1(_L("Calls CFbsBitmap::VerticalPixelsToTwips()"));
       
  1996 
       
  1997 	// get pixels from parameters
       
  1998 	TInt	pixels;
       
  1999 	if(!GetIntFromConfig(aSection, KPixels(), pixels))
       
  2000 		{
       
  2001 		ERR_PRINTF2(_L("No %S"), &KPixels());
       
  2002 		SetBlockResult(EFail);
       
  2003 		}
       
  2004 
       
  2005 	// call VerticalPixelsToTwips()
       
  2006 	TInt	value = GetFbsBitmap()->VerticalPixelsToTwips(pixels);
       
  2007 	INFO_PRINTF2(_L("Twips: %d"), value);
       
  2008 
       
  2009 	// validate returned value if needed
       
  2010 	TInt	expectedValue;
       
  2011 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
  2012 		{
       
  2013 		if (expectedValue != value)
       
  2014 			{
       
  2015 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, value);
       
  2016 			SetBlockResult(EFail);
       
  2017 			}
       
  2018 		}
       
  2019 	}
       
  2020 
       
  2021 /** Calls CFbsBitmap::VerticalTwipsToPixels() */
       
  2022 void CT_DataFbsBitmap::DoCmdVerticalTwipsToPixels(const TDesC& aSection)
       
  2023 	{
       
  2024 	INFO_PRINTF1(_L("Calls CFbsBitmap::VerticalTwipsToPixels()"));
       
  2025 
       
  2026 	// get twips from parameters
       
  2027 	TInt	twips;
       
  2028 	if(!GetIntFromConfig(aSection, KTwips(), twips))
       
  2029 		{
       
  2030 		ERR_PRINTF2(_L("No %S"), &KTwips());
       
  2031 		SetBlockResult(EFail);
       
  2032 		}
       
  2033 
       
  2034 	// call VerticalTwipsToPixels()
       
  2035 	TInt	value = GetFbsBitmap()->VerticalTwipsToPixels(twips);
       
  2036 	INFO_PRINTF2(_L("Pixels: %d"), value);
       
  2037 
       
  2038 	// validate returned value if needed
       
  2039 	TInt expectedValue;
       
  2040 	if(GetIntFromConfig(aSection, KExpectedInt(), expectedValue))
       
  2041 		{
       
  2042 		if (expectedValue != value)
       
  2043 			{
       
  2044 			ERR_PRINTF3(_L("The returned value is not as expected, expected: %d, actual: %d"), expectedValue, value);
       
  2045 			SetBlockResult(EFail);
       
  2046 			}
       
  2047 		}
       
  2048 	}
       
  2049 
       
  2050 /** Calls CFbsBitmap::ExternalizeL() or CFbsBitmap::ExternalizeRectangleL(). Used by DoCmdExternalize() and DoCmdExternalizeRectangle() methods */
       
  2051 void CT_DataFbsBitmap::ExternalizeImplL(const TDesC& aSection, const TRect& aRect, TBool aUseRect)
       
  2052 	{
       
  2053 	// get file name from parameters
       
  2054 	TPtrC	fileName;
       
  2055 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  2056 		{
       
  2057 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  2058 		SetBlockResult(EFail);
       
  2059 		}
       
  2060 
       
  2061 	// get a flag if to use closed stream from parameters
       
  2062 	TBool	useClosedStream = EFalse;
       
  2063 	if(!GetBoolFromConfig(aSection, KUseClosedStream(), useClosedStream))
       
  2064 		{
       
  2065 		ERR_PRINTF2(_L("No %S"), &KUseClosedStream());
       
  2066 		SetBlockResult(EFail);
       
  2067 		}
       
  2068 
       
  2069 	// create write store
       
  2070 	CDirectFileStore*	writestore = CDirectFileStore::ReplaceL(FileServer(), fileName, EFileStream | EFileWrite);
       
  2071 	CleanupStack::PushL(writestore);
       
  2072 	TInt				popCount=1;
       
  2073 	TUidType 			uidtype(KDirectFileStoreLayoutUid, KMultiBitmapFileImageUid);
       
  2074 
       
  2075 	writestore->SetTypeL(uidtype);
       
  2076 
       
  2077 	// create write stream
       
  2078 	RStoreWriteStream	writestrm;
       
  2079 
       
  2080 	// close stream set by parameters
       
  2081 	if (!useClosedStream)
       
  2082 		{
       
  2083 		TStreamId	headerid=writestrm.CreateL(*writestore);
       
  2084 		CleanupClosePushL(writestrm);
       
  2085 
       
  2086 		++popCount;
       
  2087 		writestore->SetRootL(headerid);
       
  2088 		}
       
  2089 
       
  2090 	if (aUseRect)
       
  2091 		{
       
  2092 		// call ExternalizeRectangleL()
       
  2093 		TRAPD(err, GetFbsBitmap()->ExternalizeRectangleL(writestrm, aRect));
       
  2094 		if (err != KErrNone)
       
  2095 			{
       
  2096 			ERR_PRINTF2(_L("Externalize rectangle error: %d"), err);
       
  2097 			SetError(err);
       
  2098 			}
       
  2099 		}
       
  2100 	else
       
  2101 		{
       
  2102 		// call ExternalizaL()
       
  2103 		TRAPD(err, GetFbsBitmap()->ExternalizeL(writestrm));
       
  2104 		if (err != KErrNone)
       
  2105 			{
       
  2106 			ERR_PRINTF2(_L("Externalize error: %d"), err);
       
  2107 			SetError(err);
       
  2108 			}
       
  2109 		}
       
  2110 
       
  2111 	// cleanup
       
  2112 	CleanupStack::PopAndDestroy(popCount, writestore);
       
  2113 	}
       
  2114 
       
  2115 /** Calls CFbsBitmap::Load() or CFbsBitmap::LoadAndCompress(). Used by DoCmdLoad() and DoCmdLoadAndCompress() methods */
       
  2116 void CT_DataFbsBitmap::LoadOrLoadAndCompressL(const TDesC& aSection, TBool aCompress)
       
  2117 	{
       
  2118 
       
  2119 	// get bitmap id from parameters
       
  2120 	TInt	bitmapId;
       
  2121 	if(!GetIntFromConfig(aSection, KBitmapId(), bitmapId))
       
  2122 		{
       
  2123 		ERR_PRINTF2(_L("No %S"), &KBitmapId());
       
  2124 		SetBlockResult(EFail);
       
  2125 		}
       
  2126 
       
  2127 	// get file name from parameters
       
  2128 	TPtrC	fileName;
       
  2129 	if (!GetStringFromConfig(aSection, KFileName(), fileName))
       
  2130 		{
       
  2131 		ERR_PRINTF2(_L("No %S"), &KFileName());
       
  2132 		SetBlockResult(EFail);
       
  2133 		}
       
  2134 
       
  2135 	// get file offset from parameters
       
  2136 	TInt	fileOffset;
       
  2137 	TBool	useOffset = GetIntFromConfig(aSection, KFileOffset(), fileOffset);
       
  2138 
       
  2139 	// get share if loaded from parameters
       
  2140 	TBool	shareIfLoaded = EFalse;
       
  2141 	GetBoolFromConfig(aSection, KShareIfLoaded(), shareIfLoaded);
       
  2142 
       
  2143 	// get flag if use RFile instance in Load() call from parameters
       
  2144 	TBool	useRFile = EFalse;
       
  2145 	GetBoolFromConfig(aSection, KUseRFile(), useRFile);
       
  2146 
       
  2147 	// get flag if use RFile instance in Load() call from parameters
       
  2148 	TBool	useClosedRFile = EFalse;
       
  2149 	GetBoolFromConfig(aSection, KUseClosedRFile(), useClosedRFile);
       
  2150 
       
  2151 	if (useClosedRFile && !useRFile)
       
  2152 		{
       
  2153 		ERR_PRINTF3(_L("Cannot use %S parameter if %S is not set to TRUE"), &KUseClosedRFile(), &KUseRFile());
       
  2154 		SetBlockResult(EFail);
       
  2155 		}
       
  2156 
       
  2157 	// load bitmap
       
  2158 	TInt	err = KErrNone;
       
  2159 	if (useRFile)
       
  2160 		{
       
  2161 		// required to allow file handle to be adopted by another process
       
  2162 		FileServer().ShareProtected();
       
  2163 
       
  2164 		// open rfile
       
  2165 		RFile	file;
       
  2166 
       
  2167 		// if we use invalid RFile handle in our test
       
  2168 		if (!useClosedRFile)
       
  2169 			{
       
  2170 			User::LeaveIfError(file.Open(FileServer(), fileName, EFileShareReadersOnly));
       
  2171 			CleanupClosePushL(file);
       
  2172 			}
       
  2173 
       
  2174 		// do load
       
  2175 		if (aCompress)
       
  2176 			{
       
  2177 			if (useOffset)
       
  2178 				{
       
  2179 				err = GetFbsBitmap()->LoadAndCompress(file, bitmapId, shareIfLoaded, fileOffset);
       
  2180 				}
       
  2181 			else
       
  2182 				{
       
  2183 				err = GetFbsBitmap()->LoadAndCompress(file, bitmapId, shareIfLoaded);
       
  2184 				}
       
  2185 			}
       
  2186 		else
       
  2187 			{
       
  2188 			if (useOffset)
       
  2189 				{
       
  2190 				err = GetFbsBitmap()->Load(file, bitmapId, shareIfLoaded, fileOffset);
       
  2191 				}
       
  2192 			else
       
  2193 				{
       
  2194 				err = GetFbsBitmap()->Load(file, bitmapId, shareIfLoaded);
       
  2195 				}
       
  2196 			}
       
  2197 
       
  2198 		if (!useClosedRFile)
       
  2199 			{
       
  2200 			CleanupStack::PopAndDestroy(&file);
       
  2201 			}
       
  2202 		}
       
  2203 	else
       
  2204 		{
       
  2205 		if (aCompress)
       
  2206 			{
       
  2207 			if (useOffset)
       
  2208 				{
       
  2209 				err = GetFbsBitmap()->LoadAndCompress(fileName, bitmapId, shareIfLoaded, fileOffset);
       
  2210 				}
       
  2211 			else
       
  2212 				{
       
  2213 				err = GetFbsBitmap()->LoadAndCompress(fileName, bitmapId, shareIfLoaded);
       
  2214 				}
       
  2215 			}
       
  2216 		else
       
  2217 			{
       
  2218 			if (useOffset)
       
  2219 				{
       
  2220 				err = GetFbsBitmap()->Load(fileName, bitmapId, shareIfLoaded, fileOffset);
       
  2221 				}
       
  2222 			else
       
  2223 				{
       
  2224 				err = GetFbsBitmap()->Load(fileName, bitmapId, shareIfLoaded);
       
  2225 				}
       
  2226 			}
       
  2227 		}
       
  2228 
       
  2229 	// check error code
       
  2230 	if (err != KErrNone)
       
  2231 		{
       
  2232 		ERR_PRINTF2(_L("Load error: %d"), err);
       
  2233 		SetError(err);
       
  2234 		}
       
  2235 	}
       
  2236 
       
  2237 /**
       
  2238  Virtual RunL - Called on completion of an asynchronous command
       
  2239  @see MTPActiveCallback
       
  2240  @param aActive Active Object that RunL has been called on
       
  2241  @pre N/A
       
  2242  @post N/A
       
  2243  @leave system wide error code
       
  2244 */
       
  2245 void CT_DataFbsBitmap::RunL(CActive* aActive, const TInt aIndex)
       
  2246 	{
       
  2247 	if ( aActive==iActiveCompressInBackground )
       
  2248 		{
       
  2249 		RunCompressInBackground(aIndex);
       
  2250 		}
       
  2251 	else
       
  2252 		{
       
  2253 		ERR_PRINTF1(_L("Stray signal"));
       
  2254 		SetBlockResult(EFail);
       
  2255 		}
       
  2256 	DecOutstanding();
       
  2257 	}
       
  2258 
       
  2259 /**
       
  2260  Virtual DoCancel - Request to cancel the asynchronous command
       
  2261  @see - MTPActiveCallback
       
  2262  @param aActive Active Object that DoCancel has been called on
       
  2263  @pre - N/A
       
  2264  @post - N/A
       
  2265  @leave system wide error code
       
  2266 */
       
  2267 void CT_DataFbsBitmap::DoCancel(CActive* aActive, const TInt aIndex)
       
  2268 	{
       
  2269 	if ( aActive==iActiveCompressInBackground )
       
  2270 		{
       
  2271 		DoCancelCompressInBackground(aIndex);
       
  2272 		}
       
  2273 	else
       
  2274 		{
       
  2275 		ERR_PRINTF1(_L("Stray signal"));
       
  2276 		SetBlockResult(EFail);
       
  2277 		}
       
  2278 	DecOutstanding();
       
  2279 	}
       
  2280 
       
  2281 void CT_DataFbsBitmap::RunCompressInBackground(const TInt aIndex)
       
  2282 	{
       
  2283 	TInt	err=iActiveCompressInBackground->iStatus.Int();
       
  2284 	INFO_PRINTF2(_L("RunCompressInBackground %d"), err);
       
  2285 	if ( err!=KErrNone )
       
  2286 		{
       
  2287 		ERR_PRINTF2(_L("RunL Error %d"), err);
       
  2288 		SetAsyncError(aIndex, err);
       
  2289 		}
       
  2290 	}
       
  2291 
       
  2292 void CT_DataFbsBitmap::DoCancelCompressInBackground(const TInt /*aIndex*/)
       
  2293 	{
       
  2294 	}