lfrfid_app.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <generic_scene.hpp>
  5. #include <scene_controller.hpp>
  6. #include <view_controller.hpp>
  7. #include <record_controller.hpp>
  8. #include <text_store.h>
  9. #include <view_modules/submenu_vm.h>
  10. #include <view_modules/popup_vm.h>
  11. #include <view_modules/dialog_ex_vm.h>
  12. #include <view_modules/text_input_vm.h>
  13. #include <view_modules/byte_input_vm.h>
  14. #include "view/container_vm.h"
  15. #include <notification/notification_messages.h>
  16. #include <storage/storage.h>
  17. #include <dialogs/dialogs.h>
  18. #include "helpers/rfid_worker.h"
  19. class LfRfidApp {
  20. public:
  21. enum class EventType : uint8_t {
  22. GENERIC_EVENT_ENUM_VALUES,
  23. Next,
  24. MenuSelected,
  25. Stay,
  26. Retry,
  27. };
  28. enum class SceneType : uint8_t {
  29. GENERIC_SCENE_ENUM_VALUES,
  30. Read,
  31. ReadSuccess,
  32. RetryConfirm,
  33. ExitConfirm,
  34. ReadKeyMenu,
  35. Write,
  36. WriteSuccess,
  37. Emulate,
  38. SaveName,
  39. SaveSuccess,
  40. SelectKey,
  41. SavedKeyMenu,
  42. SaveData,
  43. SaveType,
  44. SavedInfo,
  45. DeleteConfirm,
  46. DeleteSuccess,
  47. };
  48. class Event {
  49. public:
  50. union {
  51. int32_t menu_index;
  52. } payload;
  53. EventType type;
  54. };
  55. SceneController<GenericScene<LfRfidApp>, LfRfidApp> scene_controller;
  56. ViewController<LfRfidApp, SubmenuVM, PopupVM, DialogExVM, TextInputVM, ByteInputVM, ContainerVM>
  57. view_controller;
  58. ~LfRfidApp();
  59. LfRfidApp();
  60. RecordController<NotificationApp> notification;
  61. RecordController<Storage> storage;
  62. RecordController<DialogsApp> dialogs;
  63. RfidWorker worker;
  64. TextStore text_store;
  65. void run(void* args);
  66. static const char* app_folder;
  67. static const char* app_extension;
  68. static const char* app_filetype;
  69. bool save_key(RfidKey* key);
  70. bool load_key_from_file_select(bool need_restore);
  71. bool delete_key(RfidKey* key);
  72. bool load_key_data(const char* path, RfidKey* key);
  73. bool save_key_data(const char* path, RfidKey* key);
  74. void make_app_folder();
  75. };