mfc_editor_app_i.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include <furi.h>
  3. #include <dialogs/dialogs.h>
  4. #include <gui/gui.h>
  5. #include <gui/scene_manager.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/modules/dialog_ex.h>
  8. #include <gui/modules/popup.h>
  9. #include <gui/modules/submenu.h>
  10. #include <nfc/nfc.h>
  11. #include <nfc/nfc_device.h>
  12. #include <nfc/protocols/mf_classic/mf_classic.h>
  13. #include <storage/storage.h>
  14. #include "mfc_editor_app.h"
  15. #include "mfc_editor_icons.h"
  16. #include "scenes/mfc_editor_scene.h"
  17. #define TAG "MFCEditor"
  18. #define NFC_APP_FOLDER ANY_PATH("nfc")
  19. #define NFC_APP_EXTENSION ".nfc"
  20. #define NFC_APP_SHADOW_EXTENSION ".shd"
  21. enum MfcEditorCustomEvent {
  22. // Reserve first 100 events for button types and indexes, starting from 0
  23. MfcEditorCustomEventReserved = 100,
  24. MfcEditorCustomEventViewExit,
  25. };
  26. struct MfcEditorApp {
  27. ViewDispatcher* view_dispatcher;
  28. SceneManager* scene_manager;
  29. Gui* gui;
  30. Storage* storage;
  31. DialogsApp* dialogs;
  32. Submenu* submenu;
  33. Popup* popup;
  34. DialogEx* dialog_ex;
  35. MfClassicData* mf_classic_data;
  36. FuriString* file_path;
  37. uint8_t current_sector;
  38. uint8_t current_block;
  39. // DialogEx doesn't copy the strings given to it, so we need these
  40. FuriString* data_view_header;
  41. FuriString* data_view_text;
  42. };
  43. typedef enum {
  44. MfcEditorAppViewSubmenu,
  45. MfcEditorAppViewPopup,
  46. MfcEditorAppViewDialogEx,
  47. } MfcEditorAppView;
  48. typedef enum {
  49. // Generic
  50. MfcEditorPromptResponseSuccess,
  51. MfcEditorPromptResponseFailure,
  52. MfcEditorPromptResponseNotMfClassic,
  53. // Backed out of a prompt
  54. MfcEditorPromptResponseExitedFile,
  55. MfcEditorPromptResponseExitedShadow,
  56. } MfcEditorPromptResponse;
  57. typedef enum {
  58. MfcEditorBlockViewNormal,
  59. // Special options - Sector 0 only
  60. MfcEditorBlockViewUID,
  61. MfcEditorBlockViewBCC,
  62. MfcEditorBlockViewManufacturerBytes,
  63. // Special options - All sectors
  64. MfcEditorBlockViewKeyA,
  65. MfcEditorBlockViewKeyB,
  66. MfcEditorBlockViewAccessBits,
  67. MfcEditorBlockViewUserByte,
  68. } MfcEditorBlockView;
  69. // Main loading methods
  70. MfcEditorPromptResponse mfc_editor_prompt_load_file(MfcEditorApp* instance);
  71. MfcEditorPromptResponse mfc_editor_load_file(MfcEditorApp* instance, FuriString* file_path);
  72. // Helper methods
  73. uint8_t mfc_editor_calculate_uid_bcc(uint8_t* uid, uint8_t uid_len);