mag_i.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #pragma once
  2. #include "mag_device.h"
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <gui/gui.h>
  6. #include <gui/view.h>
  7. #include <gui/view_dispatcher.h>
  8. #include <gui/scene_manager.h>
  9. #include <notification/notification_messages.h>
  10. #include <gui/modules/submenu.h>
  11. #include <gui/modules/dialog_ex.h>
  12. #include <gui/modules/popup.h>
  13. #include <gui/modules/loading.h>
  14. #include <gui/modules/text_input.h>
  15. #include <gui/modules/widget.h>
  16. #include <notification/notification_messages.h>
  17. #include <dialogs/dialogs.h>
  18. #include <storage/storage.h>
  19. #include <flipper_format/flipper_format.h>
  20. #include <toolbox/path.h>
  21. #include "scenes/mag_scene.h"
  22. #define MAG_TEXT_STORE_SIZE 128
  23. enum MagCustomEvent {
  24. MagEventNext = 100,
  25. MagEventExit,
  26. MagEventPopupClosed,
  27. };
  28. typedef struct Mag Mag;
  29. struct Mag {
  30. ViewDispatcher* view_dispatcher;
  31. Gui* gui;
  32. NotificationApp* notifications;
  33. SceneManager* scene_manager;
  34. Storage* storage;
  35. DialogsApp* dialogs;
  36. MagDevice* mag_dev;
  37. char text_store[MAG_TEXT_STORE_SIZE + 1];
  38. FuriString* file_path;
  39. FuriString* file_name;
  40. // Common views
  41. Submenu* submenu;
  42. DialogEx* dialog_ex;
  43. Popup* popup;
  44. Loading* loading;
  45. TextInput* text_input;
  46. Widget* widget;
  47. // Custom views?
  48. };
  49. typedef enum {
  50. MagViewSubmenu,
  51. MagViewDialogEx,
  52. MagViewPopup,
  53. MagViewLoading,
  54. MagViewWidget,
  55. MagViewTextInput,
  56. } MagView;
  57. void mag_text_store_set(Mag* mag, const char* text, ...);
  58. void mag_text_store_clear(Mag* mag);
  59. void mag_show_loading_popup(void* context, bool show);
  60. // all below this comment are destined for deprecation (now handled by mag_device)
  61. bool mag_save_key(Mag* mag);
  62. bool mag_load_key_from_file_select(Mag* mag);
  63. bool mag_delete_key(Mag* mag);
  64. bool mag_load_key_data(Mag* mag, FuriString* path, bool show_dialog);
  65. bool mag_save_key_data(Mag* mag, FuriString* path);
  66. void mag_make_app_folder(Mag* mag);
  67. void mag_popup_timeout_callback(void* context);
  68. void mag_widget_callback(GuiButtonType result, InputType type, void* context);
  69. void mag_text_input_callback(void* context);