item.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <m-array.h>
  3. // Max length of a filename, final path element only
  4. #define MAX_NAME_LEN 64
  5. #define MAX_EXT_LEN 6
  6. /** Defines an individual item action or item group. Each object contains
  7. * the relevant file and type information needed to both render correctly
  8. * on-screen as well as to perform that action.
  9. */
  10. typedef enum {
  11. Item_SubGhz,
  12. Item_RFID,
  13. Item_IR,
  14. Item_NFC,
  15. Item_Playlist,
  16. Item_Group,
  17. Item_Settings,
  18. Item_count
  19. } ItemType;
  20. typedef struct Item {
  21. ItemType type;
  22. FuriString* name;
  23. FuriString* path;
  24. char ext[MAX_EXT_LEN + 1];
  25. } Item;
  26. ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
  27. typedef struct ItemsView {
  28. FuriString* name;
  29. FuriString* path;
  30. ItemArray_t items;
  31. } ItemsView;
  32. /** Allocates and returns an ItemsView* which contains the list of
  33. * items to display for the given path. Contains everything needed
  34. * to render a scene_items.
  35. *
  36. * @param context App*
  37. * @param path FuriString*
  38. * @return ItemsView*
  39. */
  40. ItemsView* item_get_items_view_from_path(void* context, const FuriString* path);
  41. /** Free ItemsView
  42. * @param items_view
  43. */
  44. void item_items_view_free(ItemsView* items_view);
  45. /** Prettify the name by removing a leading XX_, only if both X are digits,
  46. * as well as replace all '_' with ' '.
  47. * @param name FuriString*
  48. */
  49. void item_prettify_name(FuriString* name);
  50. /** Return the ItemType enum for the given extension
  51. * @param ext File extension
  52. */
  53. ItemType item_get_item_type_from_extension(const char* ext);