2022-03-23 13:45:37 +00:00
|
|
|
#include "../nfc_i.h"
|
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexSave,
|
2022-08-17 15:08:13 +00:00
|
|
|
SubmenuIndexEmulateUid,
|
|
|
|
SubmenuIndexInfo,
|
2022-03-23 13:45:37 +00:00
|
|
|
};
|
|
|
|
|
2022-07-26 15:30:49 +00:00
|
|
|
void nfc_scene_mf_desfire_menu_submenu_callback(void* context, uint32_t index) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
2022-07-26 15:30:49 +00:00
|
|
|
void nfc_scene_mf_desfire_menu_on_enter(void* context) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
Submenu* submenu = nfc->submenu;
|
|
|
|
|
|
|
|
submenu_add_item(
|
2022-07-26 15:30:49 +00:00
|
|
|
submenu, "Save", SubmenuIndexSave, nfc_scene_mf_desfire_menu_submenu_callback, nfc);
|
2022-08-17 15:08:13 +00:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Emulate UID",
|
|
|
|
SubmenuIndexEmulateUid,
|
|
|
|
nfc_scene_mf_desfire_menu_submenu_callback,
|
|
|
|
nfc);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu, "Info", SubmenuIndexInfo, nfc_scene_mf_desfire_menu_submenu_callback, nfc);
|
|
|
|
|
2022-03-23 13:45:37 +00:00
|
|
|
submenu_set_selected_item(
|
2022-07-26 15:30:49 +00:00
|
|
|
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMfDesfireMenu));
|
2022-03-23 13:45:37 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
}
|
|
|
|
|
2022-07-26 15:30:49 +00:00
|
|
|
bool nfc_scene_mf_desfire_menu_on_event(void* context, SceneManagerEvent event) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
2022-03-23 13:45:37 +00:00
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == SubmenuIndexSave) {
|
|
|
|
scene_manager_set_scene_state(
|
2022-07-26 15:30:49 +00:00
|
|
|
nfc->scene_manager, NfcSceneMfDesfireMenu, SubmenuIndexSave);
|
2022-03-23 13:45:37 +00:00
|
|
|
nfc->dev->format = NfcDeviceSaveFormatMifareDesfire;
|
|
|
|
// Clear device name
|
|
|
|
nfc_device_set_name(nfc->dev, "");
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
2022-04-19 15:23:58 +00:00
|
|
|
consumed = true;
|
2022-08-17 15:08:13 +00:00
|
|
|
} else if(event.event == SubmenuIndexEmulateUid) {
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
|
|
|
|
consumed = true;
|
|
|
|
} else if(event.event == SubmenuIndexInfo) {
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneNfcDataInfo);
|
|
|
|
consumed = true;
|
2022-03-23 13:45:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 15:23:58 +00:00
|
|
|
return consumed;
|
2022-03-23 13:45:37 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:30:49 +00:00
|
|
|
void nfc_scene_mf_desfire_menu_on_exit(void* context) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
|
2022-04-19 15:23:58 +00:00
|
|
|
// Clear view
|
2022-03-23 13:45:37 +00:00
|
|
|
submenu_reset(nfc->submenu);
|
|
|
|
}
|