void WriteText::startWriteProcess() {
	qDebug() << "XXXX startWriteProcess()";
	NfcManager* nfc = NfcManager::getInstance();

	qDebug() << "XXXX Telling NfcManager to start write process";

	qDebug() << "XXXX setting inDetectAndWriteState=true";
	StateManager* state_mgr = StateManager::getInstance();
	state_mgr->setDetectAndWriteState(true);

	nfc->writeText(&_text);

	qDebug() << "XXXX switching to event log screen";
	_eventLog->show();
}
void ApduDetails::startApduDetailsProcess() {
	qDebug() << "XXXX startApduDetailsProcess()";
	NfcManager* nfc = NfcManager::getInstance();

	qDebug() << "XXXX Telling NfcManager to start NDEF push process";
	qDebug() << "XXXX setting inNdefPushState=true";
	StateManager* state_mgr = StateManager::getInstance();
	state_mgr->setNdefPushState(false);

	nfc = NfcManager::getInstance();

	nfc->iso7816Test(&_aid, &_hex_cla, &_hex_ins, &_hex_p1p2, &_hex_lc, &_hex_command, &_hex_le);

	qDebug() << "XXXX switching to event log screen";
	_eventLog->show();
}
void WriteCustom::startWriteProcess() {
	qDebug() << "XXXX startWriteProcess()";
	NfcManager* nfc = NfcManager::getInstance();

	qDebug() << "XXXX Telling NfcManager to start write process";

	// this transition should really be handled by the NfcManager when integrated
	qDebug() << "XXXX setting inDetectAndWriteState=true";
	StateManager* state_mgr = StateManager::getInstance();
	state_mgr->setDetectAndWriteState(true);

	nfc->writeCustom(&_domain, &_type, &_content);

	qDebug() << "XXXX switching to event log screen";
	_eventLog->show();
}
void ApduDetails::startApduDetailsProcess() {
	qDebug() << "XXXX startApduDetailsProcess()";

	// validate and remove spaces

	_aid.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_cla.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_ins.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_p1p2.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_lc.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_command.remove(QChar(' '), Qt::CaseInsensitive);
	_hex_le.remove(QChar(' '), Qt::CaseInsensitive);

	_aid = _aid.toUpper();
	_hex_cla = _hex_cla.toUpper();
	_hex_ins = _hex_ins.toUpper();
	_hex_p1p2 = _hex_p1p2.toUpper();
	_hex_lc = _hex_lc.toUpper();
	_hex_command = _hex_command.toUpper();
	_hex_le = _hex_le.toUpper();

	qDebug() << "XXXX startApduDetailsProcess() is validating user input";
	if (!Utilities::isValidHex(_aid)) {
		qDebug() << "XXXX AID does not contain a valid hex string";
		_systemDialog->setBody("AID does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_cla)) {
		qDebug() << "XXXX CLA does not contain a valid hex string";
		_systemDialog->setBody("CLA does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_ins)) {
		qDebug() << "XXXX INS does not contain a valid hex string";
		_systemDialog->setBody("INS does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_p1p2)) {
		qDebug() << "XXXX P1 P2 does not contain a valid hex string";
		_systemDialog->setBody("P1 P2 does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_lc)) {
		qDebug() << "XXXX LC does not contain a valid hex string";
		_systemDialog->setBody("LC does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_command)) {
		qDebug() << "XXXX COMMAND does not contain a valid hex string";
		_systemDialog->setBody("COMMAND does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	if (!Utilities::isValidHex(_hex_le)) {
		qDebug() << "XXXX LE does not contain a valid hex string";
		_systemDialog->setBody("LE does not contain a valid hex string");
		_systemDialog->show();
		return;
	}

	NfcManager* nfc = NfcManager::getInstance();

	StateManager* state_mgr = StateManager::getInstance();
	state_mgr->setNdefPushState(false);

	nfc = NfcManager::getInstance();

	nfc->iso7816Test(&_aid, &_hex_cla, &_hex_ins, &_hex_p1p2, &_hex_lc, &_hex_command, &_hex_le);

	qDebug() << "XXXX switching to event log screen";
	_eventLog->show();
}