lfrfid_app.h 2.1 KB

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