diff --git a/src/nemo-devicelock/host/hostauthenticator.cpp b/src/nemo-devicelock/host/hostauthenticator.cpp index 0b6a54d..21ddc77 100644 --- a/src/nemo-devicelock/host/hostauthenticator.cpp +++ b/src/nemo-devicelock/host/hostauthenticator.cpp @@ -112,7 +112,13 @@ bool HostAuthenticator::authorizeSecurityCodeSettings(unsigned long) bool HostAuthenticator::isSecurityCodeSet() const { - return availability() != HostAuthenticationInput::AuthenticationNotRequired; + switch (availability()) { + case HostAuthenticationInput::AuthenticationNotRequired: + case HostAuthenticationInput::SecurityCodeRequired: + return false; + default: + return true; + } } void HostAuthenticator::authenticate( @@ -174,6 +180,7 @@ void HostAuthenticator::handleChangeSecurityCode(const QString &client, const QV switch (availability()) { case AuthenticationNotRequired: + case SecurityCodeRequired: m_state = EnteringNewSecurityCode; authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterNewSecurityCode); break; @@ -181,7 +188,6 @@ void HostAuthenticator::handleChangeSecurityCode(const QString &client, const QV case CanAuthenticate: authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterSecurityCode); break; - case SecurityCodeRequired: case ManagerLocked: case TemporarilyLocked: case PermanentlyLocked: @@ -269,12 +275,15 @@ void HostAuthenticator::enterSecurityCode(const QString &code) feedback(AuthenticationInput::SecurityCodesDoNotMatch, -1); - if (availability() != AuthenticationNotRequired) { + switch (availability()) { + case AuthenticationNotRequired: + case SecurityCodeRequired: m_state = EnteringNewSecurityCode; - feedback(AuthenticationInput::EnterSecurityCode, -1); - } else { - m_state = AuthenticatingForChange; feedback(AuthenticationInput::EnterNewSecurityCode, -1); + break; + default: + m_state = AuthenticatingForChange; + feedback(AuthenticationInput::EnterSecurityCode, -1); } return; diff --git a/src/nemo-devicelock/host/hostdevicelock.cpp b/src/nemo-devicelock/host/hostdevicelock.cpp index 5ba0ce6..6a91b0a 100644 --- a/src/nemo-devicelock/host/hostdevicelock.cpp +++ b/src/nemo-devicelock/host/hostdevicelock.cpp @@ -162,6 +162,7 @@ void HostDeviceLock::enterSecurityCode(const QString &code) m_state = EnteringNewSecurityCode; m_currentCode = code; feedback(AuthenticationInput::SecurityCodeExpired, -1); + feedback(AuthenticationInput::EnterNewSecurityCode, -1); break; case SecurityCodeInHistory: break; @@ -192,17 +193,23 @@ void HostDeviceLock::enterSecurityCode(const QString &code) break; case RepeatingNewSecurityCode: if (m_newCode != code) { - m_currentCode.clear(); + m_newCode.clear(); - m_state = Authenticating; feedback(AuthenticationInput::SecurityCodesDoNotMatch, -1); - feedback(AuthenticationInput::EnterNewSecurityCode, -1); - } else { - // With disk encryption enabled changing the code can take a few seconds, don't leave - // the user hanging. - - m_newCode.clear(); + switch (availability()) { + case AuthenticationNotRequired: + case SecurityCodeRequired: + m_state = EnteringNewSecurityCode; + feedback(AuthenticationInput::EnterNewSecurityCode, -1); + break; + default: + m_state = Authenticating; + feedback(AuthenticationInput::EnterSecurityCode, -1); + break; + } + break; + } else { setCodeFinished(setCode(m_currentCode, code)); } break; @@ -250,7 +257,7 @@ void HostDeviceLock::setCodeFinished(int result) case Success: qCDebug(daemon, "Lock code changed."); m_currentCode.clear(); - if (m_state == ChangingSecurityCode) { + if (m_state == ChangingSecurityCode || m_state == RepeatingNewSecurityCode) { unlockFinished(unlockWithCode(m_newCode)); } else if (m_state == Canceled) { m_state = Idle; @@ -258,6 +265,8 @@ void HostDeviceLock::setCodeFinished(int result) authenticationEnded(false); unlockingChanged(); + } else { + abortAuthentication(AuthenticationInput::SoftwareError); } break; case SecurityCodeInHistory: @@ -362,6 +371,9 @@ void HostDeviceLock::stateChanged() case PermanentlyLocked: m_lockState = DeviceLock::PermanentLockout; break; + case SecurityCodeRequired: + m_lockState = DeviceLock::Locked; + break; default: m_lockState = isLocked() ? DeviceLock::Locked