author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 77 | 7cee158cb8cd |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 1999-2001 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <eikenv.h> |
|
19 |
#include <eiksrvc.h> |
|
20 |
#include <eikappui.h> |
|
21 |
#include <Lcdglue.h> |
|
22 |
#include <j2me/jdebug.h> |
|
23 |
// needed for javaregistry |
|
24 |
#include <javaregistryentry.h> |
|
25 |
#include <javaregistry.h> |
|
26 |
#include <javaattribute.h> |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
27 |
|
66 | 28 |
#include "CMIDAppUi.h" |
29 |
// using CMIDApplication API for iApp |
|
30 |
#include "CMIDApplication.h" |
|
31 |
// needed for creating CMIDComponentFactory |
|
32 |
#include "CMIDComponentFactory.h" |
|
33 |
// CMIDDisplayable class for iCurrentDisplayable |
|
34 |
#include "CMIDDisplayable.h" |
|
35 |
||
36 |
#include "LcduiThread.h" |
|
37 |
||
38 |
#include "logger.h" |
|
39 |
||
40 |
using namespace java::ui; |
|
41 |
using namespace Java; |
|
42 |
||
43 |
// class CMIDAppUi |
|
44 |
CMIDAppUi::CMIDAppUi() : iCurrentDisplayable(NULL), |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
45 |
iPendingOrientationChange(EFalse), iPauseApp(EFalse) |
66 | 46 |
{ |
47 |
mJavaAppUi = java::ui::CoreUiAvkonLcdui::getInstance().getJavaAknAppUi(); |
|
48 |
mCoreAppUi = java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi(); |
|
49 |
} |
|
50 |
||
51 |
void CMIDAppUi::ConstructL() |
|
52 |
{ |
|
53 |
DEBUG("+ CMIDAppUi::ConstructL()"); |
|
54 |
// get uid of the midlet |
|
55 |
RLcdui::Get()->AttachL(this); |
|
56 |
DEBUG("- CMIDAppUi::ConstructL()"); |
|
57 |
} |
|
58 |
||
59 |
CMIDAppUi::~CMIDAppUi() |
|
60 |
{ |
|
61 |
iDisplayables.Close(); |
|
62 |
RLcdui::Get()->Detach(); |
|
63 |
} |
|
64 |
||
65 |
void CMIDAppUi::SetCurrentDisplayable(CMIDDisplayable* aDisplayable) |
|
66 |
{ |
|
67 |
iCurrentDisplayable = aDisplayable; |
|
68 |
} |
|
69 |
||
70 |
void CMIDAppUi::HandleCommandL(TInt aCommand) |
|
71 |
{ |
|
72 |
switch (aCommand) |
|
73 |
{ |
|
74 |
// Help command received (i.e. after the EStdKeyHelp button was pressed) |
|
75 |
case EAknCmdHelp: |
|
76 |
if (iCurrentDisplayable) |
|
77 |
{ |
|
78 |
// Let the current displayable to process help command |
|
79 |
iCurrentDisplayable->HandleHelpCommandL(); |
|
80 |
} |
|
81 |
break; |
|
82 |
case EEikCmdExit: |
|
83 |
if (iObserver) |
|
84 |
{ |
|
85 |
iObserver->HandleExitL(); |
|
86 |
} |
|
87 |
else |
|
88 |
{ |
|
89 |
// |
|
90 |
// |
|
91 |
// |
|
92 |
} |
|
93 |
break; |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
void CMIDAppUi::HandleSwitchOnEventL(CCoeControl*) |
|
98 |
{ |
|
99 |
if (iObserver) |
|
100 |
{ |
|
101 |
iObserver->HandleSwitchOnEventL(); |
|
102 |
} |
|
103 |
else |
|
104 |
{ |
|
105 |
// |
|
106 |
// |
|
107 |
// |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
void CMIDAppUi::HandleForegroundEventL(TBool aForeground) |
|
112 |
{ |
|
113 |
if (iObserver) |
|
114 |
{ |
|
115 |
iObserver->HandleForegroundL(aForeground); |
|
116 |
} |
|
117 |
else |
|
118 |
{ |
|
119 |
// |
|
120 |
// |
|
121 |
// |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
void CMIDAppUi::HandleResourceChangeL(TInt aType) |
|
126 |
{ |
|
127 |
if (iObserver) |
|
128 |
{ |
|
129 |
iObserver->HandleResourceChangeL(aType); |
|
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
if (aType == KEikDynamicLayoutVariantSwitch) |
|
134 |
{ |
|
135 |
// Observer not set yet. Storing it for use after it is set. |
|
136 |
iPendingOrientationChange= ETrue; |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
||
141 |
void CMIDAppUi::HandleApplicationSpecificEventL(TInt /*aType*/, const TWsEvent& /*aEvent*/) |
|
142 |
{ |
|
143 |
} |
|
144 |
||
145 |
TBool CMIDAppUi::HandleWsEventL(const TWsEvent& aEvent, |
|
146 |
CCoeControl* /*aDestination*/) |
|
147 |
{ |
|
148 |
||
149 |
// Intercept end-key press when the Nokia-MIDlet-no-exit JAD-attribute is defined. |
|
150 |
// Intercept the WS event in case of red end-key press |
|
151 |
if (aEvent.Type() == KAknUidValueEndKeyCloseEvent) |
|
152 |
{ |
|
153 |
// If JAD attribute Nokia-MIDlet-no-exit is defined, it will be used define End-key behavior |
|
154 |
if (iEnv && iEnv->MidletAttributeIsSetToVal( |
|
155 |
LcduiMidletAttributes::KAttribNoExitKey, |
|
156 |
LcduiMidletAttributeValues::KTrueValue)) |
|
157 |
{ |
|
158 |
return ETrue; |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
// No JAD attribute. Ask the CoreUi to shutdown the MIDlet. |
|
163 |
java::ui::CoreUiAvkonLcdui::getInstance().shutDownRequestFromWindowServer(); |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
if (aEvent.Type() == EEventUser) |
|
168 |
{ |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
77
diff
changeset
|
169 |
if ((*reinterpret_cast<TApaSystemEvent*>(aEvent.EventData())) == EApaSystemEventShutdown) |
66 | 170 |
{ |
171 |
// Oom or exit from task-list. Ask the CoreUi to shutdown the MIDlet. |
|
172 |
java::ui::CoreUiAvkonLcdui::getInstance().shutDownRequestFromWindowServer(); |
|
173 |
} |
|
174 |
} |
|
175 |
||
176 |
// Workaround to send pauseApp with long-press of the Menu key |
|
177 |
if (aEvent.Type() == EEventKey) |
|
178 |
{ |
|
179 |
if (aEvent.Key()->iScanCode == EStdKeyApplication0 |
|
180 |
&& aEvent.Key()->iRepeats == 1 && !iPauseApp) |
|
181 |
{ |
|
182 |
if (iEnv && iEnv->MidletAttributeIsSetToVal( |
|
183 |
LcduiMidletAttributes::KAttribFlipClose, |
|
184 |
LcduiMidletAttributeValues::KPauseValue)) |
|
185 |
{ |
|
186 |
iEnv->PostMidletEvent(EPause); |
|
187 |
SetPauseAppState(ETrue); |
|
188 |
} |
|
189 |
} |
|
190 |
} |
|
191 |
||
192 |
if (aEvent.Type() == EEventKeyUp) |
|
193 |
{ |
|
194 |
||
195 |
if (aEvent.Key()->iScanCode == EStdKeyDeviceA) // if flip is opened |
|
196 |
{ |
|
197 |
if (iEnv && iEnv->MidletAttributeIsSetToVal( |
|
198 |
LcduiMidletAttributes::KAttribFlipClose, |
|
199 |
LcduiMidletAttributeValues::KPauseValue)) |
|
200 |
||
201 |
{ |
|
202 |
iEnv->PostMidletEvent(EStart); |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
if (aEvent.Key()->iScanCode == EStdKeyDeviceB) // if flip is closed |
|
207 |
{ |
|
208 |
if (iEnv && iEnv->MidletAttributeIsSetToVal( |
|
209 |
LcduiMidletAttributes::KAttribFlipClose, |
|
210 |
LcduiMidletAttributeValues::KPauseValue)) |
|
211 |
{ |
|
212 |
iEnv->PostMidletEvent(EPause); |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
if (aEvent.Type() == EEventKeyDown) |
|
218 |
{ |
|
219 |
if (iEnv) |
|
220 |
{ |
|
221 |
iEnv->SetLastKeyEvent(*aEvent.Key()); |
|
222 |
} |
|
223 |
} |
|
224 |
||
225 |
// Handle application focus lost and notify current Displayable. |
|
226 |
if ((aEvent.Type() == KAknFullOrPartialForegroundLost) |
|
227 |
|| (aEvent.Type() == EEventFocusLost)) |
|
228 |
{ |
|
229 |
#ifdef RD_JAVA_NGA_ENABLED |
|
230 |
if (aEvent.Type() == KAknFullOrPartialForegroundLost && iObserver) |
|
231 |
{ |
|
232 |
iObserver->HandleFullOrPartialForegroundL(EFalse); |
|
233 |
} |
|
234 |
#endif // RD_JAVA_NGA_ENABLED |
|
235 |
||
236 |
if (iCurrentDisplayable && (iDisplayables.Count() > 0)) |
|
237 |
{ |
|
238 |
iCurrentDisplayable->HandleApplicationBackground(); |
|
239 |
} |
|
240 |
} |
|
241 |
||
242 |
// Handle input language change and notify current Displayable |
|
243 |
if (aEvent.Type() == KEikInputLanguageChange) |
|
244 |
{ |
|
245 |
if (iCurrentDisplayable) |
|
246 |
{ |
|
247 |
iCurrentDisplayable->HandleResourceChange(aEvent.Type()); |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
#ifdef RD_JAVA_NGA_ENABLED |
|
252 |
if (aEvent.Type() == KAknFullOrPartialForegroundGained && iObserver) |
|
253 |
{ |
|
254 |
iObserver->HandleFullOrPartialForegroundL(ETrue); |
|
255 |
} |
|
256 |
#endif // RD_JAVA_NGA_ENABLED |
|
257 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
258 |
if (aEvent.Type() == KAknShutOrHideApp) |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
259 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
260 |
java::ui::CoreUiAvkonLcdui::getInstance().shutDownRequestFromWindowServer(); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
261 |
} |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
262 |
|
66 | 263 |
return EFalse; |
264 |
} |
|
265 |
||
266 |
// Sets the link to MMIDEnv - used for jad attribute parsing |
|
267 |
void CMIDAppUi::SetEnv(MMIDEnv& aEnv) |
|
268 |
{ |
|
269 |
iEnv = &aEnv; |
|
270 |
} |
|
271 |
||
272 |
void CMIDAppUi::UnSetEnv() |
|
273 |
{ |
|
274 |
iEnv = 0; |
|
275 |
} |
|
276 |
||
277 |
// |
|
278 |
// From MLcduiPlugin |
|
279 |
// |
|
280 |
void CMIDAppUi::SetObserverL(MMIDObserver* aObserver) |
|
281 |
{ |
|
282 |
iObserver = aObserver; |
|
283 |
if (iPendingOrientationChange) |
|
284 |
{ |
|
285 |
// We have received orientation change during the construction phase. |
|
286 |
// Resending it again in order to ensure correct layout and |
|
287 |
// orientation. |
|
288 |
iObserver->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch); |
|
289 |
iPendingOrientationChange = EFalse; |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
// |
|
294 |
// From MLcduiPlugin |
|
295 |
// |
|
296 |
MMIDComponentFactory* CMIDAppUi::CreateComponentFactoryL() |
|
297 |
{ |
|
298 |
return new(ELeave) CMIDComponentFactory; |
|
299 |
} |
|
300 |
||
301 |
// |
|
302 |
// From MLcduiPlugin |
|
303 |
// |
|
304 |
void CMIDAppUi::SetEnv(MMIDEnv* aEnv) |
|
305 |
{ |
|
306 |
iEnv = aEnv; |
|
307 |
} |
|
308 |
||
309 |
RPointerArray<CMIDDisplayable>& CMIDAppUi::Displayables() |
|
310 |
{ |
|
311 |
return iDisplayables; |
|
312 |
} |
|
313 |
||
314 |
void CMIDAppUi::AddToStackL(CCoeControl *aControl, TInt aPriority, TInt aStackingFlags) |
|
315 |
{ |
|
316 |
JELOG2(EJavaUI); |
|
317 |
mJavaAppUi->AddToStackL(aControl, aPriority, aStackingFlags); |
|
318 |
} |
|
319 |
||
320 |
TRect CMIDAppUi::ApplicationRect() const |
|
321 |
{ |
|
322 |
JELOG2(EJavaUI); |
|
323 |
return mJavaAppUi->ApplicationRect(); |
|
324 |
} |
|
325 |
||
326 |
TRect CMIDAppUi::ClientRect() const |
|
327 |
{ |
|
328 |
JELOG2(EJavaUI); |
|
329 |
return mJavaAppUi->ClientRect(); |
|
330 |
} |
|
331 |
||
332 |
CAknToolbar* CMIDAppUi::CurrentFixedToolbar() const |
|
333 |
{ |
|
334 |
JELOG2(EJavaUI); |
|
335 |
return mJavaAppUi->CurrentFixedToolbar(); |
|
336 |
} |
|
337 |
||
338 |
void CMIDAppUi::RemoveFromStack(CCoeControl *aControl) |
|
339 |
{ |
|
340 |
JELOG2(EJavaUI); |
|
341 |
mJavaAppUi->RemoveFromStack(aControl); |
|
342 |
} |
|
343 |
||
344 |
CEikStatusPane* CMIDAppUi::StatusPane() |
|
345 |
{ |
|
346 |
JELOG2(EJavaUI); |
|
347 |
return mJavaAppUi->StatusPane(); |
|
348 |
} |
|
349 |
||
350 |
void CMIDAppUi::SetPauseAppState(TBool aState) |
|
351 |
{ |
|
352 |
JELOG2(EJavaUI); |
|
353 |
iPauseApp = aState; |
|
354 |
} |
|
355 |
||
356 |
TBool CMIDAppUi::GetPauseAppState() |
|
357 |
{ |
|
358 |
JELOG2(EJavaUI); |
|
359 |
return iPauseApp; |
|
360 |
} |
|
361 |