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 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Nokia Corporation - S60 implementation |
|
10 |
*******************************************************************************/ |
|
11 |
||
12 |
||
13 |
#include <hal.h> |
|
14 |
#include <aknsoundsystem.h> |
|
15 |
#include <aknappui.h> |
|
16 |
#include <aknenv.h> |
|
17 |
#include "swtmobiledevice.h" |
|
18 |
||
19 |
||
20 |
// ======== MEMBER FUNCTIONS ======== |
|
21 |
||
22 |
||
23 |
// --------------------------------------------------------------------------- |
|
24 |
// CSwtMobileDevice::NewL |
|
25 |
// --------------------------------------------------------------------------- |
|
26 |
// |
|
27 |
CSwtMobileDevice* CSwtMobileDevice::NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer) |
|
28 |
{ |
|
29 |
CSwtMobileDevice* self = new(ELeave) CSwtMobileDevice(aDisplay, aPeer); |
|
30 |
CleanupStack::PushL(self); |
|
31 |
self->ConstructL(); |
|
32 |
CleanupStack::Pop(self); |
|
33 |
return self; |
|
34 |
} |
|
35 |
||
36 |
// --------------------------------------------------------------------------- |
|
37 |
// CSwtMobileDevice::HwScreenCount |
|
38 |
// --------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
TInt CSwtMobileDevice::HwScreenCount() |
|
41 |
{ |
|
42 |
TInt count(1); |
|
43 |
HAL::Get(HAL::EDisplayNumberOfScreens, count); |
|
44 |
return count; |
|
45 |
} |
|
46 |
||
47 |
// --------------------------------------------------------------------------- |
|
48 |
// CSwtMobileDevice::GetHwInputs |
|
49 |
// --------------------------------------------------------------------------- |
|
50 |
// |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
51 |
void CSwtMobileDevice::GetHwInputs( |
66 | 52 |
RArray<CSwtMobileDevice::TSwtHwInput>& aInputs) |
53 |
{ |
|
54 |
TInt mask; |
|
55 |
TSwtHwInput tempInput; |
|
56 |
||
57 |
aInputs.Reset(); |
|
58 |
HAL::Get(HALData::EKeyboard, mask); |
|
59 |
||
60 |
if (mask & EKeyboard_Full) |
|
61 |
{ |
|
62 |
if (mask & EKeyboard_Keypad) |
|
63 |
{ |
|
64 |
tempInput.iLocation = MSwtMobileDevice::EInternal; |
|
65 |
} |
|
66 |
else |
|
67 |
{ |
|
68 |
tempInput.iLocation = MSwtMobileDevice::ELocal; |
|
69 |
} |
|
70 |
tempInput.iType = MSwtInput::ESoftKeys; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
71 |
aInputs.Append(tempInput); |
66 | 72 |
tempInput.iType = MSwtInput::EFullKeyboard; |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
73 |
aInputs.Append(tempInput); |
66 | 74 |
} |
75 |
||
76 |
if (mask & EKeyboard_Keypad) |
|
77 |
{ |
|
78 |
if (mask & EKeyboard_Full) |
|
79 |
{ |
|
80 |
tempInput.iLocation = MSwtMobileDevice::EExternal; |
|
81 |
} |
|
82 |
else |
|
83 |
{ |
|
84 |
tempInput.iLocation = MSwtMobileDevice::ELocal; |
|
85 |
} |
|
86 |
tempInput.iType = MSwtInput::ESoftKeys; |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
87 |
aInputs.Append(tempInput); |
66 | 88 |
tempInput.iType = MSwtInput::EKeyPad; |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
89 |
aInputs.Append(tempInput); |
66 | 90 |
} |
91 |
} |
|
92 |
||
93 |
// --------------------------------------------------------------------------- |
|
94 |
// CSwtMobileDevice::CSwtMobileDevice |
|
95 |
// --------------------------------------------------------------------------- |
|
96 |
// |
|
97 |
inline CSwtMobileDevice::CSwtMobileDevice(MSwtDisplay& aDisplay, TSwtPeer aPeer) |
|
98 |
: iDisplay(aDisplay), iPeer(aPeer) |
|
99 |
{ |
|
100 |
} |
|
101 |
||
102 |
// --------------------------------------------------------------------------- |
|
103 |
// CSwtMobileDevice::~CSwtMobileDevice |
|
104 |
// --------------------------------------------------------------------------- |
|
105 |
// |
|
106 |
CSwtMobileDevice::~CSwtMobileDevice() |
|
107 |
{ |
|
108 |
iObservers.Close(); |
|
109 |
if (iFlipWatch) |
|
110 |
{ |
|
111 |
delete iFlipWatch; |
|
112 |
iFlipWatch = NULL; |
|
113 |
} |
|
114 |
} |
|
115 |
||
116 |
// --------------------------------------------------------------------------- |
|
117 |
// CSwtMobileDevice::ConstructL |
|
118 |
// --------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
void CSwtMobileDevice::ConstructL() |
|
121 |
{ |
|
122 |
// Register with the display |
|
123 |
iDisplay.SetMobileDevice(this); |
|
124 |
||
125 |
// By default the device is open |
|
126 |
iFlipOpen = ETrue; |
|
127 |
||
128 |
// ASSUMPTION: The number of screens does not change |
|
129 |
iScreenCount = HwScreenCount(); |
|
130 |
||
131 |
// ASSUMPTION: No need for watching the flip for one screen |
|
132 |
if (iScreenCount > 1) |
|
133 |
{ |
|
134 |
iFlipWatch = CSwtFlipWatch::NewL(this); |
|
135 |
} |
|
136 |
||
137 |
iActiveScreenId = iDisplay.CoeEnv()->ScreenDevice()->GetScreenNumber(); |
|
138 |
} |
|
139 |
||
140 |
// --------------------------------------------------------------------------- |
|
141 |
// CSwtMobileDevice::FlipChangingL |
|
142 |
// From MSwtFlipObserver |
|
143 |
// --------------------------------------------------------------------------- |
|
144 |
// |
|
145 |
void CSwtMobileDevice::FlipChangingL() |
|
146 |
{ |
|
147 |
// For performance reasons while in fast sequence of swaps the observers |
|
148 |
// will get screen deactivated event only once. |
|
149 |
if (!iFlipChanging) |
|
150 |
{ |
|
151 |
for (TInt i = 0; i < iObservers.Count(); i++) |
|
152 |
{ |
|
153 |
iObservers[i]->ScreenDeactivatedL(iActiveScreenId); |
|
154 |
} |
|
155 |
} |
|
156 |
iFlipChanging = ETrue; |
|
157 |
} |
|
158 |
||
159 |
// --------------------------------------------------------------------------- |
|
160 |
// CSwtMobileDevice::FlipChangedL |
|
161 |
// From MSwtFlipObserver |
|
162 |
// --------------------------------------------------------------------------- |
|
163 |
// |
|
164 |
void CSwtMobileDevice::FlipChangedL(TBool aState) |
|
165 |
{ |
|
166 |
iFlipChanging = EFalse; |
|
167 |
||
168 |
// Report flip change |
|
169 |
TEventType eswtEvent; |
|
170 |
if (aState) |
|
171 |
{ |
|
172 |
eswtEvent = EEventOpened; |
|
173 |
} |
|
174 |
else |
|
175 |
{ |
|
176 |
eswtEvent = EEventClosed; |
|
177 |
} |
|
178 |
iFlipOpen = aState; |
|
179 |
iDisplay.PostMobileDeviceEventL(iPeer, eswtEvent); |
|
180 |
||
181 |
// For performance reasons while in fast sequence of swaps the observers |
|
182 |
// will get screen deactivated event only once. |
|
183 |
// ASSUMPTION: The screen changes if the flip changes. |
|
184 |
iActiveScreenId = iDisplay.CoeEnv()->ScreenDevice()->GetScreenNumber(); |
|
185 |
for (TInt i = 0; i < iObservers.Count(); i++) |
|
186 |
{ |
|
187 |
iObservers[i]->ScreenActivatedL(iActiveScreenId); |
|
188 |
} |
|
189 |
} |
|
190 |
||
191 |
// --------------------------------------------------------------------------- |
|
192 |
// CSwtMobileDevice::AddObserverL |
|
193 |
// From MSwtMobileDevice |
|
194 |
// --------------------------------------------------------------------------- |
|
195 |
// |
|
196 |
TBool CSwtMobileDevice::AddObserverL( |
|
197 |
const MSwtMobileDeviceObserver* aObserver) |
|
198 |
{ |
|
199 |
if (iObservers.Find(aObserver) != KErrNotFound) |
|
200 |
{ |
|
201 |
return EFalse; |
|
202 |
} |
|
203 |
User::LeaveIfError(iObservers.Append(aObserver)); |
|
204 |
return ETrue; |
|
205 |
} |
|
206 |
||
207 |
// --------------------------------------------------------------------------- |
|
208 |
// CSwtMobileDevice::Alert |
|
209 |
// From MSwtMobileDevice |
|
210 |
// --------------------------------------------------------------------------- |
|
211 |
// |
|
212 |
void CSwtMobileDevice::Alert(TAlertLevel aLevel) |
|
213 |
{ |
|
214 |
TAvkonSystemSID toneType(EAvkonSIDNoSound); |
|
215 |
||
216 |
switch (aLevel) |
|
217 |
{ |
|
218 |
case EAlertLowImportance: |
|
219 |
toneType = EAvkonSIDInformationTone; |
|
220 |
break; |
|
221 |
case EAlertHighImportance: |
|
222 |
toneType = EAvkonSIDWarningTone; |
|
223 |
break; |
|
224 |
case EAlertCritical: |
|
225 |
toneType = EAvkonSIDErrorTone; |
|
226 |
break; |
|
227 |
default: |
|
228 |
ASSERT(EFalse); |
|
229 |
break; |
|
230 |
} |
|
231 |
||
232 |
CEikonEnv* eikonEnv = iDisplay.CoeEnv(); |
|
233 |
if (eikonEnv) |
|
234 |
{ |
|
235 |
CAknKeySoundSystem* soundSystem = static_cast<CAknAppUi*>( |
|
236 |
eikonEnv->EikAppUi())->KeySounds(); |
|
237 |
if (soundSystem) |
|
238 |
{ |
|
239 |
soundSystem->PlaySound(toneType); |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
// --------------------------------------------------------------------------- |
|
245 |
// CSwtMobileDevice::Dispose |
|
246 |
// From MSwtMobileDevice |
|
247 |
// --------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
TSwtPeer CSwtMobileDevice::Dispose() |
|
250 |
{ |
|
251 |
TSwtPeer peer(iPeer); |
|
252 |
delete this; |
|
253 |
return peer; |
|
254 |
} |
|
255 |
||
256 |
// --------------------------------------------------------------------------- |
|
257 |
// CSwtMobileDevice::GetInputNumber |
|
258 |
// From MSwtMobileDevice |
|
259 |
// --------------------------------------------------------------------------- |
|
260 |
// |
|
261 |
TInt CSwtMobileDevice::GetInputNumber() const |
|
262 |
{ |
|
263 |
TInt res = 0; |
|
264 |
TInt mask = 0; |
|
265 |
||
266 |
HAL::Get(HALData::EKeyboard, mask); |
|
267 |
||
268 |
// WARNING: The platform returns always a single full keyboard so this will |
|
269 |
// not work properly till it is fixed by the platform. |
|
270 |
// ASSUMPTION: For each keyboard count the softkeys also. |
|
271 |
if (mask & EKeyboard_Full) |
|
272 |
{ |
|
273 |
res += 2; |
|
274 |
} |
|
275 |
if (mask & EKeyboard_Keypad) |
|
276 |
{ |
|
277 |
res += 2; |
|
278 |
} |
|
279 |
||
280 |
return res; |
|
281 |
} |
|
282 |
||
283 |
// --------------------------------------------------------------------------- |
|
284 |
// CSwtMobileDevice::GetScreenNumber |
|
285 |
// From MSwtMobileDevice |
|
286 |
// --------------------------------------------------------------------------- |
|
287 |
// |
|
288 |
TInt CSwtMobileDevice::GetScreenNumber() const |
|
289 |
{ |
|
290 |
return HwScreenCount(); |
|
291 |
} |
|
292 |
||
293 |
// --------------------------------------------------------------------------- |
|
294 |
// CSwtMobileDevice::IsOpen |
|
295 |
// From MSwtMobileDevice |
|
296 |
// --------------------------------------------------------------------------- |
|
297 |
// |
|
298 |
TBool CSwtMobileDevice::IsOpen() const |
|
299 |
{ |
|
300 |
return iFlipOpen; |
|
301 |
} |
|
302 |
||
303 |
// --------------------------------------------------------------------------- |
|
304 |
// CSwtMobileDevice::RemoveObserver |
|
305 |
// From MSwtMobileDevice |
|
306 |
// --------------------------------------------------------------------------- |
|
307 |
// |
|
308 |
TBool CSwtMobileDevice::RemoveObserver( |
|
309 |
const MSwtMobileDeviceObserver* aObserver) |
|
310 |
{ |
|
311 |
TInt pos = iObservers.Find(aObserver); |
|
312 |
if (pos == KErrNotFound) |
|
313 |
{ |
|
314 |
return EFalse; |
|
315 |
} |
|
316 |
iObservers.Remove(pos); |
|
317 |
return ETrue; |
|
318 |
} |