passy_i.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <gui/gui.h>
  5. #include <gui/view_dispatcher.h>
  6. #include <gui/scene_manager.h>
  7. #include <notification/notification_messages.h>
  8. #include <storage/storage.h>
  9. #include <dialogs/dialogs.h>
  10. #include <gui/modules/submenu.h>
  11. #include <gui/modules/popup.h>
  12. #include <gui/modules/loading.h>
  13. #include <gui/modules/text_input.h>
  14. #include <gui/modules/number_input.h>
  15. #include <gui/modules/text_box.h>
  16. #include <gui/modules/widget.h>
  17. #include <input/input.h>
  18. #include <lib/flipper_format/flipper_format.h>
  19. #include <lib/nfc/nfc.h>
  20. #include <nfc/nfc_listener.h>
  21. #include <nfc/nfc_poller.h>
  22. #include <nfc/nfc_scanner.h>
  23. #include <nfc/nfc_device.h>
  24. /* generated by fbt from .png files in images folder */
  25. #include <passy_icons.h>
  26. #include "passy.h"
  27. #include "passy_common.h"
  28. #include "scenes/passy_scene.h"
  29. #define PASSY_TEXT_STORE_SIZE 128
  30. #define PASSY_FILE_NAME_MAX_LENGTH 32
  31. #define PASSY_PASSPORT_NUMBER_MAX_LENGTH 32
  32. #define PASSY_DOB_MAX_LENGTH 8
  33. #define PASSY_DOE_MAX_LENGTH 8
  34. #define PASSY_DG1_MAX_LENGTH 256
  35. enum PassyCustomEvent {
  36. // Reserve first 100 events for button types and indexes, starting from 0
  37. PassyCustomEventReserved = 100,
  38. PassyCustomEventViewExit,
  39. PassyCustomEventTextInputDone,
  40. PassyCustomEventNumberInputDone,
  41. // Read card events
  42. PassyCustomEventReaderError,
  43. PassyCustomEventReaderSuccess,
  44. PassyCustomEventReaderRestart,
  45. PassyCustomEventReaderDetected,
  46. PassyCustomEventReaderAuthenticated,
  47. PassyCustomEventReaderReading,
  48. };
  49. struct Passy {
  50. ViewDispatcher* view_dispatcher;
  51. Gui* gui;
  52. NotificationApp* notifications;
  53. SceneManager* scene_manager;
  54. Storage* storage;
  55. char text_store[PASSY_TEXT_STORE_SIZE + 1];
  56. FuriString* text_box_store;
  57. // Common Views
  58. Submenu* submenu;
  59. Popup* popup;
  60. Loading* loading;
  61. TextInput* text_input;
  62. NumberInput* number_input;
  63. TextBox* text_box;
  64. Widget* widget;
  65. DialogsApp* dialogs;
  66. Nfc* nfc;
  67. NfcScanner* scanner;
  68. NfcListener* listener;
  69. NfcPoller* poller;
  70. NfcDevice* nfc_device;
  71. FuriString* load_path;
  72. char file_name[PASSY_FILE_NAME_MAX_LENGTH + 1];
  73. char passport_number[PASSY_PASSPORT_NUMBER_MAX_LENGTH + 1];
  74. char date_of_birth[PASSY_DOB_MAX_LENGTH + 1];
  75. char date_of_expiry[PASSY_DOE_MAX_LENGTH + 1];
  76. BitBuffer* DG1;
  77. BitBuffer* COM;
  78. BitBuffer* dg_header;
  79. PassyReadType read_type;
  80. size_t offset;
  81. size_t bytes_total;
  82. uint16_t last_sw;
  83. const char* proto;
  84. };
  85. typedef enum {
  86. PassyViewMenu,
  87. PassyViewPopup,
  88. PassyViewLoading,
  89. PassyViewTextInput,
  90. PassyViewNumberInput,
  91. PassyViewTextBox,
  92. PassyViewWidget,
  93. } PassyView;
  94. void passy_text_store_set(Passy* passy, const char* text, ...);
  95. void passy_text_store_clear(Passy* passy);
  96. void passy_blink_start(Passy* passy);
  97. void passy_blink_stop(Passy* passy);
  98. void passy_show_loading_popup(void* context, bool show);