nfc_scene_run_emv_app_confirm.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "../nfc_i.h"
  2. void nfc_scene_run_emv_app_confirm_dialog_callback(DialogExResult result, void* context) {
  3. Nfc* nfc = context;
  4. view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
  5. }
  6. void nfc_scene_run_emv_app_confirm_on_enter(void* context) {
  7. Nfc* nfc = context;
  8. DialogEx* dialog_ex = nfc->dialog_ex;
  9. dialog_ex_set_left_button_text(dialog_ex, "Back");
  10. dialog_ex_set_right_button_text(dialog_ex, "Run");
  11. dialog_ex_set_header(dialog_ex, "Run EMV app?", 64, 8, AlignCenter, AlignCenter);
  12. dialog_ex_set_text(
  13. dialog_ex,
  14. "It will try to run card's app\nand detect unencrypted\ndata",
  15. 64,
  16. 18,
  17. AlignCenter,
  18. AlignTop);
  19. dialog_ex_set_context(dialog_ex, nfc);
  20. dialog_ex_set_result_callback(dialog_ex, nfc_scene_run_emv_app_confirm_dialog_callback);
  21. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
  22. }
  23. bool nfc_scene_run_emv_app_confirm_on_event(void* context, SceneManagerEvent event) {
  24. Nfc* nfc = context;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. if(event.event == DialogExResultLeft) {
  28. consumed = scene_manager_previous_scene(nfc->scene_manager);
  29. } else if(event.event == DialogExResultRight) {
  30. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvData);
  31. consumed = true;
  32. }
  33. }
  34. return consumed;
  35. }
  36. void nfc_scene_run_emv_app_confirm_on_exit(void* context) {
  37. Nfc* nfc = context;
  38. // Clean view
  39. dialog_ex_reset(nfc->dialog_ex);
  40. }