76 #include <ProfileEngineSDKCRKeys.h> |
75 #include <ProfileEngineSDKCRKeys.h> |
77 #include <e32property.h> |
76 #include <e32property.h> |
78 #include <coreapplicationuisdomainpskeys.h> |
77 #include <coreapplicationuisdomainpskeys.h> |
79 #include "../../../inc/securityuisprivatepskeys.h" |
78 #include "../../../inc/securityuisprivatepskeys.h" |
80 #include <avkondomainpskeys.h> |
79 #include <avkondomainpskeys.h> |
|
80 #include <hwrmdomainpskeys.h> |
81 |
81 |
82 #include <hbdevicedialog.h> |
82 #include <hbdevicedialog.h> |
83 |
83 |
84 const TInt KPhoneIndex(0); |
84 const TInt KPhoneIndex(0); |
85 const TInt KTriesToConnectServer(2); |
85 const TInt KTriesToConnectServer(2); |
87 |
87 |
88 #define ESecUiTypeLock 0x00100000 |
88 #define ESecUiTypeLock 0x00100000 |
89 |
89 |
90 _LIT( KMmTsyModuleName, "PhoneTsy"); |
90 _LIT( KMmTsyModuleName, "PhoneTsy"); |
91 |
91 |
92 #define XQSERVICE_DEBUG_PRINT(a) qDebug() << (a) |
|
93 |
|
94 AutolockSrv::AutolockSrv(QWidget *parent, Qt::WFlags f) : |
92 AutolockSrv::AutolockSrv(QWidget *parent, Qt::WFlags f) : |
95 QWidget(parent, f), mService(NULL) |
93 QWidget(parent, f), mService(NULL) |
96 { |
94 { |
97 XQSERVICE_DEBUG_PRINT("AutolockSrv::AutolockSrv"); |
95 RDEBUG("start autolocksrv", 0); |
98 RDEBUG("start", 0); |
|
99 mService = new AutolockSrvService(this); |
96 mService = new AutolockSrvService(this); |
100 |
97 |
101 /* Adjust the palette */ |
98 /* Adjust the palette */ |
102 #if defined(Q_WS_S60) |
99 #if defined(Q_WS_S60) |
103 RDEBUG( "Q_WS_S60", 1 ); |
100 RDEBUG( "Q_WS_S60", 1 ); |
120 QPushButton *unguardButton = new QPushButton(tr("Unguard")); |
117 QPushButton *unguardButton = new QPushButton(tr("Unguard")); |
121 QPushButton *lockButton = new QPushButton(tr("Lock")); |
118 QPushButton *lockButton = new QPushButton(tr("Lock")); |
122 QPushButton *quitButton = new QPushButton(tr("Quit")); |
119 QPushButton *quitButton = new QPushButton(tr("Quit")); |
123 QPushButton *test1Button = new QPushButton(tr("Autolock 10 seconds")); |
120 QPushButton *test1Button = new QPushButton(tr("Autolock 10 seconds")); |
124 QPushButton *test2Button = new QPushButton(tr("Autolock never")); |
121 QPushButton *test2Button = new QPushButton(tr("Autolock never")); |
|
122 QPushButton *test3Button = new QPushButton(tr("SecUiTest")); |
125 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); |
123 connect(quitButton, SIGNAL(clicked()), this, SLOT(quit())); |
126 connect(lockButton, SIGNAL(clicked()), this, SLOT(lockAction())); |
124 connect(lockButton, SIGNAL(clicked()), this, SLOT(lockAction())); |
127 connect(unlockButton, SIGNAL(clicked()), this, SLOT(unlockAction())); |
125 connect(unlockButton, SIGNAL(clicked()), this, SLOT(unlockAction())); |
128 connect(unguardButton, SIGNAL(clicked()), this, SLOT(unguardAction())); |
126 connect(unguardButton, SIGNAL(clicked()), this, SLOT(unguardAction())); |
129 connect(test1Button, SIGNAL(clicked()), this, SLOT(test1Action())); |
127 connect(test1Button, SIGNAL(clicked()), this, SLOT(test1Action())); |
130 connect(test2Button, SIGNAL(clicked()), this, SLOT(test2Action())); |
128 connect(test2Button, SIGNAL(clicked()), this, SLOT(test2Action())); |
|
129 connect(test3Button, SIGNAL(clicked()), this, SLOT(test3Action())); |
131 RDEBUG("connect", 1); |
130 RDEBUG("connect", 1); |
132 |
131 |
133 /* there's no use for this */ |
132 /* there's no use for this */ |
134 /* |
133 /* |
135 bool isService = XQServiceUtil::isService(); |
134 bool isService = XQServiceUtil::isService(); |
161 vl->addWidget(unlockButton); |
160 vl->addWidget(unlockButton); |
162 vl->addWidget(unguardButton); |
161 vl->addWidget(unguardButton); |
163 vl->addWidget(quitButton); |
162 vl->addWidget(quitButton); |
164 vl->addWidget(test1Button); |
163 vl->addWidget(test1Button); |
165 vl->addWidget(test2Button); |
164 vl->addWidget(test2Button); |
166 RDEBUG("added test2Button", 1); |
165 vl->addWidget(test3Button); |
|
166 RDEBUG("added test3Button", 1); |
167 |
167 |
168 mLabelIcon = new QToolButton; |
168 mLabelIcon = new QToolButton; |
169 mLabelIcon->setIcon(QIcon( |
169 mLabelIcon->setIcon(QIcon( |
170 ":/AutolockSrv_hbicon/qtg_large_device_lock.svg")); |
170 ":/AutolockSrv_hbicon/qtg_large_device_lock.svg")); |
171 mLabelIcon->setIconSize(QSize(300, 300)); |
171 mLabelIcon->setIconSize(QSize(300, 300)); |
189 serviceKeyguard = new AutolockUserActivityService(); |
189 serviceKeyguard = new AutolockUserActivityService(); |
190 serviceDevicelock = new AutolockUserActivityService(); |
190 serviceDevicelock = new AutolockUserActivityService(); |
191 |
191 |
192 TInt lockValue = 0; |
192 TInt lockValue = 0; |
193 TInt lightsTimeout = 0; |
193 TInt lightsTimeout = 0; |
194 CRepository* repository; |
194 CRepository* repository = NULL; |
195 TInt cRresult = 0; |
195 TInt cRresult = 0; |
196 |
196 |
197 iLockStatusPrev = ELockNotActive; |
197 iLockStatusPrev = ELockNotActive; |
198 iLockStatus = ELockNotActive; |
198 iLockStatus = ELockNotActive; |
199 repository = CRepository::NewL(KCRUidSecuritySettings); |
199 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); |
200 cRresult = repository->Get(KSettingsAutolockStatus, lockValue); |
200 cRresult = repository->Get(KSettingsAutolockStatus, lockValue); |
201 RDEBUG("KSettingsAutolockStatus", KSettingsAutolockStatus); |
201 RDEBUG("KSettingsAutolockStatus", KSettingsAutolockStatus); |
202 RDEBUG("cRresult", cRresult); |
202 RDEBUG("cRresult", cRresult); |
203 RDEBUG("lockValue", lockValue); |
203 RDEBUG("lockValue", lockValue); |
204 iLockStatus = lockValue; |
204 iLockStatus = lockValue; |
205 // the settings says to lock |
205 // the settings says to lock |
206 delete repository; |
206 delete repository; |
207 |
207 |
208 adjustInactivityTimers(0); |
208 adjustInactivityTimers(0); |
209 |
209 |
210 repository = CRepository::NewL(KCRUidProfileEngine); |
210 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidProfileEngine) ); |
211 cRresult = repository->Get(KProEngActiveProfile, lightsTimeout); |
211 cRresult = repository->Get(KProEngActiveProfile, lightsTimeout); |
|
212 // this value is not used for now |
212 delete repository; |
213 delete repository; |
213 |
214 |
214 repository = CRepository::NewL(KCRUidLightSettings); |
215 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidLightSettings) ); |
215 cRresult = repository->Get(KDisplayLightsTimeout, lightsTimeout); |
216 cRresult = repository->Get(KDisplayLightsTimeout, lightsTimeout); |
|
217 // this value is not used for now |
216 delete repository; |
218 delete repository; |
217 |
219 |
218 // TODO flip |
220 // subscribe to settings changes |
219 |
|
220 subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber( |
221 subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber( |
221 "/KCRUidSecuritySettings/KSettingsAutolockStatus", this); |
222 "/KCRUidSecuritySettings/KSettingsAutolockStatus", this); |
222 connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()), |
223 connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()), |
223 this, SLOT(subscriberKSettingsAutolockStatusChanged())); |
224 this, SLOT(subscriberKSettingsAutolockStatusChanged())); |
224 subscriberKSettingsAutoLockTime = new QValueSpaceSubscriber( |
225 subscriberKSettingsAutoLockTime = new QValueSpaceSubscriber( |
237 subscriberKProEngActiveProfile = new QValueSpaceSubscriber( |
238 subscriberKProEngActiveProfile = new QValueSpaceSubscriber( |
238 "/KCRUidProfileEngine/KProEngActiveProfile", this); |
239 "/KCRUidProfileEngine/KProEngActiveProfile", this); |
239 connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this, |
240 connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this, |
240 SLOT(subscriberKProEngActiveProfileChanged())); |
241 SLOT(subscriberKProEngActiveProfileChanged())); |
241 |
242 |
|
243 // subscribe to environment changes |
|
244 subscriberKHWRMGripStatus = new QValueSpaceSubscriber( |
|
245 "/KPSUidHWRM/KHWRMGripStatus", this); |
|
246 connect(subscriberKHWRMGripStatus, SIGNAL(contentsChanged()), this, |
|
247 SLOT(subscriberKHWRMGripStatusChanged())); |
|
248 |
|
249 subscriberKAknKeyguardStatus = new QValueSpaceSubscriber( |
|
250 "/KPSUidAvkonDomain/KAknKeyguardStatus", this); |
|
251 connect(subscriberKAknKeyguardStatus, SIGNAL(contentsChanged()), this, |
|
252 SLOT(subscriberKAknKeyguardStatusChanged())); |
|
253 |
|
254 subscriberKCoreAppUIsAutolockStatus = new QValueSpaceSubscriber( |
|
255 "/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus", this); |
|
256 connect(subscriberKCoreAppUIsAutolockStatus, SIGNAL(contentsChanged()), this, |
|
257 SLOT(subscriberKCoreAppUIsAutolockStatusChanged())); |
|
258 |
|
259 ///////////// |
242 TSecurityPolicy readPolicy(ECapabilityReadDeviceData); |
260 TSecurityPolicy readPolicy(ECapabilityReadDeviceData); |
243 TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); |
261 TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); |
244 TInt ret = RProperty::Define(KPSUidSecurityUIs, |
262 TInt ret = RProperty::Define(KPSUidSecurityUIs, |
245 KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, |
263 KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, |
246 writePolicy); |
264 writePolicy); |
253 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
271 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
254 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
272 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
255 ret = RProperty::Define(KPSUidCoreApplicationUIs, |
273 ret = RProperty::Define(KPSUidCoreApplicationUIs, |
256 KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, |
274 KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, |
257 KWritePolicy); |
275 KWritePolicy); |
|
276 //User::LeaveIfError( RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, |
|
277 // EAutolockOff)); |
|
278 RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, |
|
279 EAutolockOff); |
258 RDEBUG("defined KCoreAppUIsAutolockStatus", ret); |
280 RDEBUG("defined KCoreAppUIsAutolockStatus", ret); |
259 |
281 |
260 ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus, |
282 ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus, |
261 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
283 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
262 KWritePolicy); |
284 KWritePolicy); |
278 |
300 |
279 ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLights, |
301 ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsLights, |
280 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
302 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
281 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
303 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
282 RDEBUG("defined KAknKeyguardStatus", ret); |
304 RDEBUG("defined KAknKeyguardStatus", ret); |
|
305 |
|
306 ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, |
|
307 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
|
308 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
|
309 RDEBUG("defined KSecurityUIsDismissDialog", ret); |
283 |
310 |
284 // inactivity |
311 // inactivity |
285 connect(serviceKeyguard, SIGNAL(active()), this, SLOT(activeKeyguard())); |
312 connect(serviceKeyguard, SIGNAL(active()), this, SLOT(activeKeyguard())); |
286 connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT( |
313 connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT( |
287 notActiveKeyguard())); |
314 notActiveKeyguard())); |
319 void AutolockSrv::adjustInactivityTimers(int aReason) |
346 void AutolockSrv::adjustInactivityTimers(int aReason) |
320 { |
347 { |
321 RDEBUG("aReason", aReason); |
348 RDEBUG("aReason", aReason); |
322 TInt keyguardTime = 0; |
349 TInt keyguardTime = 0; |
323 TInt lockTime = 0; |
350 TInt lockTime = 0; |
324 CRepository* repository; |
351 CRepository* repository = NULL; |
325 TInt cRresult = 0; |
352 TInt cRresult = 0; |
326 |
353 |
327 repository = CRepository::NewL(KCRUidSecuritySettings); |
354 QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) ); |
328 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes, handled internally as seconds |
355 cRresult = repository->Get(KSettingsAutoLockTime, lockTime); // in minutes, handled internally as seconds |
329 lockTime *= 60; |
356 lockTime *= 60; |
330 RDEBUG("KSettingsAutoLockTime", KSettingsAutoLockTime); |
357 RDEBUG("KSettingsAutoLockTime", KSettingsAutoLockTime); |
331 RDEBUG("cRresult", cRresult); |
358 RDEBUG("cRresult", cRresult); |
332 RDEBUG("lockTime", lockTime); |
359 RDEBUG("lockTime", lockTime); |
361 |
388 |
362 // from the button |
389 // from the button |
363 void AutolockSrv::unlockAction() |
390 void AutolockSrv::unlockAction() |
364 { |
391 { |
365 RDEBUG("0", 0); |
392 RDEBUG("0", 0); |
366 TryChangeStatus( ELockAppDisableDevicelock); |
393 TInt err = TryChangeStatus( ELockAppDisableDevicelock); |
|
394 RDEBUG("err", err); |
367 } |
395 } |
368 |
396 |
369 void AutolockSrv::unguardAction() |
397 void AutolockSrv::unguardAction() |
370 { |
398 { |
371 RDEBUG("0", 0); |
399 RDEBUG("0", 0); |
372 TryChangeStatus( ELockAppDisableKeyguard); |
400 TInt err = TryChangeStatus( ELockAppDisableKeyguard); |
|
401 RDEBUG("err", err); |
373 } |
402 } |
374 |
403 |
375 void AutolockSrv::test1Action() |
404 void AutolockSrv::test1Action() |
376 { |
405 { |
377 RDEBUG("Set(KSettingsAutoLockTime, 2)", 2); |
406 RDEBUG("Set(KSettingsAutoLockTime, 2)", 2); |
378 |
407 |
379 CRepository* repositorySet = CRepository::NewL(KCRUidSecuritySettings); |
408 CRepository* repositorySet = NULL; |
|
409 QT_TRAP_THROWING( repositorySet = CRepository::NewL(KCRUidSecuritySettings) ); |
380 repositorySet->Set(KSettingsAutoLockTime, 2); // in minutes |
410 repositorySet->Set(KSettingsAutoLockTime, 2); // in minutes |
381 delete repositorySet; |
411 delete repositorySet; |
382 } |
412 } |
383 |
413 |
384 void AutolockSrv::test2Action() |
414 void AutolockSrv::test2Action() |
385 { |
415 { |
386 RDEBUG("Set(KSettingsAutoLockTime, 0)", 0); |
416 RDEBUG("Set(KSettingsAutoLockTime, 0)", 0); |
387 |
417 |
388 CRepository* repositorySet = CRepository::NewL(KCRUidSecuritySettings); |
418 CRepository* repositorySet = NULL; |
|
419 QT_TRAP_THROWING( repositorySet = CRepository::NewL(KCRUidSecuritySettings) ); |
389 repositorySet->Set(KSettingsAutoLockTime, 0); // minutes |
420 repositorySet->Set(KSettingsAutoLockTime, 0); // minutes |
390 delete repositorySet; |
421 delete repositorySet; |
|
422 } |
|
423 void AutolockSrv::test3Action() |
|
424 { |
|
425 RDEBUG("SecUiTest", 0); |
|
426 RDEBUG("This should start SecUiTest, but it's not done yet", 0); |
391 } |
427 } |
392 |
428 |
393 int AutolockSrv::AskValidSecCode(int aReason) |
429 int AutolockSrv::AskValidSecCode(int aReason) |
394 { |
430 { |
395 RDEBUG("aReason", aReason); |
431 RDEBUG("aReason", aReason); |
415 { |
451 { |
416 User::After( KTimeBeforeRetryingServerConnection); |
452 User::After( KTimeBeforeRetryingServerConnection); |
417 } |
453 } |
418 err = iTelServer.LoadPhoneModule(KMmTsyModuleName); |
454 err = iTelServer.LoadPhoneModule(KMmTsyModuleName); |
419 RTelServer::TPhoneInfo PhoneInfo; |
455 RTelServer::TPhoneInfo PhoneInfo; |
420 RDEBUG("err", err); |
456 RDEBUG("LoadPhoneModule err", err); |
421 err = iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended); |
457 err = iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended); |
422 RDEBUG("err", err); |
458 RDEBUG("SetExtendedErrorGranularity err", err); |
423 err = iTelServer.GetPhoneInfo(KPhoneIndex, PhoneInfo); |
459 err = iTelServer.GetPhoneInfo(KPhoneIndex, PhoneInfo); |
424 RDEBUG("err", err); |
460 RDEBUG("GetPhoneInfo err", err); |
425 err = iPhone.Open(iTelServer, PhoneInfo.iName); |
461 err = iPhone.Open(iTelServer, PhoneInfo.iName); |
426 RDEBUG("err", err); |
462 RDEBUG("Open err", err); |
427 err = iCustomPhone.Open(iPhone); |
463 err = iCustomPhone.Open(iPhone); |
428 RDEBUG("err", err); |
464 RDEBUG("Open2 err", err); |
429 |
465 |
430 RDEBUG("CSecurityHandler", 0); |
466 RDEBUG("CSecurityHandler", 0); |
431 CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone); |
467 CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone); |
432 if (aReason == ELockAppDisableDevicelock) |
468 if (aReason == ELockAppDisableDevicelock) |
433 { |
469 { |
434 RDEBUG("calling AskSecCodeInAutoLockL", 0); |
470 RDEBUG("calling AskSecCodeInAutoLockL", 0); |
435 validCode = handler->AskSecCodeInAutoLockL(); // this returns true/false |
471 QT_TRAP_THROWING( validCode = handler->AskSecCodeInAutoLockL() ); // this returns true/false |
436 // TODO should this also do iPhone.SetLockSetting(status, lockType, lockChange); ??? |
472 // TODO should this also do iPhone.SetLockSetting(status, lockType, lockChange); ??? |
437 } |
473 } |
438 else if (aReason == ELockAppEnableDevicelock) |
474 else if (aReason == ELockAppEnableDevicelock) |
439 { |
475 { |
440 // check whether code is really needed |
476 // check whether code is really needed |
478 ret = status.Int(); |
514 ret = status.Int(); |
479 RDEBUG( "WaitForRequestL ret", ret ); |
515 RDEBUG( "WaitForRequestL ret", ret ); |
480 #else |
516 #else |
481 RDEBUG("! OLD_METHOD", 0); |
517 RDEBUG("! OLD_METHOD", 0); |
482 CWait *iWait = NULL; |
518 CWait *iWait = NULL; |
483 iWait = CWait::NewL(); |
519 QT_TRAP_THROWING( iWait = CWait::NewL() ); |
484 iWait->SetRequestType(EMobilePhoneSetLockSetting); |
520 iWait->SetRequestType(EMobilePhoneSetLockSetting); |
485 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // ask for PassPhraseRequiredL |
521 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // ask for PassPhraseRequiredL |
486 RDEBUG("WaitForRequestL", 0); |
522 RDEBUG("WaitForRequestL", 0); |
487 ret = iWait->WaitForRequestL(); |
523 QT_TRAP_THROWING( ret = iWait->WaitForRequestL() ); |
488 RDEBUG("WaitForRequestL ret", ret); |
524 RDEBUG("WaitForRequestL ret", ret); |
489 if (iWait) |
525 if (iWait) |
490 { |
526 { |
491 RDEBUG("IsActive", 0); |
527 RDEBUG("IsActive", 0); |
492 if (iWait->IsActive()) |
528 if (iWait->IsActive()) |
526 validCode = true; |
569 validCode = true; |
527 RDEBUG( "result", result ); |
570 RDEBUG( "result", result ); |
528 */ |
571 */ |
529 } |
572 } |
530 // TODO this doesn't wait on WINS , so how do I get the Acceptation? |
573 // TODO this doesn't wait on WINS , so how do I get the Acceptation? |
531 RDEBUG("validCode (true/false)", validCode); |
574 RDEBUG("validCode", validCode); |
532 if (validCode) |
575 if (validCode>0) |
533 return KErrNone; |
576 return KErrNone; |
534 |
577 |
535 // no valid code -> switch off the lights |
578 // no valid code -> switch off the lights |
536 err = RProperty::Set(KPSUidSecurityUIs, |
579 err = RProperty::Set(KPSUidSecurityUIs, |
537 KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); |
580 KSecurityUIsLights, ESecurityUIsLightsLockOffRequest); |
796 |
836 |
797 int AutolockSrv::publishStatus(int aReason) |
837 int AutolockSrv::publishStatus(int aReason) |
798 { |
838 { |
799 RDEBUG("aReason", aReason); |
839 RDEBUG("aReason", aReason); |
800 TInt err; |
840 TInt err; |
|
841 // can't use include file because it's private file. However it gives permissions |
801 const TUid KCRUidCoreApplicationUIsSysAp = { 0x101F8765 }; |
842 const TUid KCRUidCoreApplicationUIsSysAp = { 0x101F8765 }; |
802 const TUint32 KSysApKeyguardActive = 0x00000001; |
843 const TUint32 KSysApKeyguardActive = 0x00000001; |
803 CRepository* repositoryDevicelock; |
844 CRepository* repositoryDevicelock = NULL; |
804 CRepository* repositoryKeyguard; |
845 CRepository* repositoryKeyguard = NULL; |
805 repositoryDevicelock = CRepository::NewL(KCRUidSecuritySettings); |
846 QT_TRAP_THROWING( repositoryDevicelock = CRepository::NewL(KCRUidSecuritySettings) ); |
806 repositoryKeyguard = CRepository::NewL(KCRUidCoreApplicationUIsSysAp); |
847 QT_TRAP_THROWING( repositoryKeyguard = CRepository::NewL(KCRUidCoreApplicationUIsSysAp) ); |
807 TInt cRresult = KErrNone; |
848 TInt cRresult = KErrNone; |
808 if (1 == 1) // this is a quick way to disable this functionality, for testing |
849 if (1 == 1) // this is a quick way to disable this functionality, for testing |
809 { |
850 { |
810 RDEBUG("publishing", aReason); |
851 RDEBUG("publishing", aReason); |
811 if (aReason == ELockNotActive) |
852 if (aReason == ELockNotActive) |
840 RDEBUG("cRresult", cRresult); |
881 RDEBUG("cRresult", cRresult); |
841 } |
882 } |
842 else if (aReason >= EDevicelockActive) |
883 else if (aReason >= EDevicelockActive) |
843 { |
884 { |
844 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, |
885 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus, |
845 EKeyguardAutolockEmulation); // not EKeyguardLocked, not EKeyguardNotActive |
886 EKeyguardAutolockEmulation); // Other candidates might be: EKeyguardLocked and EKeyguardNotActive |
846 RDEBUG("KAknKeyguardStatus err", err); |
887 RDEBUG("KAknKeyguardStatus err", err); |
847 err = RProperty::Set(KPSUidCoreApplicationUIs, |
888 err = RProperty::Set(KPSUidCoreApplicationUIs, |
848 KCoreAppUIsAutolockStatus, EManualLocked); |
889 KCoreAppUIsAutolockStatus, EManualLocked); |
849 RDEBUG("KCoreAppUIsAutolockStatus err", err); |
890 RDEBUG("KCoreAppUIsAutolockStatus err", err); |
850 err = RProperty::Set(KPSUidSecurityUIs, |
891 err = RProperty::Set(KPSUidSecurityUIs, |
956 if (errorInProcess == KErrNone) |
1001 if (errorInProcess == KErrNone) |
957 { |
1002 { |
958 if (!callerHasECapabilityWriteDeviceData) // check permissions for calling process, because doesn't AskValidSecCode |
1003 if (!callerHasECapabilityWriteDeviceData) // check permissions for calling process, because doesn't AskValidSecCode |
959 errorInProcess = KErrPermissionDenied; |
1004 errorInProcess = KErrPermissionDenied; |
960 DebugError(errorInProcess); |
1005 DebugError(errorInProcess); |
|
1006 break; // so that "disable while disabled" doesn't mess up |
961 } |
1007 } |
962 if (errorInProcess == KErrNone) |
1008 if (errorInProcess == KErrNone) |
963 { |
1009 { |
964 RDEBUG(" calling HbDeviceMessageBox::question", 0); |
1010 RDEBUG(" calling HbDeviceMessageBox::question", 0); |
965 bool value = HbDeviceMessageBox::question("Disable Lock?"); |
1011 bool value = HbDeviceMessageBox::question("Disable Lock?"); // this doesn't block other events, so after return everything might be messed up. |
966 RDEBUG("value", value); |
1012 RDEBUG("value", value); |
967 if (!value) |
1013 if (!value) |
968 errorInProcess = KErrCancel; |
1014 errorInProcess = KErrCancel; |
969 } |
1015 } |
970 if (errorInProcess == KErrNone) |
1016 if (errorInProcess == KErrNone) |
980 updateIndicator(ELockNotActive); |
1026 updateIndicator(ELockNotActive); |
981 publishStatus(ELockNotActive); |
1027 publishStatus(ELockNotActive); |
982 } |
1028 } |
983 if (errorInProcess != KErrNone) |
1029 if (errorInProcess != KErrNone) |
984 { // re-lock. For example, if password is wrong |
1030 { // re-lock. For example, if password is wrong |
985 setLockDialog(aReason, 1); |
1031 if( iLockStatus >=EDevicelockActive) // this skips the case when unlocking, although it wan't locked. |
|
1032 setLockDialog(aReason, 1); |
986 } |
1033 } |
987 // this never shows a note |
1034 // this never shows a note |
988 } |
1035 } |
989 break; |
1036 break; |
990 case ELockAppOfferKeyguard: // 5 |
1037 case ELockAppOfferKeyguard: // 5 |
991 { |
1038 { |
992 errorInProcess = CheckIfLegal(ret); |
1039 errorInProcess = CheckIfLegal(ret); |
993 DebugError(errorInProcess); |
1040 DebugError(errorInProcess); |
994 if (errorInProcess == KErrNone) |
1041 if (errorInProcess == KErrNone) |
995 { |
1042 { |
996 bool value = HbDeviceMessageBox::question("Enable Keyguard?"); |
1043 bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up. |
997 // TODO what about a nice icon? |
1044 // TODO what about a nice icon? |
998 RDEBUG("value", value); |
1045 RDEBUG("value", value); |
999 if (!value) |
1046 if (!value) |
1000 errorInProcess = KErrCancel; |
1047 errorInProcess = KErrCancel; |
1001 } |
1048 } |
1012 DebugError(errorInProcess); |
1059 DebugError(errorInProcess); |
1013 setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. |
1060 setLockDialog(aReason, 0); // hide temporarilly because AskValidSecCode doesn't get in top of the Lock-icon. Thus, dismiss it. |
1014 errorInProcess = AskValidSecCode(ELockAppEnableDevicelock); |
1061 errorInProcess = AskValidSecCode(ELockAppEnableDevicelock); |
1015 if (errorInProcess == KErrNone) |
1062 if (errorInProcess == KErrNone) |
1016 { |
1063 { |
|
1064 RDEBUG("ELockAppOfferDevicelock calling ELockAppEnableDevicelock", ELockAppEnableDevicelock); |
1017 errorInProcess = TryChangeStatus(ELockAppEnableDevicelock); |
1065 errorInProcess = TryChangeStatus(ELockAppEnableDevicelock); |
1018 } |
1066 } |
1019 // this never shows a note. Perhaps ELockAppEnableDevicelock does. |
1067 // this never shows a note. Perhaps ELockAppEnableDevicelock does. |
1020 } |
1068 } |
1021 break; |
1069 break; |
1090 // confirm that dialog is present |
1138 // confirm that dialog is present |
1091 err = iDeviceDialog->error(); |
1139 err = iDeviceDialog->error(); |
1092 RDEBUG("err", err); |
1140 RDEBUG("err", err); |
1093 iDeviceDialogCreated = 2; |
1141 iDeviceDialogCreated = 2; |
1094 } |
1142 } |
1095 const QString KSecQueryUiDeviceDialog( |
1143 const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); |
1096 "com.nokia.secuinotificationdialog/1.0"); |
|
1097 RDEBUG("pre show", aReason); |
1144 RDEBUG("pre show", aReason); |
1098 err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing |
1145 err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing |
1099 RDEBUG("post show. err", err); |
1146 RDEBUG("post show. err", err); |
1100 err = iDeviceDialog->error(); |
1147 err = iDeviceDialog->error(); |
1101 RDEBUG("err", err); |
1148 RDEBUG("err", err); |
1216 int isSwitchKey = 0; |
1263 int isSwitchKey = 0; |
1217 // on device, this doesn't seem to get the EKeyDeviceF key: only 1ffffff |
1264 // on device, this doesn't seem to get the EKeyDeviceF key: only 1ffffff |
1218 if (ev->type() == QEvent::KeyPress) |
1265 if (ev->type() == QEvent::KeyPress) |
1219 { |
1266 { |
1220 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1267 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1221 qDebug() << QString("KeyPress:%1\n").arg(keyEvent->key(), 0, 16); |
1268 RDEBUG("KeyPress", keyEvent->key()); |
1222 qDebug() << keyEvent->key(); |
|
1223 qDebug() << EKeyInsert; |
|
1224 qDebug() << (keyEvent->key() & 0xFF); |
|
1225 qDebug() << (EKeyInsert & 0xFF); |
|
1226 if ((keyEvent->key() & 0xFF) == (EKeyInsert & 0xFF)) |
1269 if ((keyEvent->key() & 0xFF) == (EKeyInsert & 0xFF)) |
1227 { |
1270 { |
1228 qDebug() << "pressed EKeyInsert"; |
1271 RDEBUG("EKeyInsert", EKeyInsert); |
1229 // only reacts on release, not on press |
1272 // only reacts on release, not on press |
1230 isSwitchKey = 1; |
1273 isSwitchKey = 1; |
1231 } |
1274 } |
1232 if ((keyEvent->key() & 0xFF) == (EKeyTab & 0xFF)) |
1275 if ((keyEvent->key() & 0xFF) == (EKeyTab & 0xFF)) |
1233 { |
1276 { |
1234 qDebug() << "pressed EKeyTab"; |
1277 RDEBUG("EKeyTab", EKeyTab); |
1235 } |
1278 } |
1236 if ((keyEvent->key() & 0xFF) == (EKeyDeviceF & 0xFF)) |
1279 if ((keyEvent->key() & 0xFF) == (EKeyDeviceF & 0xFF)) |
1237 { |
1280 { |
1238 qDebug() << "pressed EKeyDeviceF"; |
1281 RDEBUG("EKeyDeviceF", EKeyDeviceF); |
1239 } |
1282 } |
1240 if (keyEvent->key() == 0x1ffffff) |
1283 if (keyEvent->key() == 0x1ffffff) |
1241 { |
1284 { |
1242 qDebug() << "pressed EKeyDeviceF-1ffffff"; |
1285 RDEBUG("0x1ffffff", 0x1ffffff); |
1243 isSwitchKey = 1; |
1286 isSwitchKey = 1; |
1244 } |
1287 } |
1245 } |
1288 } |
1246 else if (ev->type() == QEvent::KeyRelease) |
1289 else if (ev->type() == QEvent::KeyRelease) |
1247 { |
1290 { |
1248 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1291 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1249 qDebug() |
1292 RDEBUG("KeyRelease", keyEvent->key()); |
1250 << QString("KeyRelease:%1\n").arg(keyEvent->key(), 0, 16); |
|
1251 if (keyEvent->key() == 0x1ffffff) |
1293 if (keyEvent->key() == 0x1ffffff) |
1252 { |
1294 { |
1253 RDEBUG("released EKeyDeviceF-1ffffff", 1); |
1295 RDEBUG("released EKeyDeviceF-1ffffff", 1); |
1254 // isSwitchKey=1; this should happen is pressed was not processed (hint: if it is/was in background) |
1296 // isSwitchKey=1; this should happen is pressed was not processed (hint: if it is/was in background) |
1255 } |
1297 } |
1289 // this never happens |
1331 // this never happens |
1290 RDEBUG("0", 0); |
1332 RDEBUG("0", 0); |
1291 return QWidget::eventFilter(o, ev); |
1333 return QWidget::eventFilter(o, ev); |
1292 |
1334 |
1293 } |
1335 } |
1294 |
1336 // some setting changed |
1295 void AutolockSrv::subscriberKSettingsAutolockStatusChanged() |
1337 void AutolockSrv::subscriberKSettingsAutolockStatusChanged() |
1296 { |
1338 { |
1297 RDEBUG("0", 0); |
1339 RDEBUG("0", 0); |
1298 QVariant v = subscriberKSettingsAutolockStatus->value( |
1340 QVariant v = subscriberKSettingsAutolockStatus->value( |
1299 "/KCRUidSecuritySettings/KSettingsAutolockStatus"); |
1341 "/KCRUidSecuritySettings/KSettingsAutolockStatus"); |
1300 adjustInactivityTimers( KSettingsAutolockStatus); |
1342 adjustInactivityTimers( KSettingsAutolockStatus); |
1301 qDebug() << "AutolockSrv::subscriberKSettingsAutolockStatusChanged" << v; |
|
1302 } |
1343 } |
1303 void AutolockSrv::subscriberKSettingsAutoLockTimeChanged() |
1344 void AutolockSrv::subscriberKSettingsAutoLockTimeChanged() |
1304 { |
1345 { |
1305 RDEBUG("0", 0); |
1346 RDEBUG("0", 0); |
1306 QVariant v = subscriberKSettingsAutoLockTime->value( |
1347 QVariant v = subscriberKSettingsAutoLockTime->value( |
1307 "/KCRUidSecuritySettings/KSettingsAutoLockTime"); |
1348 "/KCRUidSecuritySettings/KSettingsAutoLockTime"); |
1308 adjustInactivityTimers( KSettingsAutoLockTime); |
1349 adjustInactivityTimers( KSettingsAutoLockTime); |
1309 qDebug() << "AutolockSrv::subscriberKSettingsAutoLockTimeChanged" << v; |
|
1310 } |
1350 } |
1311 void AutolockSrv::subscriberKSettingsAutomaticKeyguardTimeChanged() |
1351 void AutolockSrv::subscriberKSettingsAutomaticKeyguardTimeChanged() |
1312 { |
1352 { |
1313 RDEBUG("0", 0); |
1353 RDEBUG("0", 0); |
1314 QVariant v = subscriberKSettingsAutomaticKeyguardTime->value( |
1354 QVariant v = subscriberKSettingsAutomaticKeyguardTime->value( |
1315 "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime"); |
1355 "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime"); |
1316 adjustInactivityTimers( KSettingsAutoLockTime); |
1356 adjustInactivityTimers( KSettingsAutoLockTime); |
1317 qDebug() |
|
1318 << "AutolockSrv::subscriberKSettingsAutomaticKeyguardTimeChanged" |
|
1319 << v; |
|
1320 } |
1357 } |
1321 void AutolockSrv::subscriberKDisplayLightsTimeoutChanged() |
1358 void AutolockSrv::subscriberKDisplayLightsTimeoutChanged() |
1322 { |
1359 { |
1323 RDEBUG("0", 0); |
1360 RDEBUG("0", 0); |
1324 QVariant v = subscriberKDisplayLightsTimeout->value( |
1361 QVariant v = subscriberKDisplayLightsTimeout->value( |
1325 "/KCRUidLightSettings/KDisplayLightsTimeout"); |
1362 "/KCRUidLightSettings/KDisplayLightsTimeout"); |
1326 // nothing to do |
1363 // nothing to do |
1327 qDebug() << "AutolockSrv::subscriberKDisplayLightsTimeoutChanged" << v; |
|
1328 } |
1364 } |
1329 void AutolockSrv::subscriberKProEngActiveProfileChanged() |
1365 void AutolockSrv::subscriberKProEngActiveProfileChanged() |
1330 { |
1366 { |
1331 RDEBUG("0", 0); |
1367 RDEBUG("0", 0); |
1332 QVariant v = subscriberKProEngActiveProfile->value( |
1368 QVariant v = subscriberKProEngActiveProfile->value( |
1333 "/KCRUidProfileEngine/KProEngActiveProfile"); |
1369 "/KCRUidProfileEngine/KProEngActiveProfile"); |
1334 // nothing to do |
1370 // nothing to do |
1335 qDebug() << "AutolockSrv::subscriberKProEngActiveProfileChanged" << v; |
1371 } |
|
1372 // some environment changed |
|
1373 void AutolockSrv::subscriberKAknKeyguardStatusChanged() |
|
1374 { |
|
1375 RDEBUG("Error only AutolockSrv should be able to change it", 0); |
|
1376 } |
|
1377 void AutolockSrv::subscriberKCoreAppUIsAutolockStatusChanged() |
|
1378 { |
|
1379 RDEBUG("Error only AutolockSrv should be able to change it", 0); |
|
1380 } |
|
1381 void AutolockSrv::subscriberKHWRMGripStatusChanged() |
|
1382 { |
|
1383 TInt ret; |
|
1384 RDEBUG("0", 0); |
|
1385 TInt aGripStatus; |
|
1386 TInt err = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, aGripStatus ); |
|
1387 RDEBUG("err", err); |
|
1388 RDEBUG("value", aGripStatus); |
|
1389 if( aGripStatus == EPSHWRMGripOpen ) |
|
1390 { |
|
1391 if (iLockStatus == EKeyguardActive) |
|
1392 { |
|
1393 iShowKeyguardNote = 1; // note on disable keyguard |
|
1394 ret = TryChangeStatus(ELockAppDisableKeyguard); |
|
1395 } |
|
1396 else if (iLockStatus == EDevicelockActive) |
|
1397 { |
|
1398 ret = TryChangeStatus(ELockAppDisableDevicelock); |
|
1399 } |
|
1400 } |
|
1401 else if( aGripStatus == EPSHWRMGripClosed ) |
|
1402 { |
|
1403 if (iLockStatus == ELockNotActive) |
|
1404 { |
|
1405 iShowKeyguardNote = 1; // note on enable keyguard |
|
1406 ret = TryChangeStatus(ELockAppEnableKeyguard); |
|
1407 } |
|
1408 } |
1336 } |
1409 } |
1337 |
1410 |
1338 // ----------AutolockSrvService--------------- |
1411 // ----------AutolockSrvService--------------- |
1339 |
1412 |
1340 AutolockSrvService::AutolockSrvService(AutolockSrv* parent) : |
1413 AutolockSrvService::AutolockSrvService(AutolockSrv* parent) : |
1356 void AutolockSrvService::complete(QString number) |
1429 void AutolockSrvService::complete(QString number) |
1357 { |
1430 { |
1358 RDEBUG("0", 0); |
1431 RDEBUG("0", 0); |
1359 if (mAsyncReqId == -1) |
1432 if (mAsyncReqId == -1) |
1360 return; |
1433 return; |
1361 XQSERVICE_DEBUG_PRINT("AutolockSrvService::complete"); |
|
1362 completeRequest(mAsyncReqId, number.toInt()); |
1434 completeRequest(mAsyncReqId, number.toInt()); |
1363 } |
1435 } |
1364 |
1436 |
1365 // gor API request |
1437 // got API request from lockaccessextension |
1366 int AutolockSrvService::service(const QString& number, |
1438 int AutolockSrvService::service(const QString& number, |
1367 const QString& aParam1, const QString& aParam2) |
1439 const QString& aParam1, const QString& aParam2) |
1368 { |
1440 { |
1369 RDEBUG("0", 0); |
1441 RDEBUG("0", 0); |
1370 TInt err = KErrNone; |
1442 TInt err = KErrNone; |
1371 qDebug() << "number=" << number; |
1443 RDEBUG("number", number.toInt()); |
1372 qDebug() << "aParam1=" << aParam1; |
1444 RDEBUG("aParam1", aParam1.toInt()); |
1373 qDebug() << "aParam2=" << aParam2; |
1445 RDEBUG("aParam2", aParam2.toInt()); |
1374 mAsyncAnswer = false; |
1446 mAsyncAnswer = false; |
1375 XQRequestInfo info = requestInfo(); |
1447 XQRequestInfo info = requestInfo(); |
1376 QSet<int> caps = info.clientCapabilities(); |
1448 QSet<int> caps = info.clientCapabilities(); |
1377 |
1449 |
1378 mAutolockSrv->callerHasECapabilityWriteDeviceData = 0; |
1450 mAutolockSrv->callerHasECapabilityWriteDeviceData = 0; |
1403 RDEBUG("myTimeHigh", myTimeHigh); |
1475 RDEBUG("myTimeHigh", myTimeHigh); |
1404 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
1476 err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
1405 RDEBUG("err", err); |
1477 RDEBUG("err", err); |
1406 RDEBUG("myTimeLow", myTimeLow); |
1478 RDEBUG("myTimeLow", myTimeLow); |
1407 |
1479 |
1408 myTimeHigh = myTime.Int64() >> 16; |
1480 myTimeHigh = I64HIGH( myTime.Int64() ); |
1409 myTimeLow = myTime.Int64() & 0xFFFFFFFF ; |
1481 myTimeLow = I64LOW( myTime.Int64() ); |
1410 RDEBUG("myTimeHigh", myTimeHigh); |
1482 RDEBUG("myTimeHigh", myTimeHigh); |
1411 RDEBUG("myTimeLow", myTimeLow); |
1483 RDEBUG("myTimeLow", myTimeLow); |
1412 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); |
1484 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh ); |
1413 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
1485 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeLow, myTimeLow ); |
1414 |
1486 |