nfc_scene_run_emv_app_confirm.c 2.0 KB

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