nfc_magic_app_i.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "nfc_magic_app.h"
  3. #include "helpers/nfc_magic_custom_events.h"
  4. #include <furi.h>
  5. #include <gui/gui.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/scene_manager.h>
  8. #include <notification/notification_messages.h>
  9. #include <gui/modules/submenu.h>
  10. #include <gui/modules/popup.h>
  11. #include <gui/modules/loading.h>
  12. #include <gui/modules/text_input.h>
  13. #include <gui/modules/byte_input.h>
  14. #include <gui/modules/widget.h>
  15. #include <input/input.h>
  16. #include "scenes/nfc_magic_scene.h"
  17. #include <storage/storage.h>
  18. #include <dialogs/dialogs.h>
  19. #include <lib/toolbox/path.h>
  20. #include "nfc_magic_icons.h"
  21. #include <nfc/nfc.h>
  22. #include <nfc/nfc_device.h>
  23. #include "lib/magic/nfc_magic_scanner.h"
  24. #include "lib/magic/protocols/nfc_magic_protocols.h"
  25. #include "lib/magic/protocols/gen1a/gen1a_poller.h"
  26. #include "lib/magic/protocols/gen4/gen4_poller.h"
  27. #define NFC_APP_FOLDER ANY_PATH("nfc")
  28. #define NFC_APP_EXTENSION ".nfc"
  29. #define NFC_APP_SHADOW_EXTENSION ".shd"
  30. #define NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE (4)
  31. enum NfcMagicAppCustomEvent {
  32. // Reserve first 100 events for button types and indexes, starting from 0
  33. NfcMagicAppCustomEventReserved = 100,
  34. NfcMagicAppCustomEventViewExit,
  35. NfcMagicAppCustomEventWorkerExit,
  36. NfcMagicAppCustomEventByteInputDone,
  37. NfcMagicAppCustomEventTextInputDone,
  38. };
  39. struct NfcMagicApp {
  40. ViewDispatcher* view_dispatcher;
  41. Gui* gui;
  42. NotificationApp* notifications;
  43. DialogsApp* dialogs;
  44. Storage* storage;
  45. SceneManager* scene_manager;
  46. NfcDevice* source_dev;
  47. FuriString* file_name;
  48. FuriString* file_path;
  49. Nfc* nfc;
  50. NfcMagicProtocol protocol;
  51. NfcMagicScanner* scanner;
  52. Gen1aPoller* gen1a_poller;
  53. Gen4Poller* gen4_poller;
  54. uint32_t gen4_password;
  55. uint32_t gen4_password_new;
  56. FuriString* text_box_store;
  57. uint8_t byte_input_store[NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE];
  58. // Common Views
  59. Submenu* submenu;
  60. Popup* popup;
  61. Loading* loading;
  62. TextInput* text_input;
  63. ByteInput* byte_input;
  64. Widget* widget;
  65. };
  66. typedef enum {
  67. NfcMagicAppViewMenu,
  68. NfcMagicAppViewPopup,
  69. NfcMagicAppViewLoading,
  70. NfcMagicAppViewTextInput,
  71. NfcMagicAppViewByteInput,
  72. NfcMagicAppViewWidget,
  73. } NfcMagicAppView;
  74. void nfc_magic_app_blink_start(NfcMagicApp* nfc_magic);
  75. void nfc_magic_app_blink_stop(NfcMagicApp* nfc_magic);
  76. void nfc_magic_app_show_loading_popup(void* context, bool show);
  77. bool nfc_magic_load_from_file_select(NfcMagicApp* instance);