|
1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <eikstart.h> |
|
17 #include <eikapp.h> |
|
18 #include <eikenv.h> |
|
19 #include <apgtask.h> |
|
20 #include "EndTaskTestApp.h" |
|
21 #include "EndTaskTestAppExternalInterface.h" |
|
22 |
|
23 /** |
|
24 Standard DLL entry point function. |
|
25 Creates and returns an instance of the CApaApplication-derived class. |
|
26 |
|
27 @return an instance of the CApaApplication-derived class |
|
28 */ |
|
29 TInt E32Main() |
|
30 { |
|
31 return EikStart::RunApplication( CEndTaskTestApplication::NewApplication ); |
|
32 } |
|
33 |
|
34 /** |
|
35 Default constructor |
|
36 */ |
|
37 CEndTaskTestApplication::CEndTaskTestApplication() |
|
38 { |
|
39 } |
|
40 |
|
41 /** |
|
42 Virtual destructor |
|
43 */ |
|
44 CEndTaskTestApplication::~CEndTaskTestApplication() |
|
45 { |
|
46 } |
|
47 |
|
48 /** |
|
49 @return The application's UID |
|
50 */ |
|
51 TUid CEndTaskTestApplication::AppDllUid() const |
|
52 { |
|
53 const TUid dll = {KUidEndTaskAppUid}; |
|
54 return dll; |
|
55 } |
|
56 |
|
57 /** |
|
58 @return CEndTaskTestApplication or NULL if KErrNoMemory |
|
59 */ |
|
60 CApaApplication* CEndTaskTestApplication::NewApplication() |
|
61 { |
|
62 // As the framework has at this point not started up enough, and therefore the TRAP-harness and |
|
63 // exception handlers aren’t available yet, this factory function is a non-leaving function and |
|
64 // can't use the new(Eleave) operator. |
|
65 return new CEndTaskTestApplication(); |
|
66 } |
|
67 |
|
68 /** |
|
69 Called by the UI framework at application start-up to create an instance of the document class. |
|
70 |
|
71 @leave KErrNoMemory |
|
72 @return A CExampleDocument |
|
73 */ |
|
74 CApaDocument* CEndTaskTestApplication::CreateDocumentL() |
|
75 { |
|
76 return CEndTaskTestDocument::NewL(*this); |
|
77 } |
|
78 |
|
79 /** |
|
80 Constructor |
|
81 */ |
|
82 CEndTaskTestDocument::CEndTaskTestDocument(CEikApplication& aApp) : CEikDocument(aApp) |
|
83 { |
|
84 } |
|
85 |
|
86 /** |
|
87 Virtual destructor |
|
88 */ |
|
89 CEndTaskTestDocument::~CEndTaskTestDocument() |
|
90 { |
|
91 } |
|
92 |
|
93 /** |
|
94 Factory function for this class |
|
95 @return a new CEndTaskTestDocument instance. |
|
96 */ |
|
97 CEndTaskTestDocument* CEndTaskTestDocument::NewL(CEikApplication& aApp) |
|
98 { |
|
99 return new(ELeave) CEndTaskTestDocument(aApp); |
|
100 } |
|
101 |
|
102 |
|
103 /** |
|
104 Called by the UI framework to construct the application UI class. |
|
105 Note that the app UI's ConstructL() is called by the UI framework. |
|
106 */ |
|
107 CEikAppUi* CEndTaskTestDocument::CreateAppUiL() |
|
108 { |
|
109 return new(ELeave) CEndTaskTestAppUi(); |
|
110 } |
|
111 |
|
112 /** |
|
113 Constructor |
|
114 */ |
|
115 CEndTaskTestAppUi::CEndTaskTestAppUi() |
|
116 { |
|
117 } |
|
118 |
|
119 /** |
|
120 Virtual destructor |
|
121 */ |
|
122 CEndTaskTestAppUi::~CEndTaskTestAppUi() |
|
123 { |
|
124 } |
|
125 |
|
126 /** |
|
127 Second phase constructor of the application UI class. |
|
128 It creates and owns a single view. The view contents are not created |
|
129 until the first time view is activated. |
|
130 */ |
|
131 void CEndTaskTestAppUi::ConstructL() |
|
132 { |
|
133 // Complete the UI framework's construction of the App UI. |
|
134 BaseConstructL(CEikAppUi::ENoAppResourceFile); |
|
135 |
|
136 // Set higher prio to preempt test-server as soon as we have an event |
|
137 User::SetPriorityControl(EFalse); |
|
138 RProcess p; |
|
139 p.SetPriority(EPriorityHigh); |
|
140 } |
|
141 |
|
142 /** |
|
143 Events published in externalinterface.h and utilized by T_EndTaskStep.cpp |
|
144 */ |
|
145 void CEndTaskTestAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& /*aEvent*/) |
|
146 { |
|
147 switch (aType) |
|
148 { |
|
149 case EEndTaskTestAppSetSystem: |
|
150 static_cast<CEikonEnv*>(iCoeEnv)->SetSystem(ETrue); |
|
151 break; |
|
152 case EEndTaskTestAppSetNormal: |
|
153 static_cast<CEikonEnv*>(iCoeEnv)->SetSystem(EFalse); |
|
154 break; |
|
155 case ECallEndTaskWithoutPwrMgmt: |
|
156 { |
|
157 TApaTaskList taskList(iEikonEnv->WsSession()); |
|
158 TApaTask task = taskList.FindApp(Application()->AppDllUid()); |
|
159 task.EndTask(); |
|
160 break; |
|
161 } |
|
162 case ESimulateHackerAttack1: |
|
163 { |
|
164 TWsEvent event; |
|
165 TApaTaskList taskList(iEikonEnv->WsSession()); |
|
166 TApaTask task = taskList.FindApp(Application()->AppDllUid()); |
|
167 // First variant should be sorted by CCoeAppUi::HandleWsEventL |
|
168 event.SetType(EEventUser); |
|
169 *(TApaSystemEvent*)(event.EventData())=EApaSystemEventSecureShutdown; |
|
170 iEikonEnv->WsSession().SendEventToWindowGroup(task.WgId(), event); |
|
171 break; |
|
172 } |
|
173 case ESimulateHackerAttack2: |
|
174 { |
|
175 TWsEvent event; |
|
176 TApaTaskList taskList(iEikonEnv->WsSession()); |
|
177 TApaTask task = taskList.FindApp(Application()->AppDllUid()); |
|
178 // Second variant should be handled by wserv's Client::CommandL case EWsClOpSendEventToWindowGroup |
|
179 event.SetType(EEventPowerMgmt); |
|
180 *(TApaSystemEvent*)(event.EventData())=EApaSystemEventSecureShutdown; |
|
181 RWsSession wsSession; |
|
182 wsSession.Connect(); |
|
183 wsSession.SendEventToWindowGroup(task.WgId(), event); |
|
184 wsSession.Close(); |
|
185 break; |
|
186 } |
|
187 case ESimulateHackerAttack3: |
|
188 { |
|
189 TWsEvent event; |
|
190 // Third variant should be handled by wserv's Client::CommandL case EWsClOpSendEventToAllWindowGroup |
|
191 event.SetType(EEventPowerMgmt); |
|
192 *(TApaSystemEvent*)(event.EventData())=EApaSystemEventSecureShutdown; |
|
193 RWsSession wsSession; |
|
194 wsSession.Connect(); |
|
195 wsSession.SendEventToAllWindowGroups(event); |
|
196 wsSession.Close(); |
|
197 break; |
|
198 } |
|
199 default: |
|
200 break; |
|
201 } |
|
202 } |
|
203 |
|
204 void CEndTaskTestAppUi::HandleCommandL(TInt aCommand) |
|
205 { |
|
206 switch(aCommand) |
|
207 { |
|
208 case EEikCmdExit: |
|
209 Exit(); |
|
210 break; |
|
211 default: |
|
212 break; |
|
213 } |
|
214 } |