mfc_editor_app_i.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. NfcDevice* nfc_device;
  36. const MfClassicData* mf_classic_data;
  37. FuriString* file_path;
  38. uint8_t current_sector;
  39. uint8_t current_block;
  40. // DialogEx doesn't copy the strings given to it, so we need these
  41. FuriString* data_view_header;
  42. FuriString* data_view_text;
  43. };
  44. typedef enum {
  45. MfcEditorAppViewSubmenu,
  46. MfcEditorAppViewPopup,
  47. MfcEditorAppViewDialogEx,
  48. } MfcEditorAppView;
  49. typedef enum {
  50. // Generic
  51. MfcEditorPromptResponseSuccess,
  52. MfcEditorPromptResponseFailure,
  53. MfcEditorPromptResponseNotMfClassic,
  54. // Backed out of a prompt
  55. MfcEditorPromptResponseExitedFile,
  56. MfcEditorPromptResponseExitedShadow,
  57. } MfcEditorPromptResponse;
  58. typedef enum {
  59. MfcEditorBlockViewNormal,
  60. // Special options - Sector 0 only
  61. MfcEditorBlockViewUID,
  62. MfcEditorBlockViewManufacturerBytes,
  63. // Special options - All sectors
  64. MfcEditorBlockViewKeyA,
  65. MfcEditorBlockViewKeyB,
  66. MfcEditorBlockViewAccessBits,
  67. MfcEditorBlockViewUserByte,
  68. } MfcEditorBlockView;
  69. MfcEditorPromptResponse mfc_editor_prompt_load_file(MfcEditorApp* instance);
  70. MfcEditorPromptResponse mfc_editor_load_file(MfcEditorApp* instance, FuriString* file_path);