AusweisApp2/src/core/states/StateChangePin.cpp

54 lines
1.3 KiB
C++

/*!
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
*/
#include "ReaderManager.h"
#include "StateChangePin.h"
#include <QMetaObject>
using namespace governikus;
StateChangePin::StateChangePin(const QSharedPointer<WorkflowContext>& pContext)
: AbstractGenericState(pContext)
{
}
void StateChangePin::run()
{
auto cardConnection = getContext()->getCardConnection();
Q_ASSERT(cardConnection);
qDebug() << "Invoke set Eid PIN command";
mConnections += cardConnection->callSetEidPinCommand(this, &StateChangePin::onSetEidPinDone, getContext()->getNewPin());
}
void StateChangePin::onSetEidPinDone(QSharedPointer<BaseCardCommand> pCommand)
{
const CardReturnCode returnCode = pCommand->getReturnCode();
switch (returnCode)
{
case CardReturnCode::OK:
getContext()->setSuccessMessage(tr("You have successfully changed your PIN."));
Q_EMIT fireContinue();
break;
case CardReturnCode::CANCELLATION_BY_USER:
updateStatus(CardReturnCodeUtil::toGlobalStatus(returnCode));
Q_EMIT fireAbort();
break;
case CardReturnCode::NEW_PIN_MISMATCH:
updateStatus(CardReturnCodeUtil::toGlobalStatus(returnCode));
Q_EMIT fireInvalidPin();
break;
default:
updateStatus(CardReturnCodeUtil::toGlobalStatus(returnCode));
Q_EMIT fireAbort();
break;
}
}