|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 // #include "xqservicelog.h" |
|
23 |
|
24 #include <QCoreApplication> |
|
25 #include <QKeyEvent> |
|
26 #include <QEvent> |
|
27 #include <QLabel> |
|
28 #include <QVBoxLayout> |
|
29 #include <QStackedWidget> |
|
30 #include <QImageReader> |
|
31 #include <QTimer> |
|
32 #include <QPushButton> |
|
33 #include <QLineEdit> |
|
34 #include <QListView> |
|
35 #include <QMessageBox> |
|
36 #include <QToolButton> |
|
37 #include <QSymbianEvent> |
|
38 #include <QMainWindow> |
|
39 #include <qvaluespacesubscriber.h> |
|
40 #include <qvaluespacepublisher.h> |
|
41 |
|
42 QTM_USE_NAMESPACE |
|
43 |
|
44 #include <HbIndicator> |
|
45 #include <hbdevicemessagebox.h> |
|
46 |
|
47 #include <lockappclientserver.h> |
|
48 |
|
49 #include <xqsharablefile.h> |
|
50 |
|
51 #include <QGraphicsLinearLayout> |
|
52 |
|
53 #include <hblabel.h> |
|
54 |
|
55 #include "Autolock.h" |
|
56 #include <xqserviceutil.h> |
|
57 |
|
58 #include "autolockuseractivityservice.h" |
|
59 |
|
60 #include <settingsinternalcrkeys.h> // CenRep keys |
|
61 #include <w32std.h> |
|
62 #include <eikenv.h> |
|
63 |
|
64 #include <secuisecuritysettings.h> |
|
65 #include <secui.h> |
|
66 #include <secuisecurityhandler.h> |
|
67 #include <etelmm.h> |
|
68 #include <rmmcustomapi.h> |
|
69 #include <keylockpolicyapi.h> |
|
70 #include <qvaluespacesubscriber.h> |
|
71 |
|
72 #include <hwrmlightdomaincrkeys.h> |
|
73 #include <ProfileEngineSDKCRKeys.h> |
|
74 #include <e32property.h> |
|
75 #include <coreapplicationuisdomainpskeys.h> |
|
76 #include "../PubSub/securityuisprivatepskeys.h" |
|
77 #include <avkondomainpskeys.h> |
|
78 #include <hwrmdomainpskeys.h> |
|
79 |
|
80 #include <hbdevicedialog.h> |
|
81 |
|
82 const TInt KPhoneIndex(0); |
|
83 const TInt KTriesToConnectServer(2); |
|
84 const TInt KTimeBeforeRetryingServerConnection(50000); |
|
85 |
|
86 #define ESecUiTypeLock 0x00100000 |
|
87 |
|
88 _LIT( KMmTsyModuleName, "PhoneTsy"); |
|
89 |
|
90 // Constant definitions to control screensaver view types |
|
91 static const char *KSnsrViewTypeKey = "view_type"; |
|
92 static const int KSnsrViewTypeValueActive = 1; |
|
93 static const int KSnsrViewTypeValueStandby = 2; |
|
94 static const char *KSnsrCmdUnlock = "unlock"; |
|
95 |
|
96 Autolock::Autolock(QWidget *parent, Qt::WFlags f) : |
|
97 QWidget(parent, f), mService(NULL) |
|
98 { |
|
99 RDEBUG("start autolock", 0); |
|
100 |
|
101 // The very first thing is to define the properties, so that others can use them. |
|
102 TSecurityPolicy readPolicy(ECapabilityReadDeviceData); |
|
103 TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); |
|
104 TInt ret = RProperty::Define(KPSUidSecurityUIs, |
|
105 KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, |
|
106 writePolicy); |
|
107 RDEBUG("defined KSecurityUIsSecUIOriginatedQuery", ret); |
|
108 ret = RProperty::Define(KPSUidSecurityUIs, |
|
109 KSecurityUIsQueryRequestCancel, RProperty::EInt, readPolicy, |
|
110 writePolicy); |
|
111 RDEBUG("defined KSecurityUIsQueryRequestCancel", ret); |
|
112 |
|
113 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
|
114 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
|
115 ret = RProperty::Define(KPSUidCoreApplicationUIs, |
|
116 KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, |
|
117 KWritePolicy); |
|
118 RDEBUG("defined KCoreAppUIsAutolockStatus", ret); |
|
119 |
|
120 // This is important: we set the status through a property |
|
121 TInt autolockState; |
|
122 ret = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
123 RDEBUG("Get KCoreAppUIsAutolockStatus", ret); |
|
124 RDEBUG("autolockState", autolockState); |
|
125 if(autolockState==EAutolockStatusUninitialized) |
|
126 { |
|
127 autolockState = EAutolockOff; // not-initialized means taht the unlock-query hasn't been displayed. Therefore the device should not stay locked. |
|
128 } |
|
129 ret = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, |
|
130 autolockState); // this might re-set it. That's not bad. It will re-notify all listeners. |
|
131 RDEBUG("Set KCoreAppUIsAutolockStatus", ret); |
|
132 |
|
133 ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus, |
|
134 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
|
135 KWritePolicy); |
|
136 RDEBUG("defined KAknKeyguardStatus", ret); |
|
137 |
|
138 ret = RProperty::Define(KPSUidSecurityUIs, |
|
139 KSecurityUIsLockInitiatorUID, RProperty::EInt, readPolicy, |
|
140 writePolicy); |
|
141 RDEBUG("defined KSecurityUIsLockInitiatorUID", ret); |
|
142 |
|
143 ret = RProperty::Define(KPSUidSecurityUIs, |
|
144 KSecurityUIsLockInitiatorTimeHigh, RProperty::EInt, readPolicy, |
|
145 writePolicy); |
|
146 RDEBUG("defined KSecurityUIsLockInitiatorTimeHigh", ret); |
|
147 ret = RProperty::Define(KPSUidSecurityUIs, |
|
148 KSecurityUIsLockInitiatorTimeLow, RProperty::EInt, readPolicy, |
|
149 writePolicy); |
|
150 RDEBUG("defined KSecurityUIsLockInitiatorTimeLow", ret); |
|
151 |
|
152 ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLights, |
|
153 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
|
154 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
|
155 RDEBUG("defined KAknKeyguardStatus", ret); |
|
156 |
|
157 ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, |
|
158 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
|
159 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
|
160 RDEBUG("defined KSecurityUIsDismissDialog", ret); |
|
161 |
|
162 |
|
163 |
|
164 mService = new AutolockService(this); |
|
165 |
|
166 /* Adjust the palette */ |
|
167 #if defined(Q_WS_S60) |
|
168 // this is defined. |
|
169 RDEBUG( "Q_WS_S60", 1 ); |
|
170 QPalette p = qApp->palette(); |
|
171 QColor color(192,192,192); |
|
172 QColor bg(201,250,250); |
|
173 p.setColor(QPalette::Highlight, color.lighter(200)); |
|
174 p.setColor(QPalette::Text, Qt::black); |
|
175 p.setColor(QPalette::Base, bg); |
|
176 p.setColor(QPalette::WindowText, Qt::black); |
|
177 p.setColor(QPalette::Window, bg); |
|
178 p.setColor(QPalette::ButtonText, Qt::black); |
|
179 p.setColor(QPalette::Button, color.lighter(150)); |
|
180 p.setColor(QPalette::Link, QColor(240,40,40)); |
|
181 |
|
182 qApp->setPalette(p); |
|
183 #endif |
|
184 |
|
185 RDEBUG("connect", 1); |
|
186 |
|
187 |
|
188 #if defined(Q_WS_X11) || defined(Q_WS_WIN) |
|
189 setFixedSize(QSize(360,640)); // nHD |
|
190 #elif defined(Q_WS_S60) |
|
191 // this doesn't work well |
|
192 // showMaximized(); |
|
193 showFullScreen(); |
|
194 #endif |
|
195 |
|
196 serviceKeyguard = new AutolockUserActivityService(); |
|
197 serviceDevicelock = new AutolockUserActivityService(); |
|
198 |
|
199 TInt lockValue = 0; |
|
200 TInt lightsTimeout = 0; |
|
201 CRepository* repository = NULL; |
|
202 TInt cRresult = 0; |
|
203 |
|
204 iLockStatusPrev = ELockNotActive; |
|
205 iLockStatus = ELockNotActive; |
|
206 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); |
|
207 cRresult = repository->Get(KSettingsAutolockStatus, lockValue); |
|
208 RDEBUG("KSettingsAutolockStatus", KSettingsAutolockStatus); |
|
209 RDEBUG("cRresult", cRresult); |
|
210 RDEBUG("lockValue", lockValue); |
|
211 iLockStatus = lockValue; |
|
212 // the settings says to lock |
|
213 delete repository; |
|
214 |
|
215 adjustInactivityTimers(0); |
|
216 |
|
217 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidProfileEngine) ); |
|
218 cRresult = repository->Get(KProEngActiveProfile, lightsTimeout); |
|
219 // this value is not used for now |
|
220 delete repository; |
|
221 |
|
222 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidLightSettings) ); |
|
223 cRresult = repository->Get(KDisplayLightsTimeout, lightsTimeout); |
|
224 // this value is not used for now |
|
225 delete repository; |
|
226 |
|
227 // subscribe to settings changes |
|
228 subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber( |
|
229 "/KCRUidSecuritySettings/KSettingsAutolockStatus", this); |
|
230 connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()), |
|
231 this, SLOT(subscriberKSettingsAutolockStatusChanged())); |
|
232 subscriberKSettingsAutoLockTime = new QValueSpaceSubscriber( |
|
233 "/KCRUidSecuritySettings/KSettingsAutoLockTime", this); |
|
234 connect(subscriberKSettingsAutoLockTime, SIGNAL(contentsChanged()), this, |
|
235 SLOT(subscriberKSettingsAutoLockTimeChanged())); |
|
236 subscriberKSettingsAutomaticKeyguardTime = new QValueSpaceSubscriber( |
|
237 "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime", this); |
|
238 connect(subscriberKSettingsAutomaticKeyguardTime, SIGNAL( |
|
239 contentsChanged()), this, SLOT( |
|
240 subscriberKSettingsAutomaticKeyguardTimeChanged())); |
|
241 subscriberKDisplayLightsTimeout = new QValueSpaceSubscriber( |
|
242 "/KCRUidLightSettings/KDisplayLightsTimeout", this); |
|
243 connect(subscriberKDisplayLightsTimeout, SIGNAL(contentsChanged()), this, |
|
244 SLOT(subscriberKDisplayLightsTimeoutChanged())); |
|
245 subscriberKProEngActiveProfile = new QValueSpaceSubscriber( |
|
246 "/KCRUidProfileEngine/KProEngActiveProfile", this); |
|
247 connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this, |
|
248 SLOT(subscriberKProEngActiveProfileChanged())); |
|
249 |
|
250 subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber( |
|
251 "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this); |
|
252 connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, |
|
253 SLOT(subscriberKSecurityUIsDismissDialogChanged())); |
|
254 |
|
255 // subscribe to environment changes |
|
256 subscriberKHWRMGripStatus = new QValueSpaceSubscriber( |
|
257 "/KPSUidHWRM/KHWRMGripStatus"); |
|
258 connect(subscriberKHWRMGripStatus, SIGNAL(contentsChanged()), this, |
|
259 SLOT(subscriberKHWRMGripStatusChanged())); |
|
260 |
|
261 subscriberKAknKeyguardStatus = new QValueSpaceSubscriber( |
|
262 "/KPSUidAvkonDomain/KAknKeyguardStatus"); |
|
263 connect(subscriberKAknKeyguardStatus, SIGNAL(contentsChanged()), this, |
|
264 SLOT(subscriberKAknKeyguardStatusChanged())); |
|
265 |
|
266 subscriberKCoreAppUIsAutolockStatus = new QValueSpaceSubscriber( |
|
267 "/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus"); |
|
268 connect(subscriberKCoreAppUIsAutolockStatus, SIGNAL(contentsChanged()), this, |
|
269 SLOT(subscriberKCoreAppUIsAutolockStatusChanged())); |
|
270 |
|
271 |
|
272 // inactivity |
|
273 connect(serviceKeyguard, SIGNAL(active()), this, SLOT(activeKeyguard())); |
|
274 connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT( |
|
275 notActiveKeyguard())); |
|
276 connect(serviceDevicelock, SIGNAL(active()), this, SLOT( |
|
277 activeDevicelock())); |
|
278 connect(serviceDevicelock, SIGNAL(notActive()), this, SLOT( |
|
279 notActiveDevicelock())); |
|
280 |
|
281 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
|
282 RDEBUG("got groupWin", 1); |
|
283 // if I want to release, I should do: mKeyCaptureHandle = env->RootWin().CaptureKey(EKeyBackspace, 0, 0); |
|
284 groupWin.CaptureKey(EKeyDeviceF, 0, 0); |
|
285 groupWin.CaptureKey(EKeyBell, 0, 0); |
|
286 RDEBUG("got mKeyCaptureHandle", 1); |
|
287 |
|
288 iSecQueryUiCreated = -1; |
|
289 iDeviceDialogCreated = EDeviceDialogUninitialized; |
|
290 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
291 iDeviceDialog = NULL; |
|
292 // for now, always starts unlocked. This is correct because if locked, the unlock-query (from starter) is on top |
|
293 // TryChangeStatus(iLockStatus); |
|
294 TryChangeStatus( ELockNotActive); |
|
295 lower(); |
|
296 hide(); |
|
297 |
|
298 // screensaver standby mode timer |
|
299 mScreensaverModeTimer = new QTimer( this ); |
|
300 mScreensaverModeTimer->setInterval( 5*1000 ); // milliseconds, TODO: read from cenrep |
|
301 connect( mScreensaverModeTimer, SIGNAL(timeout()), SLOT(switchScreensaverToPowerSaveMode()) ); |
|
302 } |
|
303 |
|
304 Autolock::~Autolock() |
|
305 { |
|
306 RDEBUG("0", 0); |
|
307 delete mService; |
|
308 delete mScreensaverModeTimer; |
|
309 RDEBUG("1", 1); |
|
310 } |
|
311 |
|
312 void Autolock::adjustInactivityTimers(int aReason) |
|
313 { |
|
314 RDEBUG("aReason", aReason); |
|
315 TInt keyguardTime = 0; |
|
316 TInt lockTime = 0; |
|
317 CRepository* repository = NULL; |
|
318 TInt cRresult = 0; |
|
319 |
|
320 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); |
|
321 cRresult = repository->Get(KSettingsAutomaticKeyguardTime, keyguardTime); // in seconds |
|
322 RDEBUG("KSettingsAutomaticKeyguardTime", KSettingsAutomaticKeyguardTime); |
|
323 RDEBUG("cRresult", cRresult); |
|
324 RDEBUG("keyguardTime", keyguardTime); |
|
325 if (keyguardTime > 0 && keyguardTime < 1000) |
|
326 { |
|
327 serviceKeyguard->setInactivityPeriod(keyguardTime); |
|
328 } |
|
329 else |
|
330 { |
|
331 serviceKeyguard->setInactivityPeriod(12 * 31 * 24 * 60 * 60); |
|
332 } |
|
333 |
|
334 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes, handled internally as seconds |
|
335 lockTime *= 60; |
|
336 RDEBUG("KSettingsAutoLockTime", KSettingsAutoLockTime); |
|
337 RDEBUG("cRresult", cRresult); |
|
338 RDEBUG("lockTime", lockTime); |
|
339 if(lockTime == 65535*60) // Special setting "lock at same time as keyguard" at CpDeviceLockPluginView::GetAutoLockIndex which uses this magic number |
|
340 lockTime = keyguardTime-2; // lock 2 seconds before before, to avoid keyguard->devicelock sequence |
|
341 if (lockTime > 60 && lockTime < 24*60*60) // lock timer can't be bigger than 1 day |
|
342 { |
|
343 serviceDevicelock->setInactivityPeriod(lockTime); |
|
344 } |
|
345 else |
|
346 { |
|
347 serviceDevicelock->setInactivityPeriod(12 * 31 * 24 * 60 * 60); // 0x1ea6e00 |
|
348 } |
|
349 |
|
350 |
|
351 delete repository; |
|
352 } |
|
353 void Autolock::quit() |
|
354 { |
|
355 RDEBUG("0", 0); |
|
356 qApp->quit(); |
|
357 } |
|
358 |
|
359 int Autolock::AskValidSecCode(int aReason) |
|
360 { |
|
361 RDEBUG("aReason", aReason); |
|
362 RMobilePhone iPhone; // NULL in emulator |
|
363 |
|
364 #ifdef __WINS__1 |
|
365 return KErrNone; |
|
366 #endif |
|
367 |
|
368 |
|
369 TInt err(KErrGeneral); |
|
370 TBool validCode(EFalse); |
|
371 TInt thisTry(0); |
|
372 RTelServer iTelServer; |
|
373 |
|
374 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); |
|
375 RDEBUG("KSecurityUIsLights err", err); |
|
376 |
|
377 RMmCustomAPI iCustomPhone; |
|
378 while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) |
|
379 <= KTriesToConnectServer) |
|
380 { |
|
381 User::After( KTimeBeforeRetryingServerConnection); |
|
382 } |
|
383 err = iTelServer.LoadPhoneModule(KMmTsyModuleName); |
|
384 RTelServer::TPhoneInfo PhoneInfo; |
|
385 RDEBUG("LoadPhoneModule err", err); |
|
386 err = iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended); |
|
387 RDEBUG("SetExtendedErrorGranularity err", err); |
|
388 err = iTelServer.GetPhoneInfo(KPhoneIndex, PhoneInfo); |
|
389 RDEBUG("GetPhoneInfo err", err); |
|
390 err = iPhone.Open(iTelServer, PhoneInfo.iName); |
|
391 RDEBUG("Open err", err); |
|
392 err = iCustomPhone.Open(iPhone); |
|
393 RDEBUG("Open2 err", err); |
|
394 |
|
395 RDEBUG("CSecurityHandler", 0); |
|
396 CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone); |
|
397 if (aReason == ELockAppDisableDevicelock) |
|
398 { |
|
399 RDEBUG("calling AskSecCodeInAutoLockL", 0); |
|
400 QT_TRAP_THROWING( validCode = handler->AskSecCodeInAutoLockL() ); // this returns true/false |
|
401 // TODO should this also do iPhone.SetLockSetting(status, lockType, lockChange); ??? |
|
402 } |
|
403 else if (aReason == ELockAppEnableDevicelock) |
|
404 { |
|
405 // check whether code is really needed |
|
406 RMobilePhone::TMobilePhoneLock lockType = |
|
407 RMobilePhone::ELockPhoneDevice; |
|
408 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
409 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
410 RMobilePhone::TMobilePhoneLockSetting lockChange( |
|
411 RMobilePhone::ELockSetDisabled); |
|
412 TRequestStatus status = KRequestPending; |
|
413 TInt ret = KErrNone; |
|
414 RDEBUG("GetLockInfo", 0); |
|
415 iPhone.GetLockInfo(status, lockType, lockInfoPkg); |
|
416 RDEBUG("WaitForRequest", 0); |
|
417 User::WaitForRequest(status); |
|
418 ret = status.Int(); |
|
419 RDEBUG("WaitForRequest ret", ret); |
|
420 #ifdef __WINS__ |
|
421 if(ret==KErrTimedOut) |
|
422 { |
|
423 ret = KErrNone; |
|
424 lockInfo.iSetting = RMobilePhone::ELockSetDisabled; // ask password only if there's no timeout. |
|
425 } |
|
426 #endif |
|
427 if (ret == KErrNone) |
|
428 { |
|
429 RDEBUG("lockInfo.iSetting", lockInfo.iSetting); |
|
430 RDEBUG("RMobilePhone::ELockSetDisabled", |
|
431 RMobilePhone::ELockSetDisabled); |
|
432 if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled) // ask password only if there's no timeout |
|
433 { |
|
434 lockChange = RMobilePhone::ELockSetEnabled; |
|
435 RDEBUG("SetLockSetting lockChange", lockChange); |
|
436 #define OLD_METHODx |
|
437 #ifdef OLD_METHOD |
|
438 status = KRequestPending; |
|
439 RDEBUG( "SetLockSetting", 0 ); |
|
440 iPhone.SetLockSetting(status, lockType, lockChange); // ask for PassPhraseRequiredL |
|
441 RDEBUG( "WaitForRequestL", 0 ); |
|
442 User::WaitForRequest( status ); // TODO this waits 33 seconds in WINS and returns ffffffdf = KErrTimedOut |
|
443 ret = status.Int(); |
|
444 RDEBUG( "WaitForRequestL ret", ret ); |
|
445 #else |
|
446 RDEBUG("! OLD_METHOD", 0); |
|
447 CWait *iWait = NULL; |
|
448 QT_TRAP_THROWING( iWait = CWait::NewL() ); |
|
449 iWait->SetRequestType(EMobilePhoneSetLockSetting); |
|
450 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // ask for PassPhraseRequiredL |
|
451 RDEBUG("WaitForRequestL", 0); |
|
452 QT_TRAP_THROWING( ret = iWait->WaitForRequestL() ); |
|
453 RDEBUG("WaitForRequestL ret", ret); |
|
454 if (iWait) |
|
455 { |
|
456 RDEBUG("IsActive", 0); |
|
457 if (iWait->IsActive()) |
|
458 { |
|
459 RDEBUG("CancelAsyncRequest", 0); |
|
460 iPhone.CancelAsyncRequest(iWait->GetRequestType()); |
|
461 RDEBUG("cancelled", 0); |
|
462 } |
|
463 } |
|
464 delete iWait; |
|
465 #endif |
|
466 |
|
467 RDEBUG("WaitForRequestL ret", ret); |
|
468 #ifdef __WINS__ |
|
469 if(ret==KErrTimedOut) |
|
470 ret = KErrNone; |
|
471 #endif |
|
472 if (ret == KErrNone) |
|
473 validCode = 1; |
|
474 else |
|
475 validCode = 0; |
|
476 } |
|
477 else |
|
478 { |
|
479 RDEBUG("RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); |
|
480 RDEBUG("lockInfo.iSetting = RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled); |
|
481 validCode = 0x20; |
|
482 } |
|
483 } |
|
484 else |
|
485 { |
|
486 RDEBUG("Error: ret", ret); |
|
487 validCode = 0x21; |
|
488 } |
|
489 |
|
490 /* Alternative way to ask for password |
|
491 RMobilePhone::TMobilePhoneSecurityEvent iEvent; |
|
492 TInt result = KErrNone; |
|
493 iEvent = RMobilePhone::EPhonePasswordRequired; |
|
494 RDEBUG( "calling HandleEventL", 0 ); |
|
495 handler->HandleEventL(iEvent, result); // this is supposed to wait |
|
496 validCode = false; |
|
497 if(result) |
|
498 validCode = true; |
|
499 RDEBUG( "result", result ); |
|
500 */ |
|
501 } |
|
502 RDEBUG("validCode", validCode); |
|
503 if (validCode>0) |
|
504 return KErrNone; |
|
505 |
|
506 // no valid code -> switch off the lights |
|
507 err = RProperty::Set(KPSUidSecurityUIs, |
|
508 KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); |
|
509 RDEBUG("KSecurityUIsLights err", err); |
|
510 return KErrCancel; |
|
511 } |
|
512 |
|
513 void Autolock::handleAnswerDelivered() |
|
514 { |
|
515 RDEBUG("0", 0); |
|
516 // quit(); |
|
517 |
|
518 } |
|
519 |
|
520 void Autolock::setLabelNumber(QString label, QString number) |
|
521 { |
|
522 RDEBUG("0", 0); |
|
523 } |
|
524 |
|
525 void Autolock::DebugRequest(int aReason) |
|
526 { |
|
527 switch (aReason) |
|
528 { |
|
529 case ELockAppEnableKeyguard: |
|
530 RDEBUG("ELockAppEnableKeyguard", aReason); |
|
531 break; |
|
532 case ELockAppDisableKeyguard: |
|
533 RDEBUG("ELockAppDisableKeyguard", aReason); |
|
534 break; |
|
535 case ELockAppEnableDevicelock: |
|
536 RDEBUG("ELockAppEnableDevicelock", aReason); |
|
537 break; |
|
538 case ELockAppDisableDevicelock: |
|
539 RDEBUG("ELockAppDisableDevicelock", aReason); |
|
540 break; |
|
541 case ELockAppOfferKeyguard: |
|
542 RDEBUG("ELockAppOfferKeyguard", aReason); |
|
543 break; |
|
544 case ELockAppOfferDevicelock: |
|
545 RDEBUG("ELockAppOfferDevicelock", aReason); |
|
546 break; |
|
547 case ELockAppShowKeysLockedNote: |
|
548 RDEBUG("ELockAppShowKeysLockedNote", aReason); |
|
549 break; |
|
550 default: |
|
551 RDEBUG("default", aReason); |
|
552 break; |
|
553 } |
|
554 } |
|
555 void Autolock::DebugStatus(int aReason) |
|
556 { |
|
557 switch (aReason) |
|
558 { |
|
559 case ELockNotActive: |
|
560 RDEBUG("ELockNotActive", aReason); |
|
561 break; |
|
562 case EKeyguardActive: |
|
563 RDEBUG("EKeyguardActive", aReason); |
|
564 break; |
|
565 case EDevicelockActive: |
|
566 RDEBUG("EDevicelockActive", aReason); |
|
567 break; |
|
568 default: |
|
569 RDEBUG("default", aReason); |
|
570 break; |
|
571 } |
|
572 } |
|
573 void Autolock::DebugError(int aReason) |
|
574 { |
|
575 switch (aReason) |
|
576 { |
|
577 case KErrNone: |
|
578 RDEBUG("KErrNone", aReason); |
|
579 break; |
|
580 case KErrPermissionDenied: // caller doesn't have enough capabilities |
|
581 RDEBUG("KErrPermissionDenied", aReason); |
|
582 break; |
|
583 case KErrAlreadyExists: // this particular lock is already enabled |
|
584 RDEBUG("KErrAlreadyExists", aReason); |
|
585 break; |
|
586 case KErrInUse: // the dialog is already shown |
|
587 RDEBUG("KErrInUse", aReason); |
|
588 break; |
|
589 default: |
|
590 RDEBUG("default", aReason); |
|
591 break; |
|
592 } |
|
593 } |
|
594 |
|
595 int Autolock::CheckIfLegal(int aReason) |
|
596 { |
|
597 RDEBUG("aReason", aReason); |
|
598 // check whether a dialog is already displayed. This is to prevent timeout-lock and timeout-keyguard for activated on top of a PIN query, in particular at boot-up (TODO check for Starter) |
|
599 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
|
600 TInt err = RProperty::Get(KPSUidSecurityUIs, |
|
601 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
|
602 RDEBUG("err", err); |
|
603 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
|
604 switch (aReason) |
|
605 { |
|
606 case ELockAppEnableKeyguard: |
|
607 { |
|
608 RDEBUG("ELockAppEnableKeyguard iLockStatus", iLockStatus); |
|
609 if (secUiOriginatedQuery |
|
610 != ESecurityUIsSecUIOriginatedUninitialized) |
|
611 return KErrInUse; // PIN on top. Don't keyguard |
|
612 switch (iLockStatus) |
|
613 { |
|
614 case ELockNotActive: |
|
615 if ( !CKeyLockPolicyApi::KeyguardAllowed() ) |
|
616 return KErrPermissionDenied; |
|
617 else |
|
618 return KErrNone; |
|
619 case EKeyguardActive: |
|
620 return KErrAlreadyExists; |
|
621 case EDevicelockActive: |
|
622 return KErrPermissionDenied; |
|
623 } |
|
624 } |
|
625 break; |
|
626 case ELockAppDisableKeyguard: |
|
627 { |
|
628 RDEBUG("ELockAppDisableKeyguard iLockStatus", iLockStatus); |
|
629 // no matter whether PIN is displayed |
|
630 switch (iLockStatus) |
|
631 { |
|
632 case ELockNotActive: |
|
633 return KErrAlreadyExists; |
|
634 case EKeyguardActive: |
|
635 return KErrNone; |
|
636 case EDevicelockActive: |
|
637 return KErrPermissionDenied; |
|
638 } |
|
639 } |
|
640 break; |
|
641 case ELockAppEnableDevicelock: |
|
642 { |
|
643 RDEBUG("ELockAppEnableDevicelock iLockStatus", iLockStatus); |
|
644 if (secUiOriginatedQuery |
|
645 != ESecurityUIsSecUIOriginatedUninitialized |
|
646 && secUiOriginatedQuery |
|
647 != ESecurityUIsSystemLockOriginated) |
|
648 return KErrInUse; // PIN on top. Don't devicelock |
|
649 switch (iLockStatus) |
|
650 { |
|
651 case ELockNotActive: |
|
652 return KErrNone; |
|
653 case EKeyguardActive: |
|
654 return KErrNone; |
|
655 case EDevicelockActive: |
|
656 return KErrAlreadyExists; |
|
657 } |
|
658 } |
|
659 break; |
|
660 case ELockAppDisableDevicelock: |
|
661 { |
|
662 RDEBUG("ELockAppDisableDevicelock iLockStatus", iLockStatus); |
|
663 if (secUiOriginatedQuery |
|
664 != ESecurityUIsSecUIOriginatedUninitialized |
|
665 && secUiOriginatedQuery |
|
666 != ESecurityUIsSystemLockOriginated) |
|
667 { |
|
668 // PIN on top and trying to display unlock-code. This is valid |
|
669 } |
|
670 switch (iLockStatus) |
|
671 { |
|
672 case ELockNotActive: |
|
673 return KErrAlreadyExists; |
|
674 case EKeyguardActive: |
|
675 return KErrPermissionDenied; |
|
676 case EDevicelockActive: |
|
677 return KErrNone; |
|
678 } |
|
679 } |
|
680 break; |
|
681 case ELockAppOfferKeyguard: |
|
682 { |
|
683 RDEBUG("ELockAppOfferKeyguard iLockStatus", iLockStatus); |
|
684 if (secUiOriginatedQuery |
|
685 != ESecurityUIsSecUIOriginatedUninitialized |
|
686 && secUiOriginatedQuery |
|
687 != ESecurityUIsSystemLockOriginated) |
|
688 return KErrInUse; // PIN on top. Don't offer |
|
689 switch (iLockStatus) |
|
690 { |
|
691 case ELockNotActive: |
|
692 return KErrNone; |
|
693 case EKeyguardActive: |
|
694 return KErrPermissionDenied; |
|
695 case EDevicelockActive: |
|
696 return KErrPermissionDenied; |
|
697 } |
|
698 } |
|
699 break; |
|
700 case ELockAppOfferDevicelock: |
|
701 { |
|
702 RDEBUG("ELockAppOfferDevicelock iLockStatus", iLockStatus); |
|
703 if (secUiOriginatedQuery |
|
704 != ESecurityUIsSecUIOriginatedUninitialized |
|
705 && secUiOriginatedQuery |
|
706 != ESecurityUIsSystemLockOriginated) |
|
707 return KErrInUse; // PIN on top. Don't offer |
|
708 switch (iLockStatus) |
|
709 { |
|
710 case ELockNotActive: |
|
711 return KErrNone; |
|
712 case EKeyguardActive: |
|
713 return KErrNone; |
|
714 case EDevicelockActive: |
|
715 return KErrAlreadyExists; |
|
716 } |
|
717 } |
|
718 break; |
|
719 case ELockAppShowKeysLockedNote: |
|
720 { |
|
721 RDEBUG("ELockAppShowKeysLockedNote iLockStatus", iLockStatus); |
|
722 if (secUiOriginatedQuery |
|
723 != ESecurityUIsSecUIOriginatedUninitialized |
|
724 && secUiOriginatedQuery |
|
725 != ESecurityUIsSystemLockOriginated) |
|
726 return KErrInUse; // PIN on top. Don't display |
|
727 switch (iLockStatus) |
|
728 { |
|
729 case ELockNotActive: |
|
730 return KErrPermissionDenied; |
|
731 case EKeyguardActive: |
|
732 return KErrNone; |
|
733 case EDevicelockActive: |
|
734 return KErrPermissionDenied; |
|
735 } |
|
736 } |
|
737 break; |
|
738 default: |
|
739 { |
|
740 RDEBUG("default iLockStatus", iLockStatus); |
|
741 return KErrPermissionDenied; |
|
742 } |
|
743 // break; |
|
744 } // switch |
|
745 return KErrPermissionDenied; |
|
746 } |
|
747 |
|
748 int Autolock::publishStatus(int aReason) |
|
749 { |
|
750 RDEBUG("aReason", aReason); |
|
751 TInt err; |
|
752 // can't use include file because it's private file. However it gives permissions |
|
753 const TUid KCRUidCoreApplicationUIsSysAp = { 0x101F8765 }; |
|
754 const TUint32 KSysApKeyguardActive = 0x00000001; |
|
755 CRepository* repositoryDevicelock = NULL; |
|
756 CRepository* repositoryKeyguard = NULL; |
|
757 QT_TRAP_THROWING( repositoryDevicelock = CRepository::NewL(KCRUidSecuritySettings) ); |
|
758 QT_TRAP_THROWING( repositoryKeyguard = CRepository::NewL(KCRUidCoreApplicationUIsSysAp) ); |
|
759 TInt cRresult = KErrNone; |
|
760 if (1 == 1) // this is a quick way to disable this functionality, for testing |
|
761 { |
|
762 RDEBUG("publishing", aReason); |
|
763 if (aReason == ELockNotActive) |
|
764 { |
|
765 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, |
|
766 EKeyguardNotActive); |
|
767 RDEBUG("err", err); |
|
768 err = RProperty::Set(KPSUidCoreApplicationUIs, |
|
769 KCoreAppUIsAutolockStatus, EAutolockOff); |
|
770 RDEBUG("err", err); |
|
771 err = RProperty::Set(KPSUidSecurityUIs, |
|
772 KSecurityUIsLights, ESecurityUIsLightsLockOnRequest); // lights are required |
|
773 RDEBUG("KSecurityUIsLights err", err); |
|
774 |
|
775 // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); // the settings remains. Only ISA changes, as well as the P&S |
|
776 cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); |
|
777 RDEBUG("cRresult", cRresult); |
|
778 } |
|
779 if (1 == 1) // this is a quick way to disable this functionality, for testing |
|
780 { |
|
781 if (aReason == EKeyguardActive) |
|
782 { |
|
783 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, |
|
784 EKeyguardLocked); |
|
785 RDEBUG("KAknKeyguardStatus err", err); |
|
786 err = RProperty::Set(KPSUidCoreApplicationUIs, |
|
787 KCoreAppUIsAutolockStatus, EAutolockOff); |
|
788 RDEBUG("KCoreAppUIsAutolockStatus err", err); |
|
789 err = RProperty::Set(KPSUidSecurityUIs, |
|
790 KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); // same for keyguard and devicelock |
|
791 RDEBUG("KSecurityUIsLights err", err); |
|
792 // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); |
|
793 cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 1); |
|
794 RDEBUG("cRresult", cRresult); |
|
795 } |
|
796 else if (aReason >= EDevicelockActive) |
|
797 { |
|
798 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, |
|
799 EKeyguardAutolockEmulation); // Other candidates might be: EKeyguardLocked and EKeyguardNotActive |
|
800 RDEBUG("KAknKeyguardStatus err", err); |
|
801 err = RProperty::Set(KPSUidCoreApplicationUIs, |
|
802 KCoreAppUIsAutolockStatus, EManualLocked); |
|
803 RDEBUG("KCoreAppUIsAutolockStatus err", err); |
|
804 err = RProperty::Set(KPSUidSecurityUIs, |
|
805 KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); |
|
806 RDEBUG(" KSecurityUIsLights err", err); |
|
807 // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 1); |
|
808 cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); // keyguard disabled, so that user can type and DeviceF can be captured |
|
809 RDEBUG("cRresult", cRresult); |
|
810 } |
|
811 } |
|
812 } |
|
813 delete repositoryDevicelock; |
|
814 delete repositoryKeyguard; |
|
815 // this is the real point where everything is done. |
|
816 iLockStatusPrev = iLockStatus; |
|
817 iLockStatus = aReason; |
|
818 RDEBUG("setting iLockStatus", iLockStatus); |
|
819 return KErrNone; |
|
820 } |
|
821 /********************/ |
|
822 int Autolock::showNoteIfRequested(int aReason) |
|
823 { |
|
824 RDEBUG("aReason", aReason); |
|
825 // These do nothing. The reason are: |
|
826 // - the screensaver already displays/hides |
|
827 // - the notes are shown behing the icon because they have lower priorities |
|
828 // - they are annoying |
|
829 if (aReason == ELockNotActive) |
|
830 { |
|
831 if (iShowKeyguardNote == 1) |
|
832 { |
|
833 // HbDeviceMessageBox::information("Keyguard deactivated"); |
|
834 } |
|
835 } |
|
836 else if (aReason == EKeyguardActive) |
|
837 { |
|
838 if (iShowKeyguardNote == 1) |
|
839 { |
|
840 // HbDeviceMessageBox::information("Keyguard activated"); |
|
841 } |
|
842 } |
|
843 else if (aReason >= EDevicelockActive) // this doesn't happen, but we are prepared nevertheless |
|
844 { |
|
845 if (iShowKeyguardNote == 1) |
|
846 { |
|
847 // HbDeviceMessageBox::information("Devicelock activated"); |
|
848 } |
|
849 } |
|
850 return KErrNone; |
|
851 } |
|
852 /***********************/ |
|
853 int Autolock::TryChangeStatus(int aReason) |
|
854 { |
|
855 RDEBUG("aReason", aReason); |
|
856 int ret = aReason; |
|
857 int errorInProcess = KErrNone; |
|
858 DebugRequest(ret); |
|
859 |
|
860 // this will cancel any previous dialog, i.e. PIN query, or any previous code-request. |
|
861 // not sure about the screensaver, but nevertheless will be cancelled when the status is changed. |
|
862 TInt err = KErrNone; |
|
863 RDEBUG("Not setting KSecurityUIsDismissDialog ESecurityUIsDismissDialogOn", ESecurityUIsDismissDialogOn); |
|
864 //// err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn); |
|
865 RDEBUG("err", err); |
|
866 switch (ret) |
|
867 { |
|
868 case ELockAppEnableKeyguard: // 1 |
|
869 { |
|
870 errorInProcess = CheckIfLegal(ret); |
|
871 DebugError(errorInProcess); |
|
872 if (errorInProcess == KErrNone) |
|
873 { |
|
874 setLabelIcon( EKeyguardActive); |
|
875 updateIndicator(EKeyguardActive); |
|
876 publishStatus(EKeyguardActive); |
|
877 showNoteIfRequested(EKeyguardActive); |
|
878 setLockDialog(aReason, 1); |
|
879 } |
|
880 } |
|
881 break; |
|
882 case ELockAppDisableKeyguard: // 2 |
|
883 { |
|
884 errorInProcess = CheckIfLegal(ret); |
|
885 DebugError(errorInProcess); |
|
886 if (errorInProcess == KErrNone) |
|
887 { |
|
888 setLabelIcon( ELockNotActive); |
|
889 updateIndicator(ELockNotActive); |
|
890 publishStatus(ELockNotActive); |
|
891 showNoteIfRequested(ELockNotActive); |
|
892 setLockDialog(aReason, 0); |
|
893 } |
|
894 } |
|
895 break; |
|
896 case ELockAppEnableDevicelock: // 3 |
|
897 { |
|
898 errorInProcess = CheckIfLegal(ret); |
|
899 DebugError(errorInProcess); |
|
900 if (errorInProcess == KErrNone) |
|
901 { |
|
902 if (!callerHasECapabilityWriteDeviceData) // check permissions for calling process, because doesn't AskValidSecCode |
|
903 errorInProcess = KErrPermissionDenied; |
|
904 DebugError(errorInProcess); |
|
905 } |
|
906 if (errorInProcess == KErrNone) |
|
907 { |
|
908 updateIndicator( EDevicelockActive); |
|
909 publishStatus(EDevicelockActive); |
|
910 setLabelIcon(EDevicelockActive); |
|
911 setLockDialog(aReason, 1); |
|
912 } |
|
913 // aParam1 is aReason : EDevicelockManual, EDevicelockRemote |
|
914 // this never shows a note |
|
915 } |
|
916 break; |
|
917 case ELockAppDisableDevicelock: // 4 |
|
918 { |
|
919 errorInProcess = CheckIfLegal(ret); |
|
920 DebugError(errorInProcess); |
|
921 if (errorInProcess == KErrNone) |
|
922 { |
|
923 if (!callerHasECapabilityWriteDeviceData) // check permissions for calling process, because doesn't AskValidSecCode |
|
924 errorInProcess = KErrPermissionDenied; |
|
925 DebugError(errorInProcess); |
|
926 } |
|
927 if (errorInProcess == KErrNone) |
|
928 { |
|
929 setLockDialog(aReason, 0); // hide temporarilly because HbDeviceMessageBox doesn't get in top of the Lock-icon. Thus, dismiss it. |
|
930 // do I need to enable touch? it seems to work without it |
|
931 // in any case, lights are needed |
|
932 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); |
|
933 RDEBUG("calling HbDeviceMessageBox::question", 0); |
|
934 bool value = true; |
|
935 // not sure whether this question is really needed. The UI doesn't say anything, so I remove it for now. |
|
936 // HbDeviceMessageBox::question("Disable Lock?"); // this doesn't block other events, so after return everything might be messed up. |
|
937 RDEBUG("value", value); |
|
938 if (!value) |
|
939 errorInProcess = KErrCancel; |
|
940 } |
|
941 if (errorInProcess == KErrNone) |
|
942 { |
|
943 setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. |
|
944 RDEBUG("calling AskValidSecCode", 0); |
|
945 errorInProcess = AskValidSecCode(ELockAppDisableDevicelock); |
|
946 RDEBUG("errorInProcess", errorInProcess); |
|
947 } |
|
948 if (errorInProcess == KErrNone) |
|
949 { |
|
950 setLabelIcon( ELockNotActive); |
|
951 updateIndicator(ELockNotActive); |
|
952 setLockDialog(aReason, 0); |
|
953 publishStatus(ELockNotActive); |
|
954 } |
|
955 if (errorInProcess != KErrNone) |
|
956 { // re-lock. For example, if password is wrong |
|
957 if( iLockStatus >=EDevicelockActive) // this skips the case "unlocking although it wasn't locked" |
|
958 setLockDialog(ELockAppEnableDevicelock, 1); |
|
959 } |
|
960 // this never shows a note |
|
961 } |
|
962 break; |
|
963 case ELockAppOfferKeyguard: // 5 |
|
964 { |
|
965 errorInProcess = CheckIfLegal(ret); |
|
966 DebugError(errorInProcess); |
|
967 if (errorInProcess == KErrNone) |
|
968 { |
|
969 // no need to dismiss screensaver, because it's not active |
|
970 // what about any PIN-query, i.e. from settings ? In this case, the query will show after the PIN query is finished. somehow this is good because PIN is more important |
|
971 bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up. |
|
972 // what about a nice icon? |
|
973 RDEBUG("value", value); |
|
974 if (!value) |
|
975 errorInProcess = KErrCancel; |
|
976 } |
|
977 if (errorInProcess == KErrNone) |
|
978 { |
|
979 errorInProcess = TryChangeStatus(ELockAppEnableKeyguard); |
|
980 } |
|
981 // this never shows a note |
|
982 } |
|
983 break; |
|
984 case ELockAppOfferDevicelock: // 6 |
|
985 { |
|
986 errorInProcess = CheckIfLegal(ret); |
|
987 DebugError(errorInProcess); |
|
988 if (errorInProcess == KErrNone) |
|
989 { |
|
990 setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. |
|
991 errorInProcess = AskValidSecCode(ELockAppEnableDevicelock); |
|
992 } |
|
993 if (errorInProcess == KErrNone) |
|
994 { |
|
995 RDEBUG("ELockAppOfferDevicelock calling ELockAppEnableDevicelock", ELockAppEnableDevicelock); |
|
996 errorInProcess = TryChangeStatus(ELockAppEnableDevicelock); |
|
997 } |
|
998 // this never shows a note. Perhaps ELockAppEnableDevicelock does. |
|
999 } |
|
1000 break; |
|
1001 case ELockAppShowKeysLockedNote: // 7 |
|
1002 { |
|
1003 errorInProcess = CheckIfLegal(ret); // it will not be legal if the keyguard is not enabled and the devicelock is not enabled. |
|
1004 DebugError(errorInProcess); |
|
1005 if (errorInProcess == KErrNone) |
|
1006 { |
|
1007 iShowKeyguardNote = 1; // this is not sent as parameter, so we need to fake it: ON |
|
1008 showNoteIfRequested( EKeyguardActive); |
|
1009 } |
|
1010 } |
|
1011 break; |
|
1012 default: |
|
1013 RDEBUG("default", ret); |
|
1014 errorInProcess = KErrNotSupported; |
|
1015 break; |
|
1016 |
|
1017 } |
|
1018 return errorInProcess; |
|
1019 } |
|
1020 /**************************/ |
|
1021 int Autolock::setLockDialog(int aReason, int status) |
|
1022 { |
|
1023 RDEBUG("aReason", aReason); |
|
1024 RDEBUG("status", status); |
|
1025 RDEBUG("iDeviceDialogCreated", iDeviceDialogCreated); |
|
1026 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
|
1027 TInt err = RProperty::Get(KPSUidSecurityUIs, |
|
1028 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
|
1029 RDEBUG("err", err); |
|
1030 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
|
1031 |
|
1032 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
|
1033 |
|
1034 if (status == 0) // hide |
|
1035 { |
|
1036 // aReason is not important here, but let's check nevertheless |
|
1037 if (aReason != ELockAppDisableKeyguard && aReason != ELockAppDisableDevicelock ) |
|
1038 { |
|
1039 RDEBUG("!!!!****!!!!! error. status=0 but aReason", aReason); |
|
1040 } |
|
1041 // secUiOriginatedQuery should be ESecurityUIsSystemLockOriginated . If not, this is not correctly setting it |
|
1042 if (iDeviceDialogCreated >= EDeviceDialogCreated) |
|
1043 { |
|
1044 iDeviceDialogCreated = EDeviceDialogDestroyed; |
|
1045 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1046 disconnect( iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), this, SLOT(handleMessageFromScreensaver(QVariantMap)) ); |
|
1047 RDEBUG("signal disconnected", err); |
|
1048 err = iDeviceDialog->cancel(); |
|
1049 RDEBUG("cancel (bool: 1= wellCancelled) err", err); |
|
1050 err = iDeviceDialog->error(); |
|
1051 RDEBUG("err", err); |
|
1052 RDEBUG("calling iDeviceDialog->waitForClosed()", 0); |
|
1053 err = iDeviceDialog->waitForClosed(); |
|
1054 RDEBUG("cancel (bool: 1= well waitForClosed) err", err); |
|
1055 err = iDeviceDialog->error(); |
|
1056 RDEBUG("err", err); |
|
1057 |
|
1058 TInt err = RProperty::Set(KPSUidSecurityUIs, |
|
1059 KSecurityUIsSecUIOriginatedQuery, |
|
1060 ESecurityUIsSecUIOriginatedUninitialized); |
|
1061 RDEBUG("reset KSecurityUIsSecUIOriginatedQuery. err", err); |
|
1062 // Cancel power key and application key capturing |
|
1063 groupWin.CancelCaptureKey( mPowerKeyCaptureHandle ); |
|
1064 groupWin.CancelCaptureKey( mApplicationKeyCaptureHandle ); |
|
1065 groupWin.CancelCaptureLongKey( mApplicationLongKeyCaptureHandle ); |
|
1066 RDEBUG("done CancelCaptureKey", 1); |
|
1067 RDEBUG("deleting iDeviceDialog", 0); |
|
1068 delete iDeviceDialog; |
|
1069 RDEBUG("deleted iDeviceDialog", 1); |
|
1070 iDeviceDialog = NULL; |
|
1071 } |
|
1072 } |
|
1073 else if (status == 1) // show |
|
1074 { |
|
1075 // secUiOriginatedQuery should be ESecurityUIsSecUIOriginatedUninitialized . If not, the validation is not correctly filtering it |
|
1076 QVariantMap params; |
|
1077 TBool err; |
|
1078 #define ESecUiTypeDeviceLock 0x00100000 |
|
1079 #define ESecUiTypeKeyguard 0x00200000 |
|
1080 |
|
1081 if (aReason == ELockAppEnableKeyguard) |
|
1082 params.insert("type", ESecUiTypeKeyguard); |
|
1083 else if (aReason == ELockAppEnableDevicelock) |
|
1084 params.insert("type", ESecUiTypeDeviceLock); |
|
1085 else |
|
1086 { |
|
1087 RDEBUG("error. status=1 but aReason", aReason); |
|
1088 } |
|
1089 // no need for title. Icon should be explicit enough |
|
1090 // params.insert("title", "Locked"); |
|
1091 if (iDeviceDialogCreated < EDeviceDialogCreated) |
|
1092 { |
|
1093 if(iDeviceDialog != NULL) |
|
1094 { |
|
1095 RDEBUG("!!!!!!*********!!!!!!!! error: iDeviceDialog != NULL", 0); |
|
1096 } |
|
1097 RDEBUG("creating iDeviceDialog", 0); |
|
1098 iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); |
|
1099 // in theory this is needed only for screensaver, not for LockIcon. But it doesn't harm |
|
1100 connect( iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), |
|
1101 SLOT(handleMessageFromScreensaver(QVariantMap)) ); |
|
1102 iDeviceDialogCreated = EDeviceDialogCreated; |
|
1103 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1104 } |
|
1105 else |
|
1106 { |
|
1107 RDEBUG("raising iDeviceDialog", 0); |
|
1108 // confirm that dialog is present |
|
1109 err = iDeviceDialog->error(); |
|
1110 RDEBUG("err", err); |
|
1111 iDeviceDialogCreated = EDeviceDialogRaised; |
|
1112 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1113 } |
|
1114 const QString KScreensaverDeviceDialog("com.nokia.screensaver.snsrdevicedialogplugin/1.0"); |
|
1115 RDEBUG("pre show", aReason); |
|
1116 err = iDeviceDialog->show(KScreensaverDeviceDialog, params); // and continue processing |
|
1117 RDEBUG("post show. err", err); |
|
1118 err = iDeviceDialog->error(); |
|
1119 RDEBUG("iDeviceDialog->error", err); |
|
1120 if(!err) |
|
1121 { |
|
1122 iDeviceDialogCreated = EDeviceDialogScreenSaver; |
|
1123 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1124 switchScreensaverToActiveMode(); // this is needed in case the dialog was existing. |
|
1125 } |
|
1126 else // some err. Usually 3 (not existing) |
|
1127 { |
|
1128 // screensaver has failed. Probably because it's not installed. Then, try the standard lock-icon |
|
1129 iDeviceDialogCreated = EDeviceDialogLockIcon; |
|
1130 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1131 const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); |
|
1132 err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing |
|
1133 RDEBUG("post show. err", err); |
|
1134 } |
|
1135 err = iDeviceDialog->error(); |
|
1136 RDEBUG("err", err); |
|
1137 // This won't be needed when screensaver is in place, as the dialogs will be different, and therefore both can be present |
|
1138 // Somehow this should be handled by Orbit, but unfortunatelly they don't allow the same dialog twice |
|
1139 err = RProperty::Set(KPSUidSecurityUIs, |
|
1140 KSecurityUIsSecUIOriginatedQuery, |
|
1141 ESecurityUIsSecUIOriginatedUninitialized); // this could also be ESecurityUIsSystemLockOriginated |
|
1142 RDEBUG("err", err); |
|
1143 // Capture power and application keys while screen saver is open. Also works for LockIcon |
|
1144 mPowerKeyCaptureHandle = groupWin.CaptureKey( EKeyDevice2, 0, 0 ); |
|
1145 mApplicationKeyCaptureHandle = groupWin.CaptureKey( EKeyApplication0, 0, 0 ); |
|
1146 mApplicationLongKeyCaptureHandle = groupWin.CaptureLongKey( |
|
1147 EKeyApplication0, EKeyApplication0, 0, 0, 0, |
|
1148 ELongCaptureShortEventImmediately|ELongCaptureRepeatEvents ); |
|
1149 RDEBUG("keys captured", err); |
|
1150 } |
|
1151 else |
|
1152 { |
|
1153 RDEBUG("unknown status", status); |
|
1154 return KErrNotSupported; |
|
1155 } |
|
1156 return KErrNone; |
|
1157 } |
|
1158 |
|
1159 void Autolock::setLabelIcon(int aReason) |
|
1160 { |
|
1161 RDEBUG("aReason", aReason); |
|
1162 |
|
1163 if (aReason == ELockNotActive) |
|
1164 { |
|
1165 // setLockDialog(aReason, 0); // This is done already at TryChangeStatus |
|
1166 lower(); |
|
1167 hide(); |
|
1168 } |
|
1169 else if (aReason == EKeyguardActive) |
|
1170 { |
|
1171 // setLockDialog(aReason, 1); // This is done already at TryChangeStatus |
|
1172 // this shows the Autolock Application. not needed |
|
1173 } |
|
1174 else if (aReason == EDevicelockActive) |
|
1175 { |
|
1176 } |
|
1177 else |
|
1178 { |
|
1179 RDEBUG("error: aReason", aReason); |
|
1180 } |
|
1181 } |
|
1182 |
|
1183 int Autolock::updateIndicator(int aReason) |
|
1184 { |
|
1185 RDEBUG("aReason", aReason); |
|
1186 QList<QVariant> list; |
|
1187 list.insert(0, 1); |
|
1188 list.insert(1, "dummy"); |
|
1189 list.insert(2, 2); |
|
1190 |
|
1191 HbIndicator indicator; |
|
1192 bool success; |
|
1193 if (aReason == ELockNotActive) |
|
1194 success = indicator.deactivate( |
|
1195 "com.nokia.hb.indicator.autolock.autolock_8/1.0"); // maybe it's already deactivated. Not a problem |
|
1196 else if (aReason == EKeyguardActive) |
|
1197 success = indicator.activate( |
|
1198 "com.nokia.hb.indicator.autolock.autolock_8/1.0"); |
|
1199 else if (aReason == EDevicelockActive) |
|
1200 success = indicator.activate( |
|
1201 "com.nokia.hb.indicator.autolock.autolock_8/1.0"); // same. We have just 1 indicator |
|
1202 else |
|
1203 success = 0; |
|
1204 RDEBUG("success", success); |
|
1205 return success; |
|
1206 } |
|
1207 |
|
1208 void Autolock::activeKeyguard() |
|
1209 { |
|
1210 // activity while keyguarded. Nothing to do |
|
1211 RDEBUG("0", 0); |
|
1212 } |
|
1213 |
|
1214 void Autolock::notActiveKeyguard() |
|
1215 { |
|
1216 // inactivity. Keyguard should be activated |
|
1217 RDEBUG("0", 0); |
|
1218 int ret = KErrNone; |
|
1219 DebugStatus( iLockStatus); |
|
1220 if (iLockStatus == ELockNotActive) // not possible if it's keyguarded, or locked |
|
1221 { |
|
1222 ret = TryChangeStatus(ELockAppEnableKeyguard); |
|
1223 RDEBUG("ret", ret); |
|
1224 } |
|
1225 else |
|
1226 { |
|
1227 // restart screensaver. The scenario is: keyguard->screensaver->CriticalNote->lightsOn . Therefore we need lightsOff |
|
1228 // this is done when keyguard can't be enabled because it's already enabled |
|
1229 // Note that this happens only once, so it's fine to show the screensaver in full light. |
|
1230 if(ret==KErrAlreadyExists) |
|
1231 switchScreensaverToActiveMode(); |
|
1232 } |
|
1233 RDEBUG("ret", ret); |
|
1234 } |
|
1235 /* Some activity detected while the deviceLock is enabled */ |
|
1236 void Autolock::activeDevicelock() |
|
1237 { |
|
1238 // nothing to do |
|
1239 RDEBUG("0", 0); |
|
1240 } |
|
1241 |
|
1242 void Autolock::notActiveDevicelock() |
|
1243 { |
|
1244 // inactivity. Devicelock should be activated |
|
1245 RDEBUG("0", 0); |
|
1246 int ret = KErrNone; |
|
1247 DebugStatus( iLockStatus); |
|
1248 if (iLockStatus == ELockNotActive || iLockStatus == EKeyguardActive) // not possible if it's locked |
|
1249 { |
|
1250 ret = TryChangeStatus(ELockAppEnableDevicelock); |
|
1251 } |
|
1252 RDEBUG("ret", ret); |
|
1253 |
|
1254 } |
|
1255 |
|
1256 void Autolock::switchScreensaverToActiveMode() |
|
1257 { |
|
1258 RDEBUG("0", 0); |
|
1259 if ( iDeviceDialog ) |
|
1260 { |
|
1261 RDEBUG("got iDeviceDialog. iDeviceDialogCreated", iDeviceDialogCreated); |
|
1262 QVariantMap params; |
|
1263 // this is for LockIcon. Doesn't harm screensaver |
|
1264 // need to send again so that the existing dialog still knows what is its type |
|
1265 if (iLockStatus == EKeyguardActive) |
|
1266 params.insert("type", ESecUiTypeKeyguard); |
|
1267 else if (iLockStatus >= EDevicelockActive) |
|
1268 params.insert("type", ESecUiTypeDeviceLock); |
|
1269 |
|
1270 // this is for screensaver. Doesn't harm LockIcon |
|
1271 params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueActive ); |
|
1272 |
|
1273 // when screesanver triggers, set the lights. DeviceDialogs does it only on creation, not on update. |
|
1274 TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); |
|
1275 RDEBUG("KSecurityUIsLights err", err); |
|
1276 |
|
1277 iDeviceDialog->update(params); |
|
1278 |
|
1279 // (re)start timer to switch to the power save mode |
|
1280 if ( mScreensaverModeTimer ) |
|
1281 { |
|
1282 RDEBUG("start mScreensaverModeTimer", 0); |
|
1283 mScreensaverModeTimer->start(); |
|
1284 } |
|
1285 } |
|
1286 RDEBUG("1", 1); |
|
1287 } |
|
1288 |
|
1289 void Autolock::switchScreensaverToPowerSaveMode() |
|
1290 { |
|
1291 RDEBUG("0", 0); |
|
1292 if ( iDeviceDialog ) |
|
1293 { |
|
1294 RDEBUG("got iDeviceDialog. iDeviceDialogCreated", iDeviceDialogCreated); |
|
1295 QVariantMap params; |
|
1296 // this is for LockIcon. Doesn't harm screensaver |
|
1297 // need to send again so that the existing dialog still knows what is its type |
|
1298 if (iLockStatus == EKeyguardActive) |
|
1299 params.insert("type", ESecUiTypeKeyguard); |
|
1300 else if (iLockStatus >= EDevicelockActive) |
|
1301 params.insert("type", ESecUiTypeDeviceLock); |
|
1302 |
|
1303 // this is for screensaver. Doesn't harm LockIcon |
|
1304 params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueStandby ); |
|
1305 iDeviceDialog->update(params); |
|
1306 |
|
1307 if ( mScreensaverModeTimer ) |
|
1308 { |
|
1309 RDEBUG("stop mScreensaverModeTimer", 0); |
|
1310 mScreensaverModeTimer->stop(); |
|
1311 } |
|
1312 } |
|
1313 RDEBUG("1", 1); |
|
1314 } |
|
1315 |
|
1316 void Autolock::handleMessageFromScreensaver( const QVariantMap &data ) |
|
1317 { |
|
1318 RDEBUG("0", 0); |
|
1319 RDEBUG("iLockStatus", iLockStatus); |
|
1320 QVariantMap::const_iterator it = data.find( KSnsrCmdUnlock ); |
|
1321 if ( it != data.end() && iLockStatus != ELockNotActive ) |
|
1322 { |
|
1323 RDEBUG("calling handleLockSwitch", 0); |
|
1324 handleLockSwitch(); |
|
1325 } |
|
1326 } |
|
1327 |
|
1328 // some key is pressed |
|
1329 // TODO perhaps need a way to stop switch-key while asking unlock-code? |
|
1330 // Not clear what to do here. dismiss query? |
|
1331 bool Autolock::event(QEvent *ev) |
|
1332 { |
|
1333 if (ev) |
|
1334 { |
|
1335 int isSwitchKey = 0; |
|
1336 if (ev->type() == QEvent::KeyPress) |
|
1337 { |
|
1338 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
|
1339 RDEBUG("KeyPress", keyEvent->key()); |
|
1340 RDEBUG("KeyPress nativeScanCode", keyEvent->nativeScanCode()); |
|
1341 RDEBUG("EStdKeyDeviceF", EStdKeyDeviceF); |
|
1342 RDEBUG("EKeyDeviceF", EKeyDeviceF); |
|
1343 RDEBUG("keyEvent->isAutoRepeat()", keyEvent->isAutoRepeat()); |
|
1344 if ( keyEvent->nativeScanCode() == EStdKeyApplication0 || keyEvent->nativeScanCode() == EStdKeyDevice2 ) |
|
1345 { |
|
1346 // switch to active screensaver if application key or power key pressed while screensaver active |
|
1347 // This key can be repeated, so that the screensaver remains as long as key is pushed |
|
1348 switchScreensaverToActiveMode(); |
|
1349 } |
|
1350 else if( !keyEvent->isAutoRepeat() ) |
|
1351 { |
|
1352 if (keyEvent->key() == EKeyInsert ) |
|
1353 { |
|
1354 // on WINS, this is handled with the "Ins" key in the numeric keypad |
|
1355 RDEBUG("EKeyInsert", EKeyInsert); |
|
1356 // only reacts on release, not on press |
|
1357 isSwitchKey = 1; |
|
1358 } |
|
1359 else if (keyEvent->key() == EKeyDeviceF ) |
|
1360 { |
|
1361 // this never seem to happen. Nevertheless we are not doing anything |
|
1362 RDEBUG("EKeyDeviceF", EKeyDeviceF); |
|
1363 } |
|
1364 else if (keyEvent->nativeScanCode() == EStdKeyDeviceF) |
|
1365 { |
|
1366 RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF); |
|
1367 isSwitchKey = 1; |
|
1368 } |
|
1369 else if (keyEvent->nativeScanCode() == EKeyBell) // this might be sent by others, i.e. PCFW |
|
1370 { |
|
1371 RDEBUG("got EKeyBell", EKeyBell); |
|
1372 isSwitchKey = 1; |
|
1373 } |
|
1374 else if (keyEvent->key() == 0x1ffffff) |
|
1375 { |
|
1376 RDEBUG("0x1ffffff", 0x1ffffff); // some unknown key is received. Nothing to do |
|
1377 } |
|
1378 } |
|
1379 } |
|
1380 else if (ev->type() == QEvent::KeyRelease) |
|
1381 { |
|
1382 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
|
1383 RDEBUG("KeyRelease", keyEvent->key()); |
|
1384 RDEBUG("KeyRelease native", keyEvent->nativeScanCode()); |
|
1385 if (keyEvent->nativeScanCode() == EStdKeyDeviceF && !keyEvent->isAutoRepeat()) |
|
1386 { |
|
1387 RDEBUG("released EStdKeyDeviceF", 1); |
|
1388 // isSwitchKey=1; this should happen is pressed was not processed (hint: if it is/was in background) |
|
1389 } |
|
1390 } |
|
1391 RDEBUG("isSwitchKey", isSwitchKey); |
|
1392 if (isSwitchKey) |
|
1393 { |
|
1394 handleLockSwitch(); |
|
1395 RDEBUG("0", 0); |
|
1396 } // isSwitchKey |
|
1397 } // ev |
|
1398 // Process if not done before. For example, redraw or quit |
|
1399 return QWidget::event(ev); |
|
1400 } |
|
1401 |
|
1402 void Autolock::handleLockSwitch() |
|
1403 { |
|
1404 |
|
1405 int ret = KErrNone; |
|
1406 DebugStatus( iLockStatus); |
|
1407 if (iLockStatus == ELockNotActive) |
|
1408 { |
|
1409 iShowKeyguardNote = 1; // note on enable keyguard |
|
1410 callerHasECapabilityWriteDeviceData = 1; |
|
1411 ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation |
|
1412 } |
|
1413 else if (iLockStatus == EKeyguardActive) |
|
1414 { |
|
1415 iShowKeyguardNote = 1; // note on disable keyguard |
|
1416 callerHasECapabilityWriteDeviceData = 1; |
|
1417 ret = TryChangeStatus(ELockAppDisableKeyguard); |
|
1418 } |
|
1419 else if (iLockStatus == EDevicelockActive) |
|
1420 { |
|
1421 callerHasECapabilityWriteDeviceData = 1; |
|
1422 ret = TryChangeStatus(ELockAppDisableDevicelock); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 RDEBUG("unknown iLockStatus", iLockStatus); |
|
1427 } |
|
1428 RDEBUG("ret", ret); |
|
1429 } |
|
1430 |
|
1431 bool Autolock::eventFilter(QObject *o, QEvent *ev) |
|
1432 { |
|
1433 // this never happens |
|
1434 RDEBUG("0", 0); |
|
1435 return QWidget::eventFilter(o, ev); |
|
1436 } |
|
1437 // some setting changed |
|
1438 void Autolock::subscriberKSettingsAutolockStatusChanged() |
|
1439 { |
|
1440 RDEBUG("0", 0); |
|
1441 QVariant v = subscriberKSettingsAutolockStatus->value( |
|
1442 "/KCRUidSecuritySettings/KSettingsAutolockStatus"); |
|
1443 adjustInactivityTimers( KSettingsAutolockStatus); |
|
1444 } |
|
1445 void Autolock::subscriberKSettingsAutoLockTimeChanged() |
|
1446 { |
|
1447 RDEBUG("0", 0); |
|
1448 QVariant v = subscriberKSettingsAutoLockTime->value( |
|
1449 "/KCRUidSecuritySettings/KSettingsAutoLockTime"); |
|
1450 adjustInactivityTimers( KSettingsAutoLockTime); |
|
1451 } |
|
1452 void Autolock::subscriberKSettingsAutomaticKeyguardTimeChanged() |
|
1453 { |
|
1454 RDEBUG("0", 0); |
|
1455 QVariant v = subscriberKSettingsAutomaticKeyguardTime->value( |
|
1456 "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime"); |
|
1457 adjustInactivityTimers( KSettingsAutoLockTime); |
|
1458 } |
|
1459 void Autolock::subscriberKDisplayLightsTimeoutChanged() |
|
1460 { |
|
1461 RDEBUG("0", 0); |
|
1462 QVariant v = subscriberKDisplayLightsTimeout->value( |
|
1463 "/KCRUidLightSettings/KDisplayLightsTimeout"); |
|
1464 // nothing to do |
|
1465 } |
|
1466 void Autolock::subscriberKProEngActiveProfileChanged() |
|
1467 { |
|
1468 RDEBUG("0", 0); |
|
1469 QVariant v = subscriberKProEngActiveProfile->value( |
|
1470 "/KCRUidProfileEngine/KProEngActiveProfile"); |
|
1471 // nothing to do |
|
1472 } |
|
1473 // some environment changed |
|
1474 void Autolock::subscriberKAknKeyguardStatusChanged() |
|
1475 { |
|
1476 RDEBUG("Error only Autolock should be able to change it", 0); |
|
1477 } |
|
1478 void Autolock::subscriberKCoreAppUIsAutolockStatusChanged() |
|
1479 { |
|
1480 RDEBUG("Error only Autolock should be able to change it", 0); |
|
1481 } |
|
1482 void Autolock::subscriberKHWRMGripStatusChanged() |
|
1483 { |
|
1484 TInt ret; |
|
1485 RDEBUG("0", 0); |
|
1486 TInt aGripStatus; |
|
1487 TInt err = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, aGripStatus ); |
|
1488 RDEBUG("err", err); |
|
1489 RDEBUG("value", aGripStatus); |
|
1490 if( aGripStatus == EPSHWRMGripOpen ) |
|
1491 { |
|
1492 if (iLockStatus == EKeyguardActive) |
|
1493 { |
|
1494 iShowKeyguardNote = 1; // note on disable keyguard |
|
1495 ret = TryChangeStatus(ELockAppDisableKeyguard); |
|
1496 } |
|
1497 else if (iLockStatus == EDevicelockActive) |
|
1498 { |
|
1499 ret = TryChangeStatus(ELockAppDisableDevicelock); |
|
1500 } |
|
1501 } |
|
1502 else if( aGripStatus == EPSHWRMGripClosed ) |
|
1503 { |
|
1504 if (iLockStatus == ELockNotActive) |
|
1505 { |
|
1506 iShowKeyguardNote = 1; // note on enable keyguard |
|
1507 ret = TryChangeStatus(ELockAppEnableKeyguard); |
|
1508 } |
|
1509 } |
|
1510 } |
|
1511 // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() |
|
1512 // A way for Autolock to dismiss any possible PIN dialog |
|
1513 // ---------------------------------------------------------------------------- |
|
1514 // |
|
1515 void Autolock::subscriberKSecurityUIsDismissDialogChanged() |
|
1516 { |
|
1517 RDEBUG("0", 0); |
|
1518 TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized; |
|
1519 TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog ); |
|
1520 RDEBUG("err", err); |
|
1521 RDEBUG("aDismissDialog", aDismissDialog); |
|
1522 } |
|
1523 // ----------AutolockService--------------- |
|
1524 |
|
1525 AutolockService::AutolockService(Autolock* parent) : |
|
1526 XQServiceProvider(QLatin1String( |
|
1527 "com.nokia.services.Autolock.Autolock"), parent), |
|
1528 mAutolock(parent), mAsyncReqId(-1), mAsyncAnswer(false) |
|
1529 { |
|
1530 RDEBUG("0", 0); |
|
1531 publishAll(); |
|
1532 connect(this, SIGNAL(returnValueDelivered()), parent, SLOT( |
|
1533 handleAnswerDelivered())); |
|
1534 } |
|
1535 |
|
1536 AutolockService::~AutolockService() |
|
1537 { |
|
1538 RDEBUG("0", 0); |
|
1539 } |
|
1540 |
|
1541 void AutolockService::complete(QString number) |
|
1542 { |
|
1543 RDEBUG("0", 0); |
|
1544 if (mAsyncReqId == -1) |
|
1545 return; |
|
1546 completeRequest(mAsyncReqId, number.toInt()); |
|
1547 } |
|
1548 |
|
1549 // got API request from lockaccessextension |
|
1550 int AutolockService::service(const QString& number, |
|
1551 const QString& aParam1, const QString& aParam2) |
|
1552 { |
|
1553 RDEBUG("0", 0); |
|
1554 TInt err = KErrNone; |
|
1555 RDEBUG("number", number.toInt()); |
|
1556 RDEBUG("aParam1", aParam1.toInt()); |
|
1557 RDEBUG("aParam2", aParam2.toInt()); |
|
1558 mAsyncAnswer = false; |
|
1559 XQRequestInfo info = requestInfo(); |
|
1560 QSet<int> caps = info.clientCapabilities(); |
|
1561 |
|
1562 mAutolock->callerHasECapabilityWriteDeviceData = 0; |
|
1563 if (caps.contains(ECapabilityWriteDeviceData)) |
|
1564 { |
|
1565 RDEBUG("callerHasECapabilityWriteDeviceData", |
|
1566 ECapabilityWriteDeviceData); |
|
1567 mAutolock->callerHasECapabilityWriteDeviceData = 1; |
|
1568 } |
|
1569 |
|
1570 QString label = "Autolock::service:\n"; |
|
1571 label += QString("number=%1\n").arg(number); |
|
1572 |
|
1573 mNumber = number; |
|
1574 mAutolock->setLabelNumber(label, number); |
|
1575 int ret = 0; |
|
1576 ret = number.toInt(); |
|
1577 |
|
1578 mAutolock->mParam1 = aParam1.toInt(); |
|
1579 mAutolock->iShowKeyguardNote = aParam1.toInt(); |
|
1580 mAutolock->mParam2 = aParam2.toInt(); |
|
1581 TTime myTime; |
|
1582 myTime.HomeTime(); |
|
1583 TInt myTimeHigh = 0; |
|
1584 TInt myTimeLow = 0; |
|
1585 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); |
|
1586 RDEBUG("err", err); |
|
1587 RDEBUG("myTimeHigh", myTimeHigh); |
|
1588 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
|
1589 RDEBUG("err", err); |
|
1590 RDEBUG("myTimeLow", myTimeLow); |
|
1591 |
|
1592 myTimeHigh = I64HIGH( myTime.Int64() ); |
|
1593 myTimeLow = I64LOW( myTime.Int64() ); |
|
1594 RDEBUG("myTimeHigh", myTimeHigh); |
|
1595 RDEBUG("myTimeLow", myTimeLow); |
|
1596 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); |
|
1597 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
|
1598 |
|
1599 ret = mAutolock->TryChangeStatus(ret); |
|
1600 RDEBUG("ret", ret); |
|
1601 return ret; |
|
1602 } |
|
1603 |
|
1604 void AutolockService::handleClientDisconnect() |
|
1605 { |
|
1606 RDEBUG("0", 0); |
|
1607 // Just quit service application if client ends |
|
1608 mAsyncAnswer = false; |
|
1609 RDEBUG("0", 0); |
|
1610 // mAutolock->quit(); |
|
1611 } |
|
1612 |
|
1613 /****************/ |
|
1614 CWait* CWait::NewL() |
|
1615 { |
|
1616 CWait* self = new (ELeave) CWait(); |
|
1617 CleanupStack::PushL(self); |
|
1618 self->ConstructL(); |
|
1619 CleanupStack::Pop(); |
|
1620 return self; |
|
1621 } |
|
1622 void CWait::ConstructL() |
|
1623 { |
|
1624 CActiveScheduler::Add(this); |
|
1625 } |
|
1626 CWait::CWait() : |
|
1627 CActive(0) |
|
1628 { |
|
1629 } |
|
1630 CWait::~CWait() |
|
1631 { |
|
1632 Cancel(); |
|
1633 } |
|
1634 TInt CWait::WaitForRequestL() |
|
1635 { |
|
1636 SetActive(); |
|
1637 iWait.Start(); |
|
1638 return iStatus.Int(); |
|
1639 } |
|
1640 void CWait::RunL() |
|
1641 { |
|
1642 if (iWait.IsStarted()) |
|
1643 iWait.AsyncStop(); |
|
1644 } |
|
1645 void CWait::DoCancel() |
|
1646 { |
|
1647 if (iWait.IsStarted()) |
|
1648 iWait.AsyncStop(); |
|
1649 } |
|
1650 void CWait::SetRequestType(TInt aRequestType) |
|
1651 { |
|
1652 iRequestType = aRequestType; |
|
1653 } |
|
1654 TInt CWait::GetRequestType() |
|
1655 { |
|
1656 return iRequestType; |
|
1657 } |
|
1658 |