changeset 38 | e0432375ea67 |
parent 37 | 7bad16cccaca |
child 45 | 5d3e34b7618a |
37:7bad16cccaca | 38:e0432375ea67 |
---|---|
64 #include <secuisecuritysettings.h> |
64 #include <secuisecuritysettings.h> |
65 #include <secui.h> |
65 #include <secui.h> |
66 #include <secuisecurityhandler.h> |
66 #include <secuisecurityhandler.h> |
67 #include <etelmm.h> |
67 #include <etelmm.h> |
68 #include <rmmcustomapi.h> |
68 #include <rmmcustomapi.h> |
69 |
69 #include <keylockpolicyapi.h> |
70 #include <qvaluespacesubscriber.h> |
70 #include <qvaluespacesubscriber.h> |
71 |
71 |
72 #include <hwrmlightdomaincrkeys.h> |
72 #include <hwrmlightdomaincrkeys.h> |
73 #include <ProfileEngineSDKCRKeys.h> |
73 #include <ProfileEngineSDKCRKeys.h> |
74 #include <e32property.h> |
74 #include <e32property.h> |
117 KWritePolicy); |
117 KWritePolicy); |
118 RDEBUG("defined KCoreAppUIsAutolockStatus", ret); |
118 RDEBUG("defined KCoreAppUIsAutolockStatus", ret); |
119 |
119 |
120 // This is important: we set the status through a property |
120 // This is important: we set the status through a property |
121 TInt autolockState; |
121 TInt autolockState; |
122 RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
122 ret = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
123 RDEBUG("Get KCoreAppUIsAutolockStatus", ret); |
123 RDEBUG("Get KCoreAppUIsAutolockStatus", ret); |
124 RDEBUG("autolockState", autolockState); |
124 RDEBUG("autolockState", autolockState); |
125 if(autolockState==EAutolockStatusUninitialized) |
125 if(autolockState==EAutolockStatusUninitialized) |
126 { |
126 { |
127 autolockState = EAutolockOff; // not-initialized means taht the unlock-query hasn't been displayed. Therefore the device should not stay locked. |
127 autolockState = EAutolockOff; // not-initialized means taht the unlock-query hasn't been displayed. Therefore the device should not stay locked. |
278 connect(serviceDevicelock, SIGNAL(notActive()), this, SLOT( |
278 connect(serviceDevicelock, SIGNAL(notActive()), this, SLOT( |
279 notActiveDevicelock())); |
279 notActiveDevicelock())); |
280 |
280 |
281 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
281 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
282 RDEBUG("got groupWin", 1); |
282 RDEBUG("got groupWin", 1); |
283 // TODO if I want to release, I should do: mKeyCaptureHandle = env->RootWin().CaptureKey(EKeyBackspace, 0, 0); |
283 // if I want to release, I should do: mKeyCaptureHandle = env->RootWin().CaptureKey(EKeyBackspace, 0, 0); |
284 groupWin.CaptureKey(EKeyBackspace, 0, 0); |
|
285 groupWin.CaptureKey(EKeyDeviceF, 0, 0); |
284 groupWin.CaptureKey(EKeyDeviceF, 0, 0); |
286 groupWin.CaptureKey(EKeyBell, 0, 0); |
285 groupWin.CaptureKey(EKeyBell, 0, 0); |
287 groupWin.CaptureKey(EKeyTab, 0, 0); |
|
288 groupWin.CaptureKey(EKeyInsert, 0, 0); |
|
289 RDEBUG("got mKeyCaptureHandle", 1); |
286 RDEBUG("got mKeyCaptureHandle", 1); |
290 |
287 |
291 iSecQueryUiCreated = -1; |
288 iSecQueryUiCreated = -1; |
292 iDeviceDialogCreated = -1; |
289 iDeviceDialogCreated = EDeviceDialogUninitialized; |
293 // TODO for now, always starts unlocked |
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 |
|
294 // TryChangeStatus(iLockStatus); |
293 // TryChangeStatus(iLockStatus); |
295 TryChangeStatus( ELockNotActive); |
294 TryChangeStatus( ELockNotActive); |
296 lower(); |
295 lower(); |
297 hide(); |
296 hide(); |
298 |
297 |
370 TInt err(KErrGeneral); |
369 TInt err(KErrGeneral); |
371 TBool validCode(EFalse); |
370 TBool validCode(EFalse); |
372 TInt thisTry(0); |
371 TInt thisTry(0); |
373 RTelServer iTelServer; |
372 RTelServer iTelServer; |
374 |
373 |
375 err = RProperty::Set(KPSUidSecurityUIs, |
374 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); |
376 KSecurityUIsLights, ESecurityUIsLightsQueryOnRequest); |
|
377 RDEBUG("KSecurityUIsLights err", err); |
375 RDEBUG("KSecurityUIsLights err", err); |
378 |
376 |
379 RMmCustomAPI iCustomPhone; |
377 RMmCustomAPI iCustomPhone; |
380 while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) |
378 while ((err = iTelServer.Connect()) != KErrNone && (thisTry++) |
381 <= KTriesToConnectServer) |
379 <= KTriesToConnectServer) |
499 if(result) |
497 if(result) |
500 validCode = true; |
498 validCode = true; |
501 RDEBUG( "result", result ); |
499 RDEBUG( "result", result ); |
502 */ |
500 */ |
503 } |
501 } |
504 // TODO this doesn't wait on WINS , so how do I get the Acceptation? |
|
505 RDEBUG("validCode", validCode); |
502 RDEBUG("validCode", validCode); |
506 if (validCode>0) |
503 if (validCode>0) |
507 return KErrNone; |
504 return KErrNone; |
508 |
505 |
509 // no valid code -> switch off the lights |
506 // no valid code -> switch off the lights |
596 } |
593 } |
597 |
594 |
598 int Autolock::CheckIfLegal(int aReason) |
595 int Autolock::CheckIfLegal(int aReason) |
599 { |
596 { |
600 RDEBUG("aReason", aReason); |
597 RDEBUG("aReason", aReason); |
601 // 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 Starter) |
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) |
602 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
599 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
603 TInt err = RProperty::Get(KPSUidSecurityUIs, |
600 TInt err = RProperty::Get(KPSUidSecurityUIs, |
604 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
601 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
605 RDEBUG("err", err); |
602 RDEBUG("err", err); |
606 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
603 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
613 != ESecurityUIsSecUIOriginatedUninitialized) |
610 != ESecurityUIsSecUIOriginatedUninitialized) |
614 return KErrInUse; // PIN on top. Don't keyguard |
611 return KErrInUse; // PIN on top. Don't keyguard |
615 switch (iLockStatus) |
612 switch (iLockStatus) |
616 { |
613 { |
617 case ELockNotActive: |
614 case ELockNotActive: |
618 if (1 == 0) // !CKeyLockPolicyApi::KeyguardAllowed() ) |
615 if ( !CKeyLockPolicyApi::KeyguardAllowed() ) |
619 return KErrPermissionDenied; |
616 return KErrPermissionDenied; |
620 else |
617 else |
621 return KErrNone; |
618 return KErrNone; |
622 case EKeyguardActive: |
619 case EKeyguardActive: |
623 return KErrAlreadyExists; |
620 return KErrAlreadyExists; |
769 EKeyguardNotActive); |
766 EKeyguardNotActive); |
770 RDEBUG("err", err); |
767 RDEBUG("err", err); |
771 err = RProperty::Set(KPSUidCoreApplicationUIs, |
768 err = RProperty::Set(KPSUidCoreApplicationUIs, |
772 KCoreAppUIsAutolockStatus, EAutolockOff); |
769 KCoreAppUIsAutolockStatus, EAutolockOff); |
773 RDEBUG("err", err); |
770 RDEBUG("err", err); |
774 // lights are required ? |
771 err = RProperty::Set(KPSUidSecurityUIs, |
772 KSecurityUIsLights, ESecurityUIsLightsLockOnRequest); // lights are required |
|
773 RDEBUG("KSecurityUIsLights err", err); |
|
775 |
774 |
776 // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); // the settings remains. Only ISA changes, as well as the P&S |
775 // cRresult = repositoryDevicelock->Set(KSettingsAutolockStatus, 0); // the settings remains. Only ISA changes, as well as the P&S |
777 cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); |
776 cRresult = repositoryKeyguard->Set(KSysApKeyguardActive, 0); |
778 RDEBUG("cRresult", cRresult); |
777 RDEBUG("cRresult", cRresult); |
779 } |
778 } |
858 int errorInProcess = KErrNone; |
857 int errorInProcess = KErrNone; |
859 DebugRequest(ret); |
858 DebugRequest(ret); |
860 |
859 |
861 // this will cancel any previous dialog, i.e. PIN query, or any previous code-request. |
860 // this will cancel any previous dialog, i.e. PIN query, or any previous code-request. |
862 // not sure about the screensaver, but nevertheless will be cancelled when the status is changed. |
861 // not sure about the screensaver, but nevertheless will be cancelled when the status is changed. |
863 TInt err = RProperty::Set(KPSUidSecurityUIs, |
862 TInt err = KErrNone; |
864 KSecurityUIsDismissDialog, |
863 RDEBUG("Not setting KSecurityUIsDismissDialog ESecurityUIsDismissDialogOn", ESecurityUIsDismissDialogOn); |
865 ESecurityUIsDismissDialogOn); |
864 //// err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn); |
866 RDEBUG("err", err); |
865 RDEBUG("err", err); |
867 switch (ret) |
866 switch (ret) |
868 { |
867 { |
869 case ELockAppEnableKeyguard: // 1 |
868 case ELockAppEnableKeyguard: // 1 |
870 { |
869 { |
874 { |
873 { |
875 setLabelIcon( EKeyguardActive); |
874 setLabelIcon( EKeyguardActive); |
876 updateIndicator(EKeyguardActive); |
875 updateIndicator(EKeyguardActive); |
877 publishStatus(EKeyguardActive); |
876 publishStatus(EKeyguardActive); |
878 showNoteIfRequested(EKeyguardActive); |
877 showNoteIfRequested(EKeyguardActive); |
878 setLockDialog(aReason, 1); |
|
879 } |
879 } |
880 } |
880 } |
881 break; |
881 break; |
882 case ELockAppDisableKeyguard: // 2 |
882 case ELockAppDisableKeyguard: // 2 |
883 { |
883 { |
887 { |
887 { |
888 setLabelIcon( ELockNotActive); |
888 setLabelIcon( ELockNotActive); |
889 updateIndicator(ELockNotActive); |
889 updateIndicator(ELockNotActive); |
890 publishStatus(ELockNotActive); |
890 publishStatus(ELockNotActive); |
891 showNoteIfRequested(ELockNotActive); |
891 showNoteIfRequested(ELockNotActive); |
892 setLockDialog(aReason, 0); |
|
892 } |
893 } |
893 } |
894 } |
894 break; |
895 break; |
895 case ELockAppEnableDevicelock: // 3 |
896 case ELockAppEnableDevicelock: // 3 |
896 { |
897 { |
924 DebugError(errorInProcess); |
925 DebugError(errorInProcess); |
925 } |
926 } |
926 if (errorInProcess == KErrNone) |
927 if (errorInProcess == KErrNone) |
927 { |
928 { |
928 setLockDialog(aReason, 0); // hide temporarilly because HbDeviceMessageBox doesn't get in top of the Lock-icon. Thus, dismiss it. |
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); |
|
929 RDEBUG("calling HbDeviceMessageBox::question", 0); |
933 RDEBUG("calling HbDeviceMessageBox::question", 0); |
930 bool value = HbDeviceMessageBox::question("Disable Lock?"); // this doesn't block other events, so after return everything might be messed up. |
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. |
|
931 RDEBUG("value", value); |
937 RDEBUG("value", value); |
932 if (!value) |
938 if (!value) |
933 errorInProcess = KErrCancel; |
939 errorInProcess = KErrCancel; |
934 } |
940 } |
935 if (errorInProcess == KErrNone) |
941 if (errorInProcess == KErrNone) |
941 } |
947 } |
942 if (errorInProcess == KErrNone) |
948 if (errorInProcess == KErrNone) |
943 { |
949 { |
944 setLabelIcon( ELockNotActive); |
950 setLabelIcon( ELockNotActive); |
945 updateIndicator(ELockNotActive); |
951 updateIndicator(ELockNotActive); |
952 setLockDialog(aReason, 0); |
|
946 publishStatus(ELockNotActive); |
953 publishStatus(ELockNotActive); |
947 } |
954 } |
948 if (errorInProcess != KErrNone) |
955 if (errorInProcess != KErrNone) |
949 { // re-lock. For example, if password is wrong |
956 { // re-lock. For example, if password is wrong |
950 if( iLockStatus >=EDevicelockActive) // this skips the case "unlocking although it wasn't locked" |
957 if( iLockStatus >=EDevicelockActive) // this skips the case "unlocking although it wasn't locked" |
951 setLockDialog(aReason, 1); |
958 setLockDialog(ELockAppEnableDevicelock, 1); |
952 } |
959 } |
953 // this never shows a note |
960 // this never shows a note |
954 } |
961 } |
955 break; |
962 break; |
956 case ELockAppOfferKeyguard: // 5 |
963 case ELockAppOfferKeyguard: // 5 |
958 errorInProcess = CheckIfLegal(ret); |
965 errorInProcess = CheckIfLegal(ret); |
959 DebugError(errorInProcess); |
966 DebugError(errorInProcess); |
960 if (errorInProcess == KErrNone) |
967 if (errorInProcess == KErrNone) |
961 { |
968 { |
962 // no need to dismiss screensaver, because it's not active |
969 // no need to dismiss screensaver, because it's not active |
963 // TODO 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 |
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 |
964 bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up. |
971 bool value = HbDeviceMessageBox::question("Enable Keyguard?"); // this doesn't block other events, so after return everything might be messed up. |
965 // TODO what about a nice icon? |
972 // what about a nice icon? |
966 RDEBUG("value", value); |
973 RDEBUG("value", value); |
967 if (!value) |
974 if (!value) |
968 errorInProcess = KErrCancel; |
975 errorInProcess = KErrCancel; |
969 } |
976 } |
970 if (errorInProcess == KErrNone) |
977 if (errorInProcess == KErrNone) |
1024 |
1031 |
1025 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
1032 RWindowGroup& groupWin = CEikonEnv::Static()->RootWin(); |
1026 |
1033 |
1027 if (status == 0) // hide |
1034 if (status == 0) // hide |
1028 { |
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 } |
|
1029 // secUiOriginatedQuery should be ESecurityUIsSystemLockOriginated . If not, this is not correctly setting it |
1041 // secUiOriginatedQuery should be ESecurityUIsSystemLockOriginated . If not, this is not correctly setting it |
1030 if (iDeviceDialogCreated > 0) |
1042 if (iDeviceDialogCreated >= EDeviceDialogCreated) |
1031 { |
1043 { |
1032 iDeviceDialogCreated = 0; |
1044 iDeviceDialogCreated = EDeviceDialogDestroyed; |
1033 iDeviceDialog->cancel(); |
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); |
|
1034 err = iDeviceDialog->error(); |
1050 err = iDeviceDialog->error(); |
1035 RDEBUG("err", err); |
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 |
|
1036 TInt err = RProperty::Set(KPSUidSecurityUIs, |
1058 TInt err = RProperty::Set(KPSUidSecurityUIs, |
1037 KSecurityUIsSecUIOriginatedQuery, |
1059 KSecurityUIsSecUIOriginatedQuery, |
1038 ESecurityUIsSecUIOriginatedUninitialized); |
1060 ESecurityUIsSecUIOriginatedUninitialized); |
1039 RDEBUG("err", err); |
1061 RDEBUG("reset KSecurityUIsSecUIOriginatedQuery. err", err); |
1040 // Cancel power key and application key capturing |
1062 // Cancel power key and application key capturing |
1041 groupWin.CancelCaptureKey( mPowerKeyCaptureHandle ); |
1063 groupWin.CancelCaptureKey( mPowerKeyCaptureHandle ); |
1042 groupWin.CancelCaptureKey( mApplicationKeyCaptureHandle ); |
1064 groupWin.CancelCaptureKey( mApplicationKeyCaptureHandle ); |
1043 groupWin.CancelCaptureLongKey( mApplicationLongKeyCaptureHandle ); |
1065 groupWin.CancelCaptureLongKey( mApplicationLongKeyCaptureHandle ); |
1044 RDEBUG("done CancelCaptureKey", 1); |
1066 RDEBUG("done CancelCaptureKey", 1); |
1067 RDEBUG("deleting iDeviceDialog", 0); |
|
1068 delete iDeviceDialog; |
|
1069 RDEBUG("deleted iDeviceDialog", 1); |
|
1070 iDeviceDialog = NULL; |
|
1045 } |
1071 } |
1046 } |
1072 } |
1047 else if (status == 1) // show |
1073 else if (status == 1) // show |
1048 { |
1074 { |
1049 // secUiOriginatedQuery should be ESecurityUIsSecUIOriginatedUninitialized . If not, the validation is not correctly filtering it |
1075 // secUiOriginatedQuery should be ESecurityUIsSecUIOriginatedUninitialized . If not, the validation is not correctly filtering it |
1050 QVariantMap params; |
1076 QVariantMap params; |
1051 TBool err; |
1077 TBool err; |
1052 #define ESecUiTypeDeviceLock 0x00100000 |
1078 #define ESecUiTypeDeviceLock 0x00100000 |
1053 #define ESecUiTypeKeyguard 0x00200000 |
1079 #define ESecUiTypeKeyguard 0x00200000 |
1054 |
1080 |
1055 if (aReason == EKeyguardActive) |
1081 if (aReason == ELockAppEnableKeyguard) |
1056 params.insert("type", ESecUiTypeKeyguard); |
1082 params.insert("type", ESecUiTypeKeyguard); |
1057 else if (aReason >= EDevicelockActive) |
1083 else if (aReason == ELockAppEnableDevicelock) |
1058 params.insert("type", ESecUiTypeDeviceLock); |
1084 params.insert("type", ESecUiTypeDeviceLock); |
1059 else |
1085 else |
1060 { |
1086 { |
1061 RDEBUG("error. status=1 but aReason", aReason); |
1087 RDEBUG("error. status=1 but aReason", aReason); |
1062 } |
1088 } |
1063 // no need for title. Icon should be explicit enough |
1089 // no need for title. Icon should be explicit enough |
1064 // params.insert("title", "Locked"); |
1090 // params.insert("title", "Locked"); |
1065 if (iDeviceDialogCreated <= 0) |
1091 if (iDeviceDialogCreated < EDeviceDialogCreated) |
1066 { |
1092 { |
1093 if(iDeviceDialog != NULL) |
|
1094 { |
|
1095 RDEBUG("!!!!!!*********!!!!!!!! error: iDeviceDialog != NULL", 0); |
|
1096 } |
|
1067 RDEBUG("creating iDeviceDialog", 0); |
1097 RDEBUG("creating iDeviceDialog", 0); |
1068 iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); |
1098 iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this); |
1099 // in theory this is needed only for screensaver, not for LockIcon. But it doesn't harm |
|
1069 connect( iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), |
1100 connect( iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), |
1070 SLOT(handleMessageFromScreensaver(QVariantMap)) ); |
1101 SLOT(handleMessageFromScreensaver(QVariantMap)) ); |
1071 iDeviceDialogCreated = 1; |
1102 iDeviceDialogCreated = EDeviceDialogCreated; |
1103 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1072 } |
1104 } |
1073 else |
1105 else |
1074 { |
1106 { |
1075 RDEBUG("raising iDeviceDialog", 0); |
1107 RDEBUG("raising iDeviceDialog", 0); |
1076 // confirm that dialog is present |
1108 // confirm that dialog is present |
1077 err = iDeviceDialog->error(); |
1109 err = iDeviceDialog->error(); |
1078 RDEBUG("err", err); |
1110 RDEBUG("err", err); |
1079 iDeviceDialogCreated = 2; |
1111 iDeviceDialogCreated = EDeviceDialogRaised; |
1112 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1080 } |
1113 } |
1081 const QString KScreensaverDeviceDialog("com.nokia.screensaver.snsrdevicedialogplugin/1.0"); |
1114 const QString KScreensaverDeviceDialog("com.nokia.screensaver.snsrdevicedialogplugin/1.0"); |
1082 RDEBUG("pre show", aReason); |
1115 RDEBUG("pre show", aReason); |
1083 err = iDeviceDialog->show(KScreensaverDeviceDialog, params); // and continue processing |
1116 err = iDeviceDialog->show(KScreensaverDeviceDialog, params); // and continue processing |
1084 RDEBUG("post show. err", err); |
1117 RDEBUG("post show. err", err); |
1085 err = iDeviceDialog->error(); |
1118 err = iDeviceDialog->error(); |
1086 RDEBUG("iDeviceDialog->error", err); |
1119 RDEBUG("iDeviceDialog->error", err); |
1087 if(!err) |
1120 if(!err) |
1088 { |
1121 { |
1089 switchScreensaverToActiveMode(); // TODO not sure if this is needed |
1122 iDeviceDialogCreated = EDeviceDialogScreenSaver; |
1123 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
|
1124 switchScreensaverToActiveMode(); // this is needed in case the dialog was existing. |
|
1090 } |
1125 } |
1091 else // some err |
1126 else // some err. Usually 3 (not existing) |
1092 { |
1127 { |
1093 // screensaver has failed. Probably because it's not installed. Then, try the standard lock-icon |
1128 // screensaver has failed. Probably because it's not installed. Then, try the standard lock-icon |
1094 err = iDeviceDialog->error(); |
1129 iDeviceDialogCreated = EDeviceDialogLockIcon; |
1095 RDEBUG("err", err); |
1130 RDEBUG("new iDeviceDialogCreated", iDeviceDialogCreated); |
1096 const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); |
1131 const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0"); |
1097 err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing |
1132 err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing |
1133 RDEBUG("post show. err", err); |
|
1098 } |
1134 } |
1099 err = iDeviceDialog->error(); |
1135 err = iDeviceDialog->error(); |
1100 RDEBUG("err", err); |
1136 RDEBUG("err", err); |
1101 // This won't be needed when screensaver is in place, as the dialogs will be different, and therefore both can be present |
1137 // This won't be needed when screensaver is in place, as the dialogs will be different, and therefore both can be present |
1102 // Somehow this should be handled by Orbit, but unfortunatelly they don't allow the same dialog twice |
1138 // Somehow this should be handled by Orbit, but unfortunatelly they don't allow the same dialog twice |
1103 err = RProperty::Set(KPSUidSecurityUIs, |
1139 err = RProperty::Set(KPSUidSecurityUIs, |
1104 KSecurityUIsSecUIOriginatedQuery, |
1140 KSecurityUIsSecUIOriginatedQuery, |
1105 ESecurityUIsSecUIOriginatedUninitialized); // TODO this should be ESecurityUIsSystemLockOriginated ? |
1141 ESecurityUIsSecUIOriginatedUninitialized); // this could also be ESecurityUIsSystemLockOriginated |
1106 RDEBUG("err", err); |
1142 RDEBUG("err", err); |
1107 // Capture power and application keys while screen saver is open |
1143 // Capture power and application keys while screen saver is open. Also works for LockIcon |
1108 mPowerKeyCaptureHandle = groupWin.CaptureKey( EKeyDevice2, 0, 0 ); |
1144 mPowerKeyCaptureHandle = groupWin.CaptureKey( EKeyDevice2, 0, 0 ); |
1109 mApplicationKeyCaptureHandle = groupWin.CaptureKey( EKeyApplication0, 0, 0 ); |
1145 mApplicationKeyCaptureHandle = groupWin.CaptureKey( EKeyApplication0, 0, 0 ); |
1110 mApplicationLongKeyCaptureHandle = groupWin.CaptureLongKey( |
1146 mApplicationLongKeyCaptureHandle = groupWin.CaptureLongKey( |
1111 EKeyApplication0, EKeyApplication0, 0, 0, 0, |
1147 EKeyApplication0, EKeyApplication0, 0, 0, 0, |
1112 ELongCaptureShortEventImmediately|ELongCaptureRepeatEvents ); |
1148 ELongCaptureShortEventImmediately|ELongCaptureRepeatEvents ); |
1117 RDEBUG("unknown status", status); |
1153 RDEBUG("unknown status", status); |
1118 return KErrNotSupported; |
1154 return KErrNotSupported; |
1119 } |
1155 } |
1120 return KErrNone; |
1156 return KErrNone; |
1121 } |
1157 } |
1158 |
|
1122 void Autolock::setLabelIcon(int aReason) |
1159 void Autolock::setLabelIcon(int aReason) |
1123 { |
1160 { |
1124 RDEBUG("aReason", aReason); |
1161 RDEBUG("aReason", aReason); |
1125 |
1162 |
1126 if (aReason == ELockNotActive) |
1163 if (aReason == ELockNotActive) |
1127 { |
1164 { |
1128 setLockDialog(aReason, 0); // TODO isn't this done already at TryChangeStatus ??? |
1165 // setLockDialog(aReason, 0); // This is done already at TryChangeStatus |
1129 lower(); |
1166 lower(); |
1130 hide(); |
1167 hide(); |
1131 } |
1168 } |
1132 else if (aReason == EKeyguardActive) |
1169 else if (aReason == EKeyguardActive) |
1133 { |
1170 { |
1134 setLockDialog(aReason, 1); |
1171 // setLockDialog(aReason, 1); // This is done already at TryChangeStatus |
1135 // this shows the Autolock Application. not needed |
1172 // this shows the Autolock Application. not needed |
1136 } |
1173 } |
1137 else if (aReason == EDevicelockActive) |
1174 else if (aReason == EDevicelockActive) |
1138 { |
1175 { |
1139 } |
1176 } |
1185 ret = TryChangeStatus(ELockAppEnableKeyguard); |
1222 ret = TryChangeStatus(ELockAppEnableKeyguard); |
1186 RDEBUG("ret", ret); |
1223 RDEBUG("ret", ret); |
1187 } |
1224 } |
1188 else |
1225 else |
1189 { |
1226 { |
1190 // switch-off the lights. The scenario is: keyguard->screensaver->CriticalNote->lightsOn . Therefore we need lightsOff |
1227 // restart screensaver. The scenario is: keyguard->screensaver->CriticalNote->lightsOn . Therefore we need lightsOff |
1191 // this is done when keyguard can't be enabled because it's already enabled |
1228 // this is done when keyguard can't be enabled because it's already enabled |
1192 // Note that this happens only once, so it's fine to show the screensaver in full light. |
1229 // Note that this happens only once, so it's fine to show the screensaver in full light. |
1193 if(ret==KErrAlreadyExists) |
1230 if(ret==KErrAlreadyExists) |
1194 switchScreensaverToActiveMode(); |
1231 switchScreensaverToActiveMode(); |
1195 } |
1232 } |
1219 void Autolock::switchScreensaverToActiveMode() |
1256 void Autolock::switchScreensaverToActiveMode() |
1220 { |
1257 { |
1221 RDEBUG("0", 0); |
1258 RDEBUG("0", 0); |
1222 if ( iDeviceDialog ) |
1259 if ( iDeviceDialog ) |
1223 { |
1260 { |
1224 RDEBUG("got iDeviceDialog", 1); |
1261 RDEBUG("got iDeviceDialog. iDeviceDialogCreated", iDeviceDialogCreated); |
1225 QVariantMap params; |
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 |
|
1226 params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueActive ); |
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 |
|
1227 iDeviceDialog->update(params); |
1277 iDeviceDialog->update(params); |
1228 |
1278 |
1229 // (re)start timer to switch to the power save mode |
1279 // (re)start timer to switch to the power save mode |
1230 if ( mScreensaverModeTimer ) |
1280 if ( mScreensaverModeTimer ) |
1231 { |
1281 { |
1239 void Autolock::switchScreensaverToPowerSaveMode() |
1289 void Autolock::switchScreensaverToPowerSaveMode() |
1240 { |
1290 { |
1241 RDEBUG("0", 0); |
1291 RDEBUG("0", 0); |
1242 if ( iDeviceDialog ) |
1292 if ( iDeviceDialog ) |
1243 { |
1293 { |
1244 RDEBUG("got iDeviceDialog", 1); |
1294 RDEBUG("got iDeviceDialog. iDeviceDialogCreated", iDeviceDialogCreated); |
1245 QVariantMap params; |
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 |
|
1246 params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueStandby ); |
1304 params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueStandby ); |
1247 iDeviceDialog->update(params); |
1305 iDeviceDialog->update(params); |
1248 |
1306 |
1249 if ( mScreensaverModeTimer ) |
1307 if ( mScreensaverModeTimer ) |
1250 { |
1308 { |
1266 handleLockSwitch(); |
1324 handleLockSwitch(); |
1267 } |
1325 } |
1268 } |
1326 } |
1269 |
1327 |
1270 // some key is pressed |
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? |
|
1271 bool Autolock::event(QEvent *ev) |
1331 bool Autolock::event(QEvent *ev) |
1272 { |
1332 { |
1273 if (ev) |
1333 if (ev) |
1274 { |
1334 { |
1275 int isSwitchKey = 0; |
1335 int isSwitchKey = 0; |
1276 // on device, this doesn't seem to get the EKeyDeviceF key: only 1ffffff |
|
1277 if (ev->type() == QEvent::KeyPress) |
1336 if (ev->type() == QEvent::KeyPress) |
1278 { |
1337 { |
1279 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1338 QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev); |
1280 RDEBUG("KeyPress", keyEvent->key()); |
1339 RDEBUG("KeyPress", keyEvent->key()); |
1281 RDEBUG("KeyPress nativeScanCode", keyEvent->nativeScanCode()); |
1340 RDEBUG("KeyPress nativeScanCode", keyEvent->nativeScanCode()); |
1282 RDEBUG("EStdKeyDeviceF", EStdKeyDeviceF); |
1341 RDEBUG("EStdKeyDeviceF", EStdKeyDeviceF); |
1283 RDEBUG("EStdKeyDeviceF", EKeyInsert); |
1342 RDEBUG("EKeyDeviceF", EKeyDeviceF); |
1284 RDEBUG("keyEvent->isAutoRepeat()", keyEvent->isAutoRepeat()); |
1343 RDEBUG("keyEvent->isAutoRepeat()", keyEvent->isAutoRepeat()); |
1285 if( !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() ) |
|
1286 { |
1351 { |
1287 if (keyEvent->key() == EKeyInsert ) |
1352 if (keyEvent->key() == EKeyInsert ) |
1288 { |
1353 { |
1289 // on WINS, this is handled with the "Ins" key in the numeric keypad |
1354 // on WINS, this is handled with the "Ins" key in the numeric keypad |
1290 RDEBUG("EKeyInsert", EKeyInsert); |
1355 RDEBUG("EKeyInsert", EKeyInsert); |
1299 else if (keyEvent->nativeScanCode() == EStdKeyDeviceF) |
1364 else if (keyEvent->nativeScanCode() == EStdKeyDeviceF) |
1300 { |
1365 { |
1301 RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF); |
1366 RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF); |
1302 isSwitchKey = 1; |
1367 isSwitchKey = 1; |
1303 } |
1368 } |
1304 else if ( keyEvent->nativeScanCode() == EStdKeyApplication0 || keyEvent->nativeScanCode() == EStdKeyDevice2 ) |
1369 else if (keyEvent->nativeScanCode() == EKeyBell) // this might be sent by others, i.e. PCFW |
1305 { |
1370 { |
1306 // switch to active screensaver if application key or power key pressed while screensaver active |
1371 RDEBUG("got EKeyBell", EKeyBell); |
1307 switchScreensaverToActiveMode(); |
1372 isSwitchKey = 1; |
1308 } |
1373 } |
1309 else if (keyEvent->key() == 0x1ffffff) |
1374 else if (keyEvent->key() == 0x1ffffff) |
1310 { |
1375 { |
1311 RDEBUG("0x1ffffff", 0x1ffffff); // some unknown key is received. Nothing to do |
1376 RDEBUG("0x1ffffff", 0x1ffffff); // some unknown key is received. Nothing to do |
1312 } |
1377 } |
1313 } |
1378 } |
1340 int ret = KErrNone; |
1405 int ret = KErrNone; |
1341 DebugStatus( iLockStatus); |
1406 DebugStatus( iLockStatus); |
1342 if (iLockStatus == ELockNotActive) |
1407 if (iLockStatus == ELockNotActive) |
1343 { |
1408 { |
1344 iShowKeyguardNote = 1; // note on enable keyguard |
1409 iShowKeyguardNote = 1; // note on enable keyguard |
1410 callerHasECapabilityWriteDeviceData = 1; |
|
1345 ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation |
1411 ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation |
1346 } |
1412 } |
1347 else if (iLockStatus == EKeyguardActive) |
1413 else if (iLockStatus == EKeyguardActive) |
1348 { |
1414 { |
1349 iShowKeyguardNote = 1; // note on disable keyguard |
1415 iShowKeyguardNote = 1; // note on disable keyguard |
1416 callerHasECapabilityWriteDeviceData = 1; |
|
1350 ret = TryChangeStatus(ELockAppDisableKeyguard); |
1417 ret = TryChangeStatus(ELockAppDisableKeyguard); |
1351 } |
1418 } |
1352 else if (iLockStatus == EDevicelockActive) |
1419 else if (iLockStatus == EDevicelockActive) |
1353 { |
1420 { |
1421 callerHasECapabilityWriteDeviceData = 1; |
|
1354 ret = TryChangeStatus(ELockAppDisableDevicelock); |
1422 ret = TryChangeStatus(ELockAppDisableDevicelock); |
1355 } |
1423 } |
1356 else |
1424 else |
1357 { |
1425 { |
1358 RDEBUG("unknown iLockStatus", iLockStatus); |
1426 RDEBUG("unknown iLockStatus", iLockStatus); |
1445 // ---------------------------------------------------------------------------- |
1513 // ---------------------------------------------------------------------------- |
1446 // |
1514 // |
1447 void Autolock::subscriberKSecurityUIsDismissDialogChanged() |
1515 void Autolock::subscriberKSecurityUIsDismissDialogChanged() |
1448 { |
1516 { |
1449 RDEBUG("0", 0); |
1517 RDEBUG("0", 0); |
1518 TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized; |
|
1519 TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog ); |
|
1520 RDEBUG("err", err); |
|
1521 RDEBUG("aDismissDialog", aDismissDialog); |
|
1450 } |
1522 } |
1451 // ----------AutolockService--------------- |
1523 // ----------AutolockService--------------- |
1452 |
1524 |
1453 AutolockService::AutolockService(Autolock* parent) : |
1525 AutolockService::AutolockService(Autolock* parent) : |
1454 XQServiceProvider(QLatin1String( |
1526 XQServiceProvider(QLatin1String( |