mag_device.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <storage/storage.h>
  5. #include <dialogs/dialogs.h>
  6. #include "mag_icons.h"
  7. #include "helpers/mag_types.h"
  8. #include <assets_icons.h>
  9. #define MAG_DEV_NAME_MAX_LEN 22
  10. #define MAG_DEV_TRACKS 3
  11. #define MAG_APP_FOLDER STORAGE_APP_DATA_PATH_PREFIX
  12. #define MAG_APP_EXTENSION ".mag"
  13. typedef void (*MagLoadingCallback)(void* context, bool state);
  14. typedef struct {
  15. FuriString* str;
  16. size_t len;
  17. } MagTrack;
  18. typedef struct {
  19. MagTrack track[MAG_DEV_TRACKS];
  20. } MagDeviceData;
  21. typedef struct {
  22. Storage* storage;
  23. DialogsApp* dialogs;
  24. MagDeviceData dev_data;
  25. char dev_name[MAG_DEV_NAME_MAX_LEN + 1];
  26. FuriString* load_path;
  27. MagLoadingCallback loading_cb;
  28. void* loading_cb_ctx;
  29. } MagDevice;
  30. MagDevice* mag_device_alloc();
  31. void mag_device_free(MagDevice* mag_dev);
  32. void mag_device_set_name(MagDevice* mag_dev, const char* name);
  33. bool mag_device_save(MagDevice* mag_dev, const char* dev_name);
  34. bool mag_device_load_data(MagDevice* mag_dev, FuriString* path, bool show_dialog);
  35. bool mag_file_select(MagDevice* mag_dev);
  36. void mag_device_data_clear(MagDeviceData* dev_data);
  37. void mag_device_clear(MagDevice* mag_dev);
  38. bool mag_device_delete(MagDevice* mag_dev, bool use_load_path);
  39. bool mag_device_parse_card_string(MagDevice* mag_dev, FuriString* card_str);
  40. MagTrackState mag_device_autoselect_track_state(MagDevice* mag_dev);
  41. void mag_device_set_loading_callback(
  42. MagDevice* mag_dev,
  43. MagLoadingCallback callback,
  44. void* context);