graphicsapitest/graphicssvs/wserv/AnimPlugin/src/T_TWinAnim.cpp
changeset 111 29ddb8a72f0e
parent 110 7f25ef56562d
child 113 f3c3c510a760
child 152 9f1c3fea0f87
equal deleted inserted replaced
110:7f25ef56562d 111:29ddb8a72f0e
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 // 
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "T_TWinAnim.h"
       
    17 #include "T_TestAnimDll.h"
       
    18 #include "txtfrmat.h" 
       
    19 #include "bitdev.h" 
       
    20 #include "T_AnimDef.h"
       
    21 #include "w32adll.h" 
       
    22 
       
    23 // Implementation of CTimeoutTimer.
       
    24 CTimeOutTimer::CTimeOutTimer(const TInt aPriority,
       
    25 		MTimeoutNotify& aTimeOutNotify) :
       
    26 	CTimer(aPriority), iNotify(aTimeOutNotify)
       
    27 	{
       
    28 	// No implementation required
       
    29 	}
       
    30 
       
    31 CTimeOutTimer* CTimeOutTimer::NewL(const TInt aPriority, 
       
    32 		MTimeoutNotify& aTimeOutNotify)
       
    33 	{
       
    34 	CTimeOutTimer *self = new ( ELeave ) CTimeOutTimer( aPriority, aTimeOutNotify );
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	CleanupStack::Pop();
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 CTimeOutTimer::~CTimeOutTimer()
       
    42 	{
       
    43 	Cancel();
       
    44 	}
       
    45 
       
    46 void CTimeOutTimer::ConstructL()
       
    47 	{
       
    48 	CTimer::ConstructL();
       
    49 	CActiveScheduler::Add( this);
       
    50 	}
       
    51 
       
    52 void CTimeOutTimer::RunL()
       
    53 	{
       
    54 	iNotify.TimedOut();
       
    55 	}
       
    56 
       
    57 //Implementation of CTWinAnim
       
    58 CTWinAnim::CTWinAnim(CTestAnimDll* aDll, TInt aType) :
       
    59 	CAnimProc(aDll, aType)
       
    60 	{
       
    61 	// No implementation required
       
    62 	}
       
    63 
       
    64 CTWinAnim::~CTWinAnim()
       
    65 	{
       
    66 	WriteLog(_L("~CTWinAnim"));
       
    67 	if (iServerTimer)
       
    68 		{
       
    69 		iServerTimer->Cancel();
       
    70 		}
       
    71 
       
    72 	// Then delete the timer object
       
    73 	delete iServerTimer;
       
    74 	iServerTimer = NULL;
       
    75 
       
    76 	if (iIntervalTimeStamp)
       
    77 		delete [] iIntervalTimeStamp;
       
    78 
       
    79 	if (iDuplicateBitmap)
       
    80 		delete iDuplicateBitmap;
       
    81 
       
    82 	if (iMemArray.Count() > 0)
       
    83 		FreeMemory();
       
    84 	}
       
    85 
       
    86 void CTWinAnim::ConstructL(TAny *aArgs, TBool /*aHasFocus*/)
       
    87 	{
       
    88 	WriteLog(_L("CTWinAnim::ConstructL"));
       
    89 	ConstructWinL(aArgs, iFunctions);
       
    90 
       
    91 	// Store the screen size
       
    92 	iScreenSize = iWindowFunctions->WindowSize();
       
    93 
       
    94 	TBuf<50> buf;
       
    95 	buf.Format(_L("Screen width=%d height=%d"),iScreenSize.Width(),iScreenSize.Height());
       
    96 	WriteLog(buf);
       
    97 
       
    98 	// Set the screen visible
       
    99 	iWindowFunctions->SetVisible(ETrue);
       
   100 	//just for start heartbeat
       
   101 	iWindowFunctions->SetRect(TRect(0, 0, 1, 1));
       
   102 	iServerTimer = CTimeOutTimer::NewL(EPriorityHigh, *this);
       
   103 	}
       
   104 
       
   105 void CTWinAnim::Redraw()
       
   106 	{
       
   107 	WriteLog(_L("CTWinAnim::Redraw"));
       
   108 	iResult=ETrue;
       
   109 
       
   110 	Draw();
       
   111 	}
       
   112 
       
   113 void CTWinAnim::Draw()
       
   114 	{
       
   115 	// get the background colour
       
   116 	TLogicalRgb backgroundColour(TLogicalRgb::ESystemBackgroundColor);
       
   117 
       
   118 	// Clear the old image.
       
   119 	iGc->SetPenSize(iPenSize);
       
   120 	iGc->SetPenColor(backgroundColour);
       
   121 	iGc->DrawRect(TRect(iLastPoint, iSize) );
       
   122 
       
   123 	// Draw a shape at the new position
       
   124 	iGc->SetPenSize(iPenSize);
       
   125 	iGc->SetPenColor(iColor);
       
   126 	iGc->DrawRect(TRect(iNewPoint, iSize) );
       
   127 
       
   128 	if (iDuplicateBitmap)
       
   129 		{
       
   130 		TRect rect;
       
   131 		rect.SetRect(0, 0, 200, 200);
       
   132 		iGc->DrawBitmap(rect, iDuplicateBitmap);
       
   133 		}
       
   134 
       
   135 	// signal that the current position has been drawn
       
   136 	iDrawn = ETrue;
       
   137 	}
       
   138 
       
   139 void CTWinAnim::HandleNotification(const TWsEvent &aEvent)
       
   140 	{
       
   141 	if (aEvent.Type() == iExpectEventCode)
       
   142 		{
       
   143 		iResult = ETrue;
       
   144 		}
       
   145 	}
       
   146 
       
   147 void CTWinAnim::FocusChanged(TBool /*aState*/)
       
   148 	{
       
   149 
       
   150 	}
       
   151 
       
   152 void CTWinAnim::TimedOut()
       
   153 	{
       
   154 	switch (iCurrentCommand)
       
   155 		{
       
   156 		case ECmdGeneralSetInterval:
       
   157 			{
       
   158 			TInt64 interval=iIntervalTimeStamp[1]-iIntervalTimeStamp[0];
       
   159 			TInt expectInterval=0;
       
   160 			if(iInterval>0)
       
   161 				expectInterval = iInterval * 1000000 / 2;
       
   162 
       
   163 			if (interval == expectInterval)
       
   164 				iResult=ETrue;
       
   165 			else
       
   166 				iResult=EFalse;
       
   167 
       
   168 			break;
       
   169 			}
       
   170 
       
   171 		case ECmdGeneralSetNextInterval:
       
   172 			{
       
   173 			TInt64 interval1=iIntervalTimeStamp[1]-iIntervalTimeStamp[0];
       
   174 			TInt64 interval2=iIntervalTimeStamp[2]-iIntervalTimeStamp[1];
       
   175 			TInt expectInterval = iInterval * 1000000 / 2;
       
   176 			TInt expectNextInterval = 0;
       
   177 			
       
   178 			//If the value is less than 1, it automatically gets set to 1. 
       
   179 			if(iNextInterval > 0)
       
   180 				{
       
   181 				expectNextInterval = iNextInterval * 1000000 / 2;
       
   182 				}
       
   183 			else
       
   184 				{
       
   185 				expectNextInterval = 1000000 / 2;
       
   186 				}
       
   187 			
       
   188 			if ((expectNextInterval*5/12)<=interval1 && interval1<=1000000
       
   189 					&& interval2==expectInterval)
       
   190 				iResult=ETrue;
       
   191 			else
       
   192 				iResult=EFalse;
       
   193 			break;
       
   194 			}
       
   195 		}
       
   196 	}
       
   197 
       
   198 TInt CTWinAnim::CommandReplyL(TInt aOpcode, TAny *aArgs)
       
   199 	{
       
   200 	if (aOpcode != ECmdRetrieveResult)
       
   201 		{
       
   202 		iCurrentCommand=aOpcode;
       
   203 		}
       
   204 	TInt nReturn=KErrNone;
       
   205 	switch (aOpcode)
       
   206 		{
       
   207 		case ECmdWindowActivateGc:
       
   208 			iWindowFunctions->ActivateGc();
       
   209 			break;
       
   210 		case ECmdWindowSetRect:
       
   211 			nReturn=DoCmdSetRect();
       
   212 			break;
       
   213 		case ECmdWindowIsStarted:
       
   214 			iResult=EFalse;
       
   215 			iSyncMode=iFunctions->Sync();
       
   216 			iFunctions->SetSync(MAnimGeneralFunctions::ESyncFlash);
       
   217 			break;
       
   218 		case ECmdRetrieveResult:
       
   219 			nReturn=iResult;
       
   220 			break;
       
   221 		case ECmdWindowWindowSize:
       
   222 			nReturn=DoCmdWindowSize();
       
   223 			break;
       
   224 		case ECmdWindowIsHidden:
       
   225 			nReturn=iWindowFunctions->IsHidden();
       
   226 			break;
       
   227 		case ECmdWindowSetVisible:
       
   228 			nReturn=DoCmdSetVisible();
       
   229 			break;
       
   230 		case ECmdWindowInvalidate:
       
   231 			nReturn=DoCmdInvalidate();
       
   232 			break;
       
   233 		case ECmdWindowParameters:
       
   234 			nReturn=DoCmdParameters();
       
   235 			break;
       
   236 		case ECmdWindowVisibleRegion:
       
   237 			nReturn=DoCmdVisibleRegion();
       
   238 			break;
       
   239 
       
   240 		case ECmdGfweScreens:
       
   241 			nReturn=iFunctions->WindowExtension()->Screens();
       
   242 			break;
       
   243 		case ECmdGfweFocusScreens:
       
   244 			nReturn=iFunctions->WindowExtension()->FocusScreens();
       
   245 			break;
       
   246 		case ECmdGfweSetFocusScreen:
       
   247 			nReturn=DoCmdSetFocusScreen();
       
   248 			break;
       
   249 		case ECmdGfweWindowGroups:
       
   250 			nReturn=DoCmdWindowGroups();
       
   251 			break;
       
   252 		case ECmdGfweWindowGroupInfo:
       
   253 			nReturn=DoCmdWindowGroupInfo();
       
   254 			break;
       
   255 		case ECmdGfweWindowGroupName:
       
   256 			nReturn=DoCmdWindowGroupName();
       
   257 			break;
       
   258 		case ECmdGfweSetOrdinalPosition:
       
   259 			nReturn=DoCmdSetOrdinalPosition();
       
   260 			break;
       
   261 		case ECmdGfweIsFocusable:
       
   262 			nReturn=DoCmdIsFocusable();
       
   263 			break;
       
   264 		case ECmdGfweWindowConfig:
       
   265 			nReturn=DoCmdWindowConfig();
       
   266 			break;
       
   267 			
       
   268 		case ECmdGeneralDuplicateBitmapL:
       
   269 			nReturn = DoCmdDuplicateBitmapL();
       
   270 			break;
       
   271 		case ECmdGeneralDuplicateFontL:
       
   272 			nReturn = DoCmdDuplicateFontL();
       
   273 			break;
       
   274 		case ECmdGeneralCloseFont:
       
   275 			nReturn = DoCmdCloseFontL();
       
   276 			break;
       
   277 		case ECmdGeneralSetInterval:
       
   278 			nReturn = DoCmdSetIntervalL();
       
   279 			break;
       
   280 		case ECmdGeneralSetNextInterval:
       
   281 			nReturn = DoCmdSetNextIntervalL();
       
   282 			break;
       
   283 		case ECmdGeneralSystemTime:
       
   284 			nReturn = DoCmdSystemTimeL();
       
   285 			break;
       
   286 		case ECmdGeneralRegisterForNotis:
       
   287 			nReturn = DoCmdRegisterForNotisL();
       
   288 			break;
       
   289 		case ECmdGeneralMessage:
       
   290 			nReturn = DoCmdMessageL();
       
   291 			break;
       
   292 		case ECmdGeneralAnimate:
       
   293 			nReturn = DoCmdAnimateL();
       
   294 			break;
       
   295 		case ECmdGeneralFlashStateOn:
       
   296 			nReturn = DoCmdFlashStateOn();
       
   297 			break;
       
   298 		case ECmdGeneralPanic:
       
   299 			nReturn = DoCmdPanic();
       
   300 			break;
       
   301 		case ECmdGeneralScreenDevice:
       
   302 			nReturn = DoCmdScreenDevice();
       
   303 			break;
       
   304 		case ECmdGeneralWindowExtension:
       
   305 			nReturn = DoCmdWindowExtension();
       
   306 			break;
       
   307 		case ECmdGeneralEventExtension:
       
   308 			nReturn = DoCmdEventExtension();
       
   309 			break;
       
   310 		case ECmdGeneralExtendedInterface:
       
   311 			nReturn = DoCmdExtendedInterfaceL();
       
   312 			break;
       
   313 		case ECmdGeneralNumOfExtInterfaces:
       
   314 			nReturn = DoCmdNumOfExtInterfaces();
       
   315 			break;
       
   316 		case ECmdGeneralSetSync:
       
   317 			nReturn = DoCmdSetSyncL();
       
   318 			break;
       
   319 		case ECmdGeneralSync:
       
   320 			nReturn = DoCmdSync();
       
   321 			break;
       
   322 		case ECmdGeneralGetRawEvents:
       
   323 			nReturn = DoCmdGetRawEventsL();
       
   324 			break;
       
   325 		case ECmdGeneralPostRawEvent:
       
   326 			nReturn = DoCmdPostRawEventL();
       
   327 			break;
       
   328 		case ECmdGeneralPostKeyEvent:
       
   329 			nReturn = DoCmdPostKeyEventL();
       
   330 			break;
       
   331 		case ECmdGeneralClient:
       
   332 			nReturn = DoCmdClient();
       
   333 			break;
       
   334 		case ECmdGeneralReplyBuf8:
       
   335 			nReturn = DoCmdGeneralReplyBuf8L();
       
   336 			break;
       
   337 		case ECmdGeneralReplyBuf16:
       
   338 			nReturn = DoCmdGeneralReplyBuf16L();
       
   339 			break;
       
   340 		case ECmdUtilEatupMemory:
       
   341 			nReturn = DoCmdEatupMemory();
       
   342 			break;
       
   343 		case ECmdUtilFreeEatenMemory:
       
   344 			nReturn = DoCmdFreeEatenMemory();
       
   345 			break;
       
   346 		default:
       
   347 			nReturn=CmdReply(iFunctions, aOpcode, aArgs);
       
   348 		}
       
   349 
       
   350 	return nReturn;
       
   351 	}
       
   352 
       
   353 void CTWinAnim::Command(TInt aOpcode, TAny *aArgs)
       
   354 	{
       
   355 	CmdReply(iFunctions, aOpcode, aArgs);
       
   356 	}
       
   357 
       
   358 void CTWinAnim::Animate(TDateTime *aDateTime)
       
   359 	{
       
   360 	//Set iAnimateTime.
       
   361 	TTime now;
       
   362 	now.HomeTime();
       
   363 	iAnimateTime = now.DateTime();
       
   364 
       
   365 	switch (iCurrentCommand)
       
   366 		{
       
   367 		case ECmdGeneralAnimate:
       
   368 			iDateTime = *aDateTime;
       
   369 			break;
       
   370 		case ECmdGeneralSetInterval:
       
   371 			{
       
   372 			if (iIntervalTimeStamp[0]==0)
       
   373 				{
       
   374 				iIntervalTimeStamp[0]=now.Int64();
       
   375 				}
       
   376 			else
       
   377 				if (iIntervalTimeStamp[1]==0)
       
   378 					{
       
   379 					iIntervalTimeStamp[1]=now.Int64();
       
   380 					}
       
   381 			break;
       
   382 			}
       
   383 
       
   384 		case ECmdGeneralSetNextInterval:
       
   385 			{
       
   386 			if (iIntervalTimeStamp[1]==0)
       
   387 				{
       
   388 				iIntervalTimeStamp[1]=now.Int64();
       
   389 				}
       
   390 			else
       
   391 				if (iIntervalTimeStamp[2]==0)
       
   392 					{
       
   393 					iIntervalTimeStamp[2]=now.Int64();
       
   394 					}
       
   395 			break;
       
   396 			}
       
   397 		}
       
   398 
       
   399 	iResult=ETrue;
       
   400 	//if MAnimGeneralFunctions::Sync() not equal to CWindowAnim::iSyncMode then call CWindowAnim::SetSync(CWindowAnim::iSyncMode)
       
   401 	if (iFunctions->Sync()!=iSyncMode && iCurrentCommand==ECmdWindowIsStarted)
       
   402 		{
       
   403 		iFunctions->SetSync(iSyncMode);
       
   404 		}
       
   405 	// if the last position has been drawn, update the position
       
   406 	if (iDrawn)
       
   407 		{
       
   408 		// this position has not been drawn, so clear the flag
       
   409 		iDrawn = EFalse;
       
   410 
       
   411 		if (iLastPoint != iNewPoint)
       
   412 			Compare();
       
   413 
       
   414 		// Save the current position, so we can rub it out later
       
   415 		iLastPoint = iNewPoint;
       
   416 
       
   417 		TInt nextpoint=iNewPoint.iX + iStepX;
       
   418 		TInt right=iNewPoint.iX + iSize.iWidth;
       
   419 
       
   420 		if (right> iScreenSize.iBr.iX ||nextpoint >= iScreenSize.iBr.iX
       
   421 				||iNewPoint.iX<iScreenSize.iTl.iX)
       
   422 			iStepX = -iStepX;
       
   423 
       
   424 		TInt nexty=iNewPoint.iY + iStepY;
       
   425 		TInt bottom=nexty + iSize.iHeight;
       
   426 
       
   427 		if (bottom> iScreenSize.iBr.iY ||nexty >= iScreenSize.iBr.iY
       
   428 				||iNewPoint.iY<iScreenSize.iTl.iY || nexty
       
   429 				<= iScreenSize.iTl.iY)
       
   430 			iStepY = -iStepY;
       
   431 
       
   432 		iNewPoint.iX += iStepX;
       
   433 		iNewPoint.iY += iStepY;
       
   434 
       
   435 		// Force a draw to be performed by declaring the screen invalid
       
   436 		iWindowFunctions->Invalidate(iScreenSize);
       
   437 		}
       
   438 
       
   439 	RecordAnimTime();
       
   440 
       
   441 	TInt interval=(iAnimTime[KAnimTimeSize-1]-iAnimTime[KAnimTimeSize-2])/1000;
       
   442 
       
   443 	TBuf<100> buf;
       
   444 	buf.Format(_L("CTWinAnim::Animate interval=%d x=%d y=%d"),
       
   445 	interval,iNewPoint.iX,iNewPoint.iY);
       
   446 
       
   447 	WriteLog(buf);
       
   448 	}
       
   449 
       
   450 void CTWinAnim::Compare()
       
   451 	{
       
   452 	// compare     	
       
   453 	const CFbsScreenDevice* scdev=iFunctions->ScreenDevice();
       
   454 
       
   455 	TBool compare=scdev->RectCompare(TRect(iNewPoint, iSize), *scdev, TRect(
       
   456 			TPoint(0, 0), iSize));
       
   457 	TBuf<50> buf;
       
   458 	buf.Format(_L("CTWinAnim::Compare res %d"),
       
   459 	compare);
       
   460 	iDll->WriteLog(buf);
       
   461 	}
       
   462 TBool CTWinAnim::OfferRawEvent(const TRawEvent& aRawEvent)
       
   463 	{
       
   464 	WriteLog(_L("CTWinAnim::OfferRawEvent has been called"));
       
   465 	TBuf<10> event;
       
   466 	event.AppendNum(aRawEvent.Type());
       
   467 	WriteLog(event);
       
   468 	iResult = ETrue;
       
   469 	return ETrue;
       
   470 	}
       
   471 
       
   472 //for MAnimWindowFunctions
       
   473 TInt CTWinAnim::DoCmdSetRect()
       
   474 	{
       
   475 	const RMessagePtr2 *msg=iFunctions->Message();
       
   476 	TPckgBuf<TRect> arg;
       
   477 	TRect rect(0, 0, 0, 0);
       
   478 	TInt nReturn=KErrNotFound;
       
   479 
       
   480 	if (msg && !msg->IsNull())
       
   481 		{
       
   482         nReturn=msg->Read(1, arg);
       
   483 		if (KErrNone==nReturn)
       
   484 			{
       
   485 			rect=arg();
       
   486 			iWindowFunctions->SetRect(rect);
       
   487 			}
       
   488 		}
       
   489 	return nReturn;
       
   490 	}
       
   491 
       
   492 TInt CTWinAnim::DoCmdWindowSize()
       
   493 	{
       
   494 	TSize size=iWindowFunctions->WindowSize();
       
   495 	TPckgBuf<TSize> pckg(size);
       
   496 	TInt nReturn=KErrNone;
       
   497 	const RMessagePtr2 *msg=iFunctions->Message();
       
   498 
       
   499 	if (msg)
       
   500 		{
       
   501 		nReturn=msg->Write(1, pckg);
       
   502 		}
       
   503 
       
   504 	return nReturn;
       
   505 	}
       
   506 
       
   507 TInt CTWinAnim::DoCmdSetVisible()
       
   508 	{
       
   509 	TInt nReturn=KErrNotFound;
       
   510 	TPckgBuf<TBool> arg;
       
   511 	const RMessagePtr2 *msg=iFunctions->Message();
       
   512 
       
   513 	if (msg)
       
   514 		{
       
   515         nReturn=msg->Read(1, arg);
       
   516 		if (KErrNone==nReturn)
       
   517 			{
       
   518 			iWindowFunctions->SetVisible(arg());
       
   519 			}
       
   520 		}
       
   521 
       
   522 	return nReturn;
       
   523 	}
       
   524 
       
   525 TInt CTWinAnim::DoCmdInvalidate()
       
   526 	{
       
   527 	const RMessagePtr2 *msg=iFunctions->Message();
       
   528 	TPckgBuf<TRect> arg;
       
   529 	TRect rect(0, 0, 0, 0);
       
   530 	TInt nReturn=KErrNotFound;
       
   531 
       
   532 	if (msg && !msg->IsNull())
       
   533 		{
       
   534         nReturn=msg->Read(1, arg);
       
   535 		if (KErrNone==nReturn)
       
   536 			{
       
   537 			rect=arg();
       
   538 			iResult=EFalse;
       
   539 			iWindowFunctions->Invalidate(rect);
       
   540 			iWindowFunctions->ActivateGc();
       
   541 			iGc->DrawRect(rect);
       
   542 			}
       
   543 		}
       
   544 	return nReturn;
       
   545 	}
       
   546 
       
   547 TInt CTWinAnim::DoCmdParameters()
       
   548 	{
       
   549 	TWindowInfo data;
       
   550 	iWindowFunctions->Parameters(data);
       
   551 
       
   552 	TPckgBuf<TRect> pckgScreenPos(data.iScreenPos);
       
   553 	TPckgBuf<TInt> pckgMode((TInt)data.iMode);
       
   554 
       
   555 	TInt nReturn=KErrNone;
       
   556 	const RMessagePtr2 *msg=iFunctions->Message();
       
   557 
       
   558 	if (msg)
       
   559 		{
       
   560 		nReturn=msg->Write(1, pckgScreenPos);
       
   561 		nReturn=msg->Write(2, pckgMode);
       
   562 		}
       
   563 
       
   564 	return nReturn;
       
   565 	}
       
   566 
       
   567 TInt CTWinAnim::DoCmdVisibleRegion()
       
   568 	{
       
   569 	RRegion region;
       
   570 	iWindowFunctions->VisibleRegion(region);
       
   571 	return region.Count();
       
   572 	}
       
   573 
       
   574 //for MAnimGeneralFunctionsWindowExtension
       
   575 TInt CTWinAnim::DoCmdSetFocusScreen()
       
   576 	{
       
   577 	const RMessagePtr2 *msg=iFunctions->Message();
       
   578 	TPckgBuf<TInt> arg;
       
   579     TInt nReturn=KErrNotFound;
       
   580     
       
   581 	if (msg && !msg->IsNull())
       
   582 		{
       
   583         nReturn=msg->Read(1, arg);
       
   584 		if (KErrNone==nReturn)
       
   585 			{
       
   586 			iFunctions->WindowExtension()->SetFocusScreen(arg());
       
   587 			}
       
   588 		}
       
   589     return nReturn;
       
   590 	}
       
   591 
       
   592 TInt CTWinAnim::DoCmdWindowGroups()
       
   593 	{
       
   594 	const RMessagePtr2 *msg=iFunctions->Message();
       
   595 	TPckgBuf<TInt> arg;
       
   596 	TInt nReturn=KErrNotFound;
       
   597 
       
   598 	if (msg && !msg->IsNull())
       
   599 		{
       
   600         nReturn=msg->Read(1, arg);
       
   601 		if (KErrNone==nReturn)
       
   602 			{
       
   603 			nReturn=iFunctions->WindowExtension()->WindowGroups(arg());
       
   604 			}
       
   605 		}
       
   606 	return nReturn;
       
   607 	}
       
   608 
       
   609 TBool CTWinAnim::DoCmdWindowGroupInfo()
       
   610 	{
       
   611 	const RMessagePtr2 *msg=iFunctions->Message();
       
   612 	TPckgBuf<TInt> argScrNumber;
       
   613 	TPckgBuf<TInt> argPosition;
       
   614 
       
   615 	TBool nReturn=EFalse;
       
   616 	MAnimGeneralFunctionsWindowExtension::TWindowGroupInfo aInfo;
       
   617 
       
   618 	if (msg && !msg->IsNull())
       
   619 		{
       
   620 		if (KErrNone==msg->Read(1, argScrNumber) && KErrNone==msg->Read(2, argPosition))
       
   621 			{
       
   622 			nReturn=iFunctions->WindowExtension()->WindowGroupInfo(aInfo, argScrNumber(), argPosition());
       
   623 
       
   624 			if (nReturn)
       
   625 				{
       
   626 				TPckgBuf<TInt> pckgInfo(aInfo.iId);
       
   627 				msg->Write(3, pckgInfo);
       
   628 				}
       
   629 			}
       
   630 		}
       
   631 	return nReturn;
       
   632 	}
       
   633 
       
   634 TBool CTWinAnim::DoCmdWindowGroupName()
       
   635 	{
       
   636 	const RMessagePtr2 *msg=iFunctions->Message();
       
   637 	TPckgBuf<TInt> argScrNumber;
       
   638 	TPckgBuf<TInt> argPosition;
       
   639 
       
   640 	TBool nReturn=EFalse;
       
   641 
       
   642 	if (msg && !msg->IsNull())
       
   643 		{
       
   644 		if (KErrNone==msg->Read(1, argScrNumber) && KErrNone==msg->Read(2, argPosition))
       
   645 			{
       
   646 			TPtrC name;
       
   647 			nReturn=iFunctions->WindowExtension()->WindowGroupName(name, argScrNumber(), argPosition());
       
   648 			if (nReturn)
       
   649 				{
       
   650 				msg->Write(3, name);
       
   651 				}
       
   652 			}
       
   653 		}
       
   654 
       
   655 	return nReturn;
       
   656 	}
       
   657 
       
   658 TInt CTWinAnim::DoCmdSetOrdinalPosition()
       
   659 	{
       
   660 	const RMessagePtr2 *msg=iFunctions->Message();
       
   661 	TPckgBuf<TInt> argGroupId;
       
   662 	TPckgBuf<TInt> argPosition;
       
   663 	TPckgBuf<TInt> argPriority;
       
   664 
       
   665 	TInt nReturn=KErrNotFound;
       
   666 
       
   667 	if (msg && !msg->IsNull())
       
   668 		{
       
   669 		if (KErrNone==msg->Read(1, argGroupId) && KErrNone==msg->Read(2, argPosition)
       
   670 				&& KErrNone==msg->Read(3, argPriority))
       
   671 			{
       
   672 			nReturn=iFunctions->WindowExtension()->SetOrdinalPosition(argGroupId(), argPosition(),
       
   673 					argPriority());
       
   674 			}
       
   675 		}
       
   676 
       
   677 	return nReturn;
       
   678 	}
       
   679 
       
   680 TBool CTWinAnim::DoCmdIsFocusable()
       
   681 	{
       
   682 	const RMessagePtr2 *msg=iFunctions->Message();
       
   683 	TPckgBuf<TInt> argScrNumber;
       
   684 	TPckgBuf<TInt> argPosition;
       
   685 
       
   686 	TBool nReturn=EFalse;
       
   687 	MAnimGeneralFunctionsWindowExtension::TWindowGroupInfo aInfo;
       
   688 
       
   689 	if (msg && !msg->IsNull())
       
   690 		{
       
   691 		if (KErrNone==msg->Read(1, argScrNumber) && KErrNone==msg->Read(2, argPosition))
       
   692 			{
       
   693 			if (iFunctions->WindowExtension()->WindowGroupInfo(aInfo, argScrNumber(), argPosition()))
       
   694 				{
       
   695 				nReturn=aInfo.IsFocusable();
       
   696 				}
       
   697 			}
       
   698 		}
       
   699 	return nReturn;
       
   700 	}
       
   701 
       
   702 TBool CTWinAnim::DoCmdWindowConfig()
       
   703 	{
       
   704 	TWindowConfig config;
       
   705 	iFunctions->WindowExtension()->WindowConfig(config);
       
   706 	return config.iFlags & TWindowConfig::ETransparencyEnabled; 
       
   707 	}
       
   708 
       
   709 TInt CTWinAnim::DoCmdDuplicateBitmapL()
       
   710 	{
       
   711 	TInt result = 0;
       
   712 	TInt handle;
       
   713 	TPtr8 ptr1((TUint8*)&handle, sizeof(TInt));
       
   714 	const RMessagePtr2 *msg=iFunctions->Message();
       
   715 		
       
   716 	if(msg && !msg->IsNull())
       
   717 		{
       
   718 		msg->ReadL(1,ptr1);
       
   719 		iDuplicateBitmap = iFunctions->DuplicateBitmapL(handle);
       
   720 		if (iDuplicateBitmap)
       
   721 			{
       
   722 			TRect rect;
       
   723 			iWindowFunctions->ActivateGc();
       
   724 			rect.SetRect(0, 0, 200, 200);
       
   725 			iGc->DrawBitmap(rect, iDuplicateBitmap);
       
   726 			}
       
   727 		}
       
   728 	else
       
   729 		{
       
   730 		result = -1;
       
   731 		}
       
   732 	return result;
       
   733 	}
       
   734 
       
   735 TInt CTWinAnim::DoCmdDuplicateFontL()
       
   736 	{
       
   737 	TInt result = 0;
       
   738 	TInt handle;
       
   739 	TPtr8 ptr1((TUint8*)&handle, sizeof(TInt));
       
   740 	const RMessagePtr2 *msg=iFunctions->Message();
       
   741 			
       
   742 	if(msg && !msg->IsNull())
       
   743 		{
       
   744 		msg->ReadL(1,ptr1);
       
   745 		iDuplicateFont = iFunctions->DuplicateFontL(handle);
       
   746 		TInt id =0;
       
   747 		if (iDuplicateFont)
       
   748 			{
       
   749 			id = iDuplicateFont->TypeUid().iUid;
       
   750 			TPtr8 ptr2((TUint8*)&id, sizeof(TInt), sizeof(TInt));
       
   751 			msg->Write(2, ptr2);
       
   752 			}
       
   753 		}
       
   754 	else
       
   755 		{
       
   756 		return -1;
       
   757 		}
       
   758 		
       
   759 	return result;
       
   760 	}
       
   761 
       
   762 TInt CTWinAnim::DoCmdCloseFontL()
       
   763 	{
       
   764 	DoCmdDuplicateFontL();
       
   765 	iFunctions->CloseFont(iDuplicateFont);
       
   766 	return 0;
       
   767 	}
       
   768 
       
   769 TInt CTWinAnim::DoCmdSetIntervalL()
       
   770 	{
       
   771 	TInt result = 0;
       
   772 	TPtr8 ptr1((TUint8*)&iInterval, sizeof(TInt));
       
   773 	const RMessagePtr2 *msg=iFunctions->Message();
       
   774 			
       
   775 	if(msg && !msg->IsNull())
       
   776 		{
       
   777 		msg->ReadL(1,ptr1);
       
   778 		if (iIntervalTimeStamp)
       
   779 		delete [] iIntervalTimeStamp;
       
   780 		iIntervalTimeStamp=new (ELeave) TInt64[3];
       
   781 		iIntervalTimeStamp[0]=0;
       
   782 		iIntervalTimeStamp[1]=0;
       
   783 		iIntervalTimeStamp[2]=0;
       
   784 		iFunctions->SetInterval(iInterval);
       
   785 		iServerTimer->After( 5000000); // delay 5 second
       
   786 		}
       
   787 	else
       
   788 		{
       
   789 		result = -1;
       
   790 		}	
       
   791 
       
   792 	return result;
       
   793 	}
       
   794 
       
   795 TInt CTWinAnim::DoCmdSetNextIntervalL()
       
   796 	{
       
   797 	TInt result = 0;
       
   798 	TPtr8 ptr1((TUint8*)&iInterval, sizeof(TInt));
       
   799 	TPtr8 ptr2((TUint8*)&iNextInterval, sizeof(TInt));
       
   800 	const RMessagePtr2 *msg=iFunctions->Message();
       
   801 			
       
   802 	if(msg && !msg->IsNull())
       
   803 		{
       
   804 		msg->ReadL(1,ptr1);
       
   805 		msg->ReadL(2,ptr2);
       
   806 		if (iIntervalTimeStamp)
       
   807 			delete [] iIntervalTimeStamp;
       
   808 		
       
   809 		iIntervalTimeStamp=new (ELeave) TInt64[3];
       
   810 		iIntervalTimeStamp[0]=0;
       
   811 		iIntervalTimeStamp[1]=0;
       
   812 		iIntervalTimeStamp[2]=0;
       
   813 		iFunctions->SetInterval(iInterval);
       
   814 		iFunctions->SetNextInterval(iNextInterval);//2 flash = 1 second
       
   815 		if (iIntervalTimeStamp[0]==0)
       
   816 			{
       
   817 			TTime now;
       
   818 			now.HomeTime();
       
   819 			iIntervalTimeStamp[0]=now.Int64();
       
   820 			}
       
   821 
       
   822 		iServerTimer->After( 5000000); //delay 5 second
       
   823 		}
       
   824 	else
       
   825 		{
       
   826 		result = -1;
       
   827 		}
       
   828 		
       
   829 	return result;
       
   830 	}
       
   831 
       
   832 TInt CTWinAnim::DoCmdSystemTimeL()
       
   833 	{
       
   834 	TBool result = DoCmdSetSyncL();
       
   835 	if (result)
       
   836 		{
       
   837 		return result;
       
   838 		}
       
   839 	iFunctions->Animate(NULL);
       
   840 
       
   841 	TDateTime time = iFunctions->SystemTime();
       
   842 	MAnimGeneralFunctions::TAnimSync syncType = iFunctions->Sync();
       
   843 	switch (syncType)
       
   844 		{
       
   845 		case MAnimGeneralFunctions::ESyncDay:
       
   846 			if (time.Day() == iAnimateTime.Day())
       
   847 				{
       
   848 				result = ETrue;
       
   849 				}
       
   850 			else
       
   851 				{
       
   852 				result = EFalse;
       
   853 				}
       
   854 			break;
       
   855 		case MAnimGeneralFunctions::ESyncMinute:
       
   856 			if (time.Minute() == iAnimateTime.Minute() && time.Day()
       
   857 					== iAnimateTime.Day())
       
   858 				{
       
   859 				result = ETrue;
       
   860 				}
       
   861 			else
       
   862 				{
       
   863 				result = EFalse;
       
   864 				}
       
   865 			break;
       
   866 		case MAnimGeneralFunctions::ESyncFlash:
       
   867 		case MAnimGeneralFunctions::ESyncNone:
       
   868 		case MAnimGeneralFunctions::ESyncSecond:
       
   869 			if (time.Day() == iAnimateTime.Day() && time.Minute()
       
   870 					== iAnimateTime.Minute() && time.Second()
       
   871 					== iAnimateTime.Second())
       
   872 				{
       
   873 				result = ETrue;
       
   874 				}
       
   875 			else
       
   876 				{
       
   877 				result = EFalse;
       
   878 				}
       
   879 			break;
       
   880 		}
       
   881 	return result;
       
   882 	}
       
   883 
       
   884 TInt CTWinAnim::DoCmdRegisterForNotisL()
       
   885 	{
       
   886 	iResult = EFalse;
       
   887 	TUint32 notice;
       
   888 	TInt result = 0;
       
   889 	TPtr8 ptr1((TUint8*)&notice, sizeof(TUint32));
       
   890 	TPtr8 ptr2((TUint8*)&iExpectEventCode, sizeof(TEventCode));
       
   891 	const RMessagePtr2 *msg=iFunctions->Message();
       
   892 			
       
   893 	if(msg && !msg->IsNull())
       
   894 		{
       
   895 		msg->ReadL(1, ptr1);
       
   896 		msg->ReadL(2, ptr2);
       
   897 		iFunctions->RegisterForNotifications(notice);		
       
   898 		}
       
   899 	else
       
   900 		{
       
   901 		return -1;
       
   902 		}
       
   903 	
       
   904 	return result;
       
   905 	}
       
   906 
       
   907 TInt CTWinAnim::DoCmdMessageL()
       
   908 	{
       
   909 	TInt result;
       
   910 	TBuf<KBufMessage> message;
       
   911 	const RMessagePtr2 *msg=iFunctions->Message();
       
   912 			
       
   913 	if(msg && !msg->IsNull())
       
   914 		{
       
   915 		msg->ReadL(1,message);
       
   916 		msg->Write(2, message);
       
   917 		}
       
   918 	else
       
   919 		{
       
   920 		result = -1;
       
   921 		}
       
   922 	
       
   923 	return result;
       
   924 	}
       
   925 
       
   926 TInt CTWinAnim::DoCmdAnimateL()
       
   927 	{
       
   928 	TInt result = 0;
       
   929 	TDateTime time;
       
   930 	TPtr8 ptr1((TUint8*)&time, sizeof(TDateTime));
       
   931 	const RMessagePtr2 *msg=iFunctions->Message();
       
   932 			
       
   933 	if(msg && !msg->IsNull())
       
   934 		{
       
   935 		msg->ReadL(1,ptr1);
       
   936 		iResult = EFalse;
       
   937 		iFunctions->Animate(&time);
       
   938 		if (iDateTime.MicroSecond() == time.MicroSecond() && iDateTime.Minute()
       
   939 				== time.Minute() && iDateTime.Second() == time.Second())
       
   940 			{
       
   941 			iResult = ETrue;
       
   942 			}
       
   943 		else
       
   944 			{
       
   945 			iResult = EFalse;
       
   946 			}
       
   947 	
       
   948 		}
       
   949 	
       
   950 	return iResult;
       
   951 	}
       
   952 
       
   953 
       
   954 TInt CTWinAnim::DoCmdFlashStateOn()
       
   955 	{
       
   956 	TBool status = EFalse;
       
   957 	TTime time;
       
   958 	time.HomeTime();
       
   959 	TBool result = iFunctions->FlashStateOn();
       
   960 	TInt ms = time.DateTime().MicroSecond();
       
   961 	TInt H1Limit = 16000; //0.016 * 100000 = 1/64 * 1000000;
       
   962 	TInt H2Limit = 567000; // (7/12 - 1/64) * 1000000;
       
   963 	TInt H3Limit = 599000; // (7/12 + 1/64) * 1000000;
       
   964 	TInt H4Limit = 984000; // (1 - 0.016) * 1000000;
       
   965 	
       
   966 	if(ms < H1Limit || 
       
   967 			(ms > H2Limit && ms < H3Limit) ||
       
   968 			ms > H4Limit)
       
   969 		{
       
   970 		return -1;
       
   971 		}
       
   972 	
       
   973 	if (time.DateTime().MicroSecond() < 1000000 * 7/12)
       
   974 		{
       
   975 		status = ETrue;
       
   976 		}
       
   977 	else
       
   978 		{
       
   979 		status = EFalse;
       
   980 		}
       
   981 	
       
   982 	if (result == status)
       
   983 		{
       
   984 		status = ETrue;
       
   985 		}
       
   986 	else
       
   987 		{
       
   988 		status = EFalse;
       
   989 		}
       
   990 
       
   991 	return status;
       
   992 	}
       
   993 
       
   994 TInt CTWinAnim::DoCmdPanic()
       
   995 	{
       
   996 	iFunctions->Panic();
       
   997 	return 0;
       
   998 	}
       
   999 
       
  1000 TInt CTWinAnim::DoCmdScreenDevice()
       
  1001 	{
       
  1002 	TDisplayMode mode = iFunctions->ScreenDevice()->DisplayMode();
       
  1003 	return 0;
       
  1004 	}
       
  1005 
       
  1006 TInt CTWinAnim::DoCmdWindowExtension()
       
  1007 	{
       
  1008 	MAnimGeneralFunctionsWindowExtension* ext = iFunctions->WindowExtension();
       
  1009 	TInt screen = ext->FocusScreens();
       
  1010 	return 0;
       
  1011 	}
       
  1012 
       
  1013 TInt CTWinAnim::DoCmdEventExtension()
       
  1014 	{
       
  1015 	MAnimGeneralFunctionsEventExtension* ext = iFunctions->EventExtension();
       
  1016 	TKeyEvent event;
       
  1017 	event.iCode = EEventKeyDown;
       
  1018 	ext->PostKeyEvent(event, 1);
       
  1019 	return 0;
       
  1020 	}
       
  1021 
       
  1022 TInt CTWinAnim::DoCmdExtendedInterfaceL()
       
  1023 	{
       
  1024 	TInt result = 0;
       
  1025 	TInt interface;
       
  1026 	TPtr8 ptr1((TUint8*)&interface, sizeof(TInt));
       
  1027 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1028 				
       
  1029 	if(msg && !msg->IsNull())
       
  1030 		{
       
  1031 		msg->ReadL(1,ptr1);
       
  1032 		TAny* any = iFunctions->ExtendedInterface(interface);
       
  1033 		if (interface == 0)
       
  1034 			{
       
  1035 			//Zhang Yue modified.for the return result is a Int value, not a pointer address.
       
  1036 			result = (TInt)any;
       
  1037 			}
       
  1038 		else
       
  1039 			{
       
  1040 			if (interface == 1)
       
  1041 				{
       
  1042 				((MAnimGeneralFunctionsWindowExtension*) any)->FocusScreens();
       
  1043 				}
       
  1044 			else
       
  1045 				{
       
  1046 				if (interface == 2)
       
  1047 					{
       
  1048 					TKeyEvent event;
       
  1049 					event.iCode = EEventKeyDown;
       
  1050 					((MAnimGeneralFunctionsEventExtension*) any)->PostKeyEvent(
       
  1051 							event, 1);
       
  1052 					}
       
  1053 				else
       
  1054 					{
       
  1055 					if (any)
       
  1056 						{
       
  1057 						result = -1;
       
  1058 						}
       
  1059 					else
       
  1060 						{
       
  1061 						result = 0;
       
  1062 						}//end if (any)
       
  1063 					}//end if(interface 2)
       
  1064 				}//end if(interface)
       
  1065 			}//end if(interface)
       
  1066 	
       
  1067 		} //end if(msg)		
       
  1068 	else
       
  1069 		{
       
  1070 		result = -1;
       
  1071 		}
       
  1072 	
       
  1073 	return result;
       
  1074 	}
       
  1075 
       
  1076 TInt CTWinAnim::DoCmdNumOfExtInterfaces()
       
  1077 	{
       
  1078 	return iFunctions->NumberOfExtendedInterfaces();
       
  1079 	}
       
  1080 
       
  1081 TInt CTWinAnim::DoCmdSetSyncL()
       
  1082 	{
       
  1083 	TInt result = 0;
       
  1084 	MAnimGeneralFunctions::TAnimSync mode;
       
  1085 	TPtr8 ptr1((TUint8*)&mode, sizeof(MAnimGeneralFunctions::TAnimSync));
       
  1086 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1087 	if(msg && !msg->IsNull())
       
  1088 		{
       
  1089 		msg->ReadL(1,ptr1);
       
  1090 		iFunctions->SetSync(mode);		
       
  1091 		}
       
  1092 	else
       
  1093 		{
       
  1094 		return -1;
       
  1095 		}
       
  1096 	return result;
       
  1097 	}
       
  1098 
       
  1099 TInt CTWinAnim::DoCmdSync()
       
  1100 	{
       
  1101 	MAnimGeneralFunctions::TAnimSync mode = iFunctions->Sync();
       
  1102 	return mode;
       
  1103 	}
       
  1104 
       
  1105 TInt CTWinAnim::DoCmdGetRawEventsL()
       
  1106 	{
       
  1107 	TInt result = 0;
       
  1108 	TBool getevent;
       
  1109 	TPtr8 ptr1((TUint8*)&getevent, sizeof(TBool));
       
  1110 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1111 	if(msg && !msg->IsNull())
       
  1112 		{
       
  1113 		msg->ReadL(1,ptr1);
       
  1114 		iFunctions->GetRawEvents(getevent);
       
  1115 			
       
  1116 		}
       
  1117 	else
       
  1118 		{
       
  1119 		return -1;
       
  1120 		}
       
  1121 
       
  1122 	return result;
       
  1123 	}
       
  1124 
       
  1125 TInt CTWinAnim::DoCmdPostRawEventL()
       
  1126 	{
       
  1127 	iResult = EFalse;
       
  1128 	TInt result = 0;
       
  1129 	TRawEvent event;
       
  1130 	TPtr8 ptr1((TUint8*)&event, sizeof(TRawEvent));
       
  1131 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1132 	
       
  1133 	if(msg && !msg->IsNull())
       
  1134 		{
       
  1135 		msg->ReadL(1,ptr1);
       
  1136 		iFunctions->PostRawEvent(event);		
       
  1137 		}
       
  1138 	else
       
  1139 		{
       
  1140 		return -1;
       
  1141 		}
       
  1142 
       
  1143 	return result;
       
  1144 	}
       
  1145 
       
  1146 TInt CTWinAnim::DoCmdPostKeyEventL()
       
  1147 	{
       
  1148 	iResult = EFalse;
       
  1149 	TInt result = 0;
       
  1150 	TKeyEvent event;
       
  1151 	TPtr8 ptr1((TUint8*)&event, sizeof(TKeyEvent));
       
  1152 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1153 	
       
  1154 	if(msg && !msg->IsNull())
       
  1155 		{
       
  1156 		msg->ReadL(1,ptr1);
       
  1157 		iFunctions->PostKeyEvent(event);
       
  1158 		}
       
  1159 	else
       
  1160 		{
       
  1161 		result = -1;
       
  1162 		}
       
  1163 	return result;
       
  1164 	}
       
  1165 
       
  1166 TInt CTWinAnim::DoCmdClient()
       
  1167 	{
       
  1168 	return iFunctions->Client().Id();
       
  1169 	}
       
  1170 
       
  1171 TInt CTWinAnim::DoCmdGeneralReplyBuf8L()
       
  1172 	{
       
  1173 	TInt result;
       
  1174 	TBuf8<KBufMessage> message;
       
  1175 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1176 	if(msg && !msg->IsNull())
       
  1177 		{
       
  1178 		msg->ReadL(3,message);
       
  1179 		iFunctions->ReplyBuf(message);		
       
  1180 		}
       
  1181 	else
       
  1182 		{
       
  1183 		result = -1;
       
  1184 		}
       
  1185 	
       
  1186 	return result;
       
  1187 	}
       
  1188 
       
  1189 TInt CTWinAnim::DoCmdGeneralReplyBuf16L()
       
  1190 	{
       
  1191 	TInt result;
       
  1192 	TBuf<KBufMessage> message;
       
  1193 	const RMessagePtr2 *msg=iFunctions->Message();
       
  1194 	if(msg && !msg->IsNull())
       
  1195 		{
       
  1196 		msg->ReadL(3,message);
       
  1197 		iFunctions->ReplyBuf(message);
       
  1198 		}
       
  1199 	else
       
  1200 		{
       
  1201 		result = -1;
       
  1202 		}
       
  1203 	return result;
       
  1204 	}
       
  1205 
       
  1206 TInt CTWinAnim::DoCmdEatupMemory()
       
  1207 	{
       
  1208 	TInt leftsize=20;
       
  1209 
       
  1210 	// eat memory until fail to avaiable memory is less than is left size  
       
  1211 	TInt nTotalSize=User::Heap().Size();
       
  1212 	TAny* mem=User::AllocZ(nTotalSize);
       
  1213 
       
  1214 	if (mem)
       
  1215 		iMemArray.Append(mem);
       
  1216 
       
  1217 	do
       
  1218 		{
       
  1219 		mem=User::AllocZ(leftsize);
       
  1220 		if (mem)
       
  1221 			{
       
  1222 			iMemArray.Append(mem);
       
  1223 			}
       
  1224 		}
       
  1225 	while (mem);
       
  1226 
       
  1227 	iAvaiableSpace=User::Available(iBiggestBlock);
       
  1228 	return 0;
       
  1229 	}
       
  1230 
       
  1231 TInt CTWinAnim::DoCmdFreeEatenMemory()
       
  1232 	{
       
  1233 	FreeMemory();
       
  1234 	return 0;
       
  1235 	}
       
  1236 
       
  1237 void CTWinAnim::FreeMemory()
       
  1238 	{
       
  1239 	for (TInt i=0; i<iMemArray.Count(); i++)
       
  1240 		{
       
  1241 		TAny* mem=iMemArray[i];
       
  1242 		User::Free(mem);
       
  1243 		}
       
  1244 
       
  1245 	iMemArray.Reset();
       
  1246 	}