mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 21:34:35 +03:00
Merge pull request #771 from Willy-JL/emv-transactions-restructure
NFC: EMV Transactions less nested, hide if unavailable
This commit is contained in:
commit
2b25c14374
@ -9,6 +9,10 @@
|
||||
#include "../nfc_protocol_support_gui_common.h"
|
||||
#include "../iso14443_4a/iso14443_4a_i.h"
|
||||
|
||||
enum {
|
||||
SubmenuIndexTransactions = SubmenuIndexCommonMax,
|
||||
};
|
||||
|
||||
static void nfc_scene_info_on_enter_emv(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const EmvData* data = nfc_device_get_data(device, NfcProtocolEmv);
|
||||
@ -24,11 +28,6 @@ static void nfc_scene_info_on_enter_emv(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static void nfc_scene_more_info_on_enter_emv(NfcApp* instance) {
|
||||
// Jump to advanced scene right away
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneEmvMoreInfo);
|
||||
}
|
||||
|
||||
static NfcCommand nfc_scene_read_poller_callback_emv(NfcGenericEvent event, void* context) {
|
||||
furi_assert(event.protocol == NfcProtocolEmv);
|
||||
|
||||
@ -49,6 +48,20 @@ static void nfc_scene_read_on_enter_emv(NfcApp* instance) {
|
||||
nfc_poller_start(instance->poller, nfc_scene_read_poller_callback_emv, instance);
|
||||
}
|
||||
|
||||
static void nfc_scene_read_menu_on_enter_emv(NfcApp* instance) {
|
||||
Submenu* submenu = instance->submenu;
|
||||
const EmvData* data = nfc_device_get_data(instance->nfc_device, NfcProtocolEmv);
|
||||
|
||||
if(data->emv_application.active_tr > 0) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Transactions",
|
||||
SubmenuIndexTransactions,
|
||||
nfc_protocol_support_common_submenu_callback,
|
||||
instance);
|
||||
}
|
||||
}
|
||||
|
||||
static void nfc_scene_read_success_on_enter_emv(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const EmvData* data = nfc_device_get_data(device, NfcProtocolEmv);
|
||||
@ -64,8 +77,21 @@ static void nfc_scene_read_success_on_enter_emv(NfcApp* instance) {
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static bool nfc_scene_read_menu_on_event_emv(NfcApp* instance, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexTransactions) {
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneEmvTransactions);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_emv = {
|
||||
.features = NfcProtocolFeatureMoreInfo,
|
||||
.features = NfcProtocolFeatureNone,
|
||||
|
||||
.scene_info =
|
||||
{
|
||||
@ -74,7 +100,7 @@ const NfcProtocolSupportBase nfc_protocol_support_emv = {
|
||||
},
|
||||
.scene_more_info =
|
||||
{
|
||||
.on_enter = nfc_scene_more_info_on_enter_emv,
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read =
|
||||
@ -84,8 +110,8 @@ const NfcProtocolSupportBase nfc_protocol_support_emv = {
|
||||
},
|
||||
.scene_read_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
.on_enter = nfc_scene_read_menu_on_enter_emv,
|
||||
.on_event = nfc_scene_read_menu_on_event_emv,
|
||||
},
|
||||
.scene_read_success =
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ ADD_SCENE(nfc, felica_unlock_warn, FelicaUnlockWarn)
|
||||
ADD_SCENE(nfc, mf_desfire_more_info, MfDesfireMoreInfo)
|
||||
ADD_SCENE(nfc, mf_desfire_app, MfDesfireApp)
|
||||
|
||||
ADD_SCENE(nfc, emv_more_info, EmvMoreInfo)
|
||||
ADD_SCENE(nfc, emv_transactions, EmvTransactions)
|
||||
|
||||
ADD_SCENE(nfc, mf_classic_dict_attack, MfClassicDictAttack)
|
||||
ADD_SCENE(nfc, mf_classic_detect_reader, MfClassicDetectReader)
|
||||
|
@ -1,76 +0,0 @@
|
||||
#include "../nfc_app_i.h"
|
||||
|
||||
#include "../helpers/protocol_support/nfc_protocol_support_gui_common.h"
|
||||
#include "../helpers/protocol_support/emv/emv_render.h"
|
||||
|
||||
enum {
|
||||
EmvMoreInfoStateMenu,
|
||||
EmvMoreInfoStateItem, // MUST be last, states >= this correspond with submenu index
|
||||
};
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexTransactions,
|
||||
SubmenuIndexDynamic, // dynamic indices start here
|
||||
};
|
||||
|
||||
void nfc_scene_emv_more_info_on_enter(void* context) {
|
||||
NfcApp* nfc = context;
|
||||
Submenu* submenu = nfc->submenu;
|
||||
|
||||
text_box_set_font(nfc->text_box, TextBoxFontHex);
|
||||
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Transactions",
|
||||
SubmenuIndexTransactions,
|
||||
nfc_protocol_support_common_submenu_callback,
|
||||
nfc);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
bool nfc_scene_emv_more_info_on_event(void* context, SceneManagerEvent event) {
|
||||
NfcApp* nfc = context;
|
||||
bool consumed = false;
|
||||
|
||||
const uint32_t state = scene_manager_get_scene_state(nfc->scene_manager, NfcSceneEmvMoreInfo);
|
||||
const EmvData* data = nfc_device_get_data(nfc->nfc_device, NfcProtocolEmv);
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
widget_reset(nfc->widget);
|
||||
|
||||
if(event.event == SubmenuIndexTransactions) {
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_render_emv_transactions(&data->emv_application, temp_str);
|
||||
widget_add_text_scroll_element(
|
||||
nfc->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager,
|
||||
NfcSceneEmvMoreInfo,
|
||||
EmvMoreInfoStateItem + SubmenuIndexTransactions);
|
||||
consumed = true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
if(state >= EmvMoreInfoStateItem) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneEmvMoreInfo, EmvMoreInfoStateMenu);
|
||||
} else {
|
||||
// Return directly to the Info scene
|
||||
scene_manager_search_and_switch_to_previous_scene(nfc->scene_manager, NfcSceneInfo);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_scene_emv_more_info_on_exit(void* context) {
|
||||
NfcApp* nfc = context;
|
||||
|
||||
// Clear views
|
||||
widget_reset(nfc->widget);
|
||||
submenu_reset(nfc->submenu);
|
||||
}
|
31
applications/main/nfc/scenes/nfc_scene_emv_transactions.c
Normal file
31
applications/main/nfc/scenes/nfc_scene_emv_transactions.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include "../nfc_app_i.h"
|
||||
|
||||
#include "../helpers/protocol_support/nfc_protocol_support_gui_common.h"
|
||||
#include "../helpers/protocol_support/emv/emv_render.h"
|
||||
|
||||
void nfc_scene_emv_transactions_on_enter(void* context) {
|
||||
NfcApp* nfc = context;
|
||||
Widget* widget = nfc->widget;
|
||||
const EmvData* data = nfc_device_get_data(nfc->nfc_device, NfcProtocolEmv);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_render_emv_transactions(&data->emv_application, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
||||
bool nfc_scene_emv_transactions_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void nfc_scene_emv_transactions_on_exit(void* context) {
|
||||
NfcApp* nfc = context;
|
||||
|
||||
widget_reset(nfc->widget);
|
||||
}
|
Loading…
Reference in New Issue
Block a user