os/graphics/windowing/windowserver/test/SHELL.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/SHELL.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1551 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Shell to launch test code
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <f32file.h>
    1.23 +#include "W32STD.H"
    1.24 +#include "../SERVER/w32cmd.h"
    1.25 +#include <e32svr.h>
    1.26 +#include <hal.h>
    1.27 +#include "../test/tlib/testbase.h"
    1.28 +#include "../test/TClick/CLICK.H"
    1.29 +
    1.30 +#define __USING_PROCESS_
    1.31 +
    1.32 +#if !defined(__USING_PROCESS_)
    1.33 +#define RP_FILENAME_SET _L(".DLL")
    1.34 +#endif
    1.35 +
    1.36 +#define THE_PASSWORD _L("pass")
    1.37 +#define INDEX_FOR_SHELL_TEST 0
    1.38 +#define SHELL_TEST_NAME _L("ShellTest")
    1.39 +#define INDEX_FOR_RESTART_TEST 1
    1.40 +#define RESTART_TEST_NAME _L("RestartTest")
    1.41 +#define INDEX_FOR_RESTART_EVENT_TEST 2
    1.42 +#define RESTART_EVENT_TEST_NAME _L("RestartEventTest")
    1.43 +
    1.44 +const TInt EDoubleClickTime=500000;
    1.45 +const TInt EDoubleClickDistance=16;
    1.46 +
    1.47 +#ifndef __USING_PROCESS_
    1.48 +LOCAL_D const TUint KHeapSize=0x400000;
    1.49 +#endif
    1.50 +
    1.51 +enum TShellPanic
    1.52 +	{
    1.53 +	EShellPanicRunningProcessCancel,
    1.54 +	EShellPanicTemp,
    1.55 +	EShellPanicRunningProcessNullPtr,
    1.56 +	EShellPanicPassword,
    1.57 +	};
    1.58 +
    1.59 +typedef TInt (*DllTestAppEntryPoint)(TAny *aParam);
    1.60 +
    1.61 +class CShellClient;
    1.62 +
    1.63 +class RShellWsSession : public RWsSession
    1.64 +	{
    1.65 +public:
    1.66 +	static void Shutdown();
    1.67 +	void SendShutdown();
    1.68 +	};
    1.69 +
    1.70 +class MProcessObserver
    1.71 +	{
    1.72 +public:
    1.73 +	virtual void ProcessDied()=0;
    1.74 +	};
    1.75 +
    1.76 +class CRunningProcess : public CActive
    1.77 +	{
    1.78 +public:
    1.79 +	CRunningProcess(MProcessObserver* aObserver);
    1.80 +	~CRunningProcess();
    1.81 +	void ConstructL(const TDesC& aName);
    1.82 +	void ConstructTestExecuteL(const TDesC &aName);
    1.83 +	void Link(CRunningProcess** aRpPtr);
    1.84 +#if defined(__USING_PROCESS_)
    1.85 +	inline RProcess& Process() {return iProcess;}
    1.86 +#else
    1.87 +	inline RThread& Process() {return iProcess;}
    1.88 +#endif
    1.89 +private:
    1.90 +	virtual void DoCancel();
    1.91 +	virtual void RunL();
    1.92 +private:
    1.93 +#if defined(__WINS__)
    1.94 +	RLibrary iLib;
    1.95 +#endif
    1.96 +#if defined(__USING_PROCESS_)
    1.97 +	RProcess iProcess;
    1.98 +#else
    1.99 +	RThread iProcess;
   1.100 +#endif
   1.101 +	CRunningProcess* iNext;
   1.102 +	CRunningProcess** iPrevPtr;
   1.103 +	TParse iFileName;
   1.104 +	MProcessObserver* iObserver;
   1.105 +	};
   1.106 +
   1.107 +class CShellErrorDialog : public CTDialog
   1.108 +	{		  
   1.109 +public:
   1.110 +	CShellErrorDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc);
   1.111 +	void ButtonPressL(TInt aButton);
   1.112 +	void ConstructLD();
   1.113 +private:
   1.114 +	CTWindowGroup *iGroupWin;
   1.115 +	CWindowGc *iGc;
   1.116 +	};
   1.117 +
   1.118 +class CTCalibWindow : public CTWin
   1.119 +	{
   1.120 +public:
   1.121 +	CTCalibWindow();
   1.122 +	void InitWin();
   1.123 +	void DrawPoint(const TPoint &aPoint, const TDesC &aText);
   1.124 +	void Draw();
   1.125 +	void PointerL(const TPointerEvent &aPointer,const TTime& aTime);
   1.126 +private:
   1.127 +	TInt iCount;
   1.128 +	TDigitizerCalibration iCalibPoints;
   1.129 +	TDigitizerCalibration iReturnValues;
   1.130 +	};
   1.131 +
   1.132 +
   1.133 +class CListWindow : public CTTitledWindow
   1.134 +	{
   1.135 +public:
   1.136 +	CListWindow();
   1.137 +	void CloseWindow();
   1.138 +	void ConstructL(CTWinBase &parent, TBool aExitOnEscape);
   1.139 +	void Draw();
   1.140 +	virtual void SelectedL(TInt aIndex)=0;
   1.141 +	virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime);
   1.142 +	void SetExt(const TPoint &aPos, const TSize &aSize);
   1.143 +	void SetSize(const TSize &);
   1.144 +protected:
   1.145 +	virtual TPtrC GetText(TInt aLine)=0;
   1.146 +	virtual TInt ListCount()=0;
   1.147 +	void SetSize();
   1.148 +	void PointerL(const TPointerEvent &aPointer,const TTime& aTime);
   1.149 +private:
   1.150 +	void Resized(const TSize &aSize);
   1.151 +	void SetListPos(TInt aNewPos);
   1.152 +	TInt TextRowHeight() const;
   1.153 +	void RowBox(TRect &aRect, TInt aRow) const;
   1.154 +private:
   1.155 +	TRgb iColorMap[4];
   1.156 +	TInt iListPos;
   1.157 +	TTime iPrevTime;
   1.158 +	TBool iExitOnEscape;
   1.159 +	};
   1.160 +
   1.161 +class CShellWindow : public CListWindow, public MProcessObserver
   1.162 +	{
   1.163 +public:
   1.164 +	CShellWindow();
   1.165 +	~CShellWindow();
   1.166 +	void ConstructL(CTWinBase &parent);
   1.167 +	TBool RunClientL(const TDesC &aName,TBool aTestExecute);
   1.168 +	void SelectedL(TInt aIndex);
   1.169 +	virtual void WinKeyL(const TKeyEvent &aKey,const TTime& aTime);
   1.170 +	void ForegroundAppDialogL();
   1.171 +	void HeapCountDialogL();
   1.172 +	void SetPointerZone(TInt aZone);
   1.173 +	void SetAutoLaunch(TBool aAutoLaunch);
   1.174 +	// Virtual function defined in CTBaseWin and overriden in CListWindow
   1.175 +	void PointerL(const TPointerEvent &aPointer,const TTime& aTime);
   1.176 +	// Virtual function defined in CTBaseWin and overriden in CTTitledWindow
   1.177 +	void FocusChanged(TBool aState);
   1.178 +private:
   1.179 +	void DoShellTests();
   1.180 +	void BugHunt();
   1.181 +	void CheckTerminate();
   1.182 +	//Pure virtual functions defined in CListWindow
   1.183 +	TPtrC GetText(TInt aLine);
   1.184 +	TInt ListCount();
   1.185 +	//Pure virtual function defined in MProcessObserver
   1.186 +	void ProcessDied();
   1.187 +	//Simulates SwitchOffEvent
   1.188 +	void SimulateSwitchOffEvent();
   1.189 +#ifdef SYMBIAN_PROCESS_MONITORING_AND_STARTUP	
   1.190 +	//Simulates RestartSystemEvent
   1.191 +	void SimulateRestartEvent();
   1.192 +	//Simulates RestartSystemEvent and test the receiving of off event
   1.193 +	void SimulateAndReceiveRestartEvent();
   1.194 +#endif
   1.195 +	
   1.196 +private:
   1.197 +	TBool iFailModeEnabled;
   1.198 +	TInt iPointerZone;
   1.199 +	CRunningProcess *iProcessList;
   1.200 +	CArrayFixFlat<TFileName> iFileNames;
   1.201 +	CTPointerCursor *iPointerCursor;
   1.202 +	RSoundPlugIn iClick;
   1.203 +	TInt iCaptureKey;
   1.204 +	TBool iAutoLaunch;
   1.205 +	TInt iNumWindowGroups;
   1.206 +	TBool iIsFocused;
   1.207 +	};
   1.208 +
   1.209 +class CTIconWindow : public CTBlankWindow
   1.210 +	{
   1.211 +public:
   1.212 +	CTIconWindow(TInt aType);
   1.213 +	void InitWinL();
   1.214 +	void SetExtentL();
   1.215 +private:
   1.216 +	TInt iType;
   1.217 +	};
   1.218 +
   1.219 +class CTPasswordWindow: public CTTitledWindow
   1.220 +	{
   1.221 +public:
   1.222 +	CTPasswordWindow();
   1.223 +	void InitWin();
   1.224 +	void Draw();
   1.225 +private:
   1.226 +	TPoint iTextPos;
   1.227 +	};
   1.228 +
   1.229 +class CTaskListWindow : public CListWindow
   1.230 +	{
   1.231 +public:
   1.232 +	CTaskListWindow();
   1.233 +	void ConstructL(CTWinBase &parent);
   1.234 +	void SelectedL(TInt aIndex);
   1.235 +private:
   1.236 +	virtual TPtrC GetText(TInt aLine);
   1.237 +	virtual TInt ListCount();
   1.238 +private:
   1.239 +	CArrayFixFlat<TInt> iWindowHandles;
   1.240 +	CArrayFixFlat<TFullName> iWindowThreadNames;
   1.241 +	TBuf<KMaxFullName+KMaxName+2> iLatestText;
   1.242 +	};
   1.243 +
   1.244 +class CShellWindowGroup : public CTWindowGroup
   1.245 +	{
   1.246 +public:
   1.247 +	CShellWindowGroup(CTClient *aClient);
   1.248 +	~CShellWindowGroup();
   1.249 +	void ConstructL();
   1.250 +	void KeyL(const TKeyEvent &aKey,const TTime& aTime);
   1.251 +	void ErrorMessage(const TWsErrorMessage &aErrorMessage, const TTime &);
   1.252 +	void ScreenDeviceChangedL();
   1.253 +private:
   1.254 +	TUint32 iCapHandle1;
   1.255 +	TUint32 iCapHandle2;
   1.256 +	TUint32 iCapHandle3;
   1.257 +	TUint32 iCapHandle4;
   1.258 +	};
   1.259 +
   1.260 +class CIconWindowGroup : public CTWindowGroup
   1.261 +	{
   1.262 +public:
   1.263 +	CIconWindowGroup(CTClient *aClient);
   1.264 +	void ConstructL();
   1.265 +	};
   1.266 +
   1.267 +class CPasswordWindowGroup : public CTWindowGroup
   1.268 +	{
   1.269 +public:
   1.270 +	CPasswordWindowGroup(CTClient *aClient);
   1.271 +	~CPasswordWindowGroup();
   1.272 +	void ConstructL();
   1.273 +	void KeyL(const TKeyEvent &aKey,const TTime&aTime);
   1.274 +	void Cancel();
   1.275 +	void PasswordL(const TTime &aTime);
   1.276 +private:
   1.277 +	CTPasswordWindow *iWin;
   1.278 +	TBool iPasswordMode;
   1.279 +	};
   1.280 +
   1.281 +class CShellClient : public CTClient
   1.282 +	{
   1.283 +public:
   1.284 +	CShellClient();
   1.285 +	~CShellClient();
   1.286 +	void ConstructL();
   1.287 +	void KeyL(const TKeyEvent &aKey,const TTime& aTime);
   1.288 +	void Exit();
   1.289 +	void CreateTestWindowL(CTWin *aWin, const TPoint &aPos);
   1.290 +	void CreateTestWindowL(CTWin *win, const TPoint &aPos, CTWinBase *parent);
   1.291 +	void ErrorDialog(const TDesC &aTitle, TInt aErr);
   1.292 +	void ScreenDeviceChangedL();
   1.293 +public:
   1.294 +	RFs iFs;
   1.295 +private:
   1.296 +	TInt iNum;
   1.297 +	CTWindowGroup *iIconGroup;
   1.298 +	CTIconWindow *iIconWin1;
   1.299 +	CTIconWindow *iIconWin2;
   1.300 +	CTPointerCursor *iPointerCursor;
   1.301 +	CPasswordWindowGroup *iPasswordGroup;
   1.302 +	};
   1.303 +
   1.304 +class ROverrideProtectionInRSessionBase : public RWsSession
   1.305 +	{
   1.306 +public:
   1.307 +	inline TInt Send(TInt aFunction) const {return(RSessionBase::Send(aFunction,TIpcArgs()));};
   1.308 +	};
   1.309 +
   1.310 +const TInt Xmove=8;
   1.311 +const TInt Ymove=6;
   1.312 +
   1.313 +const TInt ENumPointerCursors=2;
   1.314 +
   1.315 +void DrawShellDragCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aParam);
   1.316 +void DrawShellListCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *aParam);
   1.317 +
   1.318 +TSpriteCreateParams spriteParams1(TSize(32,32),TPoint(-16,-16),DrawShellListCursor,NULL,EFalse,CGraphicsContext::EDrawModeXOR);
   1.319 +TSpriteCreateParams spriteParams2(TSize(32,32),TPoint(-16,-16),DrawShellDragCursor,NULL,ETrue,CGraphicsContext::EDrawModePEN);
   1.320 +
   1.321 +TSpriteCreateParams *PointerParams[ENumPointerCursors]={&spriteParams1,&spriteParams2};
   1.322 +
   1.323 +
   1.324 +void Panic(TInt aPanic)
   1.325 +	{
   1.326 +	User::Panic(_L("Shell"),aPanic);
   1.327 +	}
   1.328 +
   1.329 +void RShellWsSession::Shutdown()
   1.330 +	{
   1.331 +	RShellWsSession ShellSession;
   1.332 +	ShellSession.Connect();
   1.333 +	ShellSession.SendShutdown();
   1.334 +	}
   1.335 +
   1.336 +void RShellWsSession::SendShutdown()
   1.337 +	{
   1.338 +	SendReceive(EWservMessShutdown,TIpcArgs(EWservShutdownCheck));
   1.339 +	}
   1.340 +
   1.341 +//
   1.342 +// Sprite drawing functions //
   1.343 +//
   1.344 +
   1.345 +void DrawPointerCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
   1.346 +	{
   1.347 +	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
   1.348 +	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.349 +	aGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.350 +	aGc->DrawRect(TRect(aSize));
   1.351 +	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.352 +	aGc->SetPenColor(TRgb::Gray4(3));
   1.353 +	aGc->SetBrushColor(TRgb::Gray4(3));
   1.354 +	aGc->DrawRect(TRect(0,aSize.iHeight/2-1,aSize.iWidth,aSize.iHeight/2+2));
   1.355 +	aGc->DrawRect(TRect(aSize.iWidth/2-1,0,aSize.iWidth/2+2,aSize.iHeight));
   1.356 +	if (!aDoMask)
   1.357 +		{
   1.358 +		aGc->SetPenColor(TRgb::Gray4(0));
   1.359 +		aGc->DrawLine(TPoint(0,aSize.iHeight/2),TPoint(aSize.iWidth,aSize.iHeight/2));
   1.360 +		aGc->DrawLine(TPoint(aSize.iWidth/2,0),TPoint(aSize.iWidth/2,aSize.iHeight));
   1.361 +		}
   1.362 +	}
   1.363 +
   1.364 +void DrawShellDragCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool aDoMask, TAny *)
   1.365 +	{
   1.366 +	aGc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
   1.367 +	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.368 +	aGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.369 +	aGc->DrawRect(TRect(aSize));
   1.370 +	aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.371 +	aGc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 1));
   1.372 +	for(TInt y=0;y<aSize.iHeight;y++)
   1.373 +		{
   1.374 +		TInt xfact=aSize.iWidth*Abs(y-aSize.iHeight/2)/aSize.iHeight;
   1.375 +		aGc->DrawLine(TPoint(xfact,y),TPoint(aSize.iWidth-xfact,y));
   1.376 +		}
   1.377 +	}
   1.378 +
   1.379 +void DrawShellListCursor(CBitmapContext *aGc,TInt , const TSize &aSize, TBool , TAny *)
   1.380 +	{
   1.381 +	aGc->SetBrushColor(TRgb::Gray4(0));
   1.382 +	aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.383 +	aGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.384 +	aGc->DrawRect(TRect(aSize));
   1.385 +	aGc->SetBrushColor(TRgb::Gray4(3));
   1.386 +	aGc->DrawRect(TRect(0,aSize.iHeight/2-1,aSize.iWidth,aSize.iHeight/2+2));
   1.387 +	aGc->DrawRect(TRect(aSize.iWidth/2-1,0,aSize.iWidth/2+2,aSize.iHeight));
   1.388 +	}
   1.389 +
   1.390 +//
   1.391 +// Calibration window //
   1.392 +//
   1.393 +
   1.394 +CTCalibWindow::CTCalibWindow()
   1.395 +	{
   1.396 +	}
   1.397 +
   1.398 +void CTCalibWindow::InitWin()
   1.399 +	{
   1.400 +	UserHal::CalibrationPoints(iCalibPoints);
   1.401 +	AssignGC(*Client()->iGc);
   1.402 +	iWin.SetOrdinalPosition(0,1);
   1.403 +	iWin.Activate();
   1.404 +	}
   1.405 +
   1.406 +void CTCalibWindow::DrawPoint(const TPoint &aPoint, const TDesC &aText)
   1.407 +	{
   1.408 +	iGc->MoveTo(aPoint);
   1.409 +	iGc->MoveBy(TPoint(0,-20));
   1.410 +	iGc->DrawLineBy(TPoint(0,40));
   1.411 +	iGc->MoveBy(TPoint(-20,-20));
   1.412 +	iGc->DrawLineBy(TPoint(40,0));
   1.413 +	iGc->DrawText(aText, aPoint+TPoint(4,-4));
   1.414 +	}
   1.415 +
   1.416 +void CTCalibWindow::Draw()
   1.417 +	{
   1.418 +	iGc->Clear();
   1.419 +	DrawPoint(iCalibPoints.iTl,_L("1"));
   1.420 +	DrawPoint(iCalibPoints.iBl,_L("2"));
   1.421 +	DrawPoint(iCalibPoints.iTr,_L("3"));
   1.422 +	DrawPoint(iCalibPoints.iBr,_L("4"));
   1.423 +	}
   1.424 +
   1.425 +void CTCalibWindow::PointerL(const TPointerEvent &aPointer,const TTime& )
   1.426 +	{
   1.427 +	if (aPointer.iType==TPointerEvent::EButton1Down)
   1.428 +		{
   1.429 +		switch(iCount++)
   1.430 +			{
   1.431 +			case 0:
   1.432 +				iReturnValues.iTl=aPointer.iPosition;
   1.433 +				break;
   1.434 +			case 1:
   1.435 +				iReturnValues.iBl=aPointer.iPosition;
   1.436 +				break;
   1.437 +			case 2:
   1.438 +				iReturnValues.iTr=aPointer.iPosition;
   1.439 +				break;
   1.440 +			case 3:
   1.441 +				iReturnValues.iBr=aPointer.iPosition;
   1.442 +				UserHal::SetXYInputCalibration(iReturnValues);
   1.443 +				delete this;
   1.444 +				break;
   1.445 +			}
   1.446 +		}
   1.447 +	}
   1.448 +
   1.449 +//
   1.450 +// Error dialog //
   1.451 +//
   1.452 +
   1.453 +CShellErrorDialog::CShellErrorDialog(CTWindowGroup *aGroupWin,CWindowGc *aGc) : CTDialog(),
   1.454 +	iGroupWin(aGroupWin),
   1.455 +	iGc(aGc)
   1.456 +	{
   1.457 +	}
   1.458 +
   1.459 +void CShellErrorDialog::ButtonPressL(TInt aButton)
   1.460 +	{
   1.461 +	if (aButton==0)
   1.462 +		CTDialog::ButtonPressL(aButton);
   1.463 +	}
   1.464 +
   1.465 +void CShellErrorDialog::ConstructLD()
   1.466 +	{
   1.467 +	CTDialog::ConstructLD(*iGroupWin, *iGc);
   1.468 +	}
   1.469 +
   1.470 +//
   1.471 +// Offscreen icon->button window //
   1.472 +//
   1.473 +
   1.474 +CTIconWindow::CTIconWindow(TInt aType) : iType(aType)
   1.475 +	{
   1.476 +	}
   1.477 +
   1.478 +void CTIconWindow::InitWinL()
   1.479 +	{
   1.480 +	SetExtentL();
   1.481 +	iWin.SetShadowDisabled(ETrue);
   1.482 +	Activate();
   1.483 +	}
   1.484 +
   1.485 +void CTIconWindow::SetExtentL()
   1.486 +	{
   1.487 +	enum {ENumYKeys=5};
   1.488 +	enum {ENumXKeys=9};
   1.489 +	TRect digRect(Client()->iScreen->PointerRect());
   1.490 +	TSize scrSize(Client()->iScreen->SizeInPixels());
   1.491 +	TInt ypos=0;
   1.492 +	TInt count=0;
   1.493 +	iWin.RemoveAllKeyRects();
   1.494 +	if (iType==0)
   1.495 +		{
   1.496 +		for (;count<ENumYKeys;count++)
   1.497 +			{
   1.498 +			TInt oldypos=ypos;
   1.499 +			ypos=digRect.iTl.iY+(count+1)*digRect.Height()/ENumYKeys;
   1.500 +			User::LeaveIfError(iWin.AddKeyRect(TRect(0,oldypos,-digRect.iTl.iX,ypos),'A'+count,ETrue));
   1.501 +			}
   1.502 +		iWin.SetExtent(digRect.iTl,TSize(-digRect.iTl.iX,scrSize.iHeight));
   1.503 +		}
   1.504 +	else
   1.505 +		{
   1.506 +		TInt xpos=0;
   1.507 +		for (count=0;count<ENumXKeys;count++)
   1.508 +			{
   1.509 +			TInt oldxpos=xpos;
   1.510 +			xpos=digRect.iTl.iY+(count+1)*digRect.Width()/ENumXKeys;
   1.511 +			User::LeaveIfError(iWin.AddKeyRect(TRect(oldxpos,0,xpos,digRect.iBr.iY-scrSize.iHeight), EStdKeyF1+count, EFalse));
   1.512 +			}
   1.513 +		iWin.SetExtent(TPoint(digRect.iTl.iX,scrSize.iHeight),TSize(digRect.Width(),digRect.Height()-scrSize.iHeight));
   1.514 +		}
   1.515 +	}
   1.516 +
   1.517 +//
   1.518 +// Individual window sub-classes
   1.519 +//
   1.520 +
   1.521 +void CShellClient::ErrorDialog(const TDesC &aTitle, TInt aErr)
   1.522 +	{
   1.523 +	TBuf<0x20> err;
   1.524 +	err.Format(TRefByValue<const TDesC>(_L("Error %d")),aErr);
   1.525 +	DisplayDialog(this, aTitle, err,_L(""));
   1.526 +	}
   1.527 +
   1.528 +CListWindow::CListWindow() : CTTitledWindow(), iPrevTime(0)
   1.529 +	{
   1.530 +	iColorMap[0]=TRgb::Gray4(0);
   1.531 +	iColorMap[1]=TRgb::Gray4(3);
   1.532 +	iColorMap[2]=TRgb::Gray4(3);
   1.533 +	iColorMap[3]=TRgb::Gray4(0);
   1.534 +	}
   1.535 +
   1.536 +void CListWindow::CloseWindow()
   1.537 +	{
   1.538 +	CTClient *client=((CShellClient *)Client());
   1.539 +	CTWin::Delete(this);
   1.540 +	client->ResetFocus();
   1.541 +	}
   1.542 +
   1.543 +void CListWindow::SetExt(const TPoint &aPos, const TSize &)
   1.544 +	{
   1.545 +	SetPos(aPos);
   1.546 +	}
   1.547 +
   1.548 +void CListWindow::SetSize(const TSize &)
   1.549 +	{
   1.550 +	}
   1.551 +
   1.552 +void CListWindow::SetSize()
   1.553 +	{
   1.554 +	iSize.iHeight=ListCount()*(iFont->HeightInPixels()+1)+iTitleHeight+2;
   1.555 +	iSize.iWidth=iFont->TextWidthInPixels(*Client()->Title())+30;
   1.556 +	for(TInt index=0;index<ListCount();index++)
   1.557 +		{
   1.558 +		TInt wid=iFont->TextWidthInPixels(GetText(index));
   1.559 +		if (wid>iSize.iWidth)
   1.560 +			iSize.iWidth=wid;
   1.561 +		}
   1.562 +	iSize.iWidth+=4;
   1.563 +	iWin.SetSize(iSize);
   1.564 +	Resized(iSize);
   1.565 +	}
   1.566 +
   1.567 +void CListWindow::ConstructL(CTWinBase &parent, TBool aExitOnEscape)
   1.568 +	{
   1.569 +	iExitOnEscape=aExitOnEscape;
   1.570 +	CTTitledWindow::ConstructL(parent);
   1.571 +	}
   1.572 +
   1.573 +void CListWindow::SetListPos(TInt aNewPos)
   1.574 +	{
   1.575 +	if (aNewPos>=0 && aNewPos<ListCount())
   1.576 +		{
   1.577 +		iListPos=aNewPos;
   1.578 +		Invalidate();
   1.579 +		}
   1.580 +	}
   1.581 +
   1.582 +void CListWindow::WinKeyL(const TKeyEvent &aKey, const TTime&)
   1.583 +	{
   1.584 +	switch(aKey.iCode)
   1.585 +		{
   1.586 +		case EKeyUpArrow:
   1.587 +			SetListPos(iListPos-1);
   1.588 +			break;
   1.589 +		case EKeyDownArrow:
   1.590 +			SetListPos(iListPos+1);
   1.591 +			break;
   1.592 +		case EKeyEnter:
   1.593 +			SelectedL(iListPos);
   1.594 +			break;
   1.595 +		case EKeyEscape:		// Fall through from EKeyEnter
   1.596 +			if (iExitOnEscape)
   1.597 +				CloseWindow();
   1.598 +			break;
   1.599 +		}
   1.600 +	}
   1.601 +
   1.602 +void CListWindow::PointerL(const TPointerEvent &aPointer,const TTime& aTime)
   1.603 +	{
   1.604 +	if (aPointer.iType==TPointerEvent::EButton1Down)
   1.605 +		{
   1.606 +		TRect rect;
   1.607 +		for(TInt index=0;index<ListCount();index++)
   1.608 +			{
   1.609 +			RowBox(rect,index);
   1.610 +			if (rect.Contains(aPointer.iPosition))
   1.611 +				{
   1.612 +				if (index==iListPos && (aPointer.iModifiers&EModifierDoubleClick /*|| index<=INDEX_FOR_SHELL_TEST*/))
   1.613 +					SelectedL(iListPos);
   1.614 +				else
   1.615 +					{
   1.616 +					iPrevTime=aTime;
   1.617 +					SetListPos(index);
   1.618 +					}
   1.619 +				return;
   1.620 +				}
   1.621 +			}
   1.622 +		}
   1.623 +	CTTitledWindow::PointerL(aPointer,aTime);
   1.624 +	}
   1.625 +
   1.626 +TInt CListWindow::TextRowHeight() const
   1.627 +	{
   1.628 +	return(iFont->HeightInPixels()+1);
   1.629 +	}
   1.630 +
   1.631 +void CListWindow::RowBox(TRect &aRect, TInt aRow) const
   1.632 +	{
   1.633 +	aRect.iTl.iX=2;
   1.634 +	aRect.iTl.iY=iTitleHeight+TextRowHeight()*aRow;
   1.635 +	aRect.iBr.iX=iSize.iWidth-2;
   1.636 +	aRect.iBr.iY=aRect.iTl.iY+TextRowHeight();
   1.637 +	}
   1.638 +
   1.639 +void CListWindow::Draw()
   1.640 +	{
   1.641 +	CTTitledWindow::Draw();
   1.642 +	iGc->SetPenColor(TRgb::Gray16(0));
   1.643 +	TPoint pos(2,iTitleHeight+iFont->AscentInPixels()+2);
   1.644 +	TInt gap=TextRowHeight();
   1.645 +	for(TInt index=0;index<ListCount();index++,pos.iY+=gap)
   1.646 +		{
   1.647 +		iGc->DrawText(GetText(index), pos);
   1.648 +		if (index==iListPos)
   1.649 +			{
   1.650 +			TRect rect;
   1.651 +			RowBox(rect,index);
   1.652 +			iGc->MapColors(rect,iColorMap);
   1.653 +			}
   1.654 +		}
   1.655 +	}
   1.656 +
   1.657 +void CListWindow::Resized(const TSize &aSize)
   1.658 +	{
   1.659 +	SetDragRect(TRect(0,0,aSize.iWidth,iTitleHeight));
   1.660 +	}
   1.661 +
   1.662 +//
   1.663 +// CShellWindow class //
   1.664 +//
   1.665 +
   1.666 +CShellWindow::CShellWindow() : CListWindow(), iFileNames(4)
   1.667 +	{
   1.668 +	}
   1.669 +
   1.670 +CShellWindow::~CShellWindow()
   1.671 +	{
   1.672 +	if (iCaptureKey)
   1.673 +		Client()->iGroup->GroupWin()->CancelCaptureKey(iCaptureKey);
   1.674 +	delete iPointerCursor;
   1.675 +	while(iProcessList)
   1.676 +		delete iProcessList;
   1.677 +	}
   1.678 +
   1.679 +void CShellWindow::SetPointerZone(TInt aZone)
   1.680 +	{
   1.681 +	TRAPD(err,iPointerCursor->UpdateL(0, PointerParams[aZone]));
   1.682 +	if (err!=KErrNone)
   1.683 +		((CShellClient *)Client())->ErrorDialog(_L("Error Changing Pointer"), err);
   1.684 +	else
   1.685 +		iPointerZone=aZone;
   1.686 +	}
   1.687 +
   1.688 +void CShellWindow::SetAutoLaunch(TBool aAutoLaunch)
   1.689 +	{
   1.690 +	iAutoLaunch=aAutoLaunch;
   1.691 +	if (aAutoLaunch)
   1.692 +		iNumWindowGroups=Client()->iWs.NumWindowGroups();
   1.693 +	}
   1.694 +
   1.695 +void CShellWindow::PointerL(const TPointerEvent &aPointer,const TTime& aTime)
   1.696 +	{
   1.697 +	TInt zone=(aPointer.iPosition.iY<iTitleHeight) ? 1 : 0;
   1.698 +	if (iPointerZone!=zone)
   1.699 +		SetPointerZone(zone);
   1.700 +	CListWindow::PointerL(aPointer,aTime);
   1.701 +	}
   1.702 +
   1.703 +void CShellWindow::ConstructL(CTWinBase &parent)
   1.704 +	{
   1.705 +	CListWindow::ConstructL(parent, EFalse);
   1.706 +	RFile dllList;
   1.707 +	RProcess thisProc;
   1.708 +	TParse dllListFileName;
   1.709 +#if defined(__USING_PROCESS_)
   1.710 +	TFileName fName(thisProc.FileName());
   1.711 +	User::LeaveIfError(dllListFileName.Set(_L("\\SYSTEM\\DATA\\DLL_LIST.TXT"),&fName,NULL));
   1.712 +	User::LeaveIfError(dllList.Open(((CShellClient *)Client())->iFs,dllListFileName.FullName(),EFileShareReadersOnly|EFileStreamText));
   1.713 +#else
   1.714 +	User::LeaveIfError(dllList.Open(((CShellClient *)Client())->iFs,_L("Z:\\SYSTEM\\DATA\\DLL_LIST.TXT"),EFileShareReadersOnly|EFileStreamText));
   1.715 +#endif
   1.716 +	TBuf8<0x200> dllNames;
   1.717 +	User::LeaveIfError(dllList.Read(dllNames));
   1.718 +	dllList.Close();
   1.719 +	TPtrC8 name(dllNames);
   1.720 +	FOREVER
   1.721 +		{
   1.722 +		TInt pos=name.Locate('\r');
   1.723 +		if (pos==KErrNotFound)
   1.724 +			break;
   1.725 +		if (pos<=KMaxFileName)
   1.726 +			{
   1.727 +			TFileName buf;
   1.728 +			buf.Copy(name.Left(pos));
   1.729 +			iFileNames.AppendL(buf);
   1.730 +			}
   1.731 +		name.Set(name.Mid(pos+2));
   1.732 +		};
   1.733 +	SetSize();
   1.734 +	BaseWin()->PointerFilter(EPointerFilterMove|EPointerFilterDrag,0);
   1.735 +	iPointerCursor=new(ELeave) CTPointerCursor(Client()->iWs);
   1.736 +	iPointerCursor->ConstructL(0);
   1.737 +	SetPointerZone(0);
   1.738 +	iWin.SetCustomPointerCursor(iPointerCursor->PointerCursor());
   1.739 +	iClick=RSoundPlugIn(Client()->iWs);
   1.740 +	User::LeaveIfError(iClick.Construct(TUid::Uid(CLICK_THIRD_UID)));
   1.741 +	TBool isChangeAble;
   1.742 +	if (iClick.IsLoaded(isChangeAble))
   1.743 +		{
   1.744 +		TInt ret=Client()->iGroup->GroupWin()->CaptureKey(3,EModifierCtrl|EModifierShift|EModifierFunc
   1.745 +																	,EModifierCtrl|EModifierShift|EModifierFunc);	//Ctrl-Alt-Shift-C
   1.746 +		User::LeaveIfError(ret);
   1.747 +		iCaptureKey=ret;
   1.748 +		}
   1.749 +	}
   1.750 +
   1.751 +TBool CShellWindow::RunClientL(const TDesC &aName,TBool aTestExecute)
   1.752 +	{
   1.753 +	if (aName.Length()!=0)
   1.754 +		{
   1.755 +		CRunningProcess* rp=new(ELeave) CRunningProcess(this);
   1.756 +		rp->Link(&iProcessList);
   1.757 +		CActiveScheduler::Add(rp);
   1.758 +		TInt err=KErrNone;		//To stop a warning
   1.759 +		if (aTestExecute)
   1.760 +			{
   1.761 +			TRAP(err,rp->ConstructTestExecuteL(aName));
   1.762 +			}
   1.763 +		else
   1.764 +			{
   1.765 +			TRAP(err,rp->ConstructL(aName));
   1.766 +			}
   1.767 +		if (err!=KErrNone)
   1.768 +			{
   1.769 +			delete rp;
   1.770 +			User::Leave(err);
   1.771 +			}
   1.772 +		return ETrue;
   1.773 +		}
   1.774 +	return EFalse;
   1.775 +	}
   1.776 +
   1.777 +void CShellWindow::SelectedL(TInt aIndex)
   1.778 +	{
   1.779 +	TPtrC name=GetText(aIndex);
   1.780 +	if (aIndex==INDEX_FOR_SHELL_TEST && name==SHELL_TEST_NAME)
   1.781 +		{
   1.782 +		DoShellTests();
   1.783 +		return;
   1.784 +		}
   1.785 +#ifdef SYMBIAN_PROCESS_MONITORING_AND_STARTUP		
   1.786 +	else if (aIndex==INDEX_FOR_RESTART_TEST && name==RESTART_TEST_NAME)
   1.787 +		{
   1.788 +		SimulateRestartEvent();
   1.789 +		return;
   1.790 +		}
   1.791 +	else if (aIndex==INDEX_FOR_RESTART_EVENT_TEST && name==RESTART_EVENT_TEST_NAME)
   1.792 +		{
   1.793 +		SimulateAndReceiveRestartEvent();
   1.794 +		return;
   1.795 +		}
   1.796 +#endif		
   1.797 +	TRAPD(err,RunClientL(GetText(aIndex),EFalse));
   1.798 +	if (err==KErrNotFound)
   1.799 +		{
   1.800 +		TRAP(err,RunClientL(GetText(aIndex),ETrue));
   1.801 +		}
   1.802 +	if (err!=KErrNone)
   1.803 +		((CShellClient *)Client())->ErrorDialog(_L("Error launching process"), err);
   1.804 +	}
   1.805 +
   1.806 +TPtrC CShellWindow::GetText(TInt aLine)
   1.807 +	{
   1.808 +	return(TPtrC(iFileNames[aLine]));
   1.809 +	}
   1.810 +
   1.811 +TInt CShellWindow::ListCount()
   1.812 +	{
   1.813 +	return(iFileNames.Count());
   1.814 +	}
   1.815 +
   1.816 +void CShellWindow::ForegroundAppDialogL()
   1.817 +	{
   1.818 +	TInt focusGroup;
   1.819 +	TName winName;
   1.820 +	TThreadId threadId;
   1.821 +	User::LeaveIfError(focusGroup=Client()->iWs.GetFocusWindowGroup());
   1.822 +	User::LeaveIfError(Client()->iWs.GetWindowGroupClientThreadId(focusGroup, threadId));
   1.823 +	User::LeaveIfError(Client()->iWs.GetWindowGroupNameFromIdentifier(focusGroup,winName));
   1.824 +	RThread thread;
   1.825 +	User::LeaveIfError(thread.Open(threadId));
   1.826 +	CShellErrorDialog *dialog=new(ELeave) CShellErrorDialog(Client()->iGroup, iGc);
   1.827 +	dialog->ConstructLD();
   1.828 +	dialog->SetTitle(_L("The Foreground App Is"));
   1.829 +	dialog->SetLine1(thread.FullName());
   1.830 +	thread.Close();
   1.831 +	dialog->SetLine2(winName);
   1.832 +	dialog->SetNumButtons(1);
   1.833 +	dialog->SetButtonText(0,_L("Okay"));
   1.834 +	if (dialog->Display()!=0)
   1.835 +		Panic(0);
   1.836 +	dialog=NULL;
   1.837 +	}
   1.838 +
   1.839 +void CShellWindow::HeapCountDialogL()
   1.840 +	{
   1.841 +	CShellErrorDialog *dialog=new(ELeave) CShellErrorDialog(Client()->iGroup, iGc);
   1.842 +	dialog->ConstructLD();
   1.843 +	dialog->SetTitle(_L("Wserv Heap Count"));
   1.844 +	TBuf<0x20> line1;
   1.845 +	line1.Format(TRefByValue<const TDesC>(_L("Count=%d")),Client()->iWs.HeapCount());
   1.846 +	dialog->SetLine1(line1);
   1.847 +	dialog->SetNumButtons(1);
   1.848 +	dialog->SetButtonText(0,_L("Okay"));
   1.849 +	if (dialog->Display()!=0)
   1.850 +		Panic(0);
   1.851 +	dialog=NULL;
   1.852 +	}
   1.853 +
   1.854 +void CShellWindow::WinKeyL(const TKeyEvent &aKey,const TTime& aTime)
   1.855 +	{
   1.856 +	TBool funcKeyPressed=aKey.iModifiers&EModifierFunc;
   1.857 +	if (aKey.iModifiers&EModifierCtrl)
   1.858 +		{
   1.859 +		switch(aKey.iCode)
   1.860 +			{
   1.861 +			case EKeyLeftArrow:
   1.862 +				{
   1.863 +				TInt col=Client()->iWs.GetBackgroundColor().Gray16();
   1.864 +				if (col>0)
   1.865 +					Client()->iWs.SetBackgroundColor(TRgb::Gray16(col-1));
   1.866 +				}
   1.867 +				break;
   1.868 +			case EKeyRightArrow:
   1.869 +				{
   1.870 +				TInt col=Client()->iWs.GetBackgroundColor().Gray16();
   1.871 +				if (col<15)
   1.872 +					Client()->iWs.SetBackgroundColor(TRgb::Gray16(col+1));
   1.873 +				}
   1.874 +				break;
   1.875 +			case EKeyTab:
   1.876 +				if (funcKeyPressed)
   1.877 +					ForegroundAppDialogL();
   1.878 +				else
   1.879 +					{
   1.880 +					Group()->GroupWin()->SetOrdinalPosition(0);
   1.881 +					((CShellClient *)Client())->CreateTestWindowL(new(ELeave) CTaskListWindow(), TPoint(50,30));
   1.882 +					Client()->ResetFocus();
   1.883 +					}
   1.884 +				break;
   1.885 +			case 1:		//Ctrl-A
   1.886 +			case 17:	//Ctrl-Q
   1.887 +				SetPos(TPoint(3,(Client()->iScreen->SizeInPixels().iHeight-Size().iHeight)/2));
   1.888 +				break;
   1.889 +			case 2:		//Ctrl-B
   1.890 +			case 23:	//Ctrl-W
   1.891 +				SetPos(TPoint((Client()->iScreen->SizeInPixels().iWidth-Size().iWidth)/2,(Client()->iScreen->SizeInPixels().iHeight-Size().iHeight)/2));
   1.892 +				break;
   1.893 +			case 3:		//Ctrl-C
   1.894 +			case 5:		//Ctrl-E
   1.895 +				if (funcKeyPressed && aKey.iModifiers&EModifierShift && aKey.iCode==3)			//Ctrl-Alt-Sh-C
   1.896 +					iClick.CommandReply(EClickCommandToggleOutput,TPtrC8(NULL,0));
   1.897 +				else
   1.898 +					SetPos(TPoint(Client()->iScreen->SizeInPixels().iWidth-Size().iWidth-3,(Client()->iScreen->SizeInPixels().iHeight-Size().iHeight)/2));
   1.899 +				break;
   1.900 +			case 18:	//Ctrl-R
   1.901 +				{
   1.902 +				CWsScreenDevice* screen=Client()->iScreen;
   1.903 +				TPixelsAndRotation sizeAndRotation;
   1.904 +				screen->GetScreenModeSizeAndRotation(0,sizeAndRotation);
   1.905 +				Client()->iWs.SetPointerCursorArea(0,TRect(sizeAndRotation.iPixelSize));
   1.906 +				screen->SetCurrentRotations(0,CFbsBitGc::EGraphicsOrientationNormal);
   1.907 +				screen->SetScreenMode(0);
   1.908 +				CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
   1.909 +				CleanupStack::PushL(rotations);
   1.910 +				TInt numModes=screen->NumScreenModes();
   1.911 +				TInt ii,err;
   1.912 +				for (ii=1;ii<numModes;++ii)
   1.913 +					{
   1.914 +					err=screen->GetRotationsList(ii,rotations);
   1.915 +					if (err==KErrNone)
   1.916 +						screen->SetCurrentRotations(ii,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[0]));
   1.917 +					}
   1.918 +				CleanupStack::PopAndDestroy();
   1.919 +				}
   1.920 +				break;
   1.921 +			default:
   1.922 +				goto not_used;
   1.923 +			}
   1.924 +		}
   1.925 +	else if (funcKeyPressed)
   1.926 +		{
   1.927 +		switch(aKey.iCode)
   1.928 +			{
   1.929 +			case 'c':
   1.930 +				{
   1.931 +				CTCalibWindow *win=new(ELeave) CTCalibWindow();
   1.932 +				win->ConstructL(*Client()->iGroup);
   1.933 +				}
   1.934 +				break;
   1.935 +			case 's':	// Sleep
   1.936 +				User::After(2000000);
   1.937 +				break;
   1.938 +			case 'd':
   1.939 +				DisplayDialog(_L("Dialog test"),_L("Line of text"),_L(""));
   1.940 +				break;
   1.941 +			case 'o':
   1.942 +				UserHal::SwitchOff();
   1.943 +				break;
   1.944 +			case 'f':
   1.945 +				if (iFailModeEnabled)
   1.946 +					((CShellClient *)Client())->iWs.HeapSetFail(RHeap::ENone,0);
   1.947 +				else
   1.948 +					((CShellClient *)Client())->iWs.HeapSetFail(RHeap::ERandom,20);
   1.949 +				iFailModeEnabled=!iFailModeEnabled;
   1.950 +				break;
   1.951 +			case 'x':
   1.952 +			case 'X':
   1.953 +				if (aKey.iModifiers&EModifierShift)
   1.954 +					RShellWsSession::Shutdown();
   1.955 +				else
   1.956 +					((CShellClient *)Client())->Exit();
   1.957 +				break;
   1.958 +			case 'l':
   1.959 +				Client()->iWs.LogMessage(_L("Hello, this is log test"));
   1.960 +				break;
   1.961 +			case 'h':
   1.962 +				HeapCountDialogL();
   1.963 +				break;
   1.964 +			case 'b':
   1.965 +				BugHunt();
   1.966 +				break;
   1.967 +			case EKeyLeftArrow:
   1.968 +				AdjustSize(-Xmove,0,aKey.iModifiers);
   1.969 +				break;
   1.970 +			case EKeyRightArrow:
   1.971 +				AdjustSize(Xmove,0,aKey.iModifiers);
   1.972 +				break;
   1.973 +			case EKeyUpArrow:
   1.974 +				AdjustSize(0,-Ymove,aKey.iModifiers);
   1.975 +				break;
   1.976 +			case EKeyDownArrow:
   1.977 +				AdjustSize(0,Ymove,aKey.iModifiers);
   1.978 +				break;
   1.979 +			default:
   1.980 +				goto not_used;
   1.981 +			}
   1.982 +		}
   1.983 +	else
   1.984 +		goto not_used;
   1.985 +	return;
   1.986 +not_used:
   1.987 +	CListWindow::WinKeyL(aKey,aTime);
   1.988 +	}
   1.989 +
   1.990 +void CShellWindow::FocusChanged(TBool aState)
   1.991 +	{
   1.992 +	CListWindow::FocusChanged(aState);
   1.993 +	iIsFocused=aState;
   1.994 +	CheckTerminate();
   1.995 +	}
   1.996 +
   1.997 +void CShellWindow::DoShellTests()
   1.998 +//
   1.999 +//Doing testing that can only be done from the shell
  1.1000 +//
  1.1001 +	{
  1.1002 +	/*Group()->GroupWin()->EnableReceiptOfFocus(EFalse);
  1.1003 +	BaseWin()->SetSizeErr(TSize(160,220));
  1.1004 +	Group()->GroupWin()->EnableReceiptOfFocus(ETrue);
  1.1005 +	*/
  1.1006 +	SimulateSwitchOffEvent();
  1.1007 +	}
  1.1008 +
  1.1009 +/**
  1.1010 +Sends the raw events to the current registered window session.
  1.1011 +Since no Window Group is allowed to request the off events,
  1.1012 +WServ shall handle these raw events.
  1.1013 +*/
  1.1014 +void CShellWindow::SimulateSwitchOffEvent()
  1.1015 +	{
  1.1016 +	TRawEvent rawEvent;
  1.1017 +	rawEvent.Set(TRawEvent::ESwitchOff);
  1.1018 +	Client()->iWs.SimulateRawEvent(rawEvent);
  1.1019 +	Client()->iWs.Flush();
  1.1020 +	}	
  1.1021 +
  1.1022 +#ifdef SYMBIAN_PROCESS_MONITORING_AND_STARTUP	
  1.1023 +/**
  1.1024 +@SYMTestCaseID 			GRAPHICS-WSERV-0404
  1.1025 +@SYMTestCaseDesc 		Restart system event can be successfully sent through WServ
  1.1026 +@SYMPREQ				PREQ1089
  1.1027 +@SYMREQ					REQ6883
  1.1028 +@SYMTestStatus			Implemented
  1.1029 +@SYMTestPriority		High
  1.1030 +@SYMTestPurpose			Test restart system event in WServ
  1.1031 +@SYMTestActions			The test code will simulate a 'restart event'.
  1.1032 +@SYMTestExpectedResults	The system should restart (manually observed).
  1.1033 +*/
  1.1034 +void CShellWindow::SimulateRestartEvent()
  1.1035 +	{
  1.1036 +	TRawEvent rawEvent;
  1.1037 +	rawEvent.Set(TRawEvent::ERestartSystem);
  1.1038 +	Client()->iWs.SimulateRawEvent(rawEvent);
  1.1039 +	Client()->iWs.Flush();
  1.1040 +	}
  1.1041 +
  1.1042 +/**
  1.1043 +@SYMTestCaseID 			GRAPHICS-WSERV-0405
  1.1044 +@SYMTestCaseDesc 		Restart system event can be received by client that have registered for off event
  1.1045 +@SYMPREQ				PREQ1089
  1.1046 +@SYMREQ					REQ6883
  1.1047 +@SYMTestStatus			Implemented
  1.1048 +@SYMTestPriority		High
  1.1049 +@SYMTestPurpose			Test restart system event in WServ with off event handler
  1.1050 +@SYMTestActions			The test code will register for off event, simulate a 'restart event' and then receive the restart event
  1.1051 +@SYMTestExpectedResults	Verify that the restart event is received and the testPass dialog displayed for this test (manually observed).
  1.1052 +*/
  1.1053 +void CShellWindow::SimulateAndReceiveRestartEvent()
  1.1054 +	{
  1.1055 +	const TInt KEventWaitTimer = 5000000; // 5 sec, The wait time that this test will wait for the restart event before declaring this test fail
  1.1056 +	TInt err = Client()->iWs.RequestOffEvents(ETrue, Client()->iGroup->GroupWin());
  1.1057 +	if (err != KErrNone)
  1.1058 +		{
  1.1059 +		static_cast<CShellClient *>(Client())->ErrorDialog(_L("Failed to request off event"),err);
  1.1060 +		}
  1.1061 +
  1.1062 +	TRawEvent rawEvent;
  1.1063 +	rawEvent.Set(TRawEvent::ERestartSystem);
  1.1064 +	Client()->iWs.SimulateRawEvent(rawEvent);
  1.1065 +
  1.1066 +	TRequestStatus status;
  1.1067 +	Client()->iWs.EventReady(&status);
  1.1068 +	Client()->iWs.Flush();
  1.1069 +	User::WaitForRequest(status);
  1.1070 +
  1.1071 +	TWsEvent event;
  1.1072 +	RTimer timer;
  1.1073 +	timer.CreateLocal();
  1.1074 +	TRequestStatus timerStatus;
  1.1075 +	timer.After(timerStatus,KEventWaitTimer);
  1.1076 +	TBool testPass=EFalse;
  1.1077 +	while (timerStatus != KErrNone) // wait for the restart event until timer expire
  1.1078 +		{
  1.1079 +		Client()->iWs.GetEvent(event);
  1.1080 +		if (event.Type() == EEventRestartSystem)
  1.1081 +			{
  1.1082 +			timer.Cancel();
  1.1083 +			User::WaitForRequest(timerStatus); // to receive the cancel event
  1.1084 +
  1.1085 +			testPass = ETrue;
  1.1086 +			_LIT(KTestPass,"TestPassed");
  1.1087 +			TWindowTitle winTitle(KTestPass);
  1.1088 +			DisplayDialog(Client(), winTitle, _L("Received Restart Event"), KNullDesC);
  1.1089 +			break;
  1.1090 +			}
  1.1091 +
  1.1092 +		// probably got pointer event above instead of restart event, so try getting the next event until we see retart event
  1.1093 +		Client()->iWs.EventReady(&status);
  1.1094 +		User::WaitForRequest(status, timerStatus);
  1.1095 +		}
  1.1096 +
  1.1097 +	if (testPass == EFalse)
  1.1098 +		{
  1.1099 +		// timer expired before getting restart event
  1.1100 +		_LIT(KTestPass,"TestFailed");
  1.1101 +		TWindowTitle winTitle(KTestPass);
  1.1102 +		DisplayDialog(Client(), winTitle, _L("Did not receive Restart Event"), KNullDesC);
  1.1103 +		}
  1.1104 +
  1.1105 +	timer.Close();
  1.1106 +
  1.1107 +	Client()->iWs.RequestOffEvents(EFalse);
  1.1108 +	}
  1.1109 +
  1.1110 +#endif		
  1.1111 +
  1.1112 +void CShellWindow::BugHunt()
  1.1113 +//
  1.1114 +// Attempt to reproduce messaging issue while program exiting with message outstanding
  1.1115 +//
  1.1116 +	{
  1.1117 +	RThread().SetPriority(EPriorityRealTime);
  1.1118 +	((ROverrideProtectionInRSessionBase *)&(Client()->iWs))->Send(1);
  1.1119 +	RThread().Kill(0);
  1.1120 +	}
  1.1121 +
  1.1122 +void CShellWindow::CheckTerminate()
  1.1123 +	{
  1.1124 +	if (iIsFocused && iAutoLaunch && iProcessList==NULL && iNumWindowGroups==Client()->iWs.NumWindowGroups())
  1.1125 +		{
  1.1126 +#if defined(__WINS__)
  1.1127 +		delete this;
  1.1128 +		RShellWsSession::Shutdown();
  1.1129 +#else 
  1.1130 +		// on hardware for automated test purposes cause board to crash to 
  1.1131 +		// indicate the completion of test run
  1.1132 +		User::SetCritical(User::ESystemCritical);
  1.1133 +		User::Panic(_L("test"), KErrGeneral);
  1.1134 +#endif
  1.1135 +		}
  1.1136 +	}
  1.1137 +
  1.1138 +void CShellWindow::ProcessDied()
  1.1139 +	{
  1.1140 +	CheckTerminate();
  1.1141 +	}
  1.1142 +
  1.1143 +//
  1.1144 +// End of CShellWindow class //
  1.1145 +//
  1.1146 +
  1.1147 +//
  1.1148 +// CTaskListWindow class //
  1.1149 +//
  1.1150 +
  1.1151 +CTaskListWindow::CTaskListWindow() : CListWindow(), iWindowHandles(4), iWindowThreadNames(4)
  1.1152 +	{
  1.1153 +	}
  1.1154 +
  1.1155 +void CTaskListWindow::ConstructL(CTWinBase &parent)
  1.1156 +	{
  1.1157 +	CListWindow::ConstructL(parent,ETrue);
  1.1158 +	User::LeaveIfError(Client()->iWs.WindowGroupList(0,&iWindowHandles));
  1.1159 +	for(TInt index=0;index<iWindowHandles.Count();index++)
  1.1160 +		{
  1.1161 +		TThreadId id;
  1.1162 +		Client()->iWs.GetWindowGroupClientThreadId(iWindowHandles[index],id);
  1.1163 +		RThread thread;
  1.1164 +		User::LeaveIfError(thread.Open(id));
  1.1165 +		iWindowThreadNames.AppendL(thread.FullName());
  1.1166 +		thread.Close();
  1.1167 +		}
  1.1168 +	SetSize();
  1.1169 +	}
  1.1170 +
  1.1171 +void CTaskListWindow::SelectedL(TInt aIndex)
  1.1172 +	{
  1.1173 +	Client()->iWs.SetWindowGroupOrdinalPosition(iWindowHandles[aIndex], 0);
  1.1174 +	CloseWindow();
  1.1175 +	}
  1.1176 +
  1.1177 +TPtrC CTaskListWindow::GetText(TInt aLine)
  1.1178 +	{
  1.1179 +	iLatestText=iWindowThreadNames[aLine];
  1.1180 +	iLatestText.Append(_L("::"));
  1.1181 +	TName winName;
  1.1182 +	if (Client()->iWs.GetWindowGroupNameFromIdentifier(iWindowHandles[aLine],winName)==KErrNone)
  1.1183 +		iLatestText.Append(winName);
  1.1184 +	return(iLatestText);
  1.1185 +	}
  1.1186 +
  1.1187 +TInt CTaskListWindow::ListCount()
  1.1188 +	{
  1.1189 +	return(iWindowHandles.Count());
  1.1190 +	}
  1.1191 +//
  1.1192 +// End of CTaskListWindow class //
  1.1193 +//
  1.1194 +
  1.1195 +CShellWindowGroup::CShellWindowGroup(CTClient *aClient) : CTWindowGroup(aClient)
  1.1196 +	{
  1.1197 +	}
  1.1198 +
  1.1199 +CShellWindowGroup::~CShellWindowGroup()
  1.1200 +	{
  1.1201 +	iGroupWin.CancelCaptureKey(iCapHandle1);
  1.1202 +	iGroupWin.CancelCaptureKey(iCapHandle2);
  1.1203 +	iGroupWin.CancelCaptureKey(iCapHandle3);
  1.1204 +	iGroupWin.CancelCaptureKey(iCapHandle4);
  1.1205 +	}
  1.1206 +
  1.1207 +void CShellWindowGroup::ConstructL()
  1.1208 +	{
  1.1209 +	CTWindowGroup::ConstructL();
  1.1210 +	iCapHandle1=User::LeaveIfError(iGroupWin.CaptureKey(EKeyTab, EModifierCtrl|EModifierShift|EModifierPureKeycode,EModifierCtrl|EModifierShift|EModifierPureKeycode));
  1.1211 +	iGroupWin.DefaultOwningWindow();
  1.1212 +	iGroupWin.EnableErrorMessages(EEventControlOnlyWithKeyboardFocus);
  1.1213 +	iGroupWin.EnableScreenChangeEvents();
  1.1214 +	}
  1.1215 +
  1.1216 +void CShellWindowGroup::KeyL(const TKeyEvent &aKey,const TTime& aTime)
  1.1217 +	{
  1.1218 +	if (iCurWin)
  1.1219 +		iCurWin->WinKeyL(aKey,aTime);
  1.1220 +	}
  1.1221 +
  1.1222 +void CShellWindowGroup::ErrorMessage(const TWsErrorMessage &aErrorMessage, const TTime &)
  1.1223 +	{
  1.1224 +	TBuf<0x40> errorText;
  1.1225 +	switch(aErrorMessage.iErrorCategory)
  1.1226 +		{
  1.1227 +		case TWsErrorMessage::EDrawingRegion:
  1.1228 +			{
  1.1229 +			_LIT(Graphics,"Graphics %d");
  1.1230 +			errorText.Format(Graphics,aErrorMessage.iError);
  1.1231 +			}
  1.1232 +			break;
  1.1233 +		case TWsErrorMessage::EBackLight:
  1.1234 +			{
  1.1235 +			_LIT(Backlight,"Backlight %d");
  1.1236 +			errorText.Format(Backlight,aErrorMessage.iError);
  1.1237 +			}
  1.1238 +			break;
  1.1239 +		case TWsErrorMessage::ELogging:
  1.1240 +			{
  1.1241 +			_LIT(Logging,"Error Starting Logging: %d, Location: %d");
  1.1242 +			// minus the error value is stored in the bottom 8 bits
  1.1243 +			// an indication of position in the code, that the error occured in, is stored in the top 24 bits
  1.1244 +			TInt line=(aErrorMessage.iError)&0xFFFFFF00;
  1.1245 +			errorText.Format(Logging,line-aErrorMessage.iError,line>>8);
  1.1246 +			}
  1.1247 +			break;
  1.1248 +		case TWsErrorMessage::EContrast:
  1.1249 +			{
  1.1250 +			_LIT(Contrast,"Contrast %d");
  1.1251 +			errorText.Format(Contrast,aErrorMessage.iError);
  1.1252 +			}
  1.1253 +			break;
  1.1254 +		default:
  1.1255 +			{
  1.1256 +			_LIT(Unknown,"Unknown %d");
  1.1257 +			errorText.Format(Unknown,aErrorMessage.iError);
  1.1258 +			}
  1.1259 +			break;
  1.1260 +		}
  1.1261 +	_LIT(WservError,"Wserv error");
  1.1262 +	TWindowTitle winTitle(WservError);
  1.1263 +	DisplayDialog(Client(), winTitle, errorText, KNullDesC);
  1.1264 +	}
  1.1265 +
  1.1266 +void CShellWindowGroup::ScreenDeviceChangedL()
  1.1267 +	{
  1.1268 +	TPixelsTwipsAndRotation sizeAndRotation;
  1.1269 +	Client()->iScreen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
  1.1270 +	Client()->iScreen->SetScreenSizeAndRotation(sizeAndRotation);
  1.1271 +	((CShellClient *)Client())->ScreenDeviceChangedL();
  1.1272 +	}
  1.1273 +
  1.1274 +//
  1.1275 +
  1.1276 +CIconWindowGroup::CIconWindowGroup(CTClient *aClient) : CTWindowGroup(aClient)
  1.1277 +	{
  1.1278 +	}
  1.1279 +
  1.1280 +void CIconWindowGroup::ConstructL()
  1.1281 +	{
  1.1282 +	CTWindowGroup::ConstructL();
  1.1283 +	iGroupWin.EnableReceiptOfFocus(EFalse);
  1.1284 +	iGroupWin.SetOrdinalPosition(0,100);
  1.1285 +	}
  1.1286 +
  1.1287 +//
  1.1288 +// password window //
  1.1289 +//
  1.1290 +
  1.1291 +CTPasswordWindow::CTPasswordWindow()
  1.1292 +	{
  1.1293 +	}
  1.1294 +
  1.1295 +void CTPasswordWindow::InitWin()
  1.1296 +	{
  1.1297 +	TInt wid=iFont->TextWidthInPixels(_L("Press Enter"));
  1.1298 +	iTextPos.iX=(iWin.Size().iWidth-wid)/2;
  1.1299 +	iTextPos.iY=(iWin.Size().iHeight)/2;
  1.1300 +	}
  1.1301 +
  1.1302 +void CTPasswordWindow::Draw()
  1.1303 +	{
  1.1304 +	CTTitledWindow::Draw();
  1.1305 +	iGc->DrawText(_L("Press Enter"),iTextPos);
  1.1306 +	}
  1.1307 +
  1.1308 +//
  1.1309 +
  1.1310 +CPasswordWindowGroup::CPasswordWindowGroup(CTClient *aClient) : CTWindowGroup(aClient)
  1.1311 +	{
  1.1312 +	}
  1.1313 +
  1.1314 +CPasswordWindowGroup::~CPasswordWindowGroup()
  1.1315 +	{
  1.1316 +	delete iWin;
  1.1317 +	}
  1.1318 +
  1.1319 +void CPasswordWindowGroup::PasswordL(const TTime &)
  1.1320 +	{
  1.1321 +	__ASSERT_DEBUG(!iPasswordMode,Panic(EShellPanicPassword));
  1.1322 +	iPasswordMode=ETrue;
  1.1323 +	iWin->SetTitle(_L("Password Mode Enabled"));
  1.1324 +	}
  1.1325 +
  1.1326 +void CPasswordWindowGroup::Cancel()
  1.1327 +	{
  1.1328 +	iPasswordMode=EFalse;
  1.1329 +	iWin->SetVisible(EFalse);
  1.1330 +	iGroupWin.SetOrdinalPosition(0,-1000);
  1.1331 +	iWin->SetTitle(_L("Why am I here?"));
  1.1332 +	}
  1.1333 +
  1.1334 +void CPasswordWindowGroup::KeyL(const TKeyEvent &aKey,const TTime&)
  1.1335 +	{
  1.1336 +	if (iPasswordMode && aKey.iCode==EKeyEnter)
  1.1337 +		{
  1.1338 +		Client()->iWs.PasswordEntered();
  1.1339 +		Cancel();
  1.1340 +		}
  1.1341 +	}
  1.1342 +
  1.1343 +void CPasswordWindowGroup::ConstructL()
  1.1344 +	{
  1.1345 +	CTWindowGroup::ConstructL();
  1.1346 +	iGroupWin.SetOrdinalPosition(-1);
  1.1347 +	iWin=new(ELeave) CTPasswordWindow();
  1.1348 +	iWin->ConstructL(*this);
  1.1349 +	iWin->AssignGC(*Client()->iGc);
  1.1350 +	Cancel();
  1.1351 +	iWin->Win()->PasswordWindow(EPasswordAlwaysTriggerNow);
  1.1352 +	iWin->Activate();
  1.1353 +	SetCurrentWindow(iWin);
  1.1354 +	}
  1.1355 +
  1.1356 +//
  1.1357 +
  1.1358 +CShellClient::CShellClient()
  1.1359 +	{
  1.1360 +	}
  1.1361 +
  1.1362 +void CShellClient::CreateTestWindowL(CTWin *aWin, const TPoint &aPos,CTWinBase *parent)
  1.1363 +	{
  1.1364 +	TRAPD(err,aWin->ConstructL(*parent));
  1.1365 +	if (err!=KErrNone)
  1.1366 +		{
  1.1367 +		delete aWin;
  1.1368 +		User::Leave(err);
  1.1369 +		}
  1.1370 +	aWin->SetInitialPos(aPos);
  1.1371 +	aWin->Activate();
  1.1372 +	aWin->AssignGC(*iGc);
  1.1373 +	}
  1.1374 +
  1.1375 +void CShellClient::CreateTestWindowL(CTWin *aWin, const TPoint &aPos)
  1.1376 +	{
  1.1377 +	CreateTestWindowL(aWin, aPos, iGroup);
  1.1378 +	}
  1.1379 +
  1.1380 +CShellClient::~CShellClient()
  1.1381 +	{
  1.1382 +	delete iPointerCursor;
  1.1383 +	delete iIconWin1;
  1.1384 +	delete iIconWin2;
  1.1385 +	delete iIconGroup;
  1.1386 +	delete iPasswordGroup;
  1.1387 +	iWs.FreeSystemPointerCursorList();
  1.1388 +	iFs.Close();
  1.1389 +	}
  1.1390 +
  1.1391 +
  1.1392 +void CShellClient::ConstructL()
  1.1393 +	{
  1.1394 +	User::LeaveIfError(iFs.Connect());
  1.1395 +	CTClient::ConstructL();
  1.1396 +	iWs.RequestOffEvents(EFalse);		//To test this function
  1.1397 +
  1.1398 +	TBool keyClicksSupported=EFalse;
  1.1399 +	HAL::Get(HALData::EKeyboardClick,keyClicksSupported);
  1.1400 +	if (keyClicksSupported)
  1.1401 +		{
  1.1402 +		HAL::Set(HALData::EKeyboardClickState,1);
  1.1403 +		TInt maxVol=1;
  1.1404 +		HAL::Get(HALData::EKeyboardClickVolumeMax,maxVol);
  1.1405 +		HAL::Set(HALData::EKeyboardClickVolume,maxVol);
  1.1406 +		}	
  1.1407 +	
  1.1408 +	iWs.SetDoubleClick(TTimeIntervalMicroSeconds32(EDoubleClickTime), EDoubleClickDistance);
  1.1409 +
  1.1410 +	User::LeaveIfError(iWs.SetHotKey(EHotKeyBacklightToggle, 2, EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl|EModifierShift));
  1.1411 +	User::LeaveIfError(iWs.SetHotKey(EHotKeyBacklightOn, 14, EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl|EModifierShift));
  1.1412 +	User::LeaveIfError(iWs.SetHotKey(EHotKeyBacklightOff, 13, EModifierFunc|EModifierCtrl|EModifierShift,EModifierFunc|EModifierCtrl|EModifierShift));
  1.1413 +//
  1.1414 +	iGroup=new(ELeave) CShellWindowGroup(this);
  1.1415 +	iGroup->ConstructL();
  1.1416 +	iWs.RequestOffEvents(ETrue,iGroup->GroupWin());	//To test this function
  1.1417 +	iWs.RequestOffEvents(EFalse);
  1.1418 +	iIconGroup=new(ELeave) CIconWindowGroup(this);
  1.1419 +	iIconGroup->ConstructL();
  1.1420 +	iIconWin1=new(ELeave) CTIconWindow(0);
  1.1421 +	iIconWin1->ConstructL(*iIconGroup);
  1.1422 +	iIconWin2=new(ELeave) CTIconWindow(1);
  1.1423 +	iIconWin2->ConstructL(*iIconGroup);
  1.1424 +
  1.1425 +	CShellWindow *win=new(ELeave) CShellWindow();
  1.1426 +	CreateTestWindowL(win, TPoint(330,10));
  1.1427 +	TWinCommand command;
  1.1428 +	User::CommandLine(command);
  1.1429 +	win->SetAutoLaunch(win->RunClientL(command,EFalse));
  1.1430 +
  1.1431 +    iPointerCursor=new(ELeave) CTPointerCursor(iWs);
  1.1432 +    TSpriteCreateParams params(TSize(24,48),TPoint(-12,-24),DrawPointerCursor,NULL, ETrue,CGraphicsContext::EDrawModePEN);
  1.1433 +    iPointerCursor->ConstructL(1,&params,0);
  1.1434 +	iGroup->GroupWin()->SetCustomPointerCursor(iPointerCursor->PointerCursor());
  1.1435 +	ResetFocus();
  1.1436 +	}
  1.1437 +
  1.1438 +void CShellClient::ScreenDeviceChangedL()
  1.1439 +	{
  1.1440 +	iIconWin1->SetExtentL();
  1.1441 +	iIconWin2->SetExtentL();
  1.1442 +	}
  1.1443 +
  1.1444 +void CShellClient::Exit()
  1.1445 +	{
  1.1446 +	CActiveScheduler::Stop();
  1.1447 +	}
  1.1448 +
  1.1449 +CRunningProcess::CRunningProcess(MProcessObserver* aObserver) : CActive(-5), iObserver(aObserver) 
  1.1450 +	{}
  1.1451 +
  1.1452 +CRunningProcess::~CRunningProcess()
  1.1453 +	{
  1.1454 +	Cancel();
  1.1455 +	if (iNext)
  1.1456 +		iNext->iPrevPtr=iPrevPtr;
  1.1457 +	*iPrevPtr=iNext;
  1.1458 +#if defined(__WINS__)
  1.1459 +	iLib.Close();
  1.1460 +#endif
  1.1461 +#if defined(__USING_PROCESS_)
  1.1462 +	iProcess.Close();
  1.1463 +#else
  1.1464 +	iProcess.Close();
  1.1465 +#endif
  1.1466 +	if (iObserver)
  1.1467 +		iObserver->ProcessDied();
  1.1468 +	}
  1.1469 +
  1.1470 +void CRunningProcess::ConstructL(const TDesC &aName)
  1.1471 +	{
  1.1472 +#if defined(__USING_PROCESS_)
  1.1473 +	TParse fileName;
  1.1474 +	fileName.Set(_L("E:\\.EXE"),&aName,NULL);
  1.1475 +	TInt error = iProcess.Create(fileName.FullName(),_L(""));
  1.1476 +	if(error != KErrNone)
  1.1477 +		{
  1.1478 +		fileName.Set(_L(""),&aName,NULL);
  1.1479 +		User::LeaveIfError(iProcess.Create(fileName.FullName(),_L("")));
  1.1480 +		}
  1.1481 +#else
  1.1482 +	User::LeaveIfError(iFileName.Set(RP_FILENAME_SET,&aName,NULL));
  1.1483 +	User::LeaveIfError(iLib.Load(iFileName.FullName()));
  1.1484 +	DllTestAppEntryPoint libFunc=(DllTestAppEntryPoint)iLib.Lookup(1);
  1.1485 +	User::LeaveIfNull((TAny *)libFunc);
  1.1486 +	TBuf<KMaxFileName> threadName;
  1.1487 +	TInt err;
  1.1488 +	TInt num=0;
  1.1489 +	do
  1.1490 +		{
  1.1491 +		threadName.Format(TRefByValue<const TDesC>(_L("%S%02d")),&aName,num++);
  1.1492 +		err=iProcess.Create(threadName,libFunc,KDefaultStackSize,NULL,&iLib,NULL,KHeapSize,KHeapSize,EOwnerProcess);
  1.1493 +		} while(err==KErrAlreadyExists);
  1.1494 +	User::LeaveIfError(err);
  1.1495 +#endif
  1.1496 +	iProcess.Logon(iStatus);
  1.1497 +	iProcess.Resume();
  1.1498 +	SetActive();
  1.1499 +	}
  1.1500 +
  1.1501 +void CRunningProcess::ConstructTestExecuteL(const TDesC &aName)
  1.1502 +	{
  1.1503 +	//testexecute z:\wstest\wstest_t_autotest.script
  1.1504 +	_LIT(KTestExecute,"testexecute");
  1.1505 +	_LIT(KComandLinePrefix,"z:\\wstest\\wstest_t_");
  1.1506 +	_LIT(KComandLinePostfix,"test.script");
  1.1507 +#if defined(__USING_PROCESS_)
  1.1508 +	TParse fileName;
  1.1509 +	fileName.Set(KNullDesC,&KTestExecute,NULL);
  1.1510 +	TBuf<128> commandLine;
  1.1511 +	commandLine.Append(KComandLinePrefix);
  1.1512 +	commandLine.Append(aName);
  1.1513 +	commandLine.Append(KComandLinePostfix);
  1.1514 +	User::LeaveIfError(iProcess.Create(fileName.FullName(),commandLine));
  1.1515 +	iProcess.Logon(iStatus);
  1.1516 +	iProcess.Resume();
  1.1517 +	SetActive();
  1.1518 +#endif
  1.1519 +	}
  1.1520 +
  1.1521 +void CRunningProcess::Link(CRunningProcess **aRpPtr)
  1.1522 +	{
  1.1523 +	iNext=*aRpPtr;
  1.1524 +	if (iNext)
  1.1525 +		iNext->iPrevPtr=&iNext;
  1.1526 +	*aRpPtr=this;
  1.1527 +	iPrevPtr=aRpPtr;
  1.1528 +	}
  1.1529 +
  1.1530 +void CRunningProcess::DoCancel()
  1.1531 +	{
  1.1532 +	iProcess.LogonCancel(iStatus);
  1.1533 +	}
  1.1534 +
  1.1535 +void CRunningProcess::RunL()
  1.1536 +	{
  1.1537 +	if (iStatus!=KErrNone)
  1.1538 +		{
  1.1539 +		TBuf<32> buf;
  1.1540 +		buf.Num(iStatus.Int());
  1.1541 +		DisplayDialog(_L("Program exited with error"),iProcess.ExitCategory(),buf);
  1.1542 +		}
  1.1543 +	delete this;
  1.1544 +	}
  1.1545 +
  1.1546 +GLDEF_C CTClient *CreateClientL()
  1.1547 +	{
  1.1548 +	return(new(ELeave) CShellClient());
  1.1549 +	}
  1.1550 +
  1.1551 +GLDEF_C TInt E32Main()
  1.1552 +	{
  1.1553 +	return(TestLibStartUp(CreateClientL));
  1.1554 +	}