mag_device.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #define MAG_DEV_NAME_MAX_LEN 22
  8. #define MAG_APP_FOLDER ANY_PATH("mag")
  9. #define MAG_APP_EXTENSION ".mag"
  10. typedef void (*MagLoadingCallback)(void* context, bool state);
  11. typedef struct MagDevice MagDevice;
  12. struct MagDevice {
  13. Storage* storage;
  14. DialogsApp* dialogs;
  15. FuriString* dev_data;
  16. char dev_name[MAG_DEV_NAME_MAX_LEN + 1];
  17. FuriString* load_path;
  18. MagLoadingCallback loading_cb;
  19. void* loading_cb_ctx;
  20. };
  21. MagDevice* mag_device_alloc();
  22. void mag_device_free(MagDevice* mag_dev);
  23. void mag_device_set_name(MagDevice* mag_dev, const char* name);
  24. bool mag_device_save(MagDevice* mag_dev, const char* dev_name);
  25. bool mag_file_select(MagDevice* mag_dev);
  26. void mag_device_data_clear(FuriString* dev_data);
  27. void mag_device_clear(MagDevice* mag_dev);
  28. bool mag_device_delete(MagDevice* mag_dev, bool use_load_path);
  29. void mag_device_set_loading_callback(
  30. MagDevice* mag_dev,
  31. MagLoadingCallback callback,
  32. void* context);