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