author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:53:46 +0300 | |
branch | RCL_3 |
changeset 130 | 67f2ed48ad91 |
parent 114 | a5a39a295112 |
permissions | -rw-r--r-- |
114 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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: Numeric key forwarding handler implementation for Active Idle |
|
15 |
* WS Plug-in. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
#include "numerickeyhandler.h" |
|
21 |
#include "uistate.h" |
|
22 |
||
23 |
#include <e32property.h> |
|
24 |
#include <centralrepository.h> |
|
25 |
#include <w32adll.h> |
|
26 |
||
27 |
#include <easydialingcrkeys.h> |
|
28 |
#include <spsettings.h> |
|
29 |
#include <featmgr.h> |
|
30 |
||
31 |
#include <PtiEngine.h> |
|
32 |
#include <activeidle2domainpskeys.h> |
|
33 |
#include <AvkonInternalCRKeys.h> |
|
34 |
#include <AknFepInternalCRKeys.h> |
|
35 |
||
36 |
#include <aiutility.h> |
|
37 |
#include <aipspropertyobserver.h> |
|
38 |
||
39 |
namespace AiWsPlugin { |
|
40 |
||
41 |
||
42 |
CNumericKeyHandler::CNumericKeyHandler |
|
43 |
( TInt aTargetWgId, MAnimGeneralFunctionsWindowExtension* aWindowExt ) : |
|
44 |
iTargetWgId( aTargetWgId ), |
|
45 |
iWindowExt( aWindowExt ) |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
void CNumericKeyHandler::ConstructL() |
|
50 |
{ |
|
51 |
// Read capability: ReadUserData. |
|
52 |
_LIT_SECURITY_POLICY_C1( KReadUserPolicy, ECapabilityReadUserData ); |
|
53 |
// Write capability: WriteDeviceData. |
|
54 |
_LIT_SECURITY_POLICY_C1( KWriteDevicePolicy, ECapabilityWriteDeviceData ); |
|
55 |
||
56 |
RProperty::Define( |
|
57 |
KPSUidAiInformation, |
|
58 |
KActiveIdleState, |
|
59 |
RProperty::EInt, |
|
60 |
KReadUserPolicy, |
|
61 |
KWriteDevicePolicy ); |
|
62 |
||
63 |
iQwertyObserver = AiUtility::CreatePSPropertyObserverL( |
|
64 |
TCallBack( HandleQwertyModeChanged, this ), |
|
65 |
KCRUidAvkon, KAknQwertyInputModeActive ); |
|
66 |
||
67 |
iInputLanguageRepository = CRepository::NewL( KCRUidAknFep ); |
|
68 |
iInputLanguageObserver = CCenRepNotifyHandler::NewL(*this, *iInputLanguageRepository); |
|
69 |
iInputLanguageObserver->StartListeningL(); |
|
70 |
||
71 |
RProperty::Get(KCRUidAvkon, KAknQwertyInputModeActive, iQwertyMode); |
|
72 |
iInputLanguageRepository->Get( KAknFepInputTxtLang, iInputLanguage ); |
|
73 |
||
74 |
// Load numeric keys mapping for qwerty |
|
75 |
if ( iQwertyMode ) |
|
76 |
{ |
|
77 |
LoadInputLanguageKeyBindings( iInputLanguage ); |
|
78 |
} |
|
79 |
} |
|
80 |
||
81 |
CNumericKeyHandler* CNumericKeyHandler::NewLC |
|
82 |
( TInt aTargetWgId, MAnimGeneralFunctionsWindowExtension* aWindowExt ) |
|
83 |
{ |
|
84 |
CNumericKeyHandler* self = new(ELeave) CNumericKeyHandler |
|
85 |
( aTargetWgId, aWindowExt ); |
|
86 |
CleanupStack::PushL( self ); |
|
87 |
self->ConstructL(); |
|
88 |
return self; |
|
89 |
} |
|
90 |
||
91 |
CNumericKeyHandler::~CNumericKeyHandler() |
|
92 |
{ |
|
93 |
if( iInputLanguageObserver ) |
|
94 |
{ |
|
95 |
iInputLanguageObserver->StopListening(); |
|
96 |
} |
|
97 |
delete iInputLanguageObserver; |
|
98 |
delete iInputLanguageRepository; |
|
99 |
Release(iQwertyObserver); |
|
100 |
iNumericKeys.Close(); |
|
101 |
} |
|
102 |
||
103 |
void CNumericKeyHandler::SetUiStateQuery( MUiState& aUiState ) |
|
104 |
{ |
|
105 |
iUiState = &aUiState; |
|
106 |
} |
|
107 |
||
108 |
void CNumericKeyHandler::FocusChanged( TBool /*aState*/ ) |
|
109 |
{ |
|
110 |
} |
|
111 |
||
112 |
TBool CNumericKeyHandler::OfferRawEvent(const TRawEvent& aRawEvent) |
|
113 |
{ |
|
114 |
switch( aRawEvent.Type() ) |
|
115 |
{ |
|
116 |
case TRawEvent::EKeyDown: |
|
117 |
{ |
|
118 |
if ( iUiState->HasFocus() && CheckPostToTarget( aRawEvent ) ) |
|
119 |
{ |
|
120 |
TInt forwardKeys = EPSAiForwardNumericKeysToPhone; |
|
121 |
||
122 |
TInt err = RProperty::Get( |
|
123 |
KPSUidAiInformation, |
|
124 |
KActiveIdleForwardNumericKeysToPhone, |
|
125 |
forwardKeys); |
|
126 |
// Key event forwarding disabled => Ignore the keys |
|
127 |
if ( err == KErrNone && |
|
128 |
forwardKeys == EPSAiDontForwardNumericKeysToPhone ) |
|
129 |
{ |
|
130 |
return EFalse; |
|
131 |
} |
|
132 |
// Phone app is listening this key and knows that next |
|
133 |
// focus event from window server is becuase key events |
|
134 |
// are coming to it. |
|
135 |
RProperty::Set( |
|
136 |
KPSUidAiInformation, |
|
137 |
KActiveIdleState, |
|
138 |
EPSAiNumberEntry ); |
|
139 |
||
140 |
// Switch focus to Phone app |
|
141 |
if( iWindowExt ) |
|
142 |
{ |
|
143 |
iWindowExt->SetOrdinalPosition( iTargetWgId, 0, 0 ); |
|
144 |
} |
|
145 |
} |
|
146 |
break; |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
// Never consume the key event as we want target application to process it |
|
151 |
return EFalse; |
|
152 |
} |
|
153 |
||
154 |
/** |
|
155 |
* Returns true if event should be forwarded to Phone app. |
|
156 |
*/ |
|
157 |
TBool CNumericKeyHandler::CheckPostToTarget(const TRawEvent& aRawEvent ) const |
|
158 |
{ |
|
159 |
const TInt scanCode = aRawEvent.ScanCode(); |
|
160 |
const TUint modifiers = iUiState->Modifiers(); |
|
161 |
||
162 |
if ( iQwertyMode ) |
|
163 |
{ |
|
164 |
// Don't pass the check if shift is pressed. |
|
165 |
if(( modifiers & EModifierShift ) == 0 ) |
|
166 |
{ |
|
167 |
TInt numericKeysCount = iNumericKeys.Count(); |
|
168 |
while( numericKeysCount-- ) |
|
169 |
{ |
|
170 |
TPtiNumericKeyBinding numKeyBind = iNumericKeys[numericKeysCount]; |
|
171 |
if( numKeyBind.iKey == scanCode ) |
|
172 |
{ |
|
173 |
return ETrue; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
} |
|
178 |
else |
|
179 |
{ |
|
180 |
// Normal check ignore modifiers |
|
181 |
static const TInt KIdPlgScanCodes[] = |
|
182 |
{ '1','2','3','4','5','6','7','8','9','0', |
|
183 |
'*',EStdKeyNkpAsterisk,EStdKeyHash,EStdKeyNkpPlus }; |
|
184 |
static const TInt KIdPlgScanCodeCount = |
|
185 |
sizeof( KIdPlgScanCodes ) / sizeof( KIdPlgScanCodes[0] ); |
|
186 |
TInt count = KIdPlgScanCodeCount; |
|
187 |
while( count-- ) |
|
188 |
{ |
|
189 |
const TInt refCode = KIdPlgScanCodes[ count ]; |
|
190 |
// Is one of [0,1,2,3,4,5,6,7,8,9,*,#]? |
|
191 |
if( refCode == scanCode ) |
|
192 |
{ |
|
193 |
return ETrue; |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
// Homescreen should open dialer also with alpha characters, if dialer is in |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
199 |
// mode that accepts alpha characters into number entry. |
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
200 |
// ou1cimx1#299396 & ou1cimx1#552069 |
114 | 201 |
|
202 |
const TInt KPhoneKeyStart = 33; |
|
130
67f2ed48ad91
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
114
diff
changeset
|
203 |
const TInt KPhoneKeyEnd = 129; |
114 | 204 |
|
205 |
return ( ( AllowAlphaNumericMode() ) && ( ( scanCode >= KPhoneKeyStart && |
|
206 |
scanCode <= KPhoneKeyEnd ) || modifiers & EModifierSpecial ) ); |
|
207 |
} |
|
208 |
||
209 |
||
210 |
/** |
|
211 |
* Load input locales. |
|
212 |
*/ |
|
213 |
void CNumericKeyHandler::LoadInputLanguageKeyBindings( TInt aLanguage ) |
|
214 |
{ |
|
215 |
iNumericKeys.Reset(); |
|
216 |
||
217 |
TRAPD( err, |
|
218 |
{ |
|
219 |
CPtiEngine* ptiEngine = CPtiEngine::NewL(); |
|
220 |
CleanupStack::PushL( ptiEngine ); |
|
221 |
ptiEngine->GetNumericModeKeysForQwertyL( aLanguage, |
|
222 |
iNumericKeys ); |
|
223 |
CleanupStack::PopAndDestroy( ptiEngine ); |
|
224 |
} ); // TRAP |
|
225 |
||
226 |
if ( err ) |
|
227 |
{ |
|
228 |
iNumericKeys.Reset(); |
|
229 |
iQwertyMode = 0; // To default mode |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
// remove numeric chars that not open number entry |
|
234 |
TInt numericKeysCount = iNumericKeys.Count(); |
|
235 |
while ( numericKeysCount-- ) |
|
236 |
{ |
|
237 |
TPtiNumericKeyBinding numKeyBind = iNumericKeys[numericKeysCount]; |
|
238 |
||
239 |
if ( numKeyBind.iChar == 'w' || |
|
240 |
numKeyBind.iChar == 'p' |
|
241 |
#ifndef RD_INTELLIGENT_TEXT_INPUT |
|
242 |
/* |
|
243 |
* The following code is commented because |
|
244 |
* For GQF requirement Space is mapped to "0" |
|
245 |
*/ |
|
246 |
|| numKeyBind.iKey == EPtiKeyQwertySpace |
|
247 |
#endif |
|
248 |
) |
|
249 |
{ |
|
250 |
iNumericKeys.Remove( numericKeysCount ); |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
/** |
|
257 |
* Handles qwerty mode change. |
|
258 |
*/ |
|
259 |
TInt CNumericKeyHandler::HandleQwertyModeChanged( TAny *aPtr ) |
|
260 |
{ |
|
261 |
CNumericKeyHandler* self = static_cast<CNumericKeyHandler*>( aPtr ); |
|
262 |
if( self ) |
|
263 |
{ |
|
264 |
TInt value = self->iQwertyMode; |
|
265 |
TInt err = self->iQwertyObserver->Get( value ); |
|
266 |
||
267 |
if( err == KErrNone ) |
|
268 |
{ |
|
269 |
self->SetQwertyMode( value ); |
|
270 |
} |
|
271 |
// Load key bindings if not already loaded |
|
272 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
273 |
if ( self->iQwertyMode ) |
|
274 |
{ |
|
275 |
self->iNumericKeys.Reset(); |
|
276 |
#else |
|
277 |
if ( self->iQwertyMode && !self->iNumericKeys.Count() ) |
|
278 |
{ |
|
279 |
#endif |
|
280 |
self->LoadInputLanguageKeyBindings( self->iInputLanguage ); |
|
281 |
} |
|
282 |
} |
|
283 |
return KErrNone; |
|
284 |
} |
|
285 |
||
286 |
/** |
|
287 |
* Handles input language change. |
|
288 |
*/ |
|
289 |
TInt CNumericKeyHandler::HandleInputLanguageChanged( TInt aNewValue ) |
|
290 |
{ |
|
291 |
SetInputLanguage( aNewValue ); |
|
292 |
LoadInputLanguageKeyBindings( aNewValue ); |
|
293 |
return KErrNone; |
|
294 |
} |
|
295 |
||
296 |
/** |
|
297 |
* Set qwerty mode. |
|
298 |
*/ |
|
299 |
void CNumericKeyHandler::SetQwertyMode( TInt aValue ) |
|
300 |
{ |
|
301 |
iQwertyMode = aValue; |
|
302 |
} |
|
303 |
||
304 |
/** |
|
305 |
* Set input language. |
|
306 |
*/ |
|
307 |
void CNumericKeyHandler::SetInputLanguage( TInt aValue ) |
|
308 |
{ |
|
309 |
iInputLanguage = aValue; |
|
310 |
} |
|
311 |
||
312 |
/** |
|
313 |
* Check alpha numeric mode. |
|
314 |
*/ |
|
315 |
TBool CNumericKeyHandler::AllowAlphaNumericMode() const |
|
316 |
{ |
|
317 |
return ( EasyDialingEnabled() || VoIPSupported() ); |
|
318 |
} |
|
319 |
||
320 |
/** |
|
321 |
* Check if voip supported. |
|
322 |
*/ |
|
323 |
TBool CNumericKeyHandler::VoIPSupported() const |
|
324 |
{ |
|
325 |
TBool voipSupported( EFalse ); |
|
326 |
CSPSettings* serviceProviderSettings( NULL ); |
|
327 |
||
328 |
TRAP_IGNORE( serviceProviderSettings = CSPSettings::NewL() ); |
|
329 |
||
330 |
if ( serviceProviderSettings ) |
|
331 |
{ |
|
332 |
voipSupported = serviceProviderSettings->IsFeatureSupported( |
|
333 |
ESupportInternetCallFeature ); |
|
334 |
||
335 |
delete serviceProviderSettings; |
|
336 |
} |
|
337 |
||
338 |
return voipSupported; |
|
339 |
} |
|
340 |
||
341 |
/** |
|
342 |
* Check if easy dialing enabled. |
|
343 |
*/ |
|
344 |
TBool CNumericKeyHandler::EasyDialingEnabled() const |
|
345 |
{ |
|
346 |
TBool easyDialingEnabled( EFalse ); |
|
347 |
if ( FeatureManager::FeatureSupported( |
|
348 |
KFeatureIdProductIncludesHomeScreenEasyDialing ) ) |
|
349 |
{ |
|
350 |
CRepository* cenrep( NULL ); |
|
351 |
TInt easyDialingSetting; |
|
352 |
||
353 |
TRAP_IGNORE( cenrep = CRepository::NewL( KCRUidEasyDialSettings ) ); |
|
354 |
||
355 |
if ( cenrep ) |
|
356 |
{ |
|
357 |
TInt err = cenrep->Get( KEasyDialing, easyDialingSetting ); |
|
358 |
if ( !err && easyDialingSetting ) |
|
359 |
{ |
|
360 |
easyDialingEnabled = ETrue; |
|
361 |
} |
|
362 |
||
363 |
delete cenrep; |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
return easyDialingEnabled; |
|
368 |
} |
|
369 |
||
370 |
void CNumericKeyHandler::HandleNotifyGeneric(TUint32 aKey) |
|
371 |
{ |
|
372 |
if( aKey == KAknFepInputTxtLang ) |
|
373 |
{ |
|
374 |
TInt newValue = iInputLanguage; |
|
375 |
iInputLanguageRepository->Get( KAknFepInputTxtLang, newValue ); |
|
376 |
HandleInputLanguageChanged( newValue ); |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
void CNumericKeyHandler::HandleNotifyError |
|
381 |
(TUint32 /*aKey*/, TInt /*aError*/, CCenRepNotifyHandler* /*aHandler*/) |
|
382 |
{ |
|
383 |
} |
|
384 |
||
385 |
} // namespace AiWsPlugin |