passy_i.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_device.h>
  23. /* generated by fbt from .png files in images folder */
  24. #include <passy_icons.h>
  25. #include "passy.h"
  26. #include "passy_common.h"
  27. #include "scenes/passy_scene.h"
  28. #define PASSY_TEXT_STORE_SIZE 128
  29. #define PASSY_FILE_NAME_MAX_LENGTH 32
  30. #define PASSY_PASSPORT_NUMBER_MAX_LENGTH 32
  31. #define PASSY_DOB_MAX_LENGTH 8
  32. #define PASSY_DOE_MAX_LENGTH 8
  33. #define PASSY_DG1_MAX_LENGTH 256
  34. enum PassyCustomEvent {
  35. // Reserve first 100 events for button types and indexes, starting from 0
  36. PassyCustomEventReserved = 100,
  37. PassyCustomEventViewExit,
  38. PassyCustomEventTextInputDone,
  39. PassyCustomEventNumberInputDone,
  40. // Read card events
  41. PassyCustomEventReaderError,
  42. PassyCustomEventReaderSuccess,
  43. PassyCustomEventReaderDetected,
  44. PassyCustomEventReaderAuthenticated,
  45. PassyCustomEventReaderReading,
  46. PassyCustomEventReaderNoDGXData,
  47. };
  48. struct Passy {
  49. ViewDispatcher* view_dispatcher;
  50. Gui* gui;
  51. NotificationApp* notifications;
  52. SceneManager* scene_manager;
  53. Storage* storage;
  54. char text_store[PASSY_TEXT_STORE_SIZE + 1];
  55. FuriString* text_box_store;
  56. // Common Views
  57. Submenu* submenu;
  58. Popup* popup;
  59. Loading* loading;
  60. TextInput* text_input;
  61. NumberInput* number_input;
  62. TextBox* text_box;
  63. Widget* widget;
  64. DialogsApp* dialogs;
  65. Nfc* nfc;
  66. NfcListener* listener;
  67. NfcPoller* poller;
  68. NfcDevice* nfc_device;
  69. FuriString* load_path;
  70. char file_name[PASSY_FILE_NAME_MAX_LENGTH + 1];
  71. char passport_number[PASSY_PASSPORT_NUMBER_MAX_LENGTH + 1];
  72. char date_of_birth[PASSY_DOB_MAX_LENGTH + 1];
  73. char date_of_expiry[PASSY_DOE_MAX_LENGTH + 1];
  74. BitBuffer* DG1;
  75. PassyReadType read_type;
  76. size_t offset;
  77. size_t bytes_total;
  78. };
  79. typedef enum {
  80. PassyViewMenu,
  81. PassyViewPopup,
  82. PassyViewLoading,
  83. PassyViewTextInput,
  84. PassyViewNumberInput,
  85. PassyViewTextBox,
  86. PassyViewWidget,
  87. } PassyView;
  88. void passy_text_store_set(Passy* passy, const char* text, ...);
  89. void passy_text_store_clear(Passy* passy);
  90. void passy_blink_start(Passy* passy);
  91. void passy_blink_stop(Passy* passy);
  92. void passy_show_loading_popup(void* context, bool show);