| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #include "../seos_i.h"
- #include <dolphin/dolphin.h>
- #define TAG "SeosSceneReadCardSuccess"
- void seos_scene_read_success_widget_callback(GuiButtonType result, InputType type, void* context) {
- furi_assert(context);
- Seos* seos = context;
- if(type == InputTypeShort) {
- view_dispatcher_send_custom_event(seos->view_dispatcher, result);
- }
- }
- void seos_scene_read_success_on_enter(void* context) {
- Seos* seos = context;
- SeosCredential* credential = seos->credential;
- Widget* widget = seos->widget;
- dolphin_deed(DolphinDeedNfcReadSuccess);
- FuriString* primary_str = furi_string_alloc_set("SIO Captured");
- FuriString* secondary_str_label = furi_string_alloc();
- FuriString* secondary_str_value = furi_string_alloc();
- FuriString* details_str = furi_string_alloc();
- furi_string_set(secondary_str_label, "Diversifier:");
- for(size_t i = 0; i < credential->diversifier_len; i++) {
- furi_string_cat_printf(secondary_str_value, "%02X", credential->diversifier[i]);
- }
- // RID
- if(credential->sio_len > 3 && credential->sio[2] == 0x81) {
- size_t len = credential->sio[3];
- furi_string_set(details_str, "RID:");
- for(size_t i = 0; i < len; i++) {
- furi_string_cat_printf(details_str, "%02X", credential->sio[4 + i]);
- }
- if(len >= 4 && credential->sio[3 + 1] == 0x01) {
- furi_string_cat_printf(details_str, "(retail)");
- } else if(len == 2) {
- furi_string_cat_printf(details_str, "(ER)");
- } else {
- furi_string_cat_printf(details_str, "(other)");
- }
- }
- widget_add_button_element(
- widget, GuiButtonTypeLeft, "Save", seos_scene_read_success_widget_callback, seos);
- widget_add_button_element(
- widget, GuiButtonTypeRight, "Emulate", seos_scene_read_success_widget_callback, seos);
- widget_add_string_element(
- widget, 64, 5, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(primary_str));
- widget_add_string_element(
- widget,
- 64,
- 20,
- AlignCenter,
- AlignCenter,
- FontSecondary,
- furi_string_get_cstr(secondary_str_label));
- widget_add_string_element(
- widget,
- 64,
- 30,
- AlignCenter,
- AlignCenter,
- FontSecondary,
- furi_string_get_cstr(secondary_str_value));
- widget_add_string_element(
- widget, 64, 45, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(details_str));
- furi_string_free(primary_str);
- furi_string_free(secondary_str_label);
- furi_string_free(secondary_str_value);
- furi_string_free(details_str);
- view_dispatcher_switch_to_view(seos->view_dispatcher, SeosViewWidget);
- }
- bool seos_scene_read_success_on_event(void* context, SceneManagerEvent event) {
- Seos* seos = context;
- bool consumed = false;
- if(event.type == SceneManagerEventTypeCustom) {
- if(event.event == GuiButtonTypeLeft) {
- scene_manager_next_scene(seos->scene_manager, SeosSceneSaveName);
- consumed = true;
- } else if(event.event == GuiButtonTypeRight) {
- scene_manager_next_scene(seos->scene_manager, SeosSceneSavedMenu);
- consumed = true;
- }
- } else if(event.type == SceneManagerEventTypeBack) {
- scene_manager_search_and_switch_to_previous_scene(seos->scene_manager, SeosSceneMainMenu);
- consumed = true;
- }
- return consumed;
- }
- void seos_scene_read_success_on_exit(void* context) {
- Seos* seos = context;
- // Clear view
- widget_reset(seos->widget);
- }
|