Files
MuditaOS/module-apps/apps-common/locks/widgets/Lock.cpp
Marcin Smoczyński bd90e57516 [BH-907] Split utils module into components
Split module-utils into smaller components for better dependency
management. Fix many dependencies throughout the project.

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
2021-09-23 15:14:40 +02:00

47 lines
1.1 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "Lock.hpp"
#include <log/log.hpp>
namespace locks
{
void Lock::consumeState() noexcept
{
if (lockState == LockState::InputInvalid) {
lockState = LockState::InputRequired;
}
else if (lockState == LockState::NewInputInvalid) {
lockState = LockState::NewInputRequired;
}
else if (lockState == LockState::NewInputConfirmRequired) {
lockState = LockState::NewInputRequired;
}
}
void Lock::putNextChar(unsigned int c)
{
if (maxInputSize > inputValue.size()) {
inputValue.push_back(c);
}
}
void Lock::popChar()
{
if (!inputValue.empty()) {
inputValue.pop_back();
}
}
void Lock::clearAttempt() noexcept
{
inputValue.clear();
}
void Lock::setNextUnlockAttemptFormattedTime(const std::string &time)
{
nextUnlockAttemptFormattedTime = time;
}
} // namespace locks