lfrfid_app.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #include "rpc/rpc_app.h"
  21. class LfRfidApp {
  22. public:
  23. enum class EventType : uint8_t {
  24. GENERIC_EVENT_ENUM_VALUES,
  25. Next,
  26. MenuSelected,
  27. Stay,
  28. Retry,
  29. Exit,
  30. EmulateStart,
  31. RpcLoadFile,
  32. RpcSessionClose,
  33. };
  34. enum class SceneType : uint8_t {
  35. GENERIC_SCENE_ENUM_VALUES,
  36. Read,
  37. ReadSuccess,
  38. RetryConfirm,
  39. ExitConfirm,
  40. ReadKeyMenu,
  41. Write,
  42. WriteSuccess,
  43. Emulate,
  44. SaveName,
  45. SaveSuccess,
  46. SelectKey,
  47. SavedKeyMenu,
  48. SaveData,
  49. SaveType,
  50. SavedInfo,
  51. DeleteConfirm,
  52. DeleteSuccess,
  53. Rpc,
  54. };
  55. class Event {
  56. public:
  57. union {
  58. int32_t menu_index;
  59. } payload;
  60. EventType type;
  61. };
  62. SceneController<GenericScene<LfRfidApp>, LfRfidApp> scene_controller;
  63. ViewController<LfRfidApp, SubmenuVM, PopupVM, DialogExVM, TextInputVM, ByteInputVM, ContainerVM>
  64. view_controller;
  65. ~LfRfidApp();
  66. LfRfidApp();
  67. RecordController<NotificationApp> notification;
  68. RecordController<Storage> storage;
  69. RecordController<DialogsApp> dialogs;
  70. RfidWorker worker;
  71. TextStore text_store;
  72. string_t file_path;
  73. RpcAppSystem* rpc_ctx;
  74. void run(void* args);
  75. static const char* app_folder;
  76. static const char* app_extension;
  77. static const char* app_filetype;
  78. bool save_key(RfidKey* key);
  79. bool load_key_from_file_select(bool need_restore);
  80. bool delete_key(RfidKey* key);
  81. bool load_key_data(string_t path, RfidKey* key, bool show_dialog);
  82. bool save_key_data(string_t path, RfidKey* key);
  83. void make_app_folder();
  84. };