nfc_scene_extra_actions.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "../nfc_i.h"
  2. enum SubmenuIndex {
  3. SubmenuIndexReadCardType,
  4. SubmenuIndexMfClassicKeys,
  5. SubmenuIndexMfUltralightUnlock,
  6. };
  7. void nfc_scene_extra_actions_submenu_callback(void* context, uint32_t index) {
  8. Nfc* nfc = context;
  9. view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
  10. }
  11. void nfc_scene_extra_actions_on_enter(void* context) {
  12. Nfc* nfc = context;
  13. Submenu* submenu = nfc->submenu;
  14. submenu_add_item(
  15. submenu,
  16. "Read Specific Card Type",
  17. SubmenuIndexReadCardType,
  18. nfc_scene_extra_actions_submenu_callback,
  19. nfc);
  20. submenu_add_item(
  21. submenu,
  22. "Mifare Classic Keys",
  23. SubmenuIndexMfClassicKeys,
  24. nfc_scene_extra_actions_submenu_callback,
  25. nfc);
  26. submenu_add_item(
  27. submenu,
  28. "Unlock NTAG/Ultralight",
  29. SubmenuIndexMfUltralightUnlock,
  30. nfc_scene_extra_actions_submenu_callback,
  31. nfc);
  32. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
  33. }
  34. bool nfc_scene_extra_actions_on_event(void* context, SceneManagerEvent event) {
  35. Nfc* nfc = context;
  36. bool consumed = false;
  37. if(event.type == SceneManagerEventTypeCustom) {
  38. if(event.event == SubmenuIndexMfClassicKeys) {
  39. if(mf_classic_dict_check_presence(MfClassicDictTypeFlipper)) {
  40. scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicKeys);
  41. } else {
  42. scene_manager_next_scene(nfc->scene_manager, NfcSceneDictNotFound);
  43. }
  44. consumed = true;
  45. } else if(event.event == SubmenuIndexMfUltralightUnlock) {
  46. scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightUnlockMenu);
  47. consumed = true;
  48. } else if(event.event == SubmenuIndexReadCardType) {
  49. scene_manager_set_scene_state(nfc->scene_manager, NfcSceneReadCardType, 0);
  50. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadCardType);
  51. consumed = true;
  52. }
  53. scene_manager_set_scene_state(nfc->scene_manager, NfcSceneExtraActions, event.event);
  54. }
  55. return consumed;
  56. }
  57. void nfc_scene_extra_actions_on_exit(void* context) {
  58. Nfc* nfc = context;
  59. submenu_reset(nfc->submenu);
  60. }