lfrfid_app.h 2.3 KB

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